[sudo-users] sudo and variable expantion: HowTo?

Matthew Hannigan mlh at zip.com.au
Thu Jun 8 09:56:35 EDT 2006

On Thu, Jun 08, 2006 at 11:30:45AM +0400, генерал Пурпоз wrote:
> Hello Matthew,
> >>   mortal     ALL = /bin/kill -HUP $(cat /var/run/ntpd.pid)
> > At a guess the invoked shell  does not like the $( .. )
> > Try
> >         mortal     ALL = /bin/kill -HUP `cat /var/run/ntpd.pid`
> No, this way it does not work either.
> Both ways I see the correct PID shown in the refusal sudo message
> stating that "mortal is not allowed to ... as root on this host".

Hrm; how do you invoke it?

Sudo does a textual match; it's pretty hard to get something
to match backquotes without it actually being eval'd

Best off writing a wrapper script, say, hupntp, with
	/bin/kill -HUP `cat /var/run/ntpd.pid`

then in sudoers:

	mortal     ALL = /usr/local/bin/hupntp


More information about the sudo-users mailing list