From 4efadaf13cabb390f063c61fd321849197595c99 Mon Sep 17 00:00:00 2001 From: zacheiss Date: Fri, 10 Jul 2009 20:18:10 +0000 Subject: [PATCH] EXCHANGE changes. --- gen/hesiod.pc | 12 ++++++------ gen/mailhosts.gen | 44 ++++++++++++++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/gen/hesiod.pc b/gen/hesiod.pc index 52439722..c07fa43f 100644 --- a/gen/hesiod.pc +++ b/gen/hesiod.pc @@ -273,13 +273,13 @@ int do_passwd(void) if (eid != 0) { - /* Check for IMAP. Can't use iid because it should be zero. */ - EXEC SQL SELECT mach_id INTO :mid FROM filesys - WHERE label = :login || '.po' AND type = 'IMAP'; + /* eid will be for EXCHANGE.MIT.EDU, but we need to convert it to + * IMAP.EXCHANGE.MIT.EDU. + */ + EXEC SQL SELECT mach_id INTO :eid FROM machine WHERE + name = 'IMAP.EXCHANGE.MIT.EDU'; if (sqlca.sqlcode == 0) - pid = mid; - else - pid = eid; + pid = eid; } if (iid != 0) diff --git a/gen/mailhosts.gen b/gen/mailhosts.gen index 31002113..892127e6 100755 --- a/gen/mailhosts.gen +++ b/gen/mailhosts.gen @@ -14,14 +14,8 @@ use DBI; $dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira") || exit $MR_DBMS_ERR; -$sth = $dbh->prepare("SELECT f.label, m.name ". - "FROM filesys f, machine m, nfsphys p, serverhosts s ". - "WHERE s.service='POSTOFFICE' AND s.mach_id=f.mach_id ". - "AND f.mach_id=m.mach_id AND f.type='IMAP' ". - "AND f.createflg!=0 AND f.mach_id=p.mach_id ". - "AND f.phys_id=p.nfsphys_id ". - "ORDER BY f.label") - || exit $MR_DBMS_ERR; +$sth = $dbh->prepare("SELECT login, potype, exchange_id, imap_id, pop_id FROM users WHERE " . + "status = 1 OR status = 2 OR status = 5 OR status = 6") || exit $MR_DBMS_ERR; $sth->execute || exit $MR_DBMS_ERR; $tnow = localtime; @@ -34,21 +28,43 @@ print OUT "; \t\$" . "Date:" . " \$\n"; print OUT "; \t\$" . "Revision:" . " \$\n"; print OUT "; Host table generated by Moira at $tnow\n;\n"; -while (($label, $name) = $sth->fetchrow_array) { - $label =~ s/\.po$//; - $label =~ tr/a-z/A-Z/; - $name =~ tr/a-z/A-Z/; +while (($login, $potype, $exchange_id, $imap_id, $pop_id) = $sth->fetchrow_array) { + $login =~ tr/a-z/A-Z/; + + if ($exchange_id != 0) { + ($mach_id) = $dbh->selectrow_array("SELECT mach_id FROM machine WHERE " . + "name = 'IMAP.EXCHANGE.MIT.EDU'"); + if (defined($mach_id)) { + $pop_id = $mach_id; + } + } + + if ($imap_id != 0) { + ($mach_id) = $dbh->selectrow_array("SELECT mach_id FROM filesys WHERE " . + "filsys_id = " . $dbh->quote($imap_id) . + " AND type = 'IMAP'"); + if (defined($mach_id)) { + $pop_id = $mach_id; + } + } - if (16 - length($label) > 8) { + ($hostname) = $dbh->selectrow_array("SELECT name FROM machine WHERE mach_id = " . + $dbh->quote($pop_id)); + + + if ($pop_id != 0 && $potype ne "NONE") { + + if (16 - length($login) > 8) { $sp = "\t"; } else { $sp = ""; } - $row = "$label$sp\tIN\tCNAME\t$name.\n"; + $row = "$login$sp\tIN\tCNAME\t$hostname.\n"; $row =~ s/\0//g;; print OUT $row; } +} close(OUT); $dbh->disconnect; -- 2.45.1