Skip to content

Commit

Permalink
pack,unpack: Save and restore xattrs and file capabilities in tarballs
Browse files Browse the repository at this point in the history
Add options to `tar` to tell it to save and restore extended attributes:

* `--xattr`: enable extended attributes support
* `--xattrs-include=*.*`: tell `tar` to include every extended attribute
  since by default `tar` only stores attributes in the `user.*` namespace

This fixes the `pack` and `unpack` actions when dealing with tools like
`ping` which on modern distributions have been switched to use file
capabilities to do privileged operations without being setuid, as they are
based on extended attributes.

This relies on `tar` being GNU Tar >= 1.27, released in 2013 and shipped since
Debian Jessie.

Signed-off-by: Emanuele Aina <[email protected]>
  • Loading branch information
em- authored and sjoerdsimons committed Sep 6, 2019
1 parent 9b64814 commit f5be960
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 0 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ TODO
* Make actions using (host) commands check their existance early


* Ensure we copy xattrs?

* Fix race in qemu-helper (if qemu-user-static gets installed in the system
chroot things will get confused)

Expand Down
4 changes: 3 additions & 1 deletion actions/pack_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ func (pf *PackAction) Run(context *debos.DebosContext) error {
outfile := path.Join(context.Artifactdir, pf.File)

log.Printf("Compressing to %s\n", outfile)
return debos.Command{}.Run("Packing", "tar", "czf", outfile, "-C", context.Rootdir, ".")
return debos.Command{}.Run("Packing", "tar", "czf", outfile,
"--xattrs", "--xattrs-include=*.*",
"-C", context.Rootdir, ".")
}
2 changes: 2 additions & 0 deletions archiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ func (tar *ArchiveTar) Unpack(destination string) error {
}
command = append(command, "-C", destination)
command = append(command, "-x")
command = append(command, "--xattrs")
command = append(command, "--xattrs-include=*.*")

if compression, ok := tar.options["tarcompression"]; ok {
if unpackTarOpt := tarOptions(compression.(string)); len(unpackTarOpt) > 0 {
Expand Down

0 comments on commit f5be960

Please sign in to comment.