Commit d753322a authored by Leigh Stoller's avatar Leigh Stoller

Silly little change to the mail functions; add X-NetBed: header with

script name (basename, not full path).
Also moved the "use" lines below the package declaration, as I think
they are supposed to be.
parent 1ae5fe0f
......@@ -2,16 +2,10 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
use POSIX qw(strftime);
use POSIX qw(setsid);
use Fcntl;
use IO::Handle;
package libtestbed;
use Exporter;
......@@ -21,10 +15,19 @@ use Exporter;
TBMakeLogname TB_BOSSNODE TB_OPSEMAIL TBGenSecretKey TBDebugTimeStamp
TBDebugTimeStampsOn );
# After package decl.
use English;
use POSIX qw(strftime);
use POSIX qw(setsid);
use Fcntl;
use IO::Handle;
use File::Basename;
my $MAILTAG = "@OURDOMAIN@";
my $BOSSNODE = "@BOSSNODE@";
my $TIMESTAMPS = "@TIMESTAMPS@";
my $TBOPSEMAIL = "@TBOPSEMAIL@";
my $SCRIPTNAME = "Unknown";
# Hostname of our boss node
sub TB_BOSSNODE() { $BOSSNODE; }
......@@ -32,6 +35,14 @@ sub TB_BOSSNODE() { $BOSSNODE; }
# Testbed ops email address
sub TB_OPSEMAIL() { $TBOPSEMAIL; }
# Untainted scriptname for email below.
if ($PROGRAM_NAME =~ /^([-\w\.\/]+)$/) {
$SCRIPTNAME = basename($1);
}
else {
$SCRIPTNAME = "Tainted";
}
# A library of useful stuff.
# Send an email message via sendmail -t.
......@@ -63,6 +74,7 @@ sub SENDMAIL($$$;$$@)
if (defined($Headers)) {
print MAIL "$Headers\n";
}
print MAIL "X-NetBed: $SCRIPTNAME\n";
print MAIL "\n";
print MAIL "$Message\n";
print MAIL "\n";
......@@ -115,6 +127,7 @@ sub OPENMAIL($$;$$)
if (defined($Headers)) {
print MAIL "$Headers\n";
}
print MAIL "X-NetBed: $SCRIPTNAME\n";
print MAIL "\n";
return(*MAIL);
......
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