forked from TrueCloudLab/restic
Create uid/gid convertion function.
Create separate function to convert user ID / group ID of a user to integer. Windows is a stub, since this doesn't work on Windows (uid/gid is not a number).
This commit is contained in:
parent
0e7d0d8dba
commit
e1f6bbac9f
4 changed files with 39 additions and 20 deletions
24
lock_unix.go
Normal file
24
lock_unix.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
// +build !windows
|
||||
|
||||
package restic
|
||||
|
||||
import (
|
||||
"os/user"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// uidGidInt returns uid, gid of the user as a number.
|
||||
func uidGidInt(u user.User) (uid, gid uint32, err error) {
|
||||
var ui, gi int
|
||||
ui, err = strconv.ParseInt(u.Uid, 10, 32)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
gi, err = strconv.ParseInt(u.Gid, 10, 32)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
uid = uint32(ui)
|
||||
gid = uint32(gi)
|
||||
return
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue