On 2003-01-30 15:47 -0600, Frank Cox wrote:

> 2.  Creating /etc/shutdown.allow and adding -a to the line in /etc/inittab
> as follows:
> 
> ca::ctrlaltdel:/sbin/shutdown -a -t3 -r now
> 
> alows the user to shutdown (reboot) the computer only if he uses
> ctrl-alt-delete, but not by calling /sbin/shutdown from a bash script.
> 
> Is there a more elegant way to do this than using something like sudo to
> allow a shutdown by a user other than root through a script?

Write a small setuid wrapper around shutdown(8) ?

#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>

#include <unistd.h>

int main (int argc, char *argv[])
{
  const char *shutdown_pathname = "/sbin/shutdown";

  (void) argv;
  if (argc != 1)
  {
    fputs ("usage: myshutdown\n", stderr);
    exit (1);
  }
  execl (shutdown_pathname, "shutdown", "-a", "-t3", "-r", "now", NULL);
  fprintf (stderr, "%s: can't exec (%s)\n", shutdown_pathname,
    strerror (errno));
  if (errno == ENOENT)
    return 127;
  else
    return 126;
}

Compile it and make the binary setuid root. I'm really not sure
whether it's more or less elegant than using sudo, though.

-- 
Andr� Majorel <[EMAIL PROTECTED]>
http://www.teaser.fr/~amajorel/

_______________________________________________
Xmame mailing list
[EMAIL PROTECTED]
http://toybox.twisted.org.uk/mailman/listinfo/xmame

Reply via email to