Initial password aging support

This commit is contained in:
2025-11-23 03:20:58 -05:00
parent d2a6ed5eaa
commit 50d51f9d96
24 changed files with 532 additions and 260 deletions
+1
View File
@@ -4,6 +4,7 @@ type ByteInputFetcher func(prompt string) []byte
var (
GetPassword ByteInputFetcher // Clients should set this to a function that fetches hidden input from the user
rootLength = len(EntryRoot) // length of global.EntryRoot string
)
const (
+1
View File
@@ -8,6 +8,7 @@ var (
EntryRoot = back.Home + "/.local/share/libmutton" // Path to libmutton entry directory
ConfigDir = back.Home + "/.config/libmutton" // Path to libmutton configuration directory
ConfigPath = ConfigDir + "/libmutton.ini" // Path to libmutton configuration file
AgeDir = ConfigDir + "/aging" // Path to libmutton password aging database
)
const (
+1
View File
@@ -8,6 +8,7 @@ var (
EntryRoot = back.Home + "\\AppData\\Local\\libmutton\\entries" // Path to libmutton entry directory
ConfigDir = back.Home + "\\AppData\\Local\\libmutton\\config" // Path to libmutton configuration directory
ConfigPath = ConfigDir + "\\libmutton.ini" // Path to libmutton configuration file
AgeDir = ConfigDir + "\\aging" // Path to libmutton password aging database
)
const (
+8
View File
@@ -0,0 +1,8 @@
package global
import "strings"
// GetRealAgePath returns the full path to an age file (given the vanity path)
func GetRealAgePath(vanityPath string) string {
return AgeDir + PathSeparator + strings.ReplaceAll(vanityPath, "/", FSPath)
}
+13
View File
@@ -0,0 +1,13 @@
//go:build !windows
package global
// GetRealPath returns the full path to an entry (given the vanity path).
func GetRealPath(vanityPath string) string {
return EntryRoot + vanityPath
}
// GetVanityPath returns a vanityPath given a realPath
func GetVanityPath(realPath string) string {
return realPath[rootLength:]
}
+17
View File
@@ -0,0 +1,17 @@
//go:build windows
package global
import (
"strings"
)
// GetRealPath returns the full path to an entry (given the vanity path).
func GetRealPath(vanityPath string) string {
return EntryRoot + strings.ReplaceAll(vanityPath, "/", PathSeparator)
}
// GetVanityPath returns a vanityPath given a realPath
func GetVanityPath(realPath string) string {
return strings.ReplaceAll(realPath[rootLength:], "\\", "/")
}
+6
View File
@@ -39,5 +39,11 @@ func DirInit(preserveOldConfigDir bool) (string, error) {
return "", errors.New("unable to create \"" + ConfigDir + "\": " + err.Error())
}
// create password aging directory
err = os.MkdirAll(AgeDir, 0700)
if err != nil {
return "", errors.New("unable to create \"" + AgeDir + "\": " + err.Error())
}
return oldDeviceID, nil
}
-8
View File
@@ -1,8 +0,0 @@
//go:build !windows
package global
// TargetLocationFormat returns the full location of an entry (given the name) formatted for the current platform.
func TargetLocationFormat(targetLocationIncomplete string) string {
return EntryRoot + targetLocationIncomplete
}
-12
View File
@@ -1,12 +0,0 @@
//go:build windows
package global
import (
"strings"
)
// TargetLocationFormat returns the full location of an entry (given the name) formatted for the current platform.
func TargetLocationFormat(targetLocationIncomplete string) string {
return EntryRoot + strings.ReplaceAll(targetLocationIncomplete, "/", PathSeparator)
}