[2046] in Moira
Re: access service for outgoing mailers
daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Tue Oct 21 03:07:53 2003
Date: Tue, 21 Oct 2003 03:07:49 -0400 (EDT)
Message-Id: <200310210707.h9L77nO8022492@brad-majors.mit.edu>
From: Garry Zacheiss <zacheiss@MIT.EDU>
To: Mark Silis <mark@MIT.EDU>
cc: moiradev@MIT.EDU
In-reply-to: "[2044] in Moira"
Since we went through an additional revision of the patch, please
confirm that this is the most recent version of it. I've also added
Makefile.in changes to install the new DCM.
Assuming this is the most recent version you believe you've submitted,
yay. I will deploy it on moira tomorrow, and let you know so you can
create the DCM.
Garry
Index: Makefile.in
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/gen/Makefile.in,v
retrieving revision 1.35
diff -u -r1.35 Makefile.in
--- Makefile.in 27 Aug 2003 20:04:27 -0000 1.35
+++ Makefile.in 21 Oct 2003 07:05:19 -0000
@@ -42,11 +42,11 @@
mailhub.gen ndb.gen network.gen nfs.gen pobox.gen \
postoffice.gen print.gen warehouse.gen winad.gen www.gen zephyr.gen
-SCRIPTS=acl.sh aliases.sh boot.sh ca.gen calendar.gen dhcp.sh events.gen events.sh \
- hesiod.sh ip-billing.gen ip-billing.sh longjobs.gen longjobs.sh \
- mailhub.sh mailman.gen mailman.sh ndb.sh nfs.sh null.sh postoffice.sh \
- print.sh sapprint.gen sapprint.sh spwatch.gen stellar.gen stellar.sh \
- warehouse.sh www.sh zephyr.sh install_dirs install_quotas zero_quotas
+SCRIPTS=access.gen access.sh acl.sh aliases.sh boot.sh ca.gen calendar.gen dhcp.sh \
+ events.gen events.sh hesiod.sh ip-billing.gen ip-billing.sh longjobs.gen \
+ longjobs.sh mailhub.sh mailman.gen mailman.sh ndb.sh nfs.sh null.sh \
+ postoffice.sh print.sh sapprint.gen sapprint.sh spwatch.gen stellar.gen \
+ stellar.sh warehouse.sh www.sh zephyr.sh install_dirs install_quotas zero_quotas
.SUFFIXES: .pc .gen
Index: access.gen
===================================================================
RCS file: access.gen
diff -N access.gen
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ access.gen 21 Oct 2003 07:04:01 -0000
@@ -0,0 +1,50 @@
+#!/moira/bin/perl -Tw
+
+# $Id$
+
+use DBI;
+
+# The following exit codes are defined and MUST BE CONSISTENT withh the
+# error codes the library uses:
+$MR_DBMS_ERR = 47836421;
+$MR_OCONFIG = 47836460;
+%users = ();
+
+$outfile = '/moira/dcm/access.out';
+
+$dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira")
+ || exit $MR_DBMS_ERR;
+
+# Get the list of valid MIT.EDU user e-mail addresses
+$sth = $dbh->prepare("SELECT login FROM users WHERE status != 3");
+
+$sth->execute;
+
+umask 022;
+open(OUT, ">$outfile") || exit $MR_OCONFIG;
+
+while(($login) = $sth->fetchrow_array) {
+ $login =~ s/\0//g;
+ $users{$login} = $login;
+
+ print OUT "From:$login\@MIT.EDU RELAY\n";
+}
+
+# Get all the valid MIT.EDU mailing list addresses
+$sth = $dbh->prepare("SELECT name FROM list WHERE active !=0 " .
+ "AND maillist = 1");
+
+$sth->execute;
+
+while(($name) = $sth->fetchrow_array) {
+ $name =~ s/\0//g;
+
+ # Ensure we do not re-print an entry that may be a personal user group
+ # and was already handled by the user e-mail addresses
+ if(!$users{$name}) {
+ print OUT "From:$name\@MIT.EDU RELAY\n";
+ }
+}
+
+close(OUT);
+exit;
Index: access.sh
===================================================================
RCS file: access.sh
diff -N access.sh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ access.sh 21 Oct 2003 07:03:19 -0000
@@ -0,0 +1,73 @@
+#!/bin/sh
+#
+# $Header$
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin:/etc:/usr/etc:/usr/athena/bin:/usr/local/bin
+export PATH
+
+if [ -d /var/athena ] && [ -w /var/athena ]; then
+ exec >/var/athena/moira_update.log 2>&1
+else
+ exec >/tmp/moira_update.log 2>&1
+fi
+
+# The following exit codes are defined and MUST BE CONSISTENT with
+# error codes the library uses:
+MR_MKCRED=47836474
+MR_MISSINGFILE=47836473
+MR_NOCRED=47836470
+
+root=/usr/local/sendmail
+
+if [ -s $root/etc/access.new ]; then
+ cp /dev/null $root/etc/access.tmp
+
+ if [ -s $root/etc/efl-access ]; then
+ cat $root/etc/efl-access >> $root/etc/access.tmp
+ fi
+
+ cat $root/etc/access.new >> $root/etc/access.tmp
+ mv $root/etc/access.tmp $root/etc/access.new
+ chmod 644 $root/etc/access.new
+else
+ exit $MR_MISSINGFILE
+fi
+
+if [ ! -s $root/etc/access ]; then
+ logger -p mail.error -t access.sh "No current access file, aborting."
+ exit $MR_NOCRED
+fi
+
+# Play it safe and be sure we have reasonable data
+olines=`wc -l $root/etc/access | awk '{print $1}'`
+nlines=`wc -l $root/etc/access.new | awk '{print $1}'`
+diff=`expr $nlines - $olines`
+thresh=`expr $olines / 10`
+
+# Catch the zero case
+if [ $nlines -eq 0 ]; then
+ logger -p mail.error -t access.sh "Recieved empty access file, aborting."
+ exit $MR_MISSINGFILE
+fi
+
+# If its a greater than 10% shift bomb out to be safe
+if [ $diff -gt $thresh ]; then
+ logger -p mail.error -t access.sh "Access changes threshold exceeded, aborting."
+ exit $MR_NOCRED
+fi
+
+cp /dev/null $root/etc/access.new.db
+
+$root/sbin/makemap btree $root/etc/access.new < $root/etc/access.new
+if [ $? != 0 ]; then
+ exit $MR_MKCRED
+fi
+
+mv $root/etc/access $root/etc/access.old
+mv $root/etc/access.new $root/etc/access
+rm -f $root/etc/access.old.db
+ln $root/etc/access.db $root/etc/access.old.db
+mv $root/etc/access.new.db $root/etc/access.db
+
+rm -f $0
+exit 0