LSTSRV-L Archives

LISTSERV Site Administrators' Forum

LSTSRV-L

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Norm Aleks <[log in to unmask]>
Sat, 11 May 1996 14:04:19 -0400
text/plain (144 lines)
A while back I  wrote a Perl  script (attached below) to automatically take
care of the aliases LISTSERV needs to run here.  It's not very complex, but
I hope it's  helpful to others  -- what it  does is set up LISTSERV's basic
aliases ("listserv" and some convenience aliases, plus "owner-listserv" and
"all-request"), a set of aliases for each local list  (found by looking for
*.list  in LISTSERV's  home  directory -- note  that  it  does *not* handle
"List-ID" keywords),  and finally a set of  aliases allowing you to address
global  lists and their  -server  addresses as  *@yourhost, something  like
*@LISTSERV.NET. To use this script, you'll need to do two things: 1) set up
root's crontab to  run it regularly,   probably followed by  newaliases; 2)
edit sendmail.cf  to tell  Sendmail that it  should   use the script's  new
aliases files after /etc/aliases.  On my system, the relevant lines are:
 
        from root's crontab:
11 4 * * *      ( date ; /root/lsvalias.pl ; /usr/bin/newaliases ; date )
 
        from sendmail.cf:
O AliasFile=/etc/aliases,/etc/aliases-lsv-local,/etc/aliases-lsv-global
 
(You need Sendmail V8 to use  multiple alias files.  The above format, with
"AliasFile=", is for 8.7.  For prior versions you'd use "OA/etc/aliases,".)
 
Obviously this  program  could be  a security  hole because  it changes the
system aliases.  I try to avoid the hole in two ways: 1) /etc/aliases isn't
touched,  only  two files that  Sendmail  consults *after* /etc/aliases ...
thus none  of your own aliases  will be overridden  by lists.  2) Each list
name is checked to ensure it starts with an  alphanumeric and includes only
alphanumerics  and [-_+.$],  so  it can't simulate  program arguments, file
names, etc. If you still see a hole, please tell me asap :-)
 
If you find this script useful I'd enjoy hearing from you.
 
Norm
- -
SUPERMODEL TYRA BANKS:  "I haven't seen the Eiffel Tower,  Notre Dame,  the
Louvre. I haven't seen anything. I don't really care."
 ==========================================================================
#!/usr/local/bin/perl
# writes out an aliases file for LISTSERV
# Norm Aleks <[log in to unmask]> 4/16/96
 
$lsvamin =   "/usr/local/bin/lsv_amin -t";
$homedir =   "/home/listserv/lsv/home";
$globfile =  "$homedir/globlist.file";
$aliasfileL = "/etc/aliases-lsv-local";
$aliasfileG = "/etc/aliases-lsv-global";
$safename =   '^[a-z0-9][-_.+$a-z0-9]*$';
 
print STDOUT "Creating $aliasfileL ... ";
 
# FIRST DO THE LOCAL LISTS ...
opendir( LSVHOME, $homedir );
@listfiles = grep( /\.list$/, readdir(LSVHOME) );
closedir( LSVHOME );
 
$date=`date`;
open( ALIASES, ">$aliasfileL" );
print ALIASES <<"FOO";
# $aliasfileL
# Created automatically by $0
# $date
# Do not modify this file by hand ... changes will be overwritten!
 
############################################################################
##     LISTSERV SYSTEM ALIASES
############################################################################
 
# LISTSERV
listserv:               "|$lsvamin listserv"
owner-listserv:         "|$lsvamin owner-listserv"
all-request:            "|$lsvamin all-request"
listserve:              listserv
listserver:             listserv
listproc:               listserv
majordomo:              listserv
majordom:               listserv
 
############################################################################
##     LOCAL LISTS
############################################################################
FOO
 
for( sort @listfiles ) {
    ($listname) = /^(.+)\.list$/ ;
    if ($listname =~ /$safename/) {
        $locals{$listname} = 1;
        $locals_processed++;
        print ALIASES <<"FOO";
 
$listname:                 "|$lsvamin $listname"
owner-$listname:           "|$lsvamin owner-$listname"
$listname-server:          "|$lsvamin $listname-server"
$listname-request:         "|$lsvamin $listname-request"
$listname-search-request:  "|$lsvamin $listname-search-request"
FOO
    } else { warn "unsafe local list name '$listname'"; };
};
close( ALIASES );
print STDOUT "$locals_processed local lists.\n";
 
 
print STDOUT "Reading $globfile ";
$|=1; # so we see the status dots as they move across
 
# First we read in the global-list file
# The first three words of each line are list name, host name, alt list name
open( GLOBLIST, "<$globfile" );
while( <GLOBLIST> ) {
    print "." unless (++$globnum%500);
    tr/A-Z/a-z/;
    ($nm1, $host, $nm2) = /^(\S+)\s+(\S+)\s+(\S+)\s+/ ;
    $host .= ".BITNET" unless  $host =~ /\./ ;
    if ($nm1 =~ /$safename/) {
        $globs{$nm1} = $host unless ($locals{$nm1});
    } else { warn "unsafe '$nm1\@$host'"; };
    if ($nm2 =~ /$safename/) {
        $globs{$nm2} = $host unless ($locals{$nm2});
    } else { warn "unsafe '$nm2\@$host'"; };
};
close( GLOBLIST );
print " $globnum lines.\nWriting $aliasfileG ";
 
open( ALIASES, ">$aliasfileG" );
print ALIASES <<"FOO";
# $aliasfileG
# Created automatically by $0
# $date
# Do not modify this file by hand ... changes will be overwritten!
 
############################################################################
##     GLOBAL LISTS
############################################################################
FOO
 
foreach $listname ( sort keys %globs )  {
    print "." unless (++$globs_processed%500);
    print ALIASES <<"FOO";
 
$listname: $listname\@$globs{$listname}
$listname-server: "|$lsvamin $listname-server"
FOO
};
print STDOUT " $globs_processed global lists.\n";

ATOM RSS1 RSS2