source: trunk/third/moira/gen/access.gen @ 24319

Revision 24319, 1.1 KB checked in by broder, 14 years ago (diff)
New Moira snapshot from SVN.
  • Property svn:executable set to *
Line 
1#!/moira/bin/perl -Tw
2
3# $Id: access.gen 3956 2010-01-05 20:56:56Z zacheiss $
4
5use DBI;
6
7# The following exit codes are defined and MUST BE CONSISTENT withh the
8# error codes the library uses:
9$MR_DBMS_ERR = 47836421;
10$MR_OCONFIG = 47836460;
11%users = ();
12
13$outfile = '/moira/dcm/access.out';
14
15$dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira")
16    || exit $MR_DBMS_ERR;
17
18# Get the list of valid MIT.EDU user e-mail addresses
19$sth = $dbh->prepare("SELECT login FROM users WHERE status != 3");
20
21$sth->execute;
22
23umask 022;
24open(OUT, ">$outfile") || exit $MR_OCONFIG;
25
26while(($login) = $sth->fetchrow_array) {
27    $login =~ s/\0//g;
28    $users{$login} = $login;
29   
30    print OUT "From:$login\@MIT.EDU RELAY\n";
31}
32
33# Get all the valid MIT.EDU mailing list addresses
34$sth = $dbh->prepare("SELECT name FROM list WHERE active !=0 " .
35                     "AND maillist = 1");
36
37$sth->execute;
38
39while(($name) = $sth->fetchrow_array) {
40    $name =~ s/\0//g;
41   
42    # Ensure we do not re-print an entry that may be a personal user group
43    # and was already handled by the user e-mail addresses
44    if(!$users{$name}) {
45        print OUT "From:$name\@MIT.EDU RELAY\n";
46    }
47}
48
49close(OUT);
50exit;
Note: See TracBrowser for help on using the repository browser.