06da0a668a
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.
63 lines
1.3 KiB
Go
63 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
// popBool removes every occurrence of the given flag spellings from args and
|
|
// reports whether any were present.
|
|
func popBool(args []string, names ...string) (bool, []string) {
|
|
var rest []string
|
|
found := false
|
|
for _, a := range args {
|
|
if contains(names, a) {
|
|
found = true
|
|
continue
|
|
}
|
|
rest = append(rest, a)
|
|
}
|
|
return found, rest
|
|
}
|
|
|
|
func contains(ss []string, s string) bool {
|
|
for _, x := range ss {
|
|
if x == s {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// parseClip pulls pass-style clipboard flags out of args: -c / --clip copy the
|
|
// first line; --clip=N or -cN copy line N (1-based).
|
|
func parseClip(args []string) (clip bool, line int, rest []string) {
|
|
line = 1
|
|
for _, a := range args {
|
|
switch {
|
|
case a == "-c" || a == "--clip":
|
|
clip = true
|
|
case strings.HasPrefix(a, "--clip="):
|
|
clip = true
|
|
if n, err := strconv.Atoi(a[len("--clip="):]); err == nil && n > 0 {
|
|
line = n
|
|
}
|
|
case strings.HasPrefix(a, "-c") && len(a) > 2:
|
|
clip = true
|
|
if n, err := strconv.Atoi(a[2:]); err == nil && n > 0 {
|
|
line = n
|
|
}
|
|
default:
|
|
rest = append(rest, a)
|
|
}
|
|
}
|
|
return clip, line, rest
|
|
}
|
|
|
|
func atoiDefault(s string, def int) int {
|
|
if n, err := strconv.Atoi(s); err == nil {
|
|
return n
|
|
}
|
|
return def
|
|
}
|