mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-08-29 21:36:38 -04:00
Bump libmutton and support new SSH identity file passphrase entry
This commit is contained in:
+2
-2
@@ -29,12 +29,12 @@ func AddEntry(targetLocation string, hideSecrets bool, entryType uint8) {
|
||||
// determine whether to generate the password
|
||||
var password string
|
||||
if entryType == 0 {
|
||||
password = inputHidden("Password:")
|
||||
password = string(inputHidden("Password:"))
|
||||
} else {
|
||||
password = core.StringGen(inputInt("Password length:", -1), inputBinary("Generate a complex (special characters) password?"), 0.2, false)
|
||||
}
|
||||
|
||||
totp := inputHidden("TOTP secret:")
|
||||
totp := string(inputHidden("TOTP secret:"))
|
||||
url := input("URL:")
|
||||
if inputBinary("Add a note to this entry?") {
|
||||
note, _ := editNote([]string{})
|
||||
|
||||
+2
-2
@@ -29,11 +29,11 @@ func EditEntryField(targetLocation string, hideSecrets bool, field int) {
|
||||
// edit the field
|
||||
switch field {
|
||||
case 0:
|
||||
unencryptedEntry[field] = inputHidden("Password:")
|
||||
unencryptedEntry[field] = string(inputHidden("Password:"))
|
||||
case 1:
|
||||
unencryptedEntry[field] = input("Username:")
|
||||
case 2:
|
||||
unencryptedEntry[field] = inputHidden("TOTP secret:")
|
||||
unencryptedEntry[field] = string(inputHidden("TOTP secret:"))
|
||||
case 3:
|
||||
unencryptedEntry[field] = input("URL:")
|
||||
case 4: // edit notes fields
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/rwinkhart/libmutton/core"
|
||||
"github.com/rwinkhart/libmutton/sync"
|
||||
)
|
||||
|
||||
const ansiShownPassword = "\033[38;5;10m"
|
||||
@@ -63,7 +62,7 @@ func EntryReader(decryptedEntry []string, hideSecrets, syncEnabled bool) {
|
||||
}
|
||||
|
||||
if syncEnabled {
|
||||
sync.RunJob(false)
|
||||
RunJobWrapper(false)
|
||||
}
|
||||
|
||||
os.Exit(0)
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/rwinkhart/libmutton/core"
|
||||
"github.com/rwinkhart/libmutton/sync"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
@@ -18,13 +19,12 @@ func input(prompt string) string {
|
||||
return strings.TrimRight(userInput, "\n\r ") // remove trailing newlines, carriage returns, and spaces
|
||||
}
|
||||
|
||||
// inputHidden prompts the user for input and returns the input as a string, hiding the input from the terminal.
|
||||
func inputHidden(prompt string) string {
|
||||
// inputHidden prompts the user for input and returns the input as a byte array, hiding the input from the terminal.
|
||||
func inputHidden(prompt string) []byte {
|
||||
fmt.Print("\n" + prompt + " ")
|
||||
byteInput, _ := term.ReadPassword(int(os.Stdin.Fd()))
|
||||
password := string(byteInput)
|
||||
fmt.Println()
|
||||
return password
|
||||
return byteInput
|
||||
}
|
||||
|
||||
// inputInt prompts the user for input and returns the input as an integer.
|
||||
@@ -82,3 +82,9 @@ func writeEntryCLI(targetLocation string, unencryptedEntry []string, hideSecrets
|
||||
func expandPathWithHome(path string) string {
|
||||
return strings.Replace(path, "~", core.Home, 1)
|
||||
}
|
||||
|
||||
// RunJobWrapper is a wrapper for sync.RunJob that sets the passphrase input function to inputHidden.
|
||||
func RunJobWrapper(manualSync bool) {
|
||||
core.PassphraseInputFunction = inputHidden
|
||||
sync.RunJob(manualSync)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user