When we create files in the unix/posix environment, we have to consider who can change the owner of a file. As a general rule, any files you create are with your user id and primary group id. This is documented in the man pages for the open() call:
O_CREAT
If the file exists, this flag has no effect, except as noted under the O_EXCL flag. If the file does not exist, a regular file is created
with the following characteristics:
* The owner ID of the file is set to the effective user ID of the process.
* The group ID of the file is set to the group ID of the parent directory if the parent directory has the SetGroupID attribute (S_ISGID
bit) set. Otherwise, the group ID of the file is set to the effective group ID of the calling process.
* The file permission and attribute bits are set to the value of the Mode parameter, modified as follows:
* All bits set in the process file mode creation mask are cleared. (The file creation mask is described in the umask subroutine.)
* The S_ISVTX attribute bit is cleared.
The file open with the O_CREAT flag by the open64 subroutine must create an encrypted file when the file is within an encrypted directory or
inheritance schema and the calling process has an open key store. This will have the effect of generating a random symmetric file encryption
key, wrapping it with the users public key and storing it in the files metadata.
If you want to change the ownership/group/permissions of the file, then you will need root authority. If you restore the files as root, then I would expect the ownership to be preserved as stated on the gzip website:
gzip normally preserves the mode and modification timestamp of a file when compressing or decompressing. If you have appropriate privileges, it also preserves the file’s owner and group.
And we do not recommend you SUID gzip to root. You could break/damage/overwrite system files without knowing OR install a worm/trojan/etc/ If you need the permissions/ownership changed, you can consider using ACLs (Access Control Lists) or you can have a special program run to change the ownership/group/permissions.
#AIXOpenSource