Make UID/GID '0' on Windows.

We ignore parser errors on Uid/Gid, since they are not numbers on Windows.

UID/GID is usually 'root' on Linux, so I am not sure if 0/0 is a good idea.
Maybe if the type of the fields were changed from uint32 to int, we could set it
to -1 to indicate "no value".
This commit is contained in:
Klaus Post 2015-08-14 15:50:14 +02:00
parent 4dc746dac2
commit 2e7b40baca

View file

@ -76,16 +76,12 @@ func (sn *Snapshot) fillUserInfo() error {
}
sn.Username = usr.Username
uid, err := strconv.ParseInt(usr.Uid, 10, 32)
if err != nil {
return err
}
// We ignore the error. On Windows Uid is not a number
uid, _ := strconv.ParseInt(usr.Uid, 10, 32)
sn.UID = uint32(uid)
gid, err := strconv.ParseInt(usr.Gid, 10, 32)
if err != nil {
return err
}
// We ignore the error. On Windows Gid is not a number
gid, _ := strconv.ParseInt(usr.Gid, 10, 32)
sn.GID = uint32(gid)
return nil