That was a "fun" debugging session...

all 19 comments

sorted by: hot top controversial new old
[–] 62 points 1 year ago

That's what an archiving program is supposed to do.

  • source
  • [–] 23 points 1 year ago*

    Just bear in mind that uid 1001 on one machine is not generally uid 1001 on another, and that if you copy the tar off machine you're more than likely giving permission to somebody other than the intended target

  • source
  • [–] 21 points 1 year ago (1 child)

    You can even archive extended attributes with the ‘--xattrs flag.

  • source
  • hideshow 1 child comment
  • [–] 19 points 1 year ago* (1 child)

    Since no one has yet mentioned, by default if you're running tar as a non-root user it extracts files with owner/umask of the current user and if you run it as root (or superuser) it'll preserve ownership and permissions. From tar man page:

    --no-same-owner

    Extract files as yourself (default for ordinary users).

    --no-same-permissions

    Apply the user's umask when extracting permissions from the archive (default for ordinary users).

    As mentioned, with root the defaults are to keep UID/permissions as they are in the archive. (--preserve-permissions and --same-owner).

  • source
  • hideshow 1 child comment
  • [–] 14 points 1 year ago (1 child)

    Learned to make use of this the hard way when transferring a directory over a FAT32 USB drive messed up the permissions.

  • source
  • hideshow 1 child comment
  • [–] 10 points 1 year ago*

    Worse, it preserves "special" files like the ones in /dev or /var which aren't removable by anyone other than root. Love extracting a system file backup in my file server as a regular user in order to get just a few files out of it, and promptly not being able to fully delete it afterward without SSHing into the server and using sudo.

    I don't get how a regular user can even create files like that. Sounds like a security vulnerability.

  • source
  • [–] 17 points 1 year ago (5 children)

    I've never heard of an archiving program that didn't.

  • source
  • hideshow 5 child comments
  • [–] 9 points 1 year ago (2 children)

    IIRC zip can, but doesn't by default. Source : wasted 8 hours trying to figure out why something didn't work anymore (had to switch from tar to zip because stupid security system wouldn't let me transfer the tar file)

  • source
  • parent
  • hideshow 2 child comments
  • [–] 4 points 1 year ago

    For those wishing they could do that with zip and 7zip, you can add a permissions file to the archive that you first make with getfacl, and then on the target after extracting said archive, restore permissions and ownership with setfacl from that file.

    Handy for certain support organizations that insist on a zip but that later want the permissions. (Looking at you SAP and IBM).

  • source
  • [–] 4 points 1 year ago (2 children)

    Yeah I did notice that. Never really had a use for such a feature though.

  • source
  • hideshow 2 child comments