You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2007/06/15 14:27:34 UTC
svn commit: r547650 - in /spamassassin/trunk/t: SATest.pm
spamd_allow_user_rules.t spamd_plugin.t
Author: jm
Date: Fri Jun 15 05:27:33 2007
New Revision: 547650
URL: http://svn.apache.org/viewvc?view=rev&rev=547650
Log:
bug 5510: fix test suite to support running as root, now that spamd will automatically fall back to 'nobody' privs
Modified:
spamassassin/trunk/t/SATest.pm
spamassassin/trunk/t/spamd_allow_user_rules.t
spamassassin/trunk/t/spamd_plugin.t
Modified: spamassassin/trunk/t/SATest.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/SATest.pm?view=diff&rev=547650&r1=547649&r2=547650
==============================================================================
--- spamassassin/trunk/t/SATest.pm (original)
+++ spamassassin/trunk/t/SATest.pm Fri Jun 15 05:27:33 2007
@@ -88,6 +88,13 @@
read_config();
+ # if running as root, ensure "nobody" can write to it too
+ if ($> == 0) {
+ $tmp_dir_mode = 0777;
+ } else {
+ $tmp_dir_mode = 0755;
+ }
+
if (!$NO_SPAMD_REQUIRED) {
$NO_SPAMC_EXE = ($RUNNING_ON_WINDOWS &&
!$ENV{'SPAMC_SCRIPT'} &&
@@ -138,7 +145,8 @@
# create an empty .prefs file
open (PREFS, ">>log/test_default.cf"); close PREFS;
- mkdir("log/user_state",0755);
+ mkdir("log/user_state",$tmp_dir_mode);
+ chmod ($tmp_dir_mode, "log/user_state"); # unaffected by umask
$home = $ENV{'HOME'};
$home ||= $ENV{'WINDIR'} if (defined $ENV{'WINDIR'});
@@ -147,7 +155,10 @@
$ENV{'TEST_DIR'} = $cwd;
$testname = $tname;
- $current_user = (getpwuid($>))[0];
+ $spamd_run_as_user = (getpwuid($>))[0];
+ if ($> == 0) {
+ $spamd_run_as_user = "nobody";
+ }
}
# a port number between 32768 and 65535; used to allow multiple test
@@ -241,9 +252,7 @@
my $post_redir = '';
$args =~ s/ 2\>\&1$// and $post_redir = ' 2>&1';
- rmtree ("log/outputdir.tmp"); # some tests use this
- mkdir ("log/outputdir.tmp", 0755);
-
+ recreate_outputdir_tmp();
clear_pattern_counters();
if (defined $ENV{'SA_ARGS'}) {
@@ -275,8 +284,7 @@
my $args = shift;
my $read_sub = shift;
- rmtree ("log/outputdir.tmp"); # some tests use this
- mkdir ("log/outputdir.tmp", 0755);
+ recreate_outputdir_tmp();
%found = ();
%found_anti = ();
@@ -385,6 +393,12 @@
1;
}
+sub recreate_outputdir_tmp {
+ rmtree ("log/outputdir.tmp"); # some tests use this
+ mkdir ("log/outputdir.tmp", $tmp_dir_mode);
+ chmod ($tmp_dir_mode, "log/outputdir.tmp"); # unaffected by umask
+}
+
# out: $spamd_stderr
sub start_spamd {
die "NO_SPAMD_REQUIRED in start_spamd! oops" if $NO_SPAMD_REQUIRED;
@@ -394,8 +408,7 @@
return if (defined($spamd_pid) && $spamd_pid > 0);
- rmtree ("log/outputdir.tmp"); # some tests use this
- mkdir ("log/outputdir.tmp", 0755);
+ recreate_outputdir_tmp();
if (defined $ENV{'SD_ARGS'}) {
$spamd_extra_args = $ENV{'SD_ARGS'} . " ". $spamd_extra_args;
Modified: spamassassin/trunk/t/spamd_allow_user_rules.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/spamd_allow_user_rules.t?view=diff&rev=547650&r1=547649&r2=547650
==============================================================================
--- spamassassin/trunk/t/spamd_allow_user_rules.t (original)
+++ spamassassin/trunk/t/spamd_allow_user_rules.t Fri Jun 15 05:27:33 2007
@@ -36,7 +36,7 @@
";
close OUT;
-ok (start_spamd ("--virtual-config-dir=log/virtualconfig/%u -L -u $current_user"));
+ok (start_spamd ("--virtual-config-dir=log/virtualconfig/%u -L -u $spamd_run_as_user"));
ok (spamcrun ("-u testuser < data/spam/009", \&patterns_run_cb));
ok (stop_spamd ());
Modified: spamassassin/trunk/t/spamd_plugin.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/spamd_plugin.t?view=diff&rev=547650&r1=547649&r2=547650
==============================================================================
--- spamassassin/trunk/t/spamd_plugin.t (original)
+++ spamassassin/trunk/t/spamd_plugin.t Fri Jun 15 05:27:33 2007
@@ -22,6 +22,7 @@
open(COUNTER,">log/spamd_plugin.tmp");
print COUNTER "0";
close COUNTER;
+chmod (0666, "log/spamd_plugin.tmp");
my $sockpath = mk_safe_tmpdir()."/spamd.sock";
start_spamd("-D -L --socketpath=$sockpath");