mirror of
https://github.com/octoleo/restic.git
synced 2024-12-23 03:18:55 +00:00
e1f6bbac9f
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).
25 lines
390 B
Go
25 lines
390 B
Go
// +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
|
|
}
|