keyword: add missing gname
keyword functions
Fixes: #128 Reported-by: Lennart Poettering <lennart@poettering.net> Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
469590a575
commit
68651d77d6
4 changed files with 31 additions and 0 deletions
|
@ -34,6 +34,18 @@ var (
|
|||
}
|
||||
return KeyVal(fmt.Sprintf("uname=%s", u.Username)), nil
|
||||
}
|
||||
gnameKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (KeyVal, error) {
|
||||
if hdr, ok := info.Sys().(*tar.Header); ok {
|
||||
return KeyVal(fmt.Sprintf("gname=%s", hdr.Gname)), nil
|
||||
}
|
||||
|
||||
stat := info.Sys().(*syscall.Stat_t)
|
||||
g, err := user.LookupGroupId(fmt.Sprintf("%d", stat.Gid))
|
||||
if err != nil {
|
||||
return emptyKV, err
|
||||
}
|
||||
return KeyVal(fmt.Sprintf("gname=%s", g.Name)), nil
|
||||
}
|
||||
uidKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (KeyVal, error) {
|
||||
if hdr, ok := info.Sys().(*tar.Header); ok {
|
||||
return KeyVal(fmt.Sprintf("uid=%d", hdr.Uid)), nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue