Re: SUDO QUESTION
Gordon Messmer <[email protected]>
| Newsgroups | gmane.linux.redhat.release.psyche |
|---|---|
| Message-ID | <[email protected]> |
jim car wrote:
> Why can't a user issue the following commands using sudo? It always
> comes back as permission denied. The sudoer's password is accepted.
>
> sudo cat ./httpd.tmp >> /etc/httpd/conf/httpd.conf
In this example, two things are happening:
1) sudo authenticates the user and runs "cat ./httpd.tmp" as root
2) the user's shell attempts to open /etc/httpd/conf/httpd.conf and
write the output of "sudo" into that file.
Redirection is not handled by "sudo", or any other command you run: it's
a function of the shell in which the redirection was requested.
Naturally, you can't sudo that. You can however, accomplish what you
want this way:
cat ./httpd.tmp | sudo dd if=/dev/stdin of=/etc/httpd/conf/httpd.conf
( useless use of cat, primarily intended to display the use of
/dev/stdin )
or more simply:
sudo dd if=./httpd.tmp of=/etc/httpd/conf/httpd.conf
dd, unlike the shell, will do redirection in a command that can be
evoked from sudo.
--
Psyche-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/psyche-list