sys - amend user check
This commit is contained in:
parent
9d8add71f2
commit
04bd90a0ce
|
@ -192,7 +192,7 @@ func CheckSumFile(remoteChecksum string, path string) bool {
|
|||
|
||||
func IsRootUser() bool {
|
||||
done := false
|
||||
if usr, err := user.Current(); err != nil {
|
||||
if usr, err := user.Current(); err == nil {
|
||||
done = usr.Uid == "0" && usr.HomeDir == "/root"
|
||||
}
|
||||
return done
|
||||
|
@ -200,7 +200,7 @@ func IsRootUser() bool {
|
|||
|
||||
func IsUser(name string) bool {
|
||||
done := false
|
||||
if usr, err := user.Current(); err != nil {
|
||||
if usr, err := user.Current(); err == nil {
|
||||
done = usr.Name == name
|
||||
}
|
||||
return done
|
||||
|
@ -208,7 +208,7 @@ func IsUser(name string) bool {
|
|||
|
||||
func IsSystemUser(name string) bool {
|
||||
done := false
|
||||
if usr, err := user.Current(); err != nil {
|
||||
if usr, err := user.Current(); err == nil {
|
||||
var id int
|
||||
if id, err = strconv.Atoi(usr.Uid); err != nil {
|
||||
done = id < 1000
|
||||
|
|
Loading…
Reference in New Issue
Block a user