mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-08-27 20:36:29 -04:00
Initial password aging support
This commit is contained in:
@@ -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 (
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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:]
|
||||
}
|
||||
@@ -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:], "\\", "/")
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user