I cannot su to the smokeping user for some reason. Perhaps this is because the smokeping user's shell is set to /bin/false.<br><br>The script is to switch GPIO pins on my new Raspberry Pi (see <a href="http://www.raspberrypi.org">www.raspberrypi.org</a>). The script needs to run as root so that it can access the GPIO pins.<br>
<br>I tried running a shell script on the same alert using sudo and without sudo. It only works without sudo. Here is the relevant line from /etc/sudoers:<br><br>smokeping ALL=(ALL) NOPASSWD: ALL<br><br>Thanks<br><br>Andrew.<br>
<br><div class="gmail_quote">On 27 July 2012 00:13, Jim Long <span dir="ltr"><<a href="mailto:smokeping@museum.rain.com" target="_blank">smokeping@museum.rain.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Thu, Jul 26, 2012 at 11:56:41PM +0100, Andrew Pattison wrote:<br>
> I tried that but it still doesn't work. The alert is triggered as it is<br>
> logged in /var/messages but either smokeping is not calling the script or<br>
> the call is failing. Any ideas?<br>
><br>
> Andrew.<br>
<br>
</div>Once again, please pardon the basics.<br>
<br>
Using su, change your effective user ID to the smokeping user,<br>
whatever user you run smokeping under (the user account under<br>
which the alerts get invoked). Verify that this is so:<br>
<br>
$ touch /tmp/foo<br>
$ ls -l /tmp/foo<br>
(should show zero bytes, ownership by smokeping user)<br>
$ rm /tmp/foo<br>
<br>
Then manually invoke the same sudo command line that you're using<br>
in the alerts. Does it ask you for a password? If so, your<br>
sudoers file is not set up correctly.<br>
<br>
Set your script aside, and try this script 'test.sh' instead:<br>
<br>
#!/bin/sh<br>
rm -rf /tmp/smokeping-sudo.log<br>
( date; set; echo '--' ) > /tmp/smokeping-sudo.log<br>
<br>
Does that write data into /tmp/smokeping-sudo.log? Examine the<br>
set output to confirm that the effective user ID is root/UID 0.<br>
Since that script runs under sudo as root, you should also see<br>
that /tmp/smokeping-sudo.log is owned by root.<br>
<br>
Lastly, consider whether your entire alert script really needs to<br>
run under sudo or just one specific command (or only a small<br>
number). Think about whether it is feasible to call the script<br>
directly, and use sudo only from within the script, on only those<br>
few commands where it is necessary. Are there any weird<br>
characters in your sudo command line that should be quoted or<br>
escaped? Can you share the contents of your alert command and<br>
the pertinent line of your sudoers file, and some 'ps' output<br>
that shows the username you use to run smokeping under?<br>
<br>
Hope this helps.<br>
<span class="HOEnZb"><font color="#888888"><br>
Jim<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
> On 25 July 2012 17:23, Ryan Becker <<a href="mailto:rb14060@gmail.com">rb14060@gmail.com</a>> wrote:<br>
><br>
> > Try using the absolute path to the script in the sudoers file. Also, the<br>
> > /etc/sudoers file should NOT be edited directly, you should be using the<br>
> > visudo command as root.<br>
> ><br>
> > On Wed, Jul 25, 2012 at 4:41 AM, Andrew Pattison <<a href="mailto:andrum99@gmail.com">andrum99@gmail.com</a>>wrote:<br>
> ><br>
> >> I've got something similar in in /etc/sudoers already.<br>
> >><br>
> >> Thanks<br>
> >><br>
> >> Andrew.<br>
> >><br>
> >><br>
> >> On 24 July 2012 23:15, Ryan Becker <<a href="mailto:rb14060@gmail.com">rb14060@gmail.com</a>> wrote:<br>
> >><br>
> >>> Make sure that the user is allowed to execute the script without a<br>
> >>> password. Here's an example that you can modify to suit your<br>
> >>> needs: techbnc ALL = NOPASSWD: /usr/sbin/csf<br>
> >>> In this example the user techbnc is allowed to call /usr/sbin/csf<br>
> >>> without needing a password. What's happening is that normally when sudo is<br>
> >>> called, it asks for the password and Smokeping has no way to provide that<br>
> >>> password. By adding the user to the file with NOPASSWD, they are allowed<br>
> >>> to execute the script without being password prompted and therefore<br>
> >>> Smokeping will be able to complete the action.<br>
> >>><br>
> >>> On Tue, Jul 24, 2012 at 5:35 PM, Andrew Pattison <<a href="mailto:andrum99@gmail.com">andrum99@gmail.com</a>>wrote:<br>
> >>><br>
> >>>> I am trying to set up smokeping with an alert script. The alert script<br>
> >>>> is called like this entry in /etc/smokeping/config.d/Alerts:<br>
> >>>><br>
> >>>> to = |sudo script.py<br>
> >>>><br>
> >>>> When called as simply |script.py this works fine, but with sudo the<br>
> >>>> script does not get called. How can I get this working?<br>
> >>>><br>
> >>>> Thanks<br>
> >>>><br>
> >>>> Andrew.<br>
> >>>><br>
> >>>> _______________________________________________<br>
> >>>> smokeping-users mailing list<br>
> >>>> <a href="mailto:smokeping-users@lists.oetiker.ch">smokeping-users@lists.oetiker.ch</a><br>
> >>>> <a href="https://lists.oetiker.ch/cgi-bin/listinfo/smokeping-users" target="_blank">https://lists.oetiker.ch/cgi-bin/listinfo/smokeping-users</a><br>
> >>>><br>
> >>>><br>
> >>><br>
> >><br>
> ><br>
<br>
> _______________________________________________<br>
> smokeping-users mailing list<br>
> <a href="mailto:smokeping-users@lists.oetiker.ch">smokeping-users@lists.oetiker.ch</a><br>
> <a href="https://lists.oetiker.ch/cgi-bin/listinfo/smokeping-users" target="_blank">https://lists.oetiker.ch/cgi-bin/listinfo/smokeping-users</a><br>
<br>
</div></div></blockquote></div><br>