Mailing List Archive

svn commit: r165055 - /spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
Author: jm
Date: Wed Apr 27 14:53:21 2005
New Revision: 165055

URL: http://svn.apache.org/viewcvs?rev=165055&view=rev
Log:
added commentary regarding die() usage

Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm?rev=165055&r1=165054&r2=165055&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm Wed Apr 27 14:53:21 2005
@@ -825,7 +825,11 @@
my $tmpdir = Mail::SpamAssassin::Util::untaint_file_path(
File::Spec->tmpdir()
);
+
if (!$tmpdir) {
+ # note: would prefer to keep this fatal, as not being
+ # able to find a writable tmpdir is a big deal for the calling
+ # code too. Should be quite a psychotic case, also.
die "util: cannot find a temporary directory, set TMP or TMPDIR in environment";
}

@@ -1112,6 +1116,7 @@

# Check that we have now accomplished the setuid
if ($< != $touid) {
+ # keep this fatal: it's a serious security problem if it fails
die "util: setuid $< to $touid failed!";
}
}
@@ -1142,6 +1147,7 @@
# do a fork-open, so we can setuid() back
my $pid = open ($fh, '-|');
if (!defined $pid) {
+ # acceptable to die() here, calling code catches it
die "util: cannot fork: $!";
}

@@ -1171,6 +1177,7 @@
if ($f != 0) {
POSIX::close(0);
}
+ # acceptable to die() here, calling code catches it
open STDIN, "<$stdinfile" or die "util: cannot open $stdinfile: $!";

# this should be impossible; if we just closed fd 0, UNIX
@@ -1208,7 +1215,8 @@
}

exec @cmdline;
- die "util: exec failed: $!";
+ die "util: exec failed: $!";
+ # must be a die() otherwise -w will complain
}

###########################################################################