You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by fe...@apache.org on 2004/07/23 05:08:18 UTC
svn commit: rev 23168 - in spamassassin/trunk: lib/Mail/SpamAssassin spamd
Author: felicity
Date: Thu Jul 22 20:08:17 2004
New Revision: 23168
Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
spamassassin/trunk/spamd/README
Log:
bug 3586: on BSD-related platforms, the default perl may be 'picky' about when it allows setuid(). Mac OS X doesn't allow setuid() at all (documentation added to spamd/README). FreeBSD (and presumably the other *BSD variants) don't allow setuid() unless euid == 0, so we work around this by trying a simple setuid() and if it fails, change euid, then ruid, then euid again. spamd, for instance, sets euid for processing messages, which shows this issue.
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm Thu Jul 22 20:08:17 2004
@@ -926,10 +926,30 @@
sub setuid_to_euid {
return if (RUNNING_ON_WINDOWS);
- if ($< != $>) {
- dbg ("setting real uid from $< to match effective uid $>");
- $< = $>;
- if ($< != $>) { die "setuid $< to $> failed!"; }
+
+ # remember the target uid, the first number is the important one
+ my($touid) = split(/\s+/, $>);
+
+ if ($< != $touid) {
+ dbg ("changing real uid from $< to match effective uid $touid");
+ $< = $touid; # try the simple method first
+
+ # bug 3586: Some perl versions, typically those on a BSD-based
+ # platform, require RUID==EUID (and presumably == 0) before $<
+ # can be changed. So this is a kluge for us to get around the
+ # typical spamd-ish behavior of: $< = 0, $> = someuid ...
+ if ( $< != $touid ) {
+ dbg("initial attempt to change real uid failed, trying BSD workaround");
+
+ $> = $<; # revert euid to ruid
+ $< = $touid; # change ruid to target
+ $> = "$touid $touid"; # change euid back to target
+ }
+
+ # Check that we have now accomplished the setuid
+ if ($< != $touid) {
+ die "setuid $< to $touid failed!";
+ }
}
}
Modified: spamassassin/trunk/spamd/README
==============================================================================
--- spamassassin/trunk/spamd/README (original)
+++ spamassassin/trunk/spamd/README Thu Jul 22 20:08:17 2004
@@ -177,6 +177,20 @@
mail to it. If you discover compilation, runtime, or load-performance
bugs, please open a ticket at http://bugzilla.spamassassin.org/
+There is an issue if you run spamd using the standard perl installation
+on Mac OS X and certain *BSD-flavored UNIX platforms. spamd will change
+effective uid to the user calling spamd for security reasons. Before
+calling out to any external programs (DCC and Pyzor, as of 3.0.0,) spamd
+will fork() and change the real uid to the same as the effective uid.
+Unfortunately, the default perl in at least Mac OS X, does not allow perl
+programs to change the real uid so for security reasons the spamd child
+will die. To fix this issue, either disable the DCC and Pyzor rules,
+or install a different version of perl which supports setuid() calls.
+
+The default perl binary in FreeBSD had a similar issue when attempting
+to change the real uid. This has been worked around, but there could
+be an issue such as the one in Mac OS X that we have not yet heard about.
+
Network Protocol
----------------