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 2005/06/06 18:52:34 UTC
svn commit: r180340 - /spamassassin/trunk/spamd/spamd.raw
Author: mss
Date: Mon Jun 6 09:52:32 2005
New Revision: 180340
URL: http://svn.apache.org/viewcvs?rev=180340&view=rev
Log:
* bug 3490: on some systems, UNIX socket paths are silently truncated, let's fail with more information
* also check wether the directory for the socket exists as the error from IO::Socket::UNIX is misleading
* some spacing corrected
Modified:
spamassassin/trunk/spamd/spamd.raw
Modified: spamassassin/trunk/spamd/spamd.raw
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/spamd/spamd.raw?rev=180340&r1=180339&r2=180340&view=diff
==============================================================================
--- spamassassin/trunk/spamd/spamd.raw (original)
+++ spamassassin/trunk/spamd/spamd.raw Mon Jun 6 09:52:32 2005
@@ -563,8 +563,8 @@
# Yes, there is a window here: best we can do for now. There is almost
# certainly a better way, but we don't know it. Yet.
- if ( -e $path ) {
- unless ( -S $path ) {
+ if (-e $path) {
+ unless (-S $path) {
die "spamd: file $path exists but is no socket, exiting\n";
}
@@ -580,6 +580,9 @@
unlink $path;
}
}
+ if (not -d (File::Spec->splitpath($path))[1]) {
+ die "spamd: directory for $path does not exist, exiting\n";
+ }
my %socket = (
Local => $path,
@@ -587,12 +590,23 @@
Listen => SOMAXCONN,
);
dbg("spamd: creating UNIX socket:\n" . join("\n", map { " $_: " . (defined $socket{$_} ? $socket{$_} : "(undef)") } sort keys %socket));
- $server = new IO::Socket::UNIX(%socket)
- || die "spamd: could not create UNIX socket on $path: $!\n";
-
- # sanity check!
- if (!-S $path) {
- die "spamd: could not find newly-created UNIX socket on $path (" . $server->hostpath() . "): $!\n";
+ $server = IO::Socket::UNIX->new(%socket);
+
+ # sanity check! cf. bug 3490
+ if (not $server or not -S $path) {
+ unless ($server) {
+ dbg "spamd: socket path might have been truncated due to system limits\n";
+ die "spamd: could not create UNIX socket on $path: $!\n";
+ }
+ my $hostpath = $server->hostpath();
+ if ($hostpath ne $path) {
+ warn "spamd: socket path was truncated at position " . length($hostpath) . "\n";
+ warn "spamd: leaving stale socket at $hostpath\n" if -S $hostpath;
+ die "spamd: path length for UNIX socket on $path exceeds system limit, exiting\n";
+ }
+ else {
+ die "spamd: could not find newly-created UNIX socket on $path: $!\n";
+ }
}
my $mode = $opt{socketmode};