General TC > General TC Talk
sudo'd out
tobiaus:
--- Quote from: jpeters on February 12, 2009, 11:56:49 AM ---I reproduced the error. If I use "sudo find . | cpio -o -H newc | gzip -9 > tinycore.gz" I get:
--- Code: ---cpio: ./usr/sbin/visudo: Cannot open: Permission denied
cpio: ./usr/bin/sudo: Cannot open: Permission denied
--- End code ---
If I go into root with sudo su first and run the command, it works fine. I thought they were the same thing, but guess not.
--- End quote ---
i've experienced issues i would call similar, but a bit of experimenting helped my understanding. (that's assuming i'm right. if i'm not, it didn't help my understanding.)
for example, one might think:
sudo mkdir /tmp/sudotmp && cp /mnt/sda1/* /tmp/sudotmp would copy all files from /mnt/sda1 to /tmp/sudotmp, even if they can only be read by a superuser. actually, the cp command is not sudo'd.
i suspect (you'll have to figure this out) that cpio and gzip as you use them do not have root access. perhaps using sudo before cpio and gzip will help. it may at least explain your message.
jpeters:
--- Quote from: tobiaus on February 12, 2009, 12:17:31 PM ---
i suspect (you'll have to figure this out) that cpio and gzip as you use them do not have root access. perhaps using sudo before cpio and gzip will help. it may at least explain your message.
--- End quote ---
ah---that was it. It needed a separate 'sudo' for each command in the pipe. Thanks (think I'll just go into root, however...... ;) )
mikshaw:
--- Quote from: jpeters ---If I go into root with sudo su first and run the command, it works fine. I thought they were the same thing, but guess not.
--- End quote ---
It's not the same...using "sudo <command>" is essentially running a command as a regular user, with the regular user's environment, only with a temporary magic wand for that particular command. If you "sudo su" you are becoming root...the same as if you logged in as root...so everything you do after that point is done as root.
What I was never sure of, and never tested, was if sudo passes root through pipes. It looks like it doesn't, according to what you have experienced, though I'm just guessing.
^thehatsrule^:
afaik the pipe would have the same permissions as the shell it is in, since that is what handles them. For example, you could do something like
--- Code: ---sudo sh -c "command | anothercommand"
--- End code ---
jpeters:
--- Quote from: ^thehatsrule^ on February 12, 2009, 10:27:53 PM ---afaik the pipe would have the same permissions as the shell it is in, since that is what handles them. For example, you could do something like
--- Code: ---sudo sh -c "command | anothercommand"
--- End code ---
--- End quote ---
cpio needs its own 'sudo'. I just tried "sudo zcat ./tinycore.gz | cpio -H newc -i -d --no-absolute-filenames" and got a bunch of permission errors. I ran it again with " sudo zcat ./tinycore.gz | sudo cpio -H newc -i -d --no-absolute-filenames" and it unpacked.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version