LIB_TARGET=libdcm.a
OBJS= acl.o boot.o confluence.o dhcp.o directory.o events.o hesiod.o \
- hosts.o mailhub.o ndb.o network.o nfs.o pobox.o postoffice.o print.o \
- winad.o www.o zephyr.o
+ hosts.o lpcaccess.o mailhub.o ndb.o network.o nfs.o pobox.o \
+ postoffice.o print.o winad.o www.o zephyr.o
CFILES= acl.c boot.c confluence.c dhcp.c directory.c events.c hesiod.c \
- hosts.c mailhub.c ndb.c network.c nfs.c pobox.c postoffice.c print.c \
- winad.c www.c zephyr.c
+ hosts.c lpcaccess.c mailhub.c ndb.c network.c nfs.c pobox.c \
+ postoffice.c print.c winad.c www.c zephyr.c
TARGET= acl.gen boot.gen confluence.gen dhcp.gen directory.gen events.gen \
- hesiod.gen hosts.gen mailhub.gen ndb.gen network.gen nfs.gen \
- pobox.gen postoffice.gen print.gen winad.gen www.gen zephyr.gen
+ hesiod.gen hosts.gen lpcaccess.gen mailhub.gen ndb.gen network.gen \
+ nfs.gen pobox.gen postoffice.gen print.gen winad.gen www.gen zephyr.gen
SCRIPTS=access.gen access.sh acl.sh aliases.sh boot.sh ca.gen calendar.gen \
dhcp.sh events.sh hesiod.sh ip-billing.gen \
winad.gen: winad.o libdcm.a $(MR_LIBDEP)
$(CC) -o $@ $(LDFLAGS) winad.o libdcm.a $(SQL_LIBS) $(LIBS)
+
+lpcaccess.gen: lpcaccess.o libdcm.a $(MR_LIBDEP)
+ $(CC) -o $@ $(LDFLAGS) lpcaccess.o libdcm.a $(SQL_LIBS) $(LIBS)
--- /dev/null
+/* $Id$ */
+
+#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 "util.h"
+
+EXEC SQL INCLUDE sqlca;
+
+char *whoami = "lpcaccess.gen";
+char *db = "moira/moira";
+
+void sqlerr(void);
+
+int main(int argc, char **argv)
+{
+ EXEC SQL BEGIN DECLARE SECTION;
+ char name[PRINTERS_RP_SIZE], duplexname[PRINTERS_DUPLEXNAME_SIZE];
+ int lpc_acl, list_id;
+ EXEC SQL END DECLARE SECTION;
+ TARFILE *tf;
+ FILE *out;
+ char filename[MAXPATHLEN];
+ time_t mtime, now = time(NULL);
+
+ init_acls();
+
+ EXEC SQL CONNECT :db;
+
+ EXEC SQL WHENEVER SQLERROR DO sqlerr();
+
+ sprintf(filename, "%s/lpcaccess.out", DCM_DIR);
+ tf = tarfile_open(filename);
+
+ EXEC SQL SELECT list_id INTO :list_id FROM list
+ WHERE name = 'ops-lpcaccess-top';
+
+ out = tarfile_start(tf, "lpcaccess.top", 0755, 1, 1, "daemon", "daemon",
+ now);
+ dump_krb_acl(out, "LIST", list_id, 5);
+ tarfile_end(tf);
+
+ EXEC SQL SELECT list_id INTO :list_id FROM LIST
+ WHERE name = 'sap-lpcaccess-top';
+
+ out = tarfile_start(tf, "sap-lpcaccess.top", 0755, 1, 1, "daemon", "daemon",
+ now);
+ dump_krb_acl(out, "LIST", list_id, 5);
+ tarfile_end(tf);
+
+ EXEC SQL DECLARE csr_lpc CURSOR FOR SELECT UNIQUE rp, duplexname, lpc_acl
+ FROM printers WHERE lpc_acl != 0;
+ EXEC SQL OPEN csr_lpc;
+ while (1)
+ {
+ EXEC SQL FETCH csr_lpc INTO :name, :duplexname, :lpc_acl;
+ if (sqlca.sqlcode)
+ break;
+
+ strtrim(name);
+
+ tarfile_mkdir(tf, name, 0755, 1, 1, "daemon", "daemon", now);
+ sprintf(filename, "%s/lpcaccess", name);
+ out = tarfile_start(tf, filename, 0755, 1, 1, "daemon", "daemon", now);
+ dump_krb_acl(out, "LIST", lpc_acl, 5);
+ tarfile_end(tf);
+
+ if (*duplexname)
+ {
+ strtrim(duplexname);
+
+ tarfile_mkdir(tf, duplexname, 0755, 1, 1, "daemon", "daemon", now);
+ sprintf(filename, "%s/lpcaccess", duplexname);
+ out = tarfile_start(tf, filename, 0755, 1, 1, "daemon", "daemon", now);
+ dump_krb_acl(out, "LIST", lpc_acl, 5);
+ tarfile_end(tf);
+ }
+
+ }
+ EXEC SQL CLOSE csr_lpc;
+
+ tarfile_close(tf);
+
+ exit(MR_SUCCESS);
+}
+
+void sqlerr(void)
+{
+ db_error(sqlca.sqlcode);
+}
+
--- /dev/null
+#!/bin/sh
+# $Id$
+
+outfile=/home/cups/lpcaccess.out
+loadprog=/home/cups/update_acls
+
+PATH="/etc:/bin:/usr/bin:/usr/etc:/usr/athena/etc"
+
+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
+
+if [ ! -f $outfile ]; then
+ exit $MR_MISSINGFILE
+fi
+
+if [ ! -x $loadprog ]; then
+ exit $MR_MISSINGFILE
+fi
+
+$loadprog
+
+# Ignore exit status from $loadprog for now.
+#if [ $? != 0 ]; then
+# exit $MR_MKCRED
+#fi
+
+exit 0