added generic user lookup and foreground processes

This commit is contained in:
ston1th 2017-04-19 23:20:52 +02:00
commit 1e230617ce
7 changed files with 134 additions and 50 deletions

29
lookup.go Normal file
View 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)
}