You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by ms...@apache.org on 2004/11/27 00:05:00 UTC
svn commit: r106668 - /spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm /spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
Author: mss
Date: Fri Nov 26 15:04:58 2004
New Revision: 106668
URL: http://svn.apache.org/viewcvs?view=rev&rev=106668
Log:
Added some sane fallbacks for an unset $HOME in ArchiveIterator. Contrary to the short discussion on dev@ did I not put this into Util.pm as we actually should not use $HOME anywhere in the code because we tend to change $< in spamd.
Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm
Url: http://svn.apache.org/viewcvs/spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm?view=diff&rev=106668&p1=spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm&r1=106667&p2=spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm&r2=106668
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm Fri Nov 26 15:04:58 2004
@@ -1016,20 +1016,35 @@
############################################################################
-sub fix_globs {
- my ($self, $path) = @_;
+{
+ my $home;
- # replace leading tilde with home dir: ~/abc => /home/jm/abc
- $path =~ s!^~/!$ENV{'HOME'}/!;
+ sub fix_globs {
+ my ($self, $path) = @_;
- # protect/escape spaces: ./Mail/My Letters => ./Mail/My\ Letters
- $path =~ s/([^\\])(\s)/$1\\$2/g;
+ unless (defined $home) {
+ $home = $ENV{'HOME'};
- my @paths;
+ # No $HOME set? Try to find it, portably.
+ unless ($home) {
+ if (!Mail::SpamAssassin::Util::am_running_on_windows()) {
+ $home = (Mail::SpamAssassin::Util::portable_getpwuid($<))[7];
+ } else {
+ $home = File::Spec->catpath($ENV{'HOMEDRIVE'}, $ENV{'HOMEPATH'});
+ }
- # apply csh-style globs: ./corpus/*.mbox => er, you know what it does ;)
- @paths = glob $path;
- return @paths;
+ # Fall back to no replacement at all.
+ $home ||= '~';
+ }
+ }
+ $path =~ s,^~/,${home}/,;
+
+ # protect/escape spaces: ./Mail/My Letters => ./Mail/My\ Letters
+ $path =~ s/([^\\])(\s)/$1\\$2/g;
+
+ # return csh-style globs: ./corpus/*.mbox => er, you know what it does ;)
+ return glob($path);
+ }
}
############################################################################
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
Url: http://svn.apache.org/viewcvs/spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm?view=diff&rev=106668&p1=spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm&r1=106667&p2=spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm&r2=106668
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm Fri Nov 26 15:04:58 2004
@@ -492,7 +492,7 @@
$_ = pack("u57", $_);
s/^.//mg;
- tr| -_`|A-Za-z0-9+/A|;
+ tr| -_`|A-Za-z0-9+/A|; # -> #`# <- kluge against vim syntax issues
s/(A+)$/'=' x length $1/e;
return $_;
}
@@ -508,7 +508,7 @@
eval ' sub _getpwuid_wrapper { getpwuid($_[0]); } ';
} else {
dbg("util: defining getpwuid() wrapper using 'unknown' as username");
- eval ' sub _getpwuid_wrapper { fake_getpwuid($_[0]); } ';
+ eval ' sub _getpwuid_wrapper { _fake_getpwuid($_[0]); } ';
}
if ($@) {
@@ -518,7 +518,7 @@
}
}
-sub fake_getpwuid {
+sub _fake_getpwuid {
return (
'unknown', # name,
'x', # passwd,