Add passv: a Vault-backed drop-in for pass
Provide a password-store CLI that keeps pass's on-disk layout (<name>.gpg binary OpenPGP under $PASSWORD_STORE_DIR) but routes all encryption and decryption through a vault-plugin-secrets-gpg engine mount, so the GPG private key never lives on the client. - Implement init/show/ls/insert/generate/edit/rm/mv/cp/find/grep/git with pass-compatible flags and implicit `passv <name>`=show dispatch. - Resolve the recipient from a Vault ref: .gpg-id holds <mount>/<key> for passv-native stores, or a sibling .vault-id lets a store keep real GPG fingerprints in .gpg-id for dual gpg+Vault use. - mv/cp re-encrypt across differing recipients; same-recipient moves copy the ciphertext verbatim. - Ship the sibling build/packaging/CI: nfpm RPM to /usr/bin/passv (artifactapi rpm-internal on v* tag), Woodpecker PR/release pipelines, unit tests plus a real-Vault e2e that also proves dual gpg+Vault decryption. - README covers store creation, migrating a GPG pass store, and dual-mode.
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// printTree renders the entry tree under sub in the same shape pass does (via
|
||||
// `tree`): directories and entries sorted together, `.gpg` suffixes stripped,
|
||||
// dotfiles hidden.
|
||||
func printTree(s *store, sub string) error {
|
||||
root := filepath.Join(s.dir, sub)
|
||||
if fi, err := os.Stat(root); err != nil || !fi.IsDir() {
|
||||
return errf("Error: %s is not in the password store.", sub)
|
||||
}
|
||||
if sub == "" {
|
||||
fmt.Println("Password Store")
|
||||
} else {
|
||||
fmt.Println(sub)
|
||||
}
|
||||
return printBranch(root, "")
|
||||
}
|
||||
|
||||
func printBranch(dir, prefix string) error {
|
||||
ents, err := os.ReadDir(dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var items []os.DirEntry
|
||||
for _, e := range ents {
|
||||
if strings.HasPrefix(e.Name(), ".") {
|
||||
continue
|
||||
}
|
||||
if !e.IsDir() && !strings.HasSuffix(e.Name(), ".gpg") {
|
||||
continue
|
||||
}
|
||||
items = append(items, e)
|
||||
}
|
||||
sort.Slice(items, func(i, j int) bool { return items[i].Name() < items[j].Name() })
|
||||
|
||||
for i, e := range items {
|
||||
last := i == len(items)-1
|
||||
branch, extend := "├── ", "│ "
|
||||
if last {
|
||||
branch, extend = "└── ", " "
|
||||
}
|
||||
name := e.Name()
|
||||
if !e.IsDir() {
|
||||
name = strings.TrimSuffix(name, ".gpg")
|
||||
}
|
||||
fmt.Println(prefix + branch + name)
|
||||
if e.IsDir() {
|
||||
if err := printBranch(filepath.Join(dir, e.Name()), prefix+extend); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user