[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Updating files in /etc Remotely (and automated)



 On 09/12/2010 07:04 PM, Joe wrote:
Note that sudo does not completely mimic root behaviour. Commands using
  >, and presumably other composite commands, will depend on the user's
own permissions.

In an 'all-root' directory, with no existing file2:

sudo cp file1 file2 works as expected
sudo touch file2 works as expected
sudo cat file1 works as expected
sudo cat file1>  file2 fails due to lack of write permission
su -c "cat file1>  file2", then<password>, works as expected

It isn't just cat, I first noticed this some years ago with aggregate,
which also uses>. I assume that when the shell reaches the>, which is
effectively another command, the temporary sudo one-command permission
has expired. The trick with the quotation marks doesn't work, sudo
expects the entire quoted string to be the name of an executable.

Actually, the shell (running as the normal user) sees the redirection, tries to opens the file, and then runs "sudo cat file1", redirecting the output to the opened file. Then sudo runs, cat'ing the file (as root) to stdout.


--
Do YOU have redeeming social value?

Eduardo M KALINOWSKI
eduardo@kalinowski.com.br


Reply to: