epoch1970;477471 Wrote: 
> I think sudo's '-S' option may come to the rescue. I tried to replicate
> the functionality of this part of the instructions: "sudo -u
> squeezeboxserver sudo /sbin/shutdown -k -h now" with this: "sudo
> testsudo.sh"
> > 
Code:
--------------------
  >   > #!/bin/bash
  > USER="squeezeboxserver"
  > HOST=`hostname -s`
  > 
  > if [ "$EUID" -ne 0 ]; then
  > echo "Please run this command as 'sudo $0'. Exit"
  > exit 0
  > fi
  > 
  > /usr/bin/wall <<END;
  > ** Testing ${USER}'s ability to run privileged commands on $HOST **
  > 
  > You may now see a message announcing immediate shutdown.
  > This is only a test. Host $HOST WILL NOT really shutdown.
  > END
  > sleep 5;
  > # reset timestamp
  > sudo -k;
  > # send a wrong passwd from stdin if asked for it => OK = 0
  > echo "" | sudo -S -u $USER sudo -S /sbin/shutdown -k now > /dev/null 2>&1 
&& OK=1 || OK=0;
  > 
  > if [ "$OK" -eq 1 ]; then
  > echo -e "\nSuccess!\n";
  > else
  > echo -e "\nThere was a boo-boo.\n";
  > fi
--------------------
> > 
> Seems to work for me (debian, OS X) Is it useful to you ?
> 
> NB: I switched to using bash only because I had trouble with "echo
> -e" on OSX using sh. Remove the -e and sh will do nicely.
The problem here is that on OS X, Squeezebox Server does not run under
a 'squeezeboxserver' account as it does on Linux, but rather under the
user's account that was used when setting up SBS.  Ostensibly, this is
because the SBS developers want to give access permissions to the user's
iTunes files.  Just another of the myriad SBS inconsistencies that 3rd
party developers have to keep track of, imho.

Anyway, I don't think 'sudo -k' or 'sudo -K' can invalidate the user's
sudo timestamp from within a sudo session.  And that means that your
test script potentially always reports success on OS X, even when the
permissions aren't correctly set.


-- 
gharris999
------------------------------------------------------------------------
gharris999's Profile: http://forums.slimdevices.com/member.php?userid=115
View this thread: http://forums.slimdevices.com/showthread.php?t=48521

_______________________________________________
plugins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/plugins

Reply via email to