Skip to content

Instantly share code, notes, and snippets.

@imcleod
Created May 27, 2016 19:27
Show Gist options
  • Select an option

  • Save imcleod/cd32ad41d414471756763b7de36244f8 to your computer and use it in GitHub Desktop.

Select an option

Save imcleod/cd32ad41d414471756763b7de36244f8 to your computer and use it in GitHub Desktop.
#!/bin/bash
rm -rf contents
mkdir -p contents/var/foo
touch contents/var/foo/nested-file
chmod a+x contents/var/foo/nested-file
setcap cap_net_raw+ep contents/var/foo/nested-file
cd contents
echo "Attributes before tar"
getfattr -d -m ".*" var/foo/nested-file
rm -f ../f_no.tar
tar --no-selinux -cf ../f_no.tar .
cd ..
rm -rf untar_contents
mkdir untar_contents
cd untar_contents
tar --xattrs-include="*" -xf ../f_no.tar
echo "Attributes of extracted file"
getfattr -d -m ".*" var/foo/nested-file
cd ..
rm -rf f_no.tar contents untar_contents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment