You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by he...@apache.org on 2018/10/29 13:29:29 UTC

svn commit: r1845122 - in /spamassassin/trunk: lib/Mail/SpamAssassin.pm lib/Mail/SpamAssassin/Plugin.pm spamd/spamd.raw

Author: hege
Date: Mon Oct 29 13:29:29 2018
New Revision: 1845122

URL: http://svn.apache.org/viewvc?rev=1845122&view=rev
Log:
Rollback spamd_child_after_non_root changes. Use skip_prng_reseeding to check spamd_child_init / set_global_state_dir handling. Need to call spamd_child_init only after root privs dropped.

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin.pm
    spamassassin/trunk/spamd/spamd.raw

Modified: spamassassin/trunk/lib/Mail/SpamAssassin.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin.pm?rev=1845122&r1=1845121&r2=1845122&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin.pm Mon Oct 29 13:29:29 2018
@@ -1661,8 +1661,8 @@ sub init {
   # Note that this PID has run init()
   $self->{_initted} = $$;
 
-  # if spamd, wait for spamd_child_after_non_root
-  if (!$self->{spamd}) {
+  # if spamd or other forking, wait for spamd_child_init
+  if ($self->{skip_prng_reseeding}) {
     $self->set_global_state_dir();
   }
 
@@ -2191,7 +2191,7 @@ sub call_plugins {
   return unless $self->{plugins};
 
   # Use some calls ourself too
-  if ($self->{spamd} && $subname eq 'spamd_child_after_non_root') {
+  if ($subname eq 'spamd_child_init') {
     # set global dir now if spamd
     $self->set_global_state_dir();
   } elsif ($subname eq 'finish_parsing_end') {

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin.pm?rev=1845122&r1=1845121&r2=1845122&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin.pm Mon Oct 29 13:29:29 2018
@@ -901,11 +901,6 @@ Indicate if the call is being made from
 
 Called in each new child process when it starts up under spamd.
 
-=item $plugin->spamd_child_after_non_root ()
-
-Called in each new child process after spamd possibly dropped root privs.
-The running user will not change anymore.
-
 =item $plugin->log_scan_result ( { options ... } )
 
 Called when spamd has completed scanning a message.  Currently,

Modified: spamassassin/trunk/spamd/spamd.raw
URL: http://svn.apache.org/viewvc/spamassassin/trunk/spamd/spamd.raw?rev=1845122&r1=1845121&r2=1845122&view=diff
==============================================================================
--- spamassassin/trunk/spamd/spamd.raw (original)
+++ spamassassin/trunk/spamd/spamd.raw Mon Oct 29 13:29:29 2018
@@ -1163,7 +1163,6 @@ my $spamtest = Mail::SpamAssassin->new(
     paranoid             => ( $opt{'paranoid'} || 0 ),
     require_rules        => 1,
     skip_prng_reseeding  => 1,  # let us do the reseeding by ourselves
-    spamd                => 1,  # make spamd_child_after_non_root known
     home_dir_for_helpers => (
       defined $opt{'home_dir_for_helpers'}
       ? $opt{'home_dir_for_helpers'}
@@ -1354,8 +1353,6 @@ sub spawn {
     }
 
     srand;  # reseed pseudorandom number generator soon for each child process
-    $spamtest->call_plugins("spamd_child_init");
-
     if ($sockets_access_lock_tempfile) {
       # A lock will be required across select+accept in a child processes,
       # Bug 6996. Need to have a per-child filehandle on the same lock file
@@ -1399,13 +1396,14 @@ sub spawn {
       }
     }
 
-    # main() will also run this to set global_state_dir
-    $spamtest->call_plugins("spamd_child_after_non_root");
-
     # set process name where supported
     # this will help make it clear via process listing which is child/parent
     $0 = 'spamd child';
 
+    # Let's call spamd_child_init only after root privs are dropped
+    # Mail::SpamAssassin::main() will also run this to set global_state_dir
+    $spamtest->call_plugins("spamd_child_init");
+
     $backchannel->setup_backchannel_child_post_fork();
     if ($scaling) {     # only do this once, for efficiency; $$ is a syscall
       $scaling->set_my_pid($$);