Skip to content

Commit

Permalink
Hacky support for passage
Browse files Browse the repository at this point in the history
Sebastian Blunt committed Aug 23, 2022
1 parent 03e4517 commit dd761ea
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions request/fetch.go
Original file line number Diff line number Diff line change
@@ -21,13 +21,15 @@ func fetchDecryptedContents(request *request) {
response.SendErrorAndExit(
errors.CodeInvalidPasswordFileExtension,
&map[errors.Field]string{
errors.FieldMessage: "The requested password file does not have the expected '.gpg' extension",
errors.FieldMessage: "The requested password file does not have the expected '.age' extension",
errors.FieldAction: "fetch",
errors.FieldFile: request.File,
},
)
}

request.File = strings.TrimRight(request.File, ".gpg")

store, ok := request.Settings.Stores[request.StoreID]
if !ok {
log.Errorf(
@@ -147,14 +149,16 @@ func validateGpgBinary(gpgPath string) error {
}

func decryptFile(store *store, file string, gpgPath string) (string, error) {
passwordFilePath := filepath.Join(store.Path, file)
passwordFilePath := filepath.Join(store.Path, "store", file)
passwordFile, err := os.Open(passwordFilePath)
if err != nil {
return "", err
}

identityFilePath := filepath.Join(store.Path, "identities")

var stdout, stderr bytes.Buffer
gpgOptions := []string{"--decrypt", "--yes", "--quiet", "--batch", "-"}
gpgOptions := []string{"--decrypt", "--identity", identityFilePath}

cmd := exec.Command(gpgPath, gpgOptions...)
cmd.Stdin = passwordFile
4 changes: 2 additions & 2 deletions request/list.go
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ func listFiles(request *request) {

store.Path = normalizedStorePath

files, err := zglob.GlobFollowSymlinks(filepath.Join(store.Path, "/**/*.gpg"))
files, err := zglob.GlobFollowSymlinks(filepath.Join(store.Path, "store", "/**/*.age"))
if err != nil {
log.Errorf(
"Unable to list the files in the password store '%+v' at its location: %+v",
@@ -56,7 +56,7 @@ func listFiles(request *request) {
}

for i, file := range files {
relativePath, err := filepath.Rel(store.Path, file)
relativePath, err := filepath.Rel(filepath.Join(store.Path, "store"), file)
if err != nil {
log.Errorf(
"Unable to determine the relative path for a file '%v' in the password store '%+v': %+v",

0 comments on commit dd761ea

Please sign in to comment.