initial commit
This commit is contained in:
commit
3530843c4c
350 changed files with 197839 additions and 0 deletions
35
vendor/git.giftfish.de/ston1th/godrop/v2/lookup.go
vendored
Normal file
35
vendor/git.giftfish.de/ston1th/godrop/v2/lookup.go
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (C) 2022 Marius Schellenberger
|
||||
|
||||
//go:build go1.11
|
||||
// +build go1.11
|
||||
|
||||
package godrop
|
||||
|
||||
import (
|
||||
"os/user"
|
||||
"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) (int, error) {
|
||||
u, err := user.Lookup(username)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
return atoi(u.Uid)
|
||||
}
|
||||
|
||||
func groupID(name string) (int, error) {
|
||||
g, err := user.LookupGroup(name)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
return atoi(g.Gid)
|
||||
}
|
||||
Loading…
Reference in a new issue