Commit a7cf2831 authored by Robert Ricci's avatar Robert Ricci

Change the username we connecto the the database as. We now use the

name of the script, and the name of the user who ran it, in the form
"script:user" . Should be useful for accounting.
parent 720355fd
......@@ -96,6 +96,7 @@ use Exporter;
# Must come after package declaration!
use English;
use File::Basename;
use POSIX qw(strftime);
require Mysql;
......@@ -121,9 +122,27 @@ my $DB;
sub TBDBConnect()
my $maxtries = 5;
# Construct a 'username' from the name of this script and the user who
# ran it. This is for accounting purposes.
my $scriptname;
if ($0) {
$scriptname = basename($0);
if (!$scriptname) {
$scriptname = "unknown";
my $name = getpwuid($UID);
if (!$name) {
$name = "uid$UID";
my $dbuser = "$scriptname:$name";
while ($maxtries && !defined($DB)) {
$DB = Mysql->connect("localhost", $DBNAME, "script", "none");
$DB = Mysql->connect("localhost", $DBNAME, $dbuser, "none");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment