You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by bu...@spamassassin.apache.org on 2022/08/23 08:06:07 UTC

[Bug 8030] spamd SIGHUP restart failure when PERL5LIB is used (t/spamd_hup.t)

https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8030

Sidney Markowitz <si...@sidney.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sidney@sidney.com

--- Comment #1 from Sidney Markowitz <si...@sidney.com> ---
Created attachment 5799
  --> https://bz.apache.org/SpamAssassin/attachment.cgi?id=5799&action=edit
Proposed fix for this issue as patch to spamd.raw

Attached is proposed fix, posted here for an RTC vote.

I reproduced the problem on an Ubuntu VM by doing the following:

I installed CPAN module local::lib and configured it to use ~/perl5 as the
local library directory, setting the proper environment variables in ~/.bashrc

I uninstalled NetAddr::IP from my perl site library using cpanm -U NetAddr::IP

Then I installed it with cpanm -l ~/perl5 NetAddr::IP

In svn trunk I ran perl Makefile.PL < /dev/null ; make ; make test
TEST_FILES="t/spamd_hup.t" TEST_VERBOSE=1
which reproduced the bug, including the error message in the spamd STDERR log
about not being able to find NetAddr::IP in @INC.

After installing this patch, t/spamd_hup.t worked again.

I've uploaded a test build with this patch to my area on CPAN so that the test
machines will try it, and should have a useful set of results within 24 hours.

Could committers please review this patch for RTC? It has my +1, need two more.

What it does:

When spamd starts up, in a BEGIN block before anything else has a chance to add
anything to @INC, it saves the original contents of @INC into a variable. This
will contain whatever paths were added in -I options in the command call to
perl, followed by whatever the default @INC of the perl binary is.
Unfortunately, I found no way for a running perl to determine what those
defaults are other than the pretty nasty step of shelling out a call to perl -V
and parsing the output.

Later, after all required modules are loaded, the saved copy of @INC is
processed to untaint the paths remove any duplicates and paths that are not
absolute or don't exist, and turn it into a series of -I options for the call
to restart spamd.

The code that restarts spamd used to read the hashbang line at the top of the
spamd script file, and if it matched up with the executable file that perl said
it was running would exec the script file directly. That will not work if this
issue is a factor, because it will not make use of any -I options that were
used when spamd was called. So I removed that code and always invoke spamd on
the restart by calling the perl executable, including the -I options.

The restarted spamd will have duplicate paths in @INC for all the paths that
are in the perl default. They will be passed in as -I options and prefixed to
the default @INC. But perl doesn't do anything bad in tha situation, and the
removal of duplicates in the initial code ensures that the number of such
duplicates does not increase with each restart.

-- 
You are receiving this mail because:
You are the assignee for the bug.