Chris,

Yes, I did join their list and made a posting which appeared to go into /dev/null ...

Feel free to lobby them, but I deliberately designed that module such that it is outside the SA development path.

There would always be an amount of configuration involved though, although the smart money would like to see spamd -MMail::SpamAssassin::AuthCourier ...

I have also made a change to the module to reflect that /etc/passwd based auth mechanisms don't return the UID, and Mr Sam showed zero interest in my consistency patch (although this module also addresses backward compatibilities).

Cheers, Alan
#    Copyright (C) 2003  Corporation of Balclutha.  All rights reserved.
#
#    Visit us at http://www.balclutha.org for all of your open source
#    software development and support requirements and hosted solutions.
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
package Mail::SpamAssassin::AuthCourier;

#
# A mechanism which uses the Courier MTA's authdaemond server to
# determine mail account information.  Courier is found at http://courier-mta.org
#
# This module automagically overrides the builtin getpwnam and getpwuid
# functions.
#
use Exporter;
use IO::Socket::UNIX;


@ISA = qw(Exporter);
@EXPORT = qw( getpwnam getpwuid );

#
# ensure overriding for our own internal usage as well ...
#
use subs qw( getpwnam getpwuid );

#
# For some frustrating reason, the socket seems to be unusable unless set each time.
# Please contact us if you have the solution to this enhancement.
#

BEGIN {
    # $socket = IO::Socket::UNIX->new('/usr/lib/courier/var/authdaemon/socket');
}

END {
    $socket->close if $socket;
}

sub getpwnam {
    my $name = shift;
    my $socket = IO::Socket::UNIX->new('/usr/lib/courier/var/authdaemon/socket') 
                       or die "authdaemond socket error: $!\n";

    print $socket "PRE . login $name\n";

    my %results = ();
    my ($k, $v);
    while (<$socket>) {
        ($k,$v) = split '=', $_, 2;
        chomp $v if $v;
        $results{$k} = $v;
    }

    $socket->close if $socket;

    # some auth mechanisms don't return UID - these must be fetched from /etc/passwd or
    # it's moral equivalent until Sam patches these as per my request...
    my $uid = $results{'UID'} || CORE::getpwnam($name); 

    # stop some naf 'uninitialized' errors ...
    return wantarray ? ('','','','','','','') : undef unless $uid; # uid 0 = root !!!

    return wantarray ? ( $results{'USERNAME'}, 
                         $results{'PASSWD'},
                         int($uid),
                         int($results{'GID'}),
                         $results{'QUOTA'},
                         $results{'COMMENT'},
                         $results{'GCOS'},
                         $results{'HOME'},
                         '/bin/bash') : $uid;
}

sub getpwuid {
    return (getpwnam($_[0]))[2];
}


1;

Reply via email to