That was a “fun” debugging session…

  • IsoKiero@sopuli.xyz
    link
    fedilink
    English
    arrow-up
    5
    ·
    edit-2
    3 hours ago

    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).

  • tetris11@lemmy.ml
    link
    fedilink
    arrow-up
    17
    ·
    edit-2
    7 hours 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

    • esa@discuss.tchncs.de
      link
      fedilink
      arrow-up
      7
      ·
      6 hours ago

      It’s even a tape archiving tool. Just pretty much nobody uses it in the original way any more.

      Very much one of those “if it ain’t broke, don’t replace it” tools.

      • ReversalHatchery@beehaw.org
        link
        fedilink
        arrow-up
        1
        ·
        4 hours ago

        but also the way it puts file data one after the other can be beneficial for compression, especially if you can define the order of the files somehow

    • lorty@lemmy.mlOP
      link
      fedilink
      arrow-up
      2
      ·
      6 hours ago

      I just assumed that whenever it would be expanded that the contents would have the default permissions for that user.

      It’s actually a cool feature I just feel dumb for how long it took me to realize this was the issue.

  • monovergent@lemmy.ml
    link
    fedilink
    arrow-up
    12
    ·
    14 hours ago

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