1
As part of an installation procedure of a piece of software, I use:
curl -s <url-to-targz> | tar -p -x -z -C /
inside a Perl script (I use qx($command)
or system($command)
, either will do.All goes well, and the tar ball is installed to the / of my system, but when I do the same thing to an nfs share:
curl -s <url-to-targz> | tar -p -x -z -C /my-nfs/opt
Then the following occurs:
- When I do this on the prompt, this goes well (i.e. all my permissions that I saved in the tar ball are still in place).
- When I do this from withing the Perl script (or a shell script, for that matter), either
qx($command)
orsystem($command)
leaves me in with the situation that the permissions are changed (for example, what was executable, is no longer executable).
I am suspecting this has to do with umask (which is 022 on my system), and normally the -p flag should take care of that, but still no joy in this case. Does anyone have any suggestions for me (other than read the manpage :-))?
I have also tried something like system("umask xyz; $command")
, but (probably because the $command
is using a fork of my process, which gets the umask 022
): also no joy.
Edit: Some of the answers indicate I should use umask of Perl. I think a umask 000 will do the trick (but I will see this in the morning, when I am at the system. umask though, has a different effect on files and directories. Is there a way to disable umask entirely during the run of my progran (despite a thousand security reasons against it).
When you run this command on the prompt, are you
root
? I thinktar -p
also saves the owner (I'm really not sure, the man is vague), which won't work as normal user. Perhaps that's a problem?! – mpy – 2013-06-08T16:14:57.377Indeed, I run it as root. When running as normal user, -p does not restore permissions in the right fashion. As root, it should. Also, there is user:group information safed in the tar ball, which you can't restore when running tar as non-root – Willem – 2013-06-08T17:05:20.783
And it's working as root also on the NFS mount? I suspected that the error is due to the fact that lots of nfsd are configures to map
root
tonobody
(optionrootsquash
). – mpy – 2013-06-08T17:52:29.953I belive there's a perl function to change the program umask. Or, perhaps
"umask xyz && $command"
would work. – jpaugh – 2013-06-08T18:20:18.727