mirror of
https://github.com/Mic92/sops-nix.git
synced 2025-03-05 16:17:47 +00:00
Merge pull request #7 from Mic92/permission-fixes
This commit is contained in:
commit
5fbb075966
1 changed files with 6 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
@ -306,7 +307,8 @@ func atomicSymlink(oldname, newname string) error {
|
|||
|
||||
func importSSHKeys(keyPaths []string, gpgHome string) error {
|
||||
secringPath := filepath.Join(gpgHome, "secring.gpg")
|
||||
secring, err := os.Create(secringPath)
|
||||
|
||||
secring, err := os.OpenFile(secringPath, os.O_WRONLY|os.O_CREATE, 0600)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Cannot create %s: %s", secringPath, err)
|
||||
}
|
||||
|
@ -319,9 +321,12 @@ func importSSHKeys(keyPaths []string, gpgHome string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := gpgKey.SerializePrivate(secring, nil); err != nil {
|
||||
return fmt.Errorf("Cannot write secring: %s", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Imported %s with fingerprint %s", path, hex.EncodeToString(gpgKey.PrimaryKey.Fingerprint[:]))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Add table
Reference in a new issue