added generic user lookup and foreground processes
This commit is contained in:
parent
4b88a07ef5
commit
1e230617ce
7 changed files with 134 additions and 50 deletions
29
lookup.go
Normal file
29
lookup.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright (C) 2017 Marius Schellenberger
|
||||
|
||||
package godrop
|
||||
|
||||
import "strconv"
|
||||
|
||||
func atoi(a string) (int, error) {
|
||||
i, err := strconv.Atoi(a)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func userID(username string) (uid int, err error) {
|
||||
id, err := lookupUID(username)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
return atoi(id)
|
||||
}
|
||||
|
||||
func groupID(name string) (int, error) {
|
||||
id, err := lookupGID(name)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
return atoi(id)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue