Third round of fixes

This commit is contained in:
2025-09-28 02:52:39 -04:00
parent 0b398e789f
commit 93fe7a13bd
3 changed files with 36 additions and 17 deletions
+13 -8
View File
@@ -37,14 +37,7 @@ func writeFile(path, data, owner string, perms os.FileMode) {
other.PrintError("Failed to write to "+path+":"+err.Error(), 1)
}
if owner != "root" {
userInfo, err := user.Lookup(owner)
if err != nil {
other.PrintError("Failed to lookup UID for "+owner, 1)
}
uid, err := strconv.Atoi(userInfo.Uid)
if err != nil {
other.PrintError("Failed to convert UID to integer", 1)
}
uid := getUID()
err = os.Chown(path, uid, uid)
if err != nil {
other.PrintError("Failed to set ownership of "+path, 1)
@@ -59,3 +52,15 @@ func getUsername() string {
localUsername := username
return localUsername
}
func getUID() int {
userInfo, err := user.Lookup(getUsername())
if err != nil {
other.PrintError("Failed to lookup UID for "+getUsername(), 1)
}
uid, err := strconv.Atoi(userInfo.Uid)
if err != nil {
other.PrintError("Failed to convert UID to integer", 1)
}
return uid
}