Skip to content
  • Leigh B. Stoller's avatar
    Ah yes, I can waste time like the best of the best. Actually, I'm just · 88fdc7f0
    Leigh B. Stoller authored
    waiting for Mike to work on Jail. This is an auditing module. Its
    intended to serve two purposes. 1) Provide a common set of routines
    for generating all that audit email from various scripts and 2)
    provide a debugging hook for when things screw up via the web
    interface and the user is too clueless to help us out, or the
    information just got lost someplace.
    
    The main function is:
    
    	AuditStart($daemonize;$logname);
    
    To start an audit, call AuditStart(). The first arg indicates if the caller
    is wanting to daemonize. If not, just redirect stdout/stderr to a logfile,
    and return. The logfile is optional; if not provided one will be created
    based on the name of the script with mktemp. If the user wants to
    daemonize, also fork and detach. This is provided as a convenience for
    those scripts that tend to combine redirecting output and daemonizing. The
    parent is exptected to exit, like any good mother of a daemon.
    
    Okay, so all output is redirected to the log file. If a subscript is
    invoked that also calls audit, that call is ignored, under the assumption
    that the logging can be rolled into the parent, and besides it would create
    a blizzard of email.
    
    There is a package destructor (END) that is setup to email the log file to
    the audit list, and if a log was created, the log goes to the logs
    list. This is important. The audit list never gets any logs; it just gets a
    two line record of what was done ("rmacct mike (by stoller)"). The log goes
    separately to the logs list for inspection if needed at some point. This
    makes the audit list very consise and easy to distill.
    
    Like all good package destructors, you can tell if the script was
    exiting with an error. If it was, then instead of sending the mail to
    the logs list, send the message to tbops! The nice thing is that this
    gets invoked no matter how you exit! No need to explicitly send the
    email, unless of course you want it, but I have not written than
    function yet!
    
    Oh, for debugging. We can go stick in Audit calls when scripts
    misbehave, and we can watch the output.
    
    Cool, right? Really useful, right? Handy Dandy, right? Mike?
    88fdc7f0