On 3/3/21 6:53 AM, Jerry Geis wrote:
When I "tar" up an archive the files have an owner bob,
when I extract that to another machine bob is there also but user number is
different.
So when I extract bob is no longer the owner of the files but someone else.
Is there a good way to account for this ?
In order to answer that question, we need to know what system is
creating the tar file and what system is extracting the file. There are
several formats for tar archives (see the --format option to GNU tar for
a list), and tar will have different options on different platforms.
This process works the way you expect, by default, on CentOS systems.
I can demonstrate that by creating a CentOS container, adding a user and
creating a tar archive with a file owned by that user. A new container,
with users that have different numeric IDs will extract that archive and
preserve the file's ownership by name and not numeric IDs:
$ podman run -v $(pwd):$(pwd):z -w $(pwd) -it centos:8
[root@9d60934a7390 tartest]# useradd user1
[root@9d60934a7390 tartest]# touch user1file
[root@9d60934a7390 tartest]# chown user1 user1file
[root@9d60934a7390 tartest]# tar cf user1.tar user1file
[root@9d60934a7390 tartest]# exit
$ podman run -v $(pwd):$(pwd):z -w $(pwd) -it centos:8
[root@49a5818ef7a6 tartest]# useradd user2
[root@49a5818ef7a6 tartest]# useradd user1
[root@49a5818ef7a6 tartest]# rm user1file
rm: remove regular empty file 'user1file'? y
[root@49a5818ef7a6 tartest]# tar xf user1.tar
[root@49a5818ef7a6 tartest]# ls -l
total 12
-rw-r--r--. 1 root root 10240 Mar 3 19:21 user1.tar
-rw-r--r--. 1 user1 root 0 Mar 3 19:21 user1file
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
https://lists.centos.org/mailman/listinfo/centos