1

How can tar display a user name for example www-data on a system that does not have a www-data user?

I know that tar preserves user permissions based on the system ID in this case www-data being 33 ( I believe?) on Debian systems.

Whats most confusing about this is that if I change the permissions on a folder to 33 a user that does not exist and send it off to another server, tar reports the owner being user 33 but on untaring it the folders are set to owner www-data.

tar (GNU tar) 1.29

2 Answers 2

1

This is because tar is saving this information too, it's the ustar format specified in POSIX 1003.1-1990. In the offical source code this is specified in the tar.h header file. I copied the important block:

/* POSIX header.  */

struct posix_header
{               /* byte offset */
  [...]
  char uid[8];          /* 108 */
  char gid[8];          /* 116 */
  [...]
  char uname[32];       /* 265 */
  char gname[32];       /* 297 */
  [...]
};

As you can see the owner user name as well as the owner group name are stored besides the uid and gid.

0

Tar also saves the name of the user and the group in the file. You can verify this by looking at the tar file itself with tools like hexdump. The reason is that the same name might be used on different systems but with different numbers.

In the second case, the source system doesn't know a name for user 33, so it can't supply a name, just the number. The extracting tar uses this number, and as the system knows this number, it displays a user name for that number.

See also

--numeric-owner
Always use numbers for user/group names.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .