Refactor vars.
This commit is contained in:
parent
00b5b0c7d6
commit
2e8e97d0a5
@ -19,18 +19,18 @@ var configPath *string = flag.String("conf", "config.yaml", "path to configurati
|
|||||||
var logToStdout *bool = flag.Bool("log-stdout", false, "write logs to stdout")
|
var logToStdout *bool = flag.Bool("log-stdout", false, "write logs to stdout")
|
||||||
|
|
||||||
func substituteUser(username string) error {
|
func substituteUser(username string) error {
|
||||||
dwu, err := user.Lookup(username)
|
u, err := user.Lookup(username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
dwuid, err := strconv.Atoi(dwu.Uid)
|
uid, err := strconv.Atoi(u.Uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.Getuid() != dwuid {
|
if os.Getuid() != uid {
|
||||||
if err := syscall.Setuid(dwuid); err != nil {
|
if err := syscall.Setuid(uid); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user