Re: trick question about sudo



Valent Turkovic wrote:
Hi,
I have one question about sudo.

While looking for uid/gid override for samba mounts I found this solution:
sudo echo 0 > /proc/fs/cifs/LinuxExtensionsEnabled

But this obviously doesn't work on Fedora but this works:
sudo sh -c 'echo 0 > /proc/fs/cifs/LinuxExtensionsEnabled'

But the trick question is in which setups and which circumstances can
the first sudo work?

Cheers,
Valent.




The answer: Never

Here is why: plumbing

The command sudo as I type it, belongs to me, and the connections to it, ie: STDIN, STDOUT, and STDERR (file handles 0, 1, and 2) are owned by me, and controlled by the shell that I am in.

These are attached by the shell/OS when sudo is run as a part of loading it, and well before the actual sudo code begins to execute.

Think of it as plumbing and everything in the pipeline before and after the command is mine.

mine >command> mine

ls > /tmp/file

/tmp/file is created with my permissions

any_command > /tmp/file

same

sudo any_command > /tmp/file

same

command < /tmp/file1 > /tmp/file2

/tmp/file1 must be readable by me
/tmp/file2 must be writable by me

Both sides of that pipe are performed as my user, regardless of the command being executed.

Hope that helps.




--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list



Relevant Pages

  • Re: Linux shutdown
    ... You should have a look at SUDO... ... to execute a command or a subset of command. ... Henc,e you can allow user XYZ to execute shutdown: ...
    (Security-Basics)
  • Re: executing sudo from ruby
    ... I wanna execute in a script of mine commands like: "sudo apt-get clean" ... The first command needs to be executed without influence to the main process of the ruby scipt. ... I think system("sudo apt-get clean") would be the right command. ...
    (comp.lang.ruby)
  • Re: Apple recommending anti-virus software for Macs?
    ... > To be ultra-safe with the 'rm' command, ... Not a bad idea for root, It would drive me nuts in my user account. ... downloads directory and executing it. ... That I type an EOF is a trivial difference versus 'sudo' exiting ...
    (comp.sys.mac.system)
  • Re: mounting issues
    ... If the command the user would need to execute is the same ... you could set up a sudo entry to allow a user to ... Please provide the sudo config syntax ...
    (comp.os.linux.misc)
  • Re: Possible to determine the current Finder user from the shell?
    ... >>> a sudo to root so $USER won't work. ... Likewise when I put that command into a shell script and execute ...
    (comp.sys.mac.system)