aboutsummaryrefslogtreecommitdiffstats
path: root/src/c_utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/c_utils.go')
-rw-r--r--src/c_utils.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/c_utils.go b/src/c_utils.go
index 3b94cc1..cfcba8e 100644
--- a/src/c_utils.go
+++ b/src/c_utils.go
@@ -52,6 +52,7 @@
package main
import (
+ "bytes"
"errors"
"fmt"
"os"
@@ -169,3 +170,33 @@ func c_decrypt_str(str string) (string, error) {
out, err := cmd.Output()
return string(out), err
}
+
+func c_get_secret_gpg_keyring(ui *HardUI) []string {
+ var keys []string
+ var out bytes.Buffer
+ cmd_fmt := []string{
+ `gpg`,
+ `--list-secret-keys`,
+ `|`,
+ `grep`,
+ `-A`,
+ `2`,
+ `'^sec'`,
+ `|`,
+ `sed`,
+ `'{/^sec/d;/--/d;s/^uid.*] //;}'`,
+ }
+
+ ui.s.Fini()
+ cmd := exec.Command(cmd_fmt[0], cmd_fmt[1:]...)
+ cmd.Stdout = &out
+ if err := cmd.Run(); err != nil {
+ c_die("failed to list gpg secret keys", err)
+ c_error_mode("failed to list gpg secret keys", err, ui)
+ return nil
+ }
+ fmt.Printf("%s\n", out.String())
+ os.Exit(0)
+ // keys[0] = string(cmd)
+ return keys
+}