NAME

Sudoscript.pm


SYNOPSIS

 use Sudoscript;
 my $ss=Sudoscript->new();
 .. do stuff with $ss


DESCRIPTION

A module to implement some common attributes and methods shared between sudoshell and sudoscriptd. See sudoscript(8), sudoscriptd(8) and sudoshell(1) for descriptions of the sudoscript system.

This module implements routines that

The following sections docment these routimnes more fully.


Constructor

The constructor is called new(). It does the usual OO style initialization, then returns the result of calling _init();

The _init() routine:


Command Properties

These properties return unqualified command names with switches, when they appear, appropriate for the running OS. (Since _init() sets the execution path, we do not fully qualify the paths to these commands.)

SUDO()

The sudo(8) command without any switches

GREP()

The grep(1) command, without any switches

PS()

The ps(1) command with switches that produce a listing parseable by checkpid()

INITSCR()

  The complete path to the sudoscriptd init script

SCRIPT()

The script(1) command. On Linux, this will have the -q switch added.

TZNAMES()

The local time zone names set up by _init()


Methods

check_ssd()

This method checks to see if sudoscriptd is running (via checkpid()) If not, it offers to start it, and gives some helpful advice regarding starting sudoscriptd at boot time. It also tells the user they need root sudo privilege to successfully start sudoscriptd. The method then looks for the sudoscriptd init script set up by _init(). If that script is not found, or is not executable, the method prompts for an init script path to use. It then attempts to start the daemon. The method sleeps for three seconds and then checks again for sudoscriptd with checkpid(). If the daemon still isn't running, the method dies, taking the caller with it.

checkpid()

This method gets the PID of the current sudoscriptd out of /var/run/sudoscriptd.pid, if there is such a file. It looks for the PID in the process list If there is such a process, and its name contains 'sudoscriptd', the method returns the PID. Otherwise, it returns 0.

datestamp()

This method returns a date stamp string in one of three formats, depending on the passed parameter.

These are:

long
wdy mon dd hh:mm:ss TZ yyyy

sortable
yyyymoddhhmmss

anything else
wdy mon dd hh:mm:ss

 Where:
   wdy     = week day name
   mon     = three letter month name
   TZ      = three letter time zone name (e.g. 'PST')
   yyyy    = four digit year
   mo      = two digit month number
   dd      = two digit day of month
   hh      = two digit hour
   mm      = two digit minute
   ss      = two digit second

daemon_io()

This method closes STDIN and STDOUT, and redirects STDERR to a file named:

  /var/run/sudoscriptd/stderr$tag

Where $tag is a string passed to the method. There are commonly three, but sometimes two or four types of daemons running at all times in the sudoscript system. Each of them calls daemon_io() and each gets a seperate (per daemon type) stderr log. These are are overwritten on the next sudoscriptd startup.


SEE ALSO

sudoscript(8)

sudoscriptd(8)

sudoshell(1)

sudo(8)

sudoers(5)

http://www.egbok.com/sudoscript


AUTHOR

Howard Owen, <hbo@egbok.com>


COPYRIGHT AND LICENSE

Copyright 2003 by Howard Owen

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.