[24334] in Source-Commits
/svn/athena r23932 - in trunk/third/moira: db debian gen regtape server update
daemon@ATHENA.MIT.EDU (Evan Broder)
Tue Jul 28 13:37:23 2009
Date: Tue, 28 Jul 2009 13:36:38 -0400
From: Evan Broder <broder@MIT.EDU>
Message-Id: <200907281736.n6SHacId032756@drugstore.mit.edu>
To: source-commits@mit.edu
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Author: broder
Date: 2009-07-28 13:36:37 -0400 (Tue, 28 Jul 2009)
New Revision: 23932
Added:
trunk/third/moira/gen/cups-lpd.pc
trunk/third/moira/gen/cups-lpd.sh
trunk/third/moira/regtape/stellar.pl
Modified:
trunk/third/moira/db/schema.sql
trunk/third/moira/debian/changelog
trunk/third/moira/gen/Makefile.in
trunk/third/moira/gen/cups-print.pc
trunk/third/moira/gen/cups-print.sh
trunk/third/moira/gen/hesiod.pc
trunk/third/moira/gen/mailhosts.gen
trunk/third/moira/regtape/Makefile.in
trunk/third/moira/server/qrtn.pc
trunk/third/moira/update/auth_002.c
trunk/third/moira/update/ticket.c
trunk/third/moira/update/update_server.c
Log:
In moira:
* New CVS snapshot.
Modified: trunk/third/moira/db/schema.sql
===================================================================
--- trunk/third/moira/db/schema.sql 2009-07-27 23:24:37 UTC (rev 23931)
+++ trunk/third/moira/db/schema.sql 2009-07-28 17:36:37 UTC (rev 23932)
@@ -144,7 +144,7 @@
create table list
(
- name VARCHAR(32) DEFAULT CHR(0) NOT NULL,
+ name VARCHAR(56) DEFAULT CHR(0) NOT NULL,
list_id INTEGER DEFAULT 0 NOT NULL,
active INTEGER DEFAULT 0 NOT NULL,
publicflg INTEGER DEFAULT 0 NOT NULL,
Modified: trunk/third/moira/debian/changelog
===================================================================
--- trunk/third/moira/debian/changelog 2009-07-27 23:24:37 UTC (rev 23931)
+++ trunk/third/moira/debian/changelog 2009-07-28 17:36:37 UTC (rev 23932)
@@ -1,3 +1,9 @@
+debathena-moira (4.0.0+cvs20090728-0debathena1) unstable; urgency=low
+
+ * New CVS snapshot.
+
+ -- Evan Broder <broder@mit.edu> Tue, 28 Jul 2009 13:32:02 -0400
+
debathena-moira (4.0.0+cvs20090621-0debathena1) unstable; urgency=low
* New CVS snapshot.
Modified: trunk/third/moira/gen/Makefile.in
===================================================================
--- trunk/third/moira/gen/Makefile.in 2009-07-27 23:24:37 UTC (rev 23931)
+++ trunk/third/moira/gen/Makefile.in 2009-07-28 17:36:37 UTC (rev 23932)
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.55 2009-06-01 21:04:59 zacheiss Exp $
+# $Id: Makefile.in,v 1.56 2009-07-21 21:39:12 zacheiss Exp $
SHELL=/bin/sh
@SET_MAKE@
@@ -32,21 +32,21 @@
LIB_CFILES=genacl.c
LIB_TARGET=libdcm.a
-OBJS= acl.lo boot.lo confluence.lo cups-print.lo dhcp.lo directory.lo events.lo \
+OBJS= acl.lo boot.lo confluence.lo cups-print.lo cups-lpd.lo dhcp.lo directory.lo events.lo \
hesiod.lo hosts.lo lpcaccess.lo mailhub.lo ndb.lo network.lo nfs.lo pobox.lo \
postoffice.lo print.lo warehouse-lists.lo winad.lo www.lo zephyr.lo
-CFILES= acl.c boot.c confluence.c cups-print.c dhcp.c directory.c events.c \
+CFILES= acl.c boot.c confluence.c cups-print.c cups-lpd.c dhcp.c directory.c events.c \
hesiod.c hosts.c lpcaccess.c mailhub.c ndb.c network.c nfs.c pobox.c \
postoffice.c print.c warehouse-lists.c winad.c www.c zephyr.c
-TARGET= acl.gen boot.gen confluence.gen cups-print.gen dhcp.gen directory.gen \
+TARGET= acl.gen boot.gen confluence.gen cups-print.gen cups-lpd.gen dhcp.gen directory.gen \
events.gen hesiod.gen hosts.gen lpcaccess.gen mailhub.gen ndb.gen \
network.gen nfs.gen pobox.gen postoffice.gen print.gen \
warehouse-lists.gen winad.gen www.gen zephyr.gen
SCRIPTS=access.gen access.sh acl.sh aliases.sh boot.sh ca.gen calendar.gen \
- cups-print.sh dhcp.sh events.sh hesiod.sh ip-billing.gen \
+ cups-print.sh cups-lpd.sh dhcp.sh events.sh hesiod.sh ip-billing.gen \
ip-billing.sh ldap.gen longjobs.gen longjobs.sh mailhosts.gen \
mailhub.sh mailman.gen mailman.sh nagios-cluster.gen \
nagios-cluster.sh nagios-colo.gen nagios-colo.sh \
@@ -150,3 +150,6 @@
cups-print.gen: cups-print.lo libdcm.a $(MR_LIBDEP)
$(LIBTOOL) --mode=link $(CC) -static -o $@ $(LDFLAGS) cups-print.lo libdcm.a $(SQL_LIBS) $(LIBS)
+
+cups-lpd.gen: cups-lpd.lo libdcm.a $(MR_LIBDEP)
+ $(LIBTOOL) --mode=link $(CC) -static -o $@ $(LDFLAGS) cups-lpd.lo libdcm.a $(SQL_LIBS) $(LIBS)
Added: trunk/third/moira/gen/cups-lpd.pc
===================================================================
--- trunk/third/moira/gen/cups-lpd.pc 2009-07-27 23:24:37 UTC (rev 23931)
+++ trunk/third/moira/gen/cups-lpd.pc 2009-07-28 17:36:37 UTC (rev 23932)
@@ -0,0 +1,199 @@
+/* $Id: cups-lpd.pc,v 1.1 2009-07-21 21:39:13 zacheiss Exp $
+ *
+ * This generates printcaps and other files for Athena print servers
+ *
+ * Copyright (C) 1992-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
+ */
+
+#include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <time.h>
+#ifdef HAVE_KRB4
+#include <krb.h>
+#endif
+#include <krb5.h>
+
+#include "util.h"
+
+EXEC SQL INCLUDE sqlca;
+
+RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/gen/cups-lpd.pc,v 1.1 2009-07-21 21:39:13 zacheiss Exp $");
+
+char *whoami = "cups-lpd-print.gen";
+char *db = "moira/moira";
+
+/* OMG, I hate this, but it's cleaner, I guess? */
+
+void do_host(char *host);
+void sqlerr(void);
+#ifndef MAX
+#define MAX(a, b) ( (a) > (b) ? (a) : (b) )
+#endif
+
+int main(int argc, char **argv)
+{
+ EXEC SQL BEGIN DECLARE SECTION;
+ char name[MACHINE_NAME_SIZE];
+ EXEC SQL END DECLARE SECTION;
+
+ init_acls();
+
+ EXEC SQL CONNECT :db;
+
+ EXEC SQL WHENEVER SQLERROR DO sqlerr();
+
+ EXEC SQL DECLARE csr_hosts CURSOR FOR
+ SELECT m.name FROM machine m, serverhosts sh
+ WHERE m.mach_id = sh.mach_id AND sh.service = 'CUPS-LPD' AND sh.enable = 1;
+ EXEC SQL OPEN csr_hosts;
+ while (1)
+ {
+ EXEC SQL FETCH csr_hosts INTO :name;
+ if (sqlca.sqlcode)
+ break;
+
+ strtrim(name);
+ do_host(name);
+ }
+ EXEC SQL CLOSE csr_hosts;
+
+ exit(MR_SUCCESS);
+}
+
+void printer_user_list(FILE *out, char *type, int id, char *str)
+{
+ struct save_queue *sq;
+ struct imember *m;
+
+ sq = get_acl(type, id, NULL);
+ while (sq_remove_data(sq, &m))
+ {
+ if (m->type == 'U')
+ fprintf(out, "%s %s\n", str, m->name);
+ freeimember(m);
+ }
+ sq_destroy(sq);
+}
+
+
+
+void do_host(char *host)
+{
+ EXEC SQL BEGIN DECLARE SECTION;
+ char rp[PRINTERS_RP_SIZE], name[PRINTERS_NAME_SIZE];
+ char duplexname[PRINTERS_DUPLEXNAME_SIZE], location[PRINTERS_LOCATION_SIZE];
+ char hwtype[PRINTERS_HWTYPE_SIZE], lowerhwtype[PRINTERS_HWTYPE_SIZE];
+ char modtime[PRINTERS_MODTIME_SIZE], lmodtime[LIST_MODTIME_SIZE];
+ char contact[PRINTERS_CONTACT_SIZE], hostname[MACHINE_NAME_SIZE];
+ char cupshosts[MACHINE_NAME_SIZE], prtype [PRINTERS_TYPE_SIZE];
+ char *spoolhost = host, *unixtime_fmt = UNIXTIME_FMT, *p;
+ char *lhost;
+ int ka, pc, ac, lpc_acl, top_lpc_acl, banner, rm;
+ EXEC SQL END DECLARE SECTION;
+ TARFILE *tf;
+ FILE *out;
+ char filename[MAXPATHLEN], *duptc;
+ time_t mtime, now = time(NULL);
+
+ lhost = (char *) strdup (host);
+ for (p = lhost; *p; p++)
+ *p = tolower(*p);
+
+ sprintf(filename, "%s/cups-lpd/%s", DCM_DIR, host);
+ tf = tarfile_open(filename);
+
+ /* LPRng printers */
+ out = tarfile_start(tf, "/etc/cups/lprng.printers.txt", 0644, 0, 0,
+ "root", "lp", now);
+
+ EXEC SQL DECLARE csr_lprng CURSOR FOR
+ SELECT pr.rp, pr.name, pr.duplexname, pr.hwtype,
+ m.name, pr.banner, pr.location, pr.contact, pr.ka,
+ pr.ac, pr.type as prtype
+ FROM printers pr, machine m, serverhosts sh
+ WHERE m.mach_id = sh.mach_id AND sh.service = 'PRINT' AND sh.enable = 1
+ AND pr.rm = m.mach_id ORDER BY pr.name;
+ EXEC SQL OPEN csr_lprng;
+ while (1)
+ {
+ EXEC SQL FETCH csr_lprng INTO :rp, :name, :duplexname,
+ :hwtype, :hostname, :banner, :location, :contact, :ka, :ac, :prtype;
+ if (sqlca.sqlcode)
+ break;
+
+ strtrim(rp);
+ strtrim(name);
+ strtrim(duplexname);
+ strtrim(hwtype);
+ strtrim(hostname);
+ strtrim(location);
+ strtrim(contact);
+ strcpy(lowerhwtype, hwtype);
+ for (p = lowerhwtype; *p; p++)
+ *p = tolower(*p);
+ for (p = name;*p;p++)
+ *p = tolower(*p);
+ for (p = duplexname;*p;p++)
+ *p = tolower(*p);
+
+ fprintf(out, "%s|%s|%s|%s|%s|%s\n", name,duplexname,hostname,location,hwtype,prtype);
+ }
+ EXEC SQL CLOSE csr_lprng;
+ tarfile_end(tf);
+
+ /* CUPS printers */
+ out = tarfile_start(tf, "/etc/cups/cups.printers.txt", 0644, 0, 0,
+ "root", "lp", now);
+
+ EXEC SQL DECLARE csr_cups CURSOR FOR
+ SELECT pr.rp, pr.name, pr.duplexname, pr.hwtype,
+ m.name, pr.banner, pr.location, pr.contact, pr.ka,
+ pr.ac, pr.type as prtype
+ FROM printers pr, machine m, serverhosts sh
+ WHERE m.mach_id = sh.mach_id AND sh.service = 'CUPS-PRINT' AND sh.enable = 1
+ AND pr.rm = m.mach_id ORDER BY pr.name;
+ EXEC SQL OPEN csr_cups;
+ while (1)
+ {
+ EXEC SQL FETCH csr_cups INTO :rp, :name, :duplexname,
+ :hwtype, :hostname, :banner, :location, :contact, :ka, :ac, :prtype;
+ if (sqlca.sqlcode)
+ break;
+
+ strtrim(rp);
+ strtrim(name);
+ strtrim(duplexname);
+ strtrim(hwtype);
+ strtrim(hostname);
+ strtrim(location);
+ strtrim(contact);
+ strcpy(lowerhwtype, hwtype);
+ for (p = lowerhwtype; *p; p++)
+ *p = tolower(*p);
+ for (p = name;*p;p++)
+ *p = tolower(*p);
+ for (p = duplexname;*p;p++)
+ *p = tolower(*p);
+
+ fprintf(out, "%s|%s|%s|%s|%s|%s\n", name,duplexname,hostname,location,hwtype,prtype);
+ }
+ EXEC SQL CLOSE csr_cups;
+ tarfile_end(tf);
+ tarfile_close(tf);
+}
+
+void sqlerr(void)
+{
+ db_error(sqlca.sqlcode);
+}
Added: trunk/third/moira/gen/cups-lpd.sh
===================================================================
--- trunk/third/moira/gen/cups-lpd.sh 2009-07-27 23:24:37 UTC (rev 23931)
+++ trunk/third/moira/gen/cups-lpd.sh 2009-07-28 17:36:37 UTC (rev 23932)
@@ -0,0 +1,49 @@
+#! /bin/sh
+# $Id: cups-lpd.sh,v 1.1 2009-07-21 21:39:13 zacheiss Exp $
+
+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 the
+# error codes the library uses:
+MR_MISSINGFILE=47836473
+MR_MKCRED=47836474
+MR_TARERR=47836476
+
+PATH=/bin
+TARFILE=/var/tmp/cups-lpd.out
+CUPSLOCAL=/etc/cups
+
+# Alert if the tar file or other needed files do not exist
+test -r $TARFILE || exit $MR_MISSINGFILE
+test -d $CUPSLOCAL || exit $MR_MISSINGFILE
+
+# Unpack the tar file, getting only files that are newer than the
+# on-disk copies (-u).
+cd /
+tar xf $TARFILE || exit $MR_TARERR
+
+/etc/cups/bin/sync_lpd_ldap.pl 2>/dev/null
+/etc/cups/bin/gen-ppd.pl 2>/dev/null
+
+/etc/init.d/cups restart
+
+# if Samba-enabled, then restart it too to have it pick up
+# new definitions
+if [ -x /etc/init.d/smb ]; then
+ /etc/init.d/smb restart
+fi
+
+if [ $? != 0 ]; then
+ exit $MR_MKCRED
+fi
+
+# cleanup
+test -f $TARFILE && rm -f $TARFILE
+test -f $0 && rm -f $0
+
+exit 0
+
Property changes on: trunk/third/moira/gen/cups-lpd.sh
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:eol-style
+ native
Modified: trunk/third/moira/gen/cups-print.pc
===================================================================
--- trunk/third/moira/gen/cups-print.pc 2009-07-27 23:24:37 UTC (rev 23931)
+++ trunk/third/moira/gen/cups-print.pc 2009-07-28 17:36:37 UTC (rev 23932)
@@ -1,4 +1,4 @@
-/* $Id: cups-print.pc,v 1.8 2009-05-04 20:49:10 zacheiss Exp $
+/* $Id: cups-print.pc,v 1.10 2009-07-21 21:39:13 zacheiss Exp $
*
* This generates printcaps and other files for Athena print servers
*
@@ -28,7 +28,7 @@
EXEC SQL INCLUDE sqlca;
-RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/gen/cups-print.pc,v 1.8 2009-05-04 20:49:10 zacheiss Exp $");
+RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/gen/cups-print.pc,v 1.10 2009-07-21 21:39:13 zacheiss Exp $");
char *whoami = "cups-print.gen";
char *db = "moira/moira";
@@ -50,6 +50,7 @@
CUPS-Accept-Jobs CUPS-Reject-Jobs>";
const char *canceljob = "<Limit Cancel-Job CUPS-Authenticate-Job>";
const char *catchall = "<Limit All>";
+const char *phost = "printers.MIT.EDU";
void do_host(char *host);
void sqlerr(void);
@@ -134,7 +135,7 @@
/* printers.conf */
out = tarfile_start(tf, "/etc/cups/printers.conf", 0644, 0, 0,
- "root", "lp", now);
+ "lp", "lp", now);
EXEC SQL DECLARE csr_printers CURSOR FOR
SELECT pr.rp, pr.name, pr.duplexname, pr.hwtype,
@@ -211,7 +212,7 @@
/* aliases are in classes.conf */
out = tarfile_start(tf, "/etc/cups/classes.conf", 0644, 0, 0,
- "root", "root", now);
+ "lp", "lp", now);
EXEC SQL DECLARE csr_duplexqs CURSOR FOR
SELECT pr.rp, pr.name, pr.duplexname, pr.hwtype,
m.name, pr.banner, pr.location, pr.contact, pr.ka,
@@ -338,13 +339,19 @@
fprintf(out, "ServerCertificate /etc/cups/ssl/%s-ipp-crt.pem\n", lhost);
fprintf(out, "ServerKey /etc/cups/ssl/%s-ipp-key.pem\n", lhost);
fprintf(out, "ServerName %s\n", lhost);
+ fprintf(out, "ServerAlias %s\n", phost);
fprintf(out, "Krb5Keytab /etc/krb5-ipp.keytab\n");
- fprintf(out, "Browsing On\n");
- fprintf(out, "BrowseProtocols cups\n");
/* The other CUPS servers should be aware of the other hosts'
queues, so we'll let them browse each other. */
+ fprintf(out, "Include cups.local.conf\n");
+ fprintf(out, "Include cups.locations.conf\n");
+ fprintf(out, "Include cups.policies.conf\n");
+ tarfile_end(tf);
+ /* cups.hosts.conf */
+ out = tarfile_start(tf, "/etc/cups/cups.hosts.conf", 0755, 1, 1,
+ "root", "lp", now);
EXEC SQL DECLARE csr_cupshosts CURSOR FOR
SELECT m.name AS cupshosts FROM machine m, printservers ps
WHERE m.mach_id = ps.mach_id AND ps.kind = 'CUPS';
@@ -362,8 +369,6 @@
fprintf(out, "BrowsePoll %s\n", cupshosts);
}
EXEC SQL CLOSE csr_cupshosts;
- fprintf(out, "Include cups.locations.conf\n");
- fprintf(out, "Include cups.policies.conf\n");
tarfile_end(tf);
Modified: trunk/third/moira/gen/cups-print.sh
===================================================================
--- trunk/third/moira/gen/cups-print.sh 2009-07-27 23:24:37 UTC (rev 23931)
+++ trunk/third/moira/gen/cups-print.sh 2009-07-28 17:36:37 UTC (rev 23932)
@@ -1,5 +1,5 @@
#! /bin/sh
-# $Id: cups-print.sh,v 1.2 2008-10-31 20:46:11 zacheiss Exp $
+# $Id: cups-print.sh,v 1.3 2009-07-01 16:28:43 zacheiss Exp $
if [ -d /var/athena ] && [ -w /var/athena ]; then
exec >/var/athena/moira_update.log 2>&1
@@ -30,10 +30,17 @@
/etc/cups/bin/gen-ppd.pl
/etc/init.d/cups restart
+
if [ $? != 0 ]; then
exit $MR_MKCRED
fi
+# if Samba-enabled, then restart it too to have it pick up
+# new definitions
+if [ -x /etc/init.d/smb ]; then
+ /etc/init.d/smb restart
+fi
+
# cleanup
test -f $TARFILE && rm -f $TARFILE
test -f $0 && rm -f $0
Modified: trunk/third/moira/gen/hesiod.pc
===================================================================
--- trunk/third/moira/gen/hesiod.pc 2009-07-27 23:24:37 UTC (rev 23931)
+++ trunk/third/moira/gen/hesiod.pc 2009-07-28 17:36:37 UTC (rev 23932)
@@ -1,4 +1,4 @@
-/* $Id: hesiod.pc,v 1.23 2008-10-22 16:12:33 zacheiss Exp $
+/* $Id: hesiod.pc,v 1.25 2009-07-13 02:15:32 zacheiss Exp $
*
* This generates the zone files necessary to load a hesiod server.
* The following zones are generated: passwd, uid, pobox, group,
@@ -23,7 +23,7 @@
EXEC SQL INCLUDE sqlca;
-RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/gen/hesiod.pc,v 1.23 2008-10-22 16:12:33 zacheiss Exp $");
+RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/gen/hesiod.pc,v 1.25 2009-07-13 02:15:32 zacheiss Exp $");
#ifndef HTYPE
#define HTYPE "TXT"
@@ -279,7 +279,15 @@
if (sqlca.sqlcode == 0)
pid = mid;
else
- pid = eid;
+ {
+ /* EXCHANGE user with no IMAP filesystem. Give them
+ * IMAP.EXCHANGE.MIT.EDU instead of EXCHANGE.MIT.EDU.
+ */
+ EXEC SQL SELECT mach_id INTO :eid FROM machine
+ WHERE name = 'IMAP.EXCHANGE.MIT.EDU';
+ if (sqlca.sqlcode == 0)
+ pid = eid;
+ }
}
if (iid != 0)
Modified: trunk/third/moira/gen/mailhosts.gen
===================================================================
--- trunk/third/moira/gen/mailhosts.gen 2009-07-27 23:24:37 UTC (rev 23931)
+++ trunk/third/moira/gen/mailhosts.gen 2009-07-28 17:36:37 UTC (rev 23932)
@@ -1,6 +1,6 @@
#!/moira/bin/perl -Tw
-# $Id: mailhosts.gen,v 1.5 2007-07-18 19:38:27 zacheiss Exp $
+# $Id: mailhosts.gen,v 1.7 2009-07-13 02:15:32 zacheiss Exp $
# The following exit codes are defined and MUST BE CONSISTENT with the
# error codes the library uses:
@@ -14,14 +14,8 @@
$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,51 @@
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 (16 - length($label) > 8) {
+ if ($exchange_id != 0) {
+ $imap_filesystem = lc($login) . ".po";
+ ($mach_id) = $dbh->selectrow_array("SELECT mach_id FROM filesys " .
+ "WHERE label = " . $dbh->quote($imap_filesystem) .
+ "AND type = 'IMAP'");
+ if (defined($mach_id)) {
+ $pop_id = $mach_id;
+ } else {
+ ($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;
+ }
+ }
+
+ ($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;
Modified: trunk/third/moira/regtape/Makefile.in
===================================================================
--- trunk/third/moira/regtape/Makefile.in 2009-07-27 23:24:37 UTC (rev 23931)
+++ trunk/third/moira/regtape/Makefile.in 2009-07-28 17:36:37 UTC (rev 23932)
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.14 2009-06-01 21:05:01 zacheiss Exp $
+# $Id: Makefile.in,v 1.15 2009-06-30 16:31:13 zacheiss Exp $
SHELL=/bin/sh
@SET_MAKE@
@@ -35,7 +35,7 @@
CFILES=student.c staff.c common.c vote.c
TARGET=student staff vote
-SCRIPTS=grouper.pl staff.sql student.sql
+SCRIPTS=grouper.pl staff.sql stellar.pl student.sql
.SUFFIXES: .pc .lo
Added: trunk/third/moira/regtape/stellar.pl
===================================================================
--- trunk/third/moira/regtape/stellar.pl 2009-07-27 23:24:37 UTC (rev 23931)
+++ trunk/third/moira/regtape/stellar.pl 2009-07-28 17:36:37 UTC (rev 23932)
@@ -0,0 +1,170 @@
+#!/moira/bin/perl -Tw
+# $Id: stellar.pl,v 1.2 2009-07-07 03:09:30 zacheiss Exp $
+
+$db = "";
+$mrtest = "mrtest";
+$logfile = "/moira/stellar.log";
+$datafile = "/moira/stellar/stellar-groups";
+$ENV{'PATH'} = "/moira/bin";
+
+$sendmail = '/usr/lib/sendmail';
+if ( ! -x $sendmail) { $sendmail = '/usr/sbin/sendmail'; }
+
+use DBI;
+
+$moira = DBI->connect("dbi:Oracle:moira", "moira", "moira",
+ { RaiseError => 1});
+
+($root_id) = $moira->selectrow_array("SELECT users_id FROM users ".
+ "WHERE login = 'root'");
+
+# Get names of current Stellar lists
+($admin_id) = $moira->selectrow_array("SELECT list_id FROM list ".
+ "WHERE name = 'stellar-group-admin'");
+$sth = $moira->prepare("SELECT name FROM list WHERE acl_type = 'LIST' ".
+ "AND acl_id = $admin_id");
+$sth->execute;
+while (($name) = $sth->fetchrow_array) {
+ $lists{$name} = $name;
+}
+
+open(MRTEST, "|$mrtest >/dev/null 2>&1");
+print MRTEST "connect $db\n";
+print MRTEST "auth\n";
+open(LOG, ">>$logfile");
+
+open(DATA, "$datafile") or die "Unable to open $datafile: $!\n";
+while (<DATA>) {
+ $changed = 0;
+ ($stellargroup, $junk, $membership) = split(/:/);
+ chomp($stellargroup);
+ chomp($junk);
+ chomp($membership);
+ $stellargroup = lc($stellargroup);
+ @membership = split(/[,]+/, $membership);
+
+ # Skip lists with leading dashes. They scare us.
+ if ($stellargroup =~ /^-/) {
+ print LOG "Skipping $stellargroup due to leading dash.\n";
+ push(@mailout, "Skipping $stellargroup due to leading dash.\n");
+ next;
+ }
+
+ # Skip lists with names that are too long.
+ if (length($stellargroup) > 56) {
+ print LOG "Skipping $stellargroup due to name longer than 56 characters.\n";
+ push(@mailout, "Skipping $stellargroup due to name longer than 56 characters.\n");
+ next;
+ }
+
+ ($conflict_exists) = $moira->selectrow_array("SELECT count(*) FROM list ".
+ "WHERE name = " . $moira->quote($stellargroup) .
+ "AND ((acl_type != 'LIST') OR " .
+ "(acl_type = 'LIST' AND acl_id != $admin_id))");
+ if ($conflict_exists > 0) {
+ print LOG "$stellargroup already exists with an owner other than stellar-group-admin.\n";
+ push(@mailout, "$stellargroup already exists with an owner other than stellar-group-admin.\n");
+ next;
+ }
+
+ # Create list if it doesn't exist.
+ &check_list($stellargroup, "stellar-group-admin", 0, "Automatically imported from Stellar");
+
+ # Now fill in lists.
+ %mrmembers = ();
+ $sth = $moira->prepare("SELECT u.login FROM users u, imembers i, list l ".
+ "WHERE l.list_id = i.list_id AND i.member_id = ".
+ "u.users_id AND i.direct = 1 AND i.member_type = ".
+ "'USER' AND l.name = " . $moira->quote($stellargroup));
+ $sth->execute;
+ while (($login) = $sth->fetchrow_array) {
+ $mrmembers{$login} = $login;
+ }
+
+ $sth = $moira->prepare("SELECT s.string FROM strings s, imembers i, list l ".
+ "WHERE l.list_id = i.list_id AND i.member_id = ".
+ "s.string_id AND i.direct = 1 AND i.member_type = ".
+ "'STRING' AND l.name = " . $moira->quote($stellargroup));
+ $sth->execute;
+ while (($string) = $sth->fetchrow_array) {
+ $mrmembers{$string} = $string;
+ }
+
+ foreach $member (@membership) {
+ if ($member =~ /\@mit.edu/) {
+ $member =~ s/\@mit.edu//;
+ if (!$mrmembers{$member}) {
+ print LOG "Adding USER $member to $stellargroup\n";
+ &add_member($member, USER, $stellargroup);
+ $changed = 1;
+ } else {
+ delete $mrmembers{$member};
+ }
+ } else {
+ if (!$mrmembers{$member}) {
+ print LOG "Adding STRING $member to $stellargroup\n";
+ &add_member($member, STRING, $stellargroup);
+ $changed = 1;
+ } else {
+ delete $mrmembers{$member};
+ }
+ }
+ }
+
+ # Everyone in membership will have been removed from mrmembers
+ # now, so delete the remaining users since they don't belong.
+ foreach $member (keys(%mrmembers)) {
+ if ($member =~ /\@/) {
+ print LOG "Deleting STRING $member from $stellargroup\n";
+ &del_member($member, STRING, $stellargroup);
+ $changed = 1;
+ } else {
+ print LOG "Deleting USER $member from $stellargroup\n";
+ &del_member($member, USER, $stellargroup);
+ $changed = 1;
+ }
+ }
+
+ if ($changed) {
+ $moira->do("UPDATE list SET modtime = SYSDATE, modby = $root_id, ".
+ "modwith = 'stellar' WHERE name = " .
+ $moira->quote($stellargroup));
+ }
+}
+
+close(DATA);
+$moira->disconnect;
+
+if (scalar(@mailout) > 0) {
+ print LOG "Found problems. Sending mail.\n";
+ open(MAIL, "|$sendmail -t -f errors\@mit.edu" ) || die "Failed to run $sendmail";
+ print MAIL "From: errors\@mit.edu\nTo: class-wiki-request\@mit.edu\nCc: zacheiss\@mit.edu\n";
+ print MAIL "Subject: Moira Stellar group data load problems\n";
+ print MAIL "The following problems were found during the Moira import of Stellar group data:\n\n";
+ foreach $line (@mailout) {
+ print MAIL $line;
+ }
+ close(MAIL);
+} else {
+ print LOG "No problems found.\n";
+}
+
+exit 0;
+
+sub check_list {
+ my ( $name, $owner, $export, $desc ) = @_;
+ if (!$lists{$name}) {
+ print LOG "Creating $name\n";
+ print MRTEST "qy alis $name 1 0 1 1 $export \"create unique GID\" 0 0 [NONE] LIST $owner NONE NONE \"$desc\"\n";
+ }
+}
+
+sub add_member {
+ my ( $user, $type, $list ) = @_;
+ print MRTEST "qy amtl $list $type $user\n";
+}
+
+sub del_member {
+ my ( $user, $type, $list ) = @_;
+ print MRTEST "qy dmfl $list $type $user\n";
+}
Property changes on: trunk/third/moira/regtape/stellar.pl
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/third/moira/server/qrtn.pc
===================================================================
--- trunk/third/moira/server/qrtn.pc 2009-07-27 23:24:37 UTC (rev 23931)
+++ trunk/third/moira/server/qrtn.pc 2009-07-28 17:36:37 UTC (rev 23932)
@@ -1,4 +1,4 @@
-/* $Id: qrtn.pc,v 2.30 2009-06-01 21:05:02 zacheiss Exp $
+/* $Id: qrtn.pc,v 2.31 2009-07-06 16:23:15 zacheiss Exp $
*
* Query-processing routines
*
@@ -20,7 +20,7 @@
EXEC SQL INCLUDE sqlca; /* SQL Communications Area */
EXEC SQL INCLUDE sqlda; /* SQL Descriptor Area */
-RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/server/qrtn.pc,v 2.30 2009-06-01 21:05:02 zacheiss Exp $");
+RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/server/qrtn.pc,v 2.31 2009-07-06 16:23:15 zacheiss Exp $");
SQLDA *mr_sqlda;
EXEC SQL BEGIN DECLARE SECTION;
@@ -641,16 +641,20 @@
if (!strcmp(strtrim(list_type), "KERBEROS") && list_id == -cl->client_id)
return 1;
- /* see if client is a member of list */
- flag = 0;
- users_id = cl->users_id;
- client_id = -cl->client_id;
- EXEC SQL SELECT COUNT(member_id) INTO :flag FROM imembers
- WHERE list_id = :list_id
- AND ( ( member_type = 'USER' AND member_id = :users_id )
- OR (member_type = 'KERBEROS' AND member_id = :client_id ) );
- if (sqlca.sqlcode == 0)
- return flag;
+ if (!strcmp(strtrim(list_type), "LIST"))
+ {
+ /* see if client is a member of list */
+ flag = 0;
+ users_id = cl->users_id;
+ client_id = -cl->client_id;
+ EXEC SQL SELECT COUNT(member_id) INTO :flag FROM imembers
+ WHERE list_id = :list_id
+ AND ( ( member_type = 'USER' AND member_id = :users_id )
+ OR (member_type = 'KERBEROS' AND member_id = :client_id ) );
+ if (sqlca.sqlcode == 0)
+ return flag;
+ }
+
return 0;
}
Modified: trunk/third/moira/update/auth_002.c
===================================================================
--- trunk/third/moira/update/auth_002.c 2009-07-27 23:24:37 UTC (rev 23931)
+++ trunk/third/moira/update/auth_002.c 2009-07-28 17:36:37 UTC (rev 23932)
@@ -1,4 +1,4 @@
-/* $Id: auth_002.c,v 1.10 2009-05-04 20:49:12 zacheiss Exp $
+/* $Id: auth_002.c,v 1.11 2009-07-28 16:18:52 zacheiss Exp $
*
* Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
* For copying and distribution information, please see the file
@@ -19,7 +19,7 @@
#include <krb.h>
#endif
-RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/update/auth_002.c,v 1.10 2009-05-04 20:49:12 zacheiss Exp $");
+RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/update/auth_002.c,v 1.11 2009-07-28 16:18:52 zacheiss Exp $");
static char service[] = "rcmd";
static char master[] = "sms";
@@ -132,6 +132,6 @@
ad.pname, ad.pinst, ad.prealm);
send_int(conn, code);
#else
- return MR_NO_KRB4;
+ send_int(conn, MR_NO_KRB4);
#endif
}
Modified: trunk/third/moira/update/ticket.c
===================================================================
--- trunk/third/moira/update/ticket.c 2009-07-27 23:24:37 UTC (rev 23931)
+++ trunk/third/moira/update/ticket.c 2009-07-28 17:36:37 UTC (rev 23932)
@@ -1,4 +1,4 @@
-/* $Id: ticket.c,v 1.24 2009-05-04 20:49:13 zacheiss Exp $
+/* $Id: ticket.c,v 1.25 2009-07-28 16:18:53 zacheiss Exp $
*
* Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
* For copying and distribution information, please see the file
@@ -21,7 +21,7 @@
#include <krb5.h>
#include <update.h>
-RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/update/ticket.c,v 1.24 2009-05-04 20:49:13 zacheiss Exp $");
+RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/update/ticket.c,v 1.25 2009-07-28 16:18:53 zacheiss Exp $");
#ifdef HAVE_KRB4
static char realm[REALM_SZ];
@@ -35,7 +35,7 @@
static int get_mr_tgt(void);
#endif
-int get_mr_krb5_update_ticket(char *host, krb5_data auth)
+int get_mr_krb5_update_ticket(char *host, krb5_data *auth)
{
krb5_auth_context auth_con = NULL;
krb5_ccache ccache = NULL;
@@ -54,7 +54,7 @@
goto out;
code = krb5_mk_req(context, &auth_con, 0, "host", host, NULL, ccache,
- &auth);
+ auth);
out:
if (ccache)
Modified: trunk/third/moira/update/update_server.c
===================================================================
--- trunk/third/moira/update/update_server.c 2009-07-27 23:24:37 UTC (rev 23931)
+++ trunk/third/moira/update/update_server.c 2009-07-28 17:36:37 UTC (rev 23932)
@@ -1,4 +1,4 @@
-/* $Id: update_server.c,v 1.27 2009-05-04 20:49:13 zacheiss Exp $
+/* $Id: update_server.c,v 1.28 2009-07-28 16:18:53 zacheiss Exp $
*
* Copyright 1988-1998 by the Massachusetts Institute of Technology.
* For copying and distribution information, please see the file
@@ -30,7 +30,7 @@
#endif
#include "update.h"
-RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/update/update_server.c,v 1.27 2009-05-04 20:49:13 zacheiss Exp $");
+RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/update/update_server.c,v 1.28 2009-07-28 16:18:53 zacheiss Exp $");
char *whoami, *hostname;
@@ -48,9 +48,7 @@
char *str;
void (*proc)(int, char *);
} dispatch_table[] = {
-#ifdef HAVE_KRB4
{ "AUTH_002", auth_002 },
-#endif
{ "AUTH_003", auth_003 },
{ "XFER_002", xfer_002 },
{ "XFER_003", xfer_003 },