]> andersk Git - moira.git/commitdiff
EXCHANGE changes.
authorzacheiss <zacheiss>
Fri, 10 Jul 2009 20:18:10 +0000 (20:18 +0000)
committerzacheiss <zacheiss>
Fri, 10 Jul 2009 20:18:10 +0000 (20:18 +0000)
gen/hesiod.pc
gen/mailhosts.gen

index 524397229bf57358662d23a46c760d6528b95746..c07fa43ff1341698880d95797390a4f691735669 100644 (file)
@@ -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)
index 310021131db9982047667e0ddea957f1ac9fcee8..892127e69b7e487aeee08bee9e1518eac1e1ced7 100755 (executable)
@@ -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;
This page took 0.047306 seconds and 5 git commands to generate.