diff --git a/age/age.go b/age/age.go index b218e30..42e51af 100644 --- a/age/age.go +++ b/age/age.go @@ -29,7 +29,7 @@ func AgeEntry(vanityPath string, timestamp int64) error { return nil } -// AgeAllPasswordEntries adds aging data for all un-aged entries containing passwords. +// AgeAllPasswordEntries adds age data for all un-aged entries containing passwords. // Each entry is aged with a random timestamp from within the last year to prevent // all entries having their passwords expire at the same time. func AgeAllPasswordEntries(forceReage bool) error { @@ -39,7 +39,7 @@ func AgeAllPasswordEntries(forceReage bool) error { } for _, vanityPath := range allVanityPaths { - // ensure entry is not already aged (unless forcing re-aging) + // ensure entry is not already aged (unless forcing re-age) if !forceReage { // ignore error; we only care if we can access the path or not isAccessible, _ := back.TargetIsFile(global.AgeDir+global.PathSeparator+strings.ReplaceAll(vanityPath, "/", global.FSPath), true) @@ -68,7 +68,7 @@ func AgeAllPasswordEntries(forceReage bool) error { } // TranslateAgeTimestamp returns a uint8 value indicating -// the interpreted age status of an aging timestamp associated +// the interpreted age status of an age timestamp associated // with an entry. // Magic number legend: // 0 -> no age, 1 -> fresh, 2 -> expiring soon (within a month), 3 -> expired @@ -86,6 +86,3 @@ func TranslateAgeTimestamp(timestamp int64) uint8 { return 1 // fresh } } - -// TODO -// 1. Add sync support for the aging directory diff --git a/core/util.go b/core/util.go index 9e73f5f..7e9951a 100644 --- a/core/util.go +++ b/core/util.go @@ -18,7 +18,7 @@ import ( ) // WriteEntry writes entryData to an encrypted file at realPath. -// If the entry contains an updated password, an aging file is also created. +// If the entry contains an updated password, an age file is also created. func WriteEntry(realPath string, decSlice []string, passwordIsNew bool) error { err := os.WriteFile(realPath, crypt.EncryptBytes([]byte(strings.Join(decSlice, "\n"))), 0600) if err != nil { @@ -26,16 +26,16 @@ func WriteEntry(realPath string, decSlice []string, passwordIsNew bool) error { } if decSlice != nil { - if passwordIsNew { // update aging data when password changes - if decSlice[0] != "" { // if the password change was NOT a removal, update the aging file + if passwordIsNew { // update age data when password changes + if decSlice[0] != "" { // if the password change was NOT a removal, update the age file err = age.AgeEntry(global.GetVanityPath(realPath), time.Now().Unix()) if err != nil { - return errors.New("unable to update aging data: " + err.Error()) + return errors.New("unable to update age data: " + err.Error()) } - } else { // if the password change was a removal, remove the associated aging file + } else { // if the password change was a removal, remove the associated age file err = syncclient.ShearRemoteFromClient(global.GetVanityPath(realPath), true) if err != nil { - return errors.New("unable to remove aging data: " + err.Error()) + return errors.New("unable to remove age data: " + err.Error()) } } } diff --git a/global/2globals_UNIX.go b/global/2globals_UNIX.go index 842435c..a85d6eb 100644 --- a/global/2globals_UNIX.go +++ b/global/2globals_UNIX.go @@ -8,7 +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 + AgeDir = ConfigDir + "/age" // Path to libmutton password age directory ) const ( diff --git a/global/2globals_WIN.go b/global/2globals_WIN.go index 70b7233..c90dd29 100644 --- a/global/2globals_WIN.go +++ b/global/2globals_WIN.go @@ -8,7 +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 + AgeDir = ConfigDir + "\\age" // Path to libmutton password age directory ) const ( diff --git a/global/init.go b/global/init.go index 61b7116..dccc4ad 100644 --- a/global/init.go +++ b/global/init.go @@ -39,7 +39,7 @@ func DirInit(preserveOldConfigDir bool) (string, error) { return "", errors.New("unable to create \"" + ConfigDir + "\": " + err.Error()) } - // create password aging directory + // create password age directory err = os.MkdirAll(AgeDir, 0700) if err != nil { return "", errors.New("unable to create \"" + AgeDir + "\": " + err.Error()) diff --git a/libmuttonserver.go b/libmuttonserver.go index 13e97a2..ae7efa3 100644 --- a/libmuttonserver.go +++ b/libmuttonserver.go @@ -51,7 +51,7 @@ func main() { // stdin[1] is expected to be the vanityPath with FSPath representing path separators - Always pass in UNIX format _, _, _ = synccommon.ShearLocal(strings.ReplaceAll(stdin[1], global.FSPath, "/"), stdin[0], false) case "shear-age": - // shear ONLY the aging file associated with an entry from the server and add it to the deletions directory + // shear ONLY the age file associated with an entry from the server and add it to the deletions directory // stdin[0] is expected to be the device ID // stdin[1] is expected to be the vanityPath with FSPath representing path separators - Always pass in UNIX format _, _, _ = synccommon.ShearLocal(strings.ReplaceAll(stdin[1], global.FSPath, "/"), stdin[0], true) diff --git a/syncclient/oneOff.go b/syncclient/oneOff.go index 8d22249..e742f72 100644 --- a/syncclient/oneOff.go +++ b/syncclient/oneOff.go @@ -15,8 +15,8 @@ import ( // It can safely be called in offline mode, as well, so this is // the intended interface for shearing (ShearLocal should only // be used directly by the server binary). -func ShearRemoteFromClient(vanityPath string, onlyShearAgingFile bool) error { - deviceID, isDir, err := synccommon.ShearLocal(vanityPath, "", onlyShearAgingFile) // remove the target from the local system and get the device ID of the client +func ShearRemoteFromClient(vanityPath string, onlyShearAgeFile bool) error { + deviceID, isDir, err := synccommon.ShearLocal(vanityPath, "", onlyShearAgeFile) // remove the target from the local system and get the device ID of the client if err != nil { return errors.New("unable to shear target locally: " + err.Error()) } @@ -39,7 +39,7 @@ func ShearRemoteFromClient(vanityPath string, onlyShearAgingFile bool) error { } // call the server to remotely shear the target and add it to the deletions list - if onlyShearAgingFile { + if onlyShearAgeFile { modifier = "-age" } _, err = GetSSHOutput(sshClient, "libmuttonserver shear"+modifier, deviceID+"\n"+strings.ReplaceAll(vanityPath, global.PathSeparator, global.FSPath)) diff --git a/synccommon/common.go b/synccommon/common.go index a0b73e3..e86851b 100644 --- a/synccommon/common.go +++ b/synccommon/common.go @@ -32,7 +32,7 @@ func GetModTimes(entryList []string) []int64 { // isDir (only on client; for use in ShearRemoteFromClient). // If the local system is a server, it will also add the target to the deletions list for all clients (except the requesting client). // This function should only be used directly by the server binary. -func ShearLocal(vanityPath, clientDeviceID string, onlyShearAgingFile bool) (string, bool, error) { +func ShearLocal(vanityPath, clientDeviceID string, onlyShearAgeFile bool) (string, bool, error) { // determine if running on a server var onServer bool if clientDeviceID != "" { @@ -48,7 +48,7 @@ func ShearLocal(vanityPath, clientDeviceID string, onlyShearAgingFile bool) (str if onServer { for _, device := range deviceIDList { if device.Name() != clientDeviceID { - if !onlyShearAgingFile { + if !onlyShearAgeFile { f, err := os.OpenFile(global.ConfigDir+global.PathSeparator+"deletions"+global.PathSeparator+device.Name()+global.FSSpace+"entry"+global.FSSpace+strings.ReplaceAll(vanityPath, "/", global.FSPath), os.O_CREATE|os.O_WRONLY, 0600) if err != nil { // do not print error as there is currently no way of seeing server-side errors @@ -80,7 +80,7 @@ func ShearLocal(vanityPath, clientDeviceID string, onlyShearAgingFile bool) (str isFile = true } } - if !onlyShearAgingFile { + if !onlyShearAgeFile { err = os.RemoveAll(realPath) if err != nil { return "", false, errors.New("unable to remove local entry (" + vanityPath + "): " + err.Error()) @@ -109,12 +109,12 @@ func ShearAgeFileLocal(vanityPath string) error { return nil } -// GetEntryAges reads the aging directory and returns a +// GetEntryAges reads the age directory and returns a // map of vanity paths to their corresponding age timestamps. func GetEntryAges() (map[string]int64, error) { contents, err := os.ReadDir(global.AgeDir) if err != nil { - return nil, errors.New("unable to read aging directory contents: " + err.Error()) + return nil, errors.New("unable to read age directory contents: " + err.Error()) } var vanityPathsToTimestamps = make(map[string]int64) @@ -123,7 +123,7 @@ func GetEntryAges() (map[string]int64, error) { vanityPath := strings.ReplaceAll(dirEntry.Name(), global.FSPath, "/") info, err := dirEntry.Info() if err != nil { - return nil, errors.New("unable to read aging file modtime for " + vanityPath + ": " + err.Error()) + return nil, errors.New("unable to read age file modtime for " + vanityPath + ": " + err.Error()) } vanityPathsToTimestamps[vanityPath] = info.ModTime().Unix() }