Please help

Matthew Hannigan mlh at
Sat Mar 23 02:42:58 EST 2002

Douglas De Vine wrote:
> my sudoers file:
> root    ALL=(ALL) ALL
> www     ALL = NOPASSWD: ALL
> my command, run as 'www':
> /usr/bin/sudo echo "Hello" >> /tmp/hosts
> the error:
> bash: /tmp/hosts: Permission denied
> the file permissions:
> -rw-r--r--    1 root     nobody         30 Mar 23 14:26 hosts

That's a shell feature.  /tmp/hosts is opened by
the shell before sudo is executed.

This might work (I'm away from my sudo machine
at the moment)

/usr/bin/sudo 'echo "Hello" >> /tmp/hosts'

if that doesn't, then try:

/usr/bin/sudo echo '"Hello" >> /tmp/hosts'

A surefire way and much safer way to  make it work would
be to that entire command in a shell script and only allow
www to execute that shell script.

Another security note .. as root, (or anybody really)
you should NOT create files with simple nonrandom
file names like "hosts" in /tmp.



More information about the sudo-users mailing list