uid_plan9.go (1165B)
1 //go:build plan9 2 3 package diskfs 4 5 import ( 6 "os/exec" 7 "os/user" 8 "strings" 9 ) 10 11 func isGroupLeader(group, uid string) bool { 12 usr, err := user.Lookup(uid) 13 if err != nil { 14 return false 15 } 16 cmd := exec.Command("rc", "-c", "whois "+usr.Username+" | awk -F: '{print }'") 17 b, err := cmd.Output() 18 if err != nil { 19 return false 20 } 21 groups := strings.Split(string(b), "\n") 22 groups = groups[:len(groups)-1] 23 cmd = exec.Command("rc", "-c", "whois "+usr.Username+" | awk -F: '{print }'") 24 b, err = cmd.Output() 25 if err != nil { 26 return false 27 } 28 leaders := strings.Split(string(b), "\n") 29 leaders = leaders[:len(leaders)-1] 30 for i := 0; i < len(groups); i++ { 31 if groups[i] == group && uid == leaders[i] { 32 return true 33 } 34 } 35 return false 36 } 37 38 func isGroupMember(group, uid string) bool { 39 usr, err := user.Lookup(uid) 40 if err != nil { 41 return false 42 } 43 cmd := exec.Command("rc", "-c", "whois "+usr.Username+" | awk -F: '{print }'") 44 b, err := cmd.Output() 45 if err != nil { 46 return false 47 } 48 groups := strings.Split(string(b), "\n") 49 groups = groups[:len(groups)-1] 50 for i := 0; i < len(groups); i++ { 51 if groups[i] == group { 52 return true 53 } 54 } 55 return false 56 }