mirror of
https://github.com/clearlinux/rkt.git
synced 2026-11-25 21:42:50 +00:00
Merge pull request #462 from sgotti/tarrestoreuidgid
tar: restore entry's uid and gid.
This commit is contained in:
@@ -149,6 +149,13 @@ func ExtractFile(tr *tar.Reader, hdr *tar.Header, dir string, overwrite bool) er
|
||||
return fmt.Errorf("unsupported type: %v", typ)
|
||||
}
|
||||
|
||||
// TODO(sgotti). lchown(2) says that, depending on the linux kernel
|
||||
// version, chown can change the file mode also if executed as root.
|
||||
// To be sure, Should we call os.Chmod after it?
|
||||
if err := os.Lchown(p, hdr.Uid, hdr.Gid); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,9 @@ func newTestTar(entries []*testTarEntry) (string, error) {
|
||||
entry.header.Mode = 0644
|
||||
}
|
||||
}
|
||||
// Add calling user uid and gid or tests will fail
|
||||
entry.header.Uid = os.Getuid()
|
||||
entry.header.Gid = os.Getgid()
|
||||
if err := tw.WriteHeader(entry.header); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user