fortify: use resolved username
test / test (push) Successful in 21s
Details
test / test (push) Successful in 21s
Details
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
parent
9faf3b3596
commit
6bf33ce507
48
main.go
48
main.go
|
@ -8,6 +8,7 @@ import (
|
||||||
"os/user"
|
"os/user"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
|
|
||||||
"git.ophivana.moe/security/fortify/dbus"
|
"git.ophivana.moe/security/fortify/dbus"
|
||||||
|
@ -188,20 +189,41 @@ func main() {
|
||||||
panic("unreachable")
|
panic("unreachable")
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolve home directory from os when flag is unset
|
// resolve home/username from os when flag is unset
|
||||||
|
var (
|
||||||
|
passwd *user.User
|
||||||
|
passwdOnce sync.Once
|
||||||
|
passwdFunc = func() {
|
||||||
|
var us string
|
||||||
|
if uid, err := os.Uid(aid); err != nil {
|
||||||
|
fmsg.Fatalf("cannot obtain uid from fsu: %v", err)
|
||||||
|
} else {
|
||||||
|
us = strconv.Itoa(uid)
|
||||||
|
}
|
||||||
|
|
||||||
|
if u, err := user.LookupId(us); err != nil {
|
||||||
|
fmsg.VPrintf("cannot look up uid %s", us)
|
||||||
|
passwd = &user.User{
|
||||||
|
Uid: us,
|
||||||
|
Gid: us,
|
||||||
|
Username: "chronos",
|
||||||
|
Name: "Fortify",
|
||||||
|
HomeDir: "/var/empty",
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
passwd = u
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
if homeDir == "os" {
|
if homeDir == "os" {
|
||||||
var us string
|
passwdOnce.Do(passwdFunc)
|
||||||
if uid, err := os.Uid(aid); err != nil {
|
homeDir = passwd.HomeDir
|
||||||
fmsg.Fatalf("cannot obtain uid from fsu: %v", err)
|
}
|
||||||
} else {
|
|
||||||
us = strconv.Itoa(uid)
|
if userName == "chronos" {
|
||||||
}
|
passwdOnce.Do(passwdFunc)
|
||||||
if u, err := user.LookupId(us); err != nil {
|
userName = passwd.Username
|
||||||
fmsg.VPrintf("cannot look up uid %s", us)
|
|
||||||
homeDir = "/var/empty"
|
|
||||||
} else {
|
|
||||||
homeDir = u.HomeDir
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Confinement.AppID = aid
|
config.Confinement.AppID = aid
|
||||||
|
|
Loading…
Reference in New Issue