mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-09-03 15:47:23 -04:00
Remove the gpg-gen file after use
This commit is contained in:
+7
-2
@@ -1,12 +1,12 @@
|
||||
package offline
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// TempInit ensures libmutton directories exist and writes the libmutton configuration file
|
||||
func TempInit(configFileMap map[string]string) {
|
||||
// create EntryRoot and ConfigDir
|
||||
dirInit()
|
||||
@@ -51,6 +51,7 @@ func GpgUIDListGen() []string {
|
||||
|
||||
// GpgKeyGen generates a new GPG key and returns the key ID as a string
|
||||
func GpgKeyGen() string {
|
||||
// create and write gpg-gen file
|
||||
createFile(ConfigDir+"/gpg-gen", []string{"Key-Type: eddsa", "Key-Curve: ed25519", "Key-Usage: sign", "Subkey-Type: ecdh", "Subkey-Curve: cv25519", "Subkey-Usage: encrypt", "Name-Real: libmutton", "Name-Comment: gpg-libmutton", "Name-Email: github.com/rwinkhart/libmutton", "Expire-Date: 0"})
|
||||
cmd := exec.Command("gpg", "-q", "--batch", "--generate-key", ConfigDir+"/gpg-gen")
|
||||
cmd.Stdout = os.Stdout
|
||||
@@ -58,10 +59,14 @@ func GpgKeyGen() string {
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Run()
|
||||
|
||||
// generate GPG key based on gog-gen file
|
||||
cmd = exec.Command("gpg", "-k", "--with-colons")
|
||||
gpgOutputBytes, _ := cmd.Output()
|
||||
gpgOutputLines := strings.Split(string(gpgOutputBytes), "\n")
|
||||
uid := strings.Split(gpgOutputLines[len(gpgOutputLines)-4], ":")[9]
|
||||
fmt.Println(uid)
|
||||
|
||||
// remove gpg-gen file
|
||||
removeFile(ConfigDir + "/gpg-gen")
|
||||
|
||||
return uid
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user