+++ /dev/null
-/* $Header$ */
-
-#include <stdio.h>
-#include <sys/file.h>
-#include <rx/xdr.h>
-#include "print.h"
-#include "prserver.h"
-#include "prerror.h"
-
-int dbase_fd;
-extern struct prheader cheader;
-
-main(argc, argv)
-int argc;
-char **argv;
-{
- char *name, *msg;
- long id, status;
-
- if (argc != 3) {
- fprintf(stderr, "usage: %s listname gid\n", argv[0]);
- exit(1);
- }
- name = argv[1];
- id = atoi(argv[2]);
-
- dbase_fd = open("/usr/afs/db/xprdb.DB0", O_RDWR|O_CREAT, 0660);
-
- status = PR_INewEntry(NULL, name, -id, SYSADMINID);
- if (status != 0) {
- switch (status) {
- case PREXIST:
- msg = "name already exists";
- break;
- case PRIDEXIST:
- msg = "ID already exists";
- break;
- case PRNOIDS:
- msg = "no IDs available";
- break;
- case PRDBFAIL:
- msg = "database failed";
- break;
- case PRNOENT:
- msg = "no space left in database";
- break;
- case PRPERM:
- msg = "permission denied";
- break;
- case PRNOTGROUP:
- msg = "not a group";
- break;
- case PRNOTUSER:
- msg = "not a user";
- break;
- case PRBADNAM:
- msg = "bad name";
- break;
- default:
- msg = "unknown code";
- break;
- }
- fprintf(stderr, "Failed: %s (%d)\n", msg, status);
- }
- exit(status);
-}
+++ /dev/null
-/* $Header$ */
-
-#include <stdio.h>
-#include <sys/file.h>
-#include <rx/xdr.h>
-#include "print.h"
-#include "prserver.h"
-#include "prerror.h"
-
-int dbase_fd;
-extern struct prheader cheader;
-
-main(argc, argv)
-int argc;
-char **argv;
-{
- char *name, *msg;
- long id, status;
-
- if (argc != 3) {
- fprintf(stderr, "usage: %s loginname uid\n", argv[0]);
- exit(1);
- }
- name = argv[1];
- id = atoi(argv[2]);
-
- dbase_fd = open("/usr/afs/db/xprdb.DB0", O_RDWR|O_CREAT, 0660);
-
- status = PR_INewEntry(NULL, name, id, 0);
- if (status != 0) {
- switch (status) {
- case PREXIST:
- msg = "name already exists";
- break;
- case PRIDEXIST:
- msg = "ID already exists";
- break;
- case PRNOIDS:
- msg = "no IDs available";
- break;
- case PRDBFAIL:
- msg = "database failed";
- break;
- case PRNOENT:
- msg = "no space left in database";
- break;
- case PRPERM:
- msg = "permission denied";
- break;
- case PRNOTGROUP:
- msg = "not a group";
- break;
- case PRNOTUSER:
- msg = "not a user";
- break;
- case PRBADNAM:
- msg = "bad name";
- break;
- default:
- msg = "unknown code";
- break;
- }
- fprintf(stderr, "Failed: %s (%d)\n", msg, status);
- }
- exit(status);
-}
--- /dev/null
+/*
+ *
+ * ptdump: Program to dump the AFS protection server database
+ * into an ascii file.
+ *
+ * Assumptions: We *cheat* here and read the datafile directly, ie.
+ * not going through the ubik distributed data manager.
+ * therefore the database must be quiescent for the
+ * output of this program to be valid.
+ */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <strings.h>
+#include <sys/file.h>
+
+#include <afs/param.h>
+#include <lock.h>
+#include <netinet/in.h>
+#define UBIK_INTERNALS
+#include <ubik.h>
+#include <rx/xdr.h>
+#include <rx/rx.h>
+#include "ptint.h"
+#include "ptserver.h"
+#include "pterror.h"
+
+#define IDHash(x) (abs(x) % HASHSIZE)
+#define print_id(x) ( ((flags&DO_SYS)==0 && (x<-32767 || x>97536)) || \
+ ((flags&DO_OTR)==0 && (x>-32768 && x<97537)))
+
+extern char *optarg;
+extern int optind;
+extern int errno;
+extern char *sys_errlist[];
+#define strerror(a) sys_errlist[a]
+
+int display_entry();
+void add_group();
+void display_groups();
+void display_group();
+void fix_pre();
+char *checkin();
+char *check_core();
+char *id_to_name();
+
+struct hash_entry {
+ char h_name[PR_MAXNAMELEN];
+ int h_id;
+ struct hash_entry *next;
+};
+struct hash_entry *hat[HASHSIZE];
+
+static struct contentry prco;
+static struct prentry pre;
+static struct prheader prh;
+static struct ubik_version uv;
+
+struct grp_list {
+ struct grp_list *next;
+ long groups[1024];
+};
+static struct grp_list *grp_head=0;
+static long grp_count=0;
+
+struct usr_list {
+ struct usr_list *next;
+ char name[PR_MAXNAMELEN];
+ long uid;
+};
+static struct usr_list *usr_head=0;
+
+char buffer[1024];
+int dbase_fd;
+FILE *dfp;
+
+#define FMT_BASE "%-10s %d/%d %d %d %d\n"
+#define FMT_MEM " %-8s %d\n"
+
+#define DO_USR 1
+#define DO_GRP 2
+#define DO_MEM 4
+#define DO_SYS 8
+#define DO_OTR 16
+
+int nflag = 0;
+int wflag = 0;
+int flags = 0;
+
+main(argc, argv)
+int argc;
+char **argv;
+{
+ register int i;
+ register long code;
+ long cc, upos, gpos;
+ struct prentry uentry, gentry;
+ struct ubik_hdr *uh;
+ char *dfile = 0;
+ char *pfile = "/usr/afs/db/prdb.DB0";
+ int need_gwrite = 0;
+
+ while ((cc = getopt(argc, argv, "wugmxsnp:d:")) != EOF) {
+ switch (cc) {
+ case 'p':
+ pfile = optarg;
+ break;
+ case 'd':
+ dfile = optarg;
+ break;
+ case 'n':
+ nflag++;
+ break;
+ case 'w':
+ wflag++;
+ break;
+ case 'u':
+ flags |= DO_USR;
+ break;
+ case 'm':
+ flags |= (DO_GRP|DO_MEM);
+ break;
+ case 'g':
+ flags |= DO_GRP;
+ break;
+ case 's':
+ flags |= DO_SYS;
+ break;
+ case 'x':
+ flags |= DO_OTR;
+ break;
+ default:
+ fprintf(stderr,
+ "Usage: ptdump [options] [-d data] [-p prdb]\n");
+ fputs(" Options:\n", stderr);
+ fputs(" -w Update prdb with contents of data file\n", stderr);
+ fputs(" -u Display users\n", stderr);
+ fputs(" -g Display groups\n", stderr);
+ fputs(" -m Display group members\n", stderr);
+ fputs(" -n Follow name hash chains (not id hashes)\n", stderr);
+ fputs(" -s Display only system (Moira) data\n", stderr);
+ fputs(" -x Display extra users/groups\n", stderr);
+ exit(1);
+ }
+ }
+ if ((dbase_fd = open(pfile, wflag ? O_RDWR : O_RDONLY, 0600)) < 0) {
+ fprintf(stderr, "ptdump: cannot open %s: %s\n",
+ pfile, sys_errlist[errno]);
+ exit (1);
+ }
+ if (read(dbase_fd, buffer, HDRSIZE) < 0) {
+ fprintf(stderr, "ptdump: error reading %s: %s\n",
+ pfile, sys_errlist[errno]);
+ exit (1);
+ }
+
+ if (dfile) {
+ if ((dfp = fopen(dfile, wflag ? "r" : "w")) == 0) {
+ fprintf(stderr, "ptdump: error opening %s: %s\n",
+ dfile, sys_errlist[errno]);
+ exit(1);
+ }
+ } else
+ dfp = (wflag ? stdin : stdout);
+
+ uh = (struct ubik_hdr *)buffer;
+ if (ntohl(uh->magic) != UBIK_MAGIC)
+ fprintf(stderr, "ptdump: %s: Bad UBIK_MAGIC. Is %x should be %x\n",
+ pfile, ntohl(uh->magic), UBIK_MAGIC);
+ bcopy(&uh->version, &uv, sizeof(struct ubik_version));
+ fprintf(stderr, "Ubik Version is: %d.%d\n",
+ ntohl(uv.epoch), ntohl(uv.counter));
+ if (read(dbase_fd, &prh, sizeof(struct prheader)) < 0) {
+ fprintf(stderr, "ptdump: error reading %s: %s\n",
+ pfile, sys_errlist[errno]);
+ exit (1);
+ }
+
+ Initdb();
+ initialize_pt_error_table();
+
+#define FLUSH_GROUP \
+ if (need_gwrite) { \
+ code = pr_WriteEntry(0,0,gpos,&gentry); \
+ if (code) \
+ fprintf(stderr, "Error while writing group %s: %s\n", \
+ gentry.name, error_message(code)); \
+ else need_write = 0; \
+ }
+
+ if (wflag) {
+ struct usr_list *u;
+
+ while(fgets(buffer, sizeof(buffer), dfp)) {
+ int id, oid, cid, flags, quota, uid;
+ char name[PR_MAXNAMELEN], mem[PR_MAXNAMELEN];
+
+ if (isspace(*buffer)) {
+ sscanf(buffer, "%s %d", mem, &uid);
+
+ for (u=usr_head; u; u=u->next)
+ if (u->uid && u->uid==uid) break;
+ if (u) {
+ /* Add user - deferred because it is probably foreign */
+ u->uid = 0;
+ if (upos = FindByID(0, uid))
+ code = PRIDEXIST;
+ else {
+ if (!code && (flags&(PRGRP|PRQUOTA))==(PRGRP|PRQUOTA)){
+ gentry.ngroups++;
+ code = pr_WriteEntry(0,0,gpos,&gentry);
+ if (code)
+ fprintf(stderr, "Error setting group count on %s: %s\n",
+ name, error_message(code));
+ }
+ code = CreateEntry
+ (0, u->name, &uid, 1/*idflag*/, 1/*gflag*/,
+ SYSADMINID/*oid*/, SYSADMINID/*cid*/);
+ }
+ if (code)
+ fprintf(stderr, "Error while creating %s: %s\n",
+ u->name, error_message(code));
+ continue;
+ }
+ /* Add user to group */
+ if (id==ANYUSERID || id==AUTHUSERID || uid==ANONYMOUSID) {
+ code = PRPERM;
+ }
+ if (!code && !upos) {
+ upos = FindByID(0,uid);
+ if (upos) code = pr_ReadEntry(0,0,upos,&uentry);
+ }
+ if (!upos || !gpos)
+ code = PRNOENT;
+
+ /* Fast group update */
+ if (!code && (gentry.count < PRSIZE)) {
+ gentry.count++;
+ for (i=0; i<PRSIZE; i++) {
+ if (gentry.entries[i] == PRBADID) {
+ gentry.entries[i] = uid;
+ break;
+ }
+ }
+ } else {
+ FLUSH_GROUP;
+ if (!code) code = AddToEntry (0, &gentry, gpos, uid);
+ }
+
+ if (!code) code = AddToEntry (0, &uentry, upos, id);
+
+ if (code)
+ fprintf(stderr, "Error while adding %s to %s: %s\n",
+ mem, name, error_message(code));
+ } else {
+ FLUSH_GROUP;
+ sscanf(buffer, "%s %d/%d %d %d %d",
+ name, &flags, "a, &id, &oid, &cid);
+
+ if (gpos = FindByID(0, id))
+ code = PRIDEXIST;
+ else {
+ code = CreateEntry(0, name, &id, 1/*idflag*/,
+ flags&PRGRP, oid, cid);
+ if (!code) gpos = FindByID(0, id);
+ }
+ if (code == PRBADNAM) {
+ u = (struct usr_list *)malloc(sizeof(struct usr_list));
+ u->next = usr_head;
+ u->uid = id;
+ strcpy(u->name, name);
+ usr_head = u;
+ } else
+ if (code) {
+ fprintf(stderr, "Error while creating %s: %s\n",
+ name, error_message(code));
+ }
+ code = pr_ReadEntry(0,0,gpos,&gentry);
+ if (code)
+ fprintf(stderr,"Error while reading group %s: %s\n",
+ name, error_message(code));
+ else if ((flags&PRACCESS) ||
+ (flags&(PRGRP|PRQUOTA))==(PRGRP|PRQUOTA)) {
+ gentry.flags = flags;
+ gentry.ngroups = quota;
+ need_gwrite = 1;
+ if (code)
+ fprintf(stderr,
+ "Error while setting flags on %s: %s\n",
+ name, error_message(code));
+ }
+ }
+ }
+ FLUSH_GROUP;
+ for (u=usr_head; u; u=u->next)
+ if (u->uid)
+ fprintf(stderr, "Error while creating %s: %s\n",
+ u->name, error_message(PRBADNAM));
+ } else {
+ for (i = 0; i < HASHSIZE; i++) {
+ upos = nflag ? ntohl(prh.nameHash[i]) : ntohl(prh.idHash[i]);
+ while (upos)
+ upos = display_entry(upos);
+ }
+ if (flags & DO_GRP)
+ display_groups();
+ }
+
+ lseek (dbase_fd, 0, L_SET); /* rewind to beginning of file */
+ if (read(dbase_fd, buffer, HDRSIZE) < 0) {
+ fprintf(stderr, "ptdump: error reading %s: %s\n",
+ pfile, sys_errlist[errno]);
+ exit (1);
+ }
+ uh = (struct ubik_hdr *)buffer;
+ if ((uh->version.epoch != uv.epoch) ||
+ (uh->version.counter != uv.counter)) {
+ fprintf(stderr, "ptdump: Ubik Version number changed during execution.\n");
+ fprintf(stderr, "Old Version = %d.%d, new version = %d.%d\n",
+ ntohl(uv.epoch), ntohl(uv.counter),
+ ntohl(uh->version.epoch), ntohl(uh->version.counter));
+ }
+ close (dbase_fd);
+ exit (0);
+}
+
+int display_entry (offset)
+int offset;
+{
+ register int i;
+
+ lseek (dbase_fd, offset+HDRSIZE, L_SET);
+ read(dbase_fd, &pre, sizeof(struct prentry));
+
+ fix_pre(&pre);
+
+ if ((pre.flags & PRFREE) == 0) {
+ if (pre.flags & PRGRP) {
+ if (flags & DO_GRP)
+ add_group(pre.id);
+ } else {
+ if (print_id(pre.id) && (flags&DO_USR))
+ fprintf(dfp, FMT_BASE,
+ pre.name, pre.flags, pre.ngroups,
+ pre.id, pre.owner, pre.creator);
+ checkin(&pre);
+ }
+ }
+ return(nflag ? pre.nextName: pre.nextID);
+}
+
+void add_group(id)
+ long id;
+{
+ struct grp_list *g;
+ register long i;
+
+ i = grp_count++ % 1024;
+ if (i == 0) {
+ g = (struct grp_list *)malloc(sizeof(struct grp_list));
+ g->next = grp_head;
+ grp_head = g;
+ }
+ g = grp_head;
+ g->groups[i] = id;
+}
+
+void display_groups()
+{
+ register int i, id;
+ struct grp_list *g;
+
+ g = grp_head;
+ while (grp_count--) {
+ i = grp_count%1024;
+ id = g->groups[i];
+ display_group(id);
+ if (i==0) {
+ grp_head = g->next;
+ free(g);
+ g = grp_head;
+ }
+ }
+}
+
+void display_group(id)
+ int id;
+{
+ register int i, offset;
+ int print_grp = 0;
+
+ offset = ntohl(prh.idHash[IDHash(id)]);
+ while (offset) {
+ lseek(dbase_fd, offset+HDRSIZE, L_SET);
+ if (read(dbase_fd, &pre, sizeof(struct prentry)) < 0) {
+ fprintf(stderr, "ptdump: read i/o error: %s\n",
+ strerror(errno));
+ exit (1);
+ }
+ fix_pre(&pre);
+ if (pre.id == id)
+ break;
+ offset = pre.nextID;
+ }
+
+ if (print_id(id)) {
+ fprintf(dfp, FMT_BASE,
+ pre.name, pre.flags, pre.ngroups,
+ pre.id, pre.owner, pre.creator);
+ print_grp = 1;
+ }
+
+ if ((flags&DO_MEM) == 0)
+ return;
+
+ for (i=0; i<PRSIZE; i++) {
+ if ((id=pre.entries[i]) == 0)
+ break;
+ if (id==PRBADID) continue;
+ if (print_id(id) || print_grp==1) {
+ if (print_grp==0) {
+ fprintf(dfp, FMT_BASE,
+ pre.name, pre.flags, pre.ngroups,
+ pre.id, pre.owner, pre.creator);
+ print_grp = 2;
+ }
+ fprintf(dfp, FMT_MEM, id_to_name(id), id);
+ }
+ }
+ if (i == PRSIZE) {
+ offset = pre.next;
+ while (offset) {
+ lseek(dbase_fd, offset+HDRSIZE, L_SET);
+ read(dbase_fd, &prco, sizeof(struct contentry));
+ prco.next = ntohl(prco.next);
+ for (i = 0; i < COSIZE; i++) {
+ prco.entries[i] = ntohl(prco.entries[i]);
+ if ((id=prco.entries[i]) == 0)
+ break;
+ if (id==PRBADID) continue;
+ if (print_id(id) || print_grp==1) {
+ if (print_grp==0) {
+ fprintf(dfp, FMT_BASE,
+ pre.name, pre.flags, pre.ngroups,
+ pre.id, pre.owner, pre.creator);
+ print_grp = 2;
+ }
+ fprintf(dfp, FMT_MEM, id_to_name(id), id);
+ }
+ }
+ if ((i == COSIZE) && prco.next)
+ offset = prco.next;
+ else offset = 0;
+ }
+ }
+}
+
+void fix_pre(pre)
+ struct prentry *pre;
+{
+ register int i;
+
+ pre->flags = ntohl(pre->flags);
+ pre->id = ntohl(pre->id);
+ pre->cellid = ntohl(pre->cellid);
+ pre->next = ntohl(pre->next);
+ pre->nextID = ntohl(pre->nextID);
+ pre->nextName = ntohl(pre->nextName);
+ pre->owner = ntohl(pre->owner);
+ pre->creator = ntohl(pre->creator);
+ pre->ngroups = ntohl(pre->ngroups);
+ pre->nusers = ntohl(pre->nusers);
+ pre->count = ntohl(pre->count);
+ pre->instance = ntohl(pre->instance);
+ pre->owned = ntohl(pre->owned);
+ pre->nextOwned = ntohl(pre->nextOwned);
+ pre->parent = ntohl(pre->parent);
+ pre->sibling = ntohl(pre->sibling);
+ pre->child = ntohl(pre->child);
+ for (i = 0; i < PRSIZE; i++) {
+ pre->entries[i] = ntohl(pre->entries[i]);
+ }
+}
+
+char *id_to_name(id)
+int id;
+{
+ register int offset;
+ static struct prentry pre;
+ char *name;
+
+ name = check_core(id);
+ if (name) return(name);
+ offset = ntohl(prh.idHash[IDHash(id)]);
+ while (offset) {
+ lseek(dbase_fd, offset+HDRSIZE, L_SET);
+ if (read(dbase_fd, &pre, sizeof(struct prentry)) < 0) {
+ fprintf(stderr, "ptdump: read i/o error: %s\n",
+ sys_errlist[errno]);
+ exit (1);
+ }
+ pre.id = ntohl(pre.id);
+ if (pre.id == id) {
+ name = checkin(&pre);
+ return(name);
+ }
+ offset = ntohl(pre.nextID);
+ }
+ return 0;
+}
+
+char *checkin(pre)
+struct prentry *pre;
+{
+ struct hash_entry *he, *last;
+ register int id;
+
+ id = pre->id;
+ last = (struct hash_entry *)0;
+ he = hat[IDHash(id)];
+ while (he) {
+ if (id == he->h_id) return(he->h_name);
+ last = he;
+ he = he->next;
+ }
+ he = (struct hash_entry *)malloc(sizeof(struct hash_entry));
+ if (he == 0) {
+ fprintf(stderr, "ptdump: No Memory for internal hash table.\n");
+ exit (1);
+ }
+ he->h_id = id;
+ he->next = (struct hash_entry *)0;
+ strncpy(he->h_name, pre->name, PR_MAXNAMELEN);
+ if (last == (struct hash_entry *)0) hat[IDHash(id)] = he;
+ else last->next = he;
+ return(he->h_name);
+}
+
+char *check_core(id)
+register int id;
+{
+ struct hash_entry *he;
+ he = hat[IDHash(id)];
+ while (he) {
+ if (id == he->h_id) return(he->h_name);
+ he = he->next;
+ }
+ return 0;
+}
+++ /dev/null
-/* Copyright (C) 1990, 1989 Transarc Corporation - All rights reserved */
-/*
- * P_R_P_Q_# (C) COPYRIGHT IBM CORPORATION 1988
- * LICENSED MATERIALS - PROPERTY OF IBM
- * REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
- */
-
-/*
- Sherri Nichols
- Information Technology Center
- November, 1988
-*/
-
-#include <afs/param.h>
-#include <afs/stds.h>
-#include <ctype.h>
-#include <stdio.h>
-#ifdef AFS_HPUX_ENV
-#include <string.h>
-#else
-#include <strings.h>
-#endif
-#include <lock.h>
-#include <ubik.h>
-#include <rx/xdr.h>
-#include <rx/rx.h>
-#include <rx/rxkad.h>
-#include <afs/auth.h>
-#include <netinet/in.h>
-#include "ptserver.h"
-#include "pterror.h"
-
-#if defined(CROSS_CELL) && !defined(WhoIsThisWithName)
-static long WhoIsThisWithName();
-#endif
-
-
-RCSID ("$Header$")
-
-extern struct ubik_dbase *dbase;
-extern long Initdb();
-extern int pr_noAuth;
-extern char *prdir;
-
-static int CreateOK (ut, cid, oid, flag, admin)
- struct ubik_trans *ut;
- long cid; /* id of caller */
- long oid; /* id of owner */
- long flag; /* indicates type of entry */
- int admin; /* sysadmin membership */
-{
- if (flag & (PRGRP | PRFOREIGN)) {
- /* Allow anonymous group creation only if owner specified and running
- * noAuth. */
- if (cid == ANONYMOUSID) {
- if ((oid == 0) || !pr_noAuth) return 0;
- }
- }
- else { /* creating a user */
- if (!admin && !pr_noAuth) return 0;
- }
- return 1; /* OK! */
-}
-
-#if !defined(WhoIsThis)
-long WhoIsThis (acall, at, aid)
- struct rx_call *acall;
- struct ubik_trans *at;
- long *aid;
-{
- /* aid is set to the identity of the caller, if known, else ANONYMOUSID */
- /* returns -1 and sets aid to ANONYMOUSID on any failure */
- register struct rx_connection *tconn;
- register long code;
- char tcell[MAXKTCREALMLEN];
- char name[MAXKTCNAMELEN];
- char inst[MAXKTCNAMELEN];
- int ilen;
- char vname[256];
-#ifdef CROSS_CELL
- int foreign = 0;
-#endif
-
- *aid = SYSADMINID;
- return 0;
-
- *aid = ANONYMOUSID;
- tconn = rx_ConnectionOf(acall);
- code = rx_SecurityClassOf(tconn);
- if (code == 0) return 0;
- else if (code == 1) { /* vab class */
- goto done; /* no longer supported */
- }
- else if (code == 2) { /* kad class */
- if (code = rxkad_GetServerInfo
- (acall->conn, (long *) 0, 0/*was &exp*/,
- name, inst, tcell, (long *) 0))
- goto done;
-#if 0
- /* This test is unnecessary, since rxkad_GetServerInfo already check.
- * In addition, this is wrong since exp must be unsigned. */
- if (exp < FT_ApproxTime()) goto done;
-#endif
- if (strlen (tcell)) {
- if (!afsconf_LocalRealm(prdir, tcell)) {
-#ifdef CROSS_CELL
- foreign = 1;
-#else
- goto done;
-#endif
- }
- }
- strncpy (vname, name, sizeof(vname));
- if (ilen = strlen (inst)) {
- if (strlen(vname) + 1 + ilen >= sizeof(vname)) goto done;
- strcat (vname, ".");
- strcat (vname, inst);
- }
-#ifdef CROSS_CELL
- if (foreign) {
- if ((strlen(name)+strlen(tcell)+1) >= sizeof(vname)) {
- goto done;
- }
- strcat (vname, "@");
- strcat (vname, tcell);
- }
-#endif
- if (strcmp (AUTH_SUPERUSER, vname) == 0)
- *aid = SYSADMINID; /* special case for the fileserver */
- else {
- lcstring(vname, vname, sizeof(vname));
- code = NameToID(at,vname,aid);
- }
- }
- done:
- if (code && !pr_noAuth) return -1;
- return 0;
-}
-#endif
-
-long PR_INewEntry(call,aname,aid,oid)
- struct rx_call *call;
- char aname[PR_MAXNAMELEN];
- long aid;
- long oid;
-{
- /* used primarily for conversion - not intended to be used as usual means
- of entering people into the database. */
- struct ubik_trans *tt;
- register long code;
- long gflag = 0;
- long cid;
- int admin;
-
-#define abort_with(code) return (ubik_AbortTrans(tt),code)
-
- stolower(aname);
- code = Initdb();
- if (code != PRSUCCESS) return code;
- code = ubik_BeginTrans(dbase,UBIK_WRITETRANS, &tt);
- if (code) return code;
- code = ubik_SetLock(tt, 1,1,LOCKWRITE);
- if (code) abort_with (code);
-
- code = WhoIsThis(call,tt,&cid);
- if (code) abort_with (PRPERM);
- admin = IsAMemberOf(tt,cid,SYSADMINID);
-
- /* first verify the id is good */
- if (aid == 0) abort_with (PRPERM);
- if (aid < 0) {
- gflag |= PRGRP;
- /* only sysadmin can reuse a group id */
- if (!admin && !pr_noAuth && (aid != ntohl(cheader.maxGroup)-1))
- abort_with (PRPERM);
- }
- if (FindByID (tt, aid)) abort_with (PRIDEXIST);
-
- /* check a few other things */
- if (!CreateOK (tt, cid, oid, gflag, admin)) abort_with (PRPERM);
-
- code = CreateEntry (tt,aname,&aid,1,gflag,oid,cid);
- if (code != PRSUCCESS) {
- ubik_AbortTrans(tt);
- return code;
- }
- /* finally, commit transaction */
- code = ubik_EndTrans(tt);
- if (code) return code;
- return PRSUCCESS;
-}
-
-
-long PR_NewEntry (call, aname, flag, oid, aid)
- struct rx_call *call;
- char aname[PR_MAXNAMELEN];
- long flag;
- long oid;
- long *aid;
-{
- register long code;
- struct ubik_trans *tt;
- long cid;
- int admin;
-#ifdef CROSS_CELL
- char cname[PR_MAXNAMELEN];
-#endif
-
- stolower(aname);
- code = Initdb();
- if (code) return code;
- code = ubik_BeginTrans(dbase,UBIK_WRITETRANS,&tt);
- if (code) return code;
- code = ubik_SetLock(tt,1,1,LOCKWRITE);
- if (code) {
- abort:
- ubik_AbortTrans(tt);
- return code;
- }
-
-#ifdef CROSS_CELL
- /* this is for cross-cell self registration */
- code = WhoIsThisWithName(call,tt,&cid,cname);
- if (code != 2) { /* 2 specifies that this is a foreign cell request */
- if (code) {
- perm:
- ubik_AbortTrans(tt);
- return PRPERM;
- }
- admin = IsAMemberOf(tt,cid,SYSADMINID);
- } else {
- admin = (!strcmp(aname,cname)) || IsAMemberOf(tt,cid,SYSADMINID);
- oid = cid = SYSADMINID;
- }
-#else
- code = WhoIsThis(call,tt,&cid);
- if (code) {
- perm:
- ubik_AbortTrans(tt);
- return PRPERM;
- }
- admin = IsAMemberOf(tt,cid,SYSADMINID);
-#endif
-
- if (!CreateOK (tt, cid, oid, flag, admin)) goto perm;
-
- code = CreateEntry (tt,aname,aid,0,flag,oid,cid);
- if (code != PRSUCCESS) goto abort;
-
- code = ubik_EndTrans(tt);
- if (code) return code;
- return PRSUCCESS;
-}
-
-
-
-PR_WhereIsIt(call,aid,apos)
-struct rx_call *call;
-long aid;
-long *apos;
-{
- register long code;
- struct ubik_trans *tt;
- long temp;
-
- code = Initdb();
- if (code != PRSUCCESS) return code;
- code = ubik_BeginTrans(dbase,UBIK_READTRANS,&tt);
- if (code) return code;
- code = ubik_SetLock(tt,1,1,LOCKREAD);
- if (code) {
- ubik_AbortTrans(tt);
- return code;
- }
- temp = FindByID(tt,aid);
- if (!temp) {
- ubik_AbortTrans(tt);
- return PRNOENT;
- }
- *apos = temp;
- code = ubik_EndTrans(tt);
- if (code) return code;
- return PRSUCCESS;
-}
-
-
-PR_DumpEntry(call,apos, aentry)
-struct rx_call *call;
-long apos;
-struct prdebugentry *aentry;
-{
- register long code;
- struct ubik_trans *tt;
-
- code = Initdb();
- if (code != PRSUCCESS) return code;
- code = ubik_BeginTransReadAny(dbase,UBIK_READTRANS,&tt);
- if (code) return code;
- code = ubik_SetLock(tt,1,1,LOCKREAD);
- if (code) {
- abort:
- ubik_AbortTrans(tt);
- return code;
- }
- code = pr_ReadEntry(tt, 0, apos, aentry);
- if (code) goto abort;
-
- /* Since prdebugentry is in the form of a prentry not a coentry, we will
- * return the coentry slots in network order where the string is. */
-#if 0
- if (aentry->flags & PRCONT) { /* wrong type, get coentry instead */
- code = pr_ReadCoEntry(tt, 0, apos, aentry);
- if (code) goto abort;
- }
-#endif
- code = ubik_EndTrans(tt);
- if (code) return code;
- return PRSUCCESS;
-}
-
-PR_AddToGroup(call,aid,gid)
-struct rx_call *call;
-long aid;
-long gid;
-{
- register long code;
- struct ubik_trans *tt;
- long tempu;
- long tempg;
- struct prentry tentry;
- struct prentry uentry;
- long cid;
-
- code = Initdb();
- if (code != PRSUCCESS) return code;
- if (gid == ANYUSERID || gid == AUTHUSERID) return PRPERM;
- if (aid == ANONYMOUSID) return PRPERM;
- code = ubik_BeginTrans(dbase,UBIK_WRITETRANS,&tt);
- if (code) return code;
- code = ubik_SetLock(tt,1,1,LOCKWRITE);
- if (code) {
- ubik_AbortTrans(tt);
- return code;
- }
- code = WhoIsThis(call, tt, &cid);
- if (code) {
- ubik_AbortTrans(tt);
- return PRPERM;
- }
- tempu = FindByID(tt,aid);
- if (!tempu) {
- ubik_AbortTrans(tt);
- return PRNOENT;
- }
- bzero(&uentry,sizeof(uentry));
- code = pr_ReadEntry(tt,0,tempu,&uentry);
- if (code != 0) {
- ubik_AbortTrans(tt);
- return code;
- }
- /* we don't allow groups as members of groups at present */
- if (uentry.flags & PRGRP) {
- ubik_AbortTrans(tt);
- return PRNOTUSER;
- }
- tempg = FindByID(tt,gid);
- if (!tempg) {
- ubik_AbortTrans(tt);
- return PRNOENT;
- }
- code = pr_ReadEntry(tt,0,tempg,&tentry);
- if (code != 0) {
- ubik_AbortTrans(tt);
- return code;
- }
- /* make sure that this is a group */
- if (!(tentry.flags & PRGRP)) {
- ubik_AbortTrans(tt);
- return PRNOTGROUP;
- }
- if (!AccessOK (tt, cid, &tentry, PRP_ADD_MEM, PRP_ADD_ANY)) {
- ubik_AbortTrans(tt);
- return PRPERM;
- }
-
- code = AddToEntry (tt, &tentry, tempg, aid);
- if (code != PRSUCCESS) {
- ubik_AbortTrans(tt);
- return code;
- }
- /* now, modify the user's entry as well */
- code = AddToEntry (tt, &uentry, tempu, gid);
- if (code != PRSUCCESS) {
- ubik_AbortTrans(tt);
- return code;
- }
- code = ubik_EndTrans(tt);
- if (code) return code;
- return PRSUCCESS;
-}
-
-long PR_NameToID (call, aname, aid)
- struct rx_call *call;
- namelist *aname;
- idlist *aid;
-{
- register long code;
- struct ubik_trans *tt;
- long i;
- int size;
- int count = 0;
-
- /* must do this first for RPC stub to work */
- size = aname->namelist_len;
- if ((size <= 0) || (size > PR_MAXLIST)) size = 0;
- aid->idlist_val = (long *)malloc(size*sizeof(long));
- aid->idlist_len = 0;
- if (aname->namelist_len == 0) return 0;
- if (size == 0) return PRTOOMANY; /* rxgen will probably handle this */
-
- code = Initdb();
- if (code != PRSUCCESS) return code;
- code = ubik_BeginTransReadAny(dbase,UBIK_READTRANS,&tt);
- if (code) return code;
- code = ubik_SetLock(tt,1,1,LOCKREAD);
- if (code) {
- ubik_AbortTrans(tt);
- return code;
- }
- for (i=0;i<aname->namelist_len;i++) {
- code = NameToID(tt,aname->namelist_val[i],&aid->idlist_val[i]);
- if (code != PRSUCCESS) aid->idlist_val[i] = ANONYMOUSID;
- if (count++ > 50) IOMGR_Poll(), count = 0;
- }
- aid->idlist_len = aname->namelist_len;
-
- code = ubik_EndTrans(tt);
- if (code) return code;
- return PRSUCCESS;
-}
-
-long PR_IDToName (call, aid, aname)
- struct rx_call *call;
- idlist *aid;
- namelist *aname;
-{
- register long code;
- struct ubik_trans *tt;
- long i;
- int size;
- int count = 0;
-
- /* leave this first for rpc stub */
- size = aid->idlist_len;
- if ((size <= 0) || (size > PR_MAXLIST)) size = 0;
- aname->namelist_val = (prname *)malloc(size*PR_MAXNAMELEN);
- aname->namelist_len = 0;
- if (aid->idlist_len == 0) return 0;
- if (size == 0) return PRTOOMANY; /* rxgen will probably handle this */
-
- code = Initdb();
- if (code != PRSUCCESS) return code;
- code = ubik_BeginTransReadAny(dbase,UBIK_READTRANS,&tt);
- if (code) return code;
- code = ubik_SetLock(tt,1,1,LOCKREAD);
- if (code) {
- ubik_AbortTrans(tt);
- return code;
- }
- for (i=0;i<aid->idlist_len;i++) {
- /* interface won't allow more than PR_MAXLIST to be sent in */
- code = IDToName(tt,aid->idlist_val[i],aname->namelist_val[i]);
- if (code != PRSUCCESS)
- sprintf(aname->namelist_val[i],"%d",aid->idlist_val[i]);
- if (count++ > 50) IOMGR_Poll(), count = 0;
- }
- aname->namelist_len = aid->idlist_len;
-
- code = ubik_EndTrans(tt);
- if (code) return code;
- return PRSUCCESS;
-}
-
-long PR_Delete (call, aid)
- struct rx_call *call;
- long aid;
-{
- register long code;
- struct ubik_trans *tt;
- long cid;
- struct prentry tentry;
- long loc, nptr;
- int count;
-
- code = Initdb();
- if (code) return code;
- if (code != PRSUCCESS) return code;
- if (aid == SYSADMINID || aid == ANYUSERID || aid == AUTHUSERID ||
- aid == ANONYMOUSID) return PRPERM;
- code = ubik_BeginTrans(dbase,UBIK_WRITETRANS,&tt);
- if (code) return code;
- code = ubik_SetLock(tt,1,1,LOCKWRITE);
- if (code) {
- abort:
- ubik_AbortTrans(tt);
- return code;
- }
- code = WhoIsThis(call,tt,&cid);
- if (code) {
- ubik_AbortTrans(tt);
- return PRPERM;
- }
-
- /* Read in entry to be deleted */
- loc = FindByID (tt, aid);
- if (loc == 0) {code = PRNOENT; goto abort;}
- code = pr_ReadEntry (tt, 0, loc, &tentry);
- if (code) {code = PRDBFAIL; goto abort;}
-
- /* Do some access checking */
- if (tentry.owner != cid &&
- !IsAMemberOf (tt, cid, SYSADMINID) &&
- !IsAMemberOf (tt, cid, tentry.owner) && !pr_noAuth)
- {code = PRPERM; goto abort;}
-
- /* Delete each continuation block as a separate transaction so that no one
- * transaction become to large to complete. */
- nptr = tentry.next;
- while (nptr != NULL) {
- struct contentry centry;
- int i;
-
- code = pr_ReadCoEntry(tt, 0, nptr, ¢ry);
- if (code != 0) {code = PRDBFAIL; goto abort;}
- for (i=0;i<COSIZE;i++) {
- if (centry.entries[i] == PRBADID) continue;
- if (centry.entries[i] == 0) break;
- code = RemoveFromEntry (tt, aid, centry.entries[i]);
- if (code) goto abort;
- tentry.count--; /* maintain count */
- if ((i&3) == 0) IOMGR_Poll();
- }
- tentry.next = centry.next; /* thread out this block */
- code = FreeBlock (tt, nptr); /* free continuation block */
- if (code) goto abort;
- code = pr_WriteEntry (tt, 0, loc, &tentry); /* update main entry */
- if (code) goto abort;
-
- /* end this trans and start a new one */
- code = ubik_EndTrans(tt);
- if (code) return code;
- IOMGR_Poll(); /* just to keep the connection alive */
- code = ubik_BeginTrans(dbase,UBIK_WRITETRANS,&tt);
- if (code) return code;
- code = ubik_SetLock(tt,1,1,LOCKWRITE);
- if (code) goto abort;
-
- /* re-read entry to get consistent uptodate info */
- loc = FindByID (tt, aid);
- if (loc == 0) {code = PRNOENT; goto abort;}
- code = pr_ReadEntry (tt, 0, loc, &tentry);
- if (code) {code = PRDBFAIL; goto abort;}
-
- nptr = tentry.next;
- }
-
- /* Then move the owned chain, except possibly ourself to the orphan list.
- * Because this list can be very long and so exceed the size of a ubik
- * transaction, we start a new transaction every 50 entries. */
- count = 0;
- nptr = tentry.owned;
- while (nptr != NULL) {
- struct prentry nentry;
-
- code = pr_ReadEntry (tt, 0, nptr, &nentry);
- if (code) {code = PRDBFAIL; goto abort;}
- nptr = tentry.owned = nentry.nextOwned; /* thread out */
-
- if (nentry.id != tentry.id) { /* don't add us to orphan chain! */
- code = AddToOrphan (tt, nentry.id);
- if (code) goto abort;
- count++;
- if ((count & 3) == 0) IOMGR_Poll();
- }
- if (count < 50) continue;
- code = pr_WriteEntry (tt, 0, loc, &tentry); /* update main entry */
- if (code) goto abort;
-
- /* end this trans and start a new one */
- code = ubik_EndTrans(tt);
- if (code) return code;
- IOMGR_Poll(); /* just to keep the connection alive */
- code = ubik_BeginTrans(dbase,UBIK_WRITETRANS,&tt);
- if (code) return code;
- code = ubik_SetLock(tt,1,1,LOCKWRITE);
- if (code) goto abort;
-
- /* re-read entry to get consistent uptodate info */
- loc = FindByID (tt, aid);
- if (loc == 0) {code = PRNOENT; goto abort;}
- code = pr_ReadEntry (tt, 0, loc, &tentry);
- if (code) {code = PRDBFAIL; goto abort;}
-
- nptr = tentry.owned;
- }
-
- /* now do what's left of the deletion stuff */
- code = DeleteEntry (tt, &tentry, loc);
- if (code != PRSUCCESS) {
- ubik_AbortTrans(tt);
- return code;
- }
- code = ubik_EndTrans(tt);
- if (code) return code;
- return PRSUCCESS;
-}
-
-PR_RemoveFromGroup(call,aid,gid)
-struct rx_call *call;
-long aid;
-long gid;
-{
- register long code;
- struct ubik_trans *tt;
- long tempu;
- long tempg;
- struct prentry uentry;
- struct prentry gentry;
- long cid;
-
- code = Initdb();
- if (code != PRSUCCESS) return code;
- code = ubik_BeginTrans(dbase,UBIK_WRITETRANS,&tt);
- if (code) return code;
- code = ubik_SetLock(tt,1,1,LOCKWRITE);
- if (code) {
- ubik_AbortTrans(tt);
- return code;
- }
- code = WhoIsThis(call,tt,&cid);
- if (code) {
- ubik_AbortTrans(tt);
- return PRPERM;
- }
- tempu = FindByID(tt,aid);
- if (!tempu) {
- ubik_AbortTrans(tt);
- return PRNOENT;
- }
- tempg = FindByID(tt,gid);
- if (!tempg) {
- ubik_AbortTrans(tt);
- return PRNOENT;
- }
- bzero(&uentry,sizeof(uentry));
- bzero(&gentry,sizeof(gentry));
- code = pr_ReadEntry(tt,0,tempu,&uentry);
- if (code != 0) {
- ubik_AbortTrans(tt);
- return code;
- }
- code = pr_ReadEntry(tt,0,tempg,&gentry);
- if (code != 0) {
- ubik_AbortTrans(tt);
- return code;
- }
- if (!(gentry.flags & PRGRP)) {
- ubik_AbortTrans(tt);
- return PRNOTGROUP;
- }
- if (uentry.flags & PRGRP) {
- ubik_AbortTrans(tt);
- return PRNOTUSER;
- }
- if (!AccessOK (tt, cid, &gentry, PRP_REMOVE_MEM, 0)) {
- ubik_AbortTrans(tt);
- return PRPERM;
- }
- code = RemoveFromEntry(tt,aid,gid);
- if (code != PRSUCCESS) {
- ubik_AbortTrans(tt);
- return code;
- }
- code = RemoveFromEntry(tt,gid,aid);
- if (code != PRSUCCESS) {
- ubik_AbortTrans(tt);
- return code;
- }
- code = ubik_EndTrans(tt);
- if (code) return code;
- return PRSUCCESS;
-}
-
-long PR_GetCPS (call, aid, alist, over)
- struct rx_call *call;
- long aid;
- prlist *alist;
- long *over;
-{
- register long code;
- struct ubik_trans *tt;
- long temp;
- long cid;
- struct prentry tentry;
-
- alist->prlist_len = 0;
- alist->prlist_val = (long *) 0;
- code = Initdb();
- if (code != PRSUCCESS) goto done;
- code = ubik_BeginTransReadAny(dbase,UBIK_READTRANS,&tt);
- if (code) goto done;
- code = ubik_SetLock(tt,1,1,LOCKREAD);
- if (code) {
- abort:
- ubik_AbortTrans(tt);
- goto done;
- }
-
- temp = FindByID (tt, aid);
- if (!temp) {code = PRNOENT; goto abort;}
- code = pr_ReadEntry (tt, 0, temp, &tentry);
- if (code) goto abort;
-
- /* afs does authenticate now */
- code = WhoIsThis (call, tt, &cid);
- if (code || !AccessOK (tt, cid, &tentry, PRP_MEMBER_MEM, PRP_MEMBER_ANY)) {
- code = PRPERM;
- goto abort;
- }
-
- code = GetList(tt, &tentry, alist, 1);
- *over = 0;
- if (code == PRTOOMANY) *over = 1;
- else if (code != PRSUCCESS) {
- ubik_AbortTrans(tt);
- goto done;
- }
-
- code = ubik_EndTrans(tt);
-
-done:
- /* return code, making sure that prlist_val points to malloc'd memory */
- if (!alist->prlist_val)
- alist->prlist_val = (long *) malloc(0); /* make xdr stub happy */
- return code;
-}
-
-PR_ListMax(call,uid,gid)
-struct rx_call *call;
-long *uid;
-long *gid;
-{
- register long code;
- struct ubik_trans *tt;
-
- code = Initdb();
- if (code != PRSUCCESS) return code;
- code = ubik_BeginTransReadAny(dbase,UBIK_READTRANS,&tt);
- if (code) return code;
- code = ubik_SetLock(tt,1,1,LOCKREAD);
- if (code) {
- ubik_AbortTrans(tt);
- return code;
- }
- code = GetMax(tt,uid,gid);
- if (code != PRSUCCESS) {
- ubik_AbortTrans(tt);
- return code;
- }
- code = ubik_EndTrans(tt);
- if (code) return code;
- return PRSUCCESS;
-}
-
-PR_SetMax(call,aid,gflag)
-struct rx_call *call;
-long aid;
-long gflag;
-{
- register long code;
- struct ubik_trans *tt;
- long cid;
-
- code = Initdb();
- if (code != PRSUCCESS) return code;
- code = ubik_BeginTrans(dbase,UBIK_WRITETRANS,&tt);
- if (code) return code;
- code = ubik_SetLock(tt,1,1,LOCKWRITE);
- if (code) {
- ubik_AbortTrans(tt);
- return code;
- }
- code = WhoIsThis(call,tt,&cid);
- if (code) {
- ubik_AbortTrans(tt);
- return PRPERM;
- }
- if (!AccessOK (tt, cid, 0, 0, 0)) {
- ubik_AbortTrans(tt);
- return PRPERM;
- }
- if (((gflag & PRGRP) && (aid > 0)) ||
- (!(gflag & PRGRP) && (aid < 0))) {
- code = PRBADARG;
- goto abort;
- }
-
- code = SetMax(tt,aid,gflag);
- if (code != PRSUCCESS) {
- abort:
- ubik_AbortTrans(tt);
- return code;
- }
- code = ubik_EndTrans(tt);
- if (code) return code;
- return PRSUCCESS;
-}
-
-PR_ListEntry(call,aid,aentry)
-struct rx_call *call;
-long aid;
-struct prcheckentry *aentry;
-{
- register long code;
- struct ubik_trans *tt;
- long cid;
- long temp;
- struct prentry tentry;
-
- code = Initdb();
- if (code != PRSUCCESS) return code;
- code = ubik_BeginTransReadAny(dbase,UBIK_READTRANS,&tt);
- if (code) return code;
- code = ubik_SetLock(tt,1,1,LOCKREAD);
- if (code) {
- ubik_AbortTrans(tt);
- return code;
- }
- code = WhoIsThis(call,tt,&cid);
- if (code) {
- perm:
- ubik_AbortTrans(tt);
- return PRPERM;
- }
- temp = FindByID(tt,aid);
- if (!temp) {
- ubik_AbortTrans(tt);
- return PRNOENT;
- }
- code = pr_ReadEntry(tt, 0, temp, &tentry);
- if (code != 0) {
- ubik_AbortTrans(tt);
- return code;
- }
- if (!AccessOK (tt, cid, &tentry, PRP_STATUS_MEM, PRP_STATUS_ANY))
- goto perm;
-
- aentry->flags = tentry.flags >> PRIVATE_SHIFT;
- if (aentry->flags == 0)
- if (tentry.flags & PRGRP)
- aentry->flags = PRP_GROUP_DEFAULT >> PRIVATE_SHIFT;
- else aentry->flags = PRP_USER_DEFAULT >> PRIVATE_SHIFT;
- aentry->owner = tentry.owner;
- aentry->id = tentry.id;
- strncpy(aentry->name,tentry.name,PR_MAXNAMELEN);
- aentry->creator = tentry.creator;
- aentry->ngroups = tentry.ngroups;
- aentry->nusers = tentry.nusers;
- aentry->count = tentry.count;
- bzero (aentry->reserved, sizeof(aentry->reserved));
- code = ubik_EndTrans(tt);
- if (code) return code;
- return PRSUCCESS;
-}
-
-PR_ChangeEntry(call,aid,name,oid,newid)
-struct rx_call *call;
-long aid;
-char *name;
-long oid;
-long newid;
-{
- register long code;
- struct ubik_trans *tt;
- long pos;
- long cid;
-
- stolower(name);
- code = Initdb();
- if (code) return code;
- if (aid == ANYUSERID || aid == AUTHUSERID || aid == ANONYMOUSID ||
- aid == SYSADMINID) return PRPERM;
- if (code != PRSUCCESS) return code;
- code = ubik_BeginTrans(dbase,UBIK_WRITETRANS,&tt);
- if (code) return code;
- code = ubik_SetLock(tt,1,1,LOCKWRITE);
- if (code) {
- ubik_AbortTrans(tt);
- return code;
- }
- code = WhoIsThis(call,tt,&cid);
- if (code) {
- ubik_AbortTrans(tt);
- return PRPERM;
- }
- pos = FindByID(tt,aid);
- if (!pos) {
- ubik_AbortTrans(tt);
- return PRNOENT;
- }
- /* protection check in changeentry */
- code = ChangeEntry(tt,aid,cid,name,oid,newid);
- if (code != PRSUCCESS) {
- ubik_AbortTrans(tt);
- return code;
- }
- code = ubik_EndTrans(tt);
- return code;
-}
-
-PR_SetFieldsEntry(call, id, mask, flags, ngroups, nusers, spare1, spare2)
- struct rx_call *call;
- long id;
- long mask; /* specify which fields to update */
- long flags, ngroups, nusers;
- long spare1, spare2;
-{
- register long code;
- struct ubik_trans *tt;
- long pos;
- long cid;
- struct prentry tentry;
- long tflags;
-
- if (mask == 0) return 0; /* no-op */
- code = Initdb();
- if (code) return code;
- if (id == ANYUSERID || id == AUTHUSERID || id == ANONYMOUSID)
- return PRPERM;
- if (code != PRSUCCESS) return code;
- code = ubik_BeginTrans(dbase,UBIK_WRITETRANS,&tt);
- if (code) return code;
- code = ubik_SetLock(tt,1,1,LOCKWRITE);
- if (code) {
- abort:
- ubik_AbortTrans(tt);
- return code;
- }
- code = WhoIsThis(call,tt,&cid);
- if (code) {
- perm:
- ubik_AbortTrans(tt);
- return PRPERM;
- }
- pos = FindByID(tt,id);
- if (!pos) {
- ubik_AbortTrans(tt);
- return PRNOENT;
- }
- code = pr_ReadEntry (tt, 0, pos, &tentry);
- if (code) goto abort;
- tflags = tentry.flags;
-
- if (mask & (PR_SF_NGROUPS | PR_SF_NUSERS)) {
- if (!AccessOK (tt, cid, 0, 0, 0)) goto perm;
- if ((tflags & PRQUOTA) == 0) { /* default if only setting one */
- tentry.ngroups = tentry.nusers = 20;
- }
- } else {
- if (!AccessOK (tt, cid, &tentry, 0, 0)) goto perm;
- }
-
- if (mask & 0xffff) { /* if setting flag bits */
- long flagsMask = mask & 0xffff;
- tflags &= ~(flagsMask << PRIVATE_SHIFT);
- tflags |= (flags & flagsMask) << PRIVATE_SHIFT;
- tflags |= PRACCESS;
- }
-
- if (mask & PR_SF_NGROUPS) { /* setting group limit */
- if (ngroups < 0) {code = PRBADARG; goto abort;}
- tentry.ngroups = ngroups;
- tflags |= PRQUOTA;
- }
-
- if (mask & PR_SF_NUSERS) { /* setting foreign user limit */
- if (nusers < 0) {code = PRBADARG; goto abort;}
- tentry.nusers = nusers;
- tflags |= PRQUOTA;
- }
- tentry.flags = tflags;
-
- code = pr_WriteEntry (tt, 0, pos, &tentry);
- if (code) goto abort;
-
- code = ubik_EndTrans(tt);
- return code;
-}
-
-long PR_ListElements (call, aid, alist, over)
- struct rx_call *call;
- long aid;
- prlist *alist;
- long *over;
-{
- register long code;
- struct ubik_trans *tt;
- long cid;
- long temp;
- struct prentry tentry;
-
- alist->prlist_len = 0;
- alist->prlist_val = (long *) 0;
-
- code = Initdb();
- if (code != PRSUCCESS) goto done;
- code = ubik_BeginTransReadAny(dbase,UBIK_READTRANS,&tt);
- if (code) goto done;
- code = ubik_SetLock(tt,1,1,LOCKREAD);
- if (code) {
- abort:
- ubik_AbortTrans(tt);
- goto done;
- }
- code = WhoIsThis(call,tt,&cid);
- if (code) {
- perm:
- code = PRPERM;
- ubik_AbortTrans(tt);
- goto done;
- }
-
- temp = FindByID(tt,aid);
- if (!temp) {code = PRNOENT; goto abort;}
- code = pr_ReadEntry (tt, 0, temp, &tentry);
- if (code) goto abort;
- if (!AccessOK (tt, cid, &tentry, PRP_MEMBER_MEM, PRP_MEMBER_ANY))
- goto perm;
-
- code = GetList (tt, &tentry, alist, 0);
- *over = 0;
- if (code == PRTOOMANY) *over = 1;
- else if (code != PRSUCCESS) goto abort;
-
- code = ubik_EndTrans(tt);
-
-done:
- if (!alist->prlist_val)
- alist->prlist_val = (long *) malloc(0); /* make calling stub happy */
- return code;
-}
-
-/* List the entries owned by this id. If the id is zero return the orphans
- * list. */
-
-PR_ListOwned (call, aid, alist, over)
- struct rx_call *call;
- long aid;
- prlist *alist;
- long *over;
-{
- register long code;
- struct ubik_trans *tt;
- long cid;
- struct prentry tentry;
- long head;
-
- alist->prlist_len = 0;
- alist->prlist_val = (long *) 0;
-
- code = Initdb();
- if (code != PRSUCCESS) goto done;
- code = ubik_BeginTransReadAny(dbase,UBIK_READTRANS,&tt);
- if (code) goto done;
- code = ubik_SetLock(tt,1,1,LOCKREAD);
- if (code) {
- abort:
- ubik_AbortTrans(tt);
- goto done;
- }
- code = WhoIsThis(call,tt,&cid);
- if (code) {
- perm:
- code = PRPERM;
- ubik_AbortTrans(tt);
- goto done;
- }
-
- if (aid) {
- long loc = FindByID (tt, aid);
- if (loc == 0) { code = PRNOENT; goto abort; }
- code = pr_ReadEntry (tt, 0, loc, &tentry);
- if (code) goto abort;
-;
- if (!AccessOK (tt, cid, &tentry, -1, PRP_OWNED_ANY)) goto perm;
- head = tentry.owned;
- } else {
- if (!AccessOK (tt, cid, 0, 0, 0)) goto perm;
- head = ntohl(cheader.orphan);
- }
-
- code = GetOwnedChain (tt, head, alist);
- *over = 0;
- if (code == PRTOOMANY) *over = 1;
- else if (code) goto abort;
-
- code = ubik_EndTrans(tt);
-
-done:
- if (!alist->prlist_val)
- alist->prlist_val = (long *) malloc(0); /* make calling stub happy */
- return code;
-}
-
-PR_IsAMemberOf(call,uid,gid,flag)
-struct rx_call *call;
-long uid;
-long gid;
-long *flag;
-{
- register long code;
- struct ubik_trans *tt;
-
- code = Initdb();
- if (code != PRSUCCESS) return code;
- code = ubik_BeginTrans(dbase,UBIK_READTRANS,&tt);
- if (code) return code;
- code = ubik_SetLock(tt,1,1,LOCKREAD);
- if (code) {
- abort:
- ubik_AbortTrans(tt);
- return code;
- }
- { long cid;
- long uloc = FindByID (tt, uid);
- long gloc = FindByID (tt, gid);
- struct prentry uentry, gentry;
-
- if (!uloc || !gloc) {
- code = PRNOENT;
- goto abort;
- }
- code = WhoIsThis(call, tt, &cid);
- if (code) {
- perm:
- code = PRPERM;
- goto abort;
- }
- code = pr_ReadEntry (tt, 0, uloc, &uentry);
- if (code) goto abort;
- code = pr_ReadEntry (tt, 0, gloc, &gentry);
- if (code) goto abort;
- if ((uentry.flags & PRGRP) || !(gentry.flags & PRGRP)) {
- code = PRBADARG;
- goto abort;
- }
- if (!AccessOK (tt, cid, &uentry, 0, PRP_MEMBER_ANY) &&
- !AccessOK (tt, cid, &gentry, PRP_MEMBER_MEM, PRP_MEMBER_ANY))
- goto perm;
- }
-
- *flag = IsAMemberOf(tt,uid,gid);
- code = ubik_EndTrans(tt);
- return code;
-}
-
-
-static stolower(s)
-register char *s;
-{
- register int tc;
- while (tc = *s) {
- if (isupper(tc)) *s = tolower(tc);
- s++;
- }
-}
-
-#if defined(CROSS_CELL) && !defined(WhoIsThisWithName)
-static long WhoIsThisWithName(acall, at, aid, aname)
- struct rx_call *acall;
- struct ubik_trans *at;
- long *aid;
- char *aname;
-{
- /* aid is set to the identity of the caller, if known, else ANONYMOUSID */
- /* returns -1 and sets aid to ANONYMOUSID on any failure */
-
- register struct rx_connection *tconn;
- register long code;
- char tcell[MAXKTCREALMLEN];
- char name[MAXKTCNAMELEN];
- char inst[MAXKTCNAMELEN];
- int ilen;
- char vname[256];
-
- *aid = SYSADMINID;
- return 0;
-
- *aid = ANONYMOUSID;
- tconn = rx_ConnectionOf(acall);
- code = rx_SecurityClassOf(tconn);
- if (code == 0) return 0;
- else if (code == 1) { /* vab class */
- goto done; /* no longer supported */
- }
- else if (code == 2) { /* kad class */
-
- int clen;
- extern char *pr_realmName;
-
- if (code = rxkad_GetServerInfo
- (acall->conn, (long *)0, 0 /*was &exp*/,
- name, inst, tcell, (long *)0))
- goto done;
- strncpy (vname, name, sizeof(vname));
- if (ilen = strlen (inst)) {
- if (strlen(vname) + 1 + ilen >= sizeof(vname)) goto done;
- strcat (vname, ".");
- strcat (vname, inst);
- }
- if (clen = strlen (tcell)) {
- if (!afsconf_LocalRealm(prdir, tcell)) {
- if (strlen(vname) + 1 + clen >= sizeof(vname)) goto done;
- strcat(vname,"@");
- strcat(vname,tcell);
- lcstring(vname, vname, sizeof(vname));
- code = NameToID(at,vname,aid);
- strcpy(aname,vname);
- return 2;
- }
- }
-
- if (strcmp (AUTH_SUPERUSER, vname) == 0)
- /* special case for the fileserver */
- *aid = SYSADMINID;
- else {
- lcstring(vname, vname, sizeof(vname));
- code = NameToID(at,vname,aid);
- }
- }
-done:
- if (code && !pr_noAuth) return -1;
- return 0;
-}
-#endif
+++ /dev/null
-#define WhoIsThis(call,a,id) \
- ((*(id) = ((call)?(int)(call):SYSADMINID)), 0)
-#define WhoIsThisWithName(call,a,id,name) \
- ((*(id) = ((call)?(int)(call):SYSADMINID)), 0)
-
-#include <afs/ptserver.h>
+++ /dev/null
-/* $Header$
- *
- */
-
-#include <mit-copyright.h>
-#include <stdio.h>
-#include <sys/file.h>
-#include <rx/xdr.h>
-#include <afs/ptint.h>
-#include <afs/ptserver.h>
-#include <afs/pterror.h>
-#include <moira.h>
-#include <moira_site.h>
-#include <ctype.h>
-
-
-#define min(x,y) ((x) < (y) ? (x) : (y))
-#define abs(x) (((x) > 0) ? (x) : -(x))
-struct hash *users, *groups, *usersid, *groupsid;
-char *whoami = "sync";
-
-char *malloc(), *strsave(), *perm_malloc();
-int dbase_fd;
-int replaceflag = 0;
-struct prheader prh;
-
-
-main(argc, argv)
-int argc;
-char **argv;
-{
- int i;
- char *file = NULL;
- int ingerr();
-
- for (i = 1; i < argc; i++) {
- if (argv[i][0] == '-') {
- switch (argv[i][1]) {
- case 'r':
- replaceflag++;
- break;
- default:
- usage(argv[0]);
- }
- } else {
- if (file == NULL)
- file = argv[i];
- else
- usage(argv[0]);
- }
- }
-
- i = O_RDONLY;
- if (replaceflag)
- i = O_RDWR;
- dbase_fd = open(file, i, 0660);
- if (dbase_fd < 0) {
- perror("opening file %s", file);
- exit(1);
- }
- IIseterr(ingerr);
- initialize_sms_error_table ();
-
-## ingres sms
-## set lockmode session where level = table
-## begin transaction
-
- get_users();
- get_groups();
- get_members();
-
-## end transaction
-## exit
-
- pr_Read(NULL, 0, 0, &prh, sizeof(prh));
- check_users_and_groups();
-
- exit(MR_SUCCESS);
-}
-
-usage(name)
-char *name;
-{
- fprintf(stderr, "usage: %s [-r] dbfile\n", name);
- exit(MR_ARGS);
-}
-
-
-/*
- * ingerr: (supposedly) called when Ingres indicates an error.
- * I have not yet been able to get this to work to intercept a
- * database open error.
- */
-#define INGRES_DEADLOCK 4700
-
-static int ingerr(num)
- int *num;
-{
- char buf[256];
- int ingres_errno;
-
- switch (*num) {
- case INGRES_DEADLOCK:
- ingres_errno = MR_DEADLOCK;
- break;
- default:
- ingres_errno = MR_INGRES_ERR;
- }
- com_err(whoami, MR_INGRES_ERR, " code %d\n", *num);
- exit(ingres_errno);
-}
-
-
-prserror(status, msg, arg1, arg2)
-int status;
-char *msg;
-unsigned long arg1, arg2;
-{
- char buf[512];
-
- sprintf(buf, msg, arg1, arg2);
- switch (status) {
- case PREXIST:
- msg = "name already exists";
- break;
- case PRIDEXIST:
- msg = "ID already exists";
- break;
- case PRNOIDS:
- msg = "no IDs available";
- break;
- case PRDBFAIL:
- msg = "database failed";
- break;
- case PRNOENT:
- msg = "no space left in database";
- break;
- case PRPERM:
- msg = "permission denied";
- break;
- case PRNOTGROUP:
- msg = "not a group";
- break;
- case PRNOTUSER:
- msg = "not a user";
- break;
- case PRBADNAM:
- msg = "bad name";
- break;
- case 0:
- msg = "no error";
- break;
- default:
- msg = "unknown code";
- break;
- }
- fprintf(stderr, "%s (%d): %s\n", msg, status, buf);
-}
-
-
-nomem(msg)
-char *msg;
-{
- fprintf(stderr, "Out of memory: %s\n", msg);
- exit(1);
-}
-
-
-struct user {
- char login[9];
- char flag;
- short uid;
-};
-
-
-get_users()
-##{
-## char login[9];
-## int uid, id;
- struct user *u;
-
- fprintf(stderr, "Loading users from Moira\n");
- users = create_hash(10000);
- usersid = create_hash(10000);
-## range of u is users
-## retrieve (login = u.#login, uid = u.#uid, id = u.users_id)
-## where u.#status = 1 {
- strtrim(login);
- u = (struct user *)perm_malloc(sizeof(struct user));
- if (u == NULL)
- nomem("loading users");
- strncpy(u->login, login, 9);
- u->flag = 0;
- u->uid = uid;
- hash_store(users, uid, u);
- hash_store(usersid, id, u);
-## }
-##}
-
-
-#define CHUNKSIZE 5
-struct chunk {
- short member[CHUNKSIZE];
- struct chunk *xmem;
-};
-
-struct group {
- char name[33];
- char flag;
- short gid;
- short members;
- struct chunk ch;
-};
-
-
-get_groups()
-##{
-## char name[33];
-## int gid, id;
- struct group *g;
-
- fprintf(stderr, "Loading groups from Moira\n");
- groups = create_hash(10000);
- groupsid = create_hash(10000);
-## range of l is list
-## retrieve (name = l.#name, gid = l.#gid, id = l.list_id)
-## where l.#active = 1 and l.#group = 1 {
- strtrim(name);
- g = (struct group *)perm_malloc(sizeof(struct group));
- if (g == NULL)
- nomem("loading groups");
- bzero(g, sizeof(struct group));
- strncpy(g->name, name, 33);
- g->gid = gid;
- hash_store(groups, gid, g);
- hash_store(groupsid, id, g);
-## }
-##}
-
-
-get_members()
-##{
- struct user *u;
- struct group *g;
-## int id, lid;
-
- fprintf(stderr, "Fetching members from Moira\n");
-
-## range of m is imembers
-
-## retrieve (lid = m.list_id, id = m.member_id)
-## where m.member_type = "USER" {
- if ((u = (struct user *) hash_lookup(usersid, id)) &&
- (g = (struct group *) hash_lookup(groupsid, lid))) {
- if (g->members < CHUNKSIZE) {
- g->ch.member[g->members] = u->uid;
- } else {
- int i = g->members - CHUNKSIZE;
- struct chunk *c;
-
- if ((c = g->ch.xmem) == NULL) {
- c = (struct chunk *) perm_malloc(sizeof(struct chunk));
- if (c == NULL)
- nomem("loading members");
- g->ch.xmem = c;
- }
- while (i >= CHUNKSIZE) {
- i -= CHUNKSIZE;
- if (c->xmem == NULL) {
- c->xmem = (struct chunk *) perm_malloc(sizeof(struct chunk));
- if (c->xmem == NULL)
- nomem("loading members");
- }
- c = c->xmem;
- }
- c->member[i] = u->uid;
- }
- g->members++;
- }
-## }
-
-##}
-
-
-
-checkuser(id, u)
-int id;
-struct user *u;
-{
- int status;
-
- if (u->flag == 0) {
- printf("< User %s id %d is in Moira but not in prs\n",
- u->login, u->uid);
- if (replaceflag) {
- status = PR_INewEntry(NULL, u->login, u->uid, 0);
- if (status) {
- prserror(status, "adding user %s uid %d to prs database",
- u->login, u->uid);
- }
- }
- }
-}
-
-checkgroup(id, g)
-int id;
-struct group *g;
-{
- register int i, j, status;
- struct chunk *c;
-
- if (g->flag == 0) {
- printf("< Group %s id %d is in Moira but not in prs\n",
- g->name, g->gid);
- if (replaceflag) {
- char namebuf[64];
- sprintf(namebuf, "system:%s", g->name);
- status = PR_INewEntry(NULL, namebuf, -g->gid, SYSADMINID);
- if (status)
- prserror(status, "adding list %s gid %d to prs database",
- namebuf, -g->gid);
- }
- }
- c = (struct chunk *)&(g->ch);
- for (i = 0; i < g->members; i++) {
- j = i % CHUNKSIZE;
- printf("< Group %s contains user %d in Moira but not in prs\n",
- g->name, c->member[j]);
- if (replaceflag) {
- status = PR_AddToGroup(NULL, c->member[j], -g->gid);
- if (status)
- prserror(status, "adding %d to group %d in prs",
- c->member[j], -g->gid);
- }
- if (j == CHUNKSIZE - 1)
- c = c->xmem;
- }
-}
-
-check_users_and_groups()
-{
- register int i;
- int offset;
-
- fprintf(stderr, "Scanning PRS database\n");
-
- for (i = 0; i < HASHSIZE; i++) {
- offset = ntohl(prh.idHash[i]);
- while (offset)
- offset = check_entry(offset);
- }
- hash_step(users, checkuser, NULL);
- hash_step(groups, checkgroup, NULL);
-}
-
-check_entry(offset)
-int offset;
-{
- struct prentry entry;
- int flags, id, status;
- struct user *u;
- struct group *g;
-
- status = pr_Read(NULL, 0, offset, &entry, sizeof(entry));
- if (status)
- prserror(status, "reading prentry at %d", offset, 0);
- flags = ntohl(entry.flags);
- id = ntohl(entry.id);
- if ((flags & PRFREE) == 0) {
- if (flags & PRGRP) {
- g = (struct group *) hash_lookup(groups, abs(id));
- if (g == NULL) {
- if (!strncmp(entry.name, "system:", 7)) {
- printf("> Group %s, id %d is in prs but not moira\n",
- entry.name, id);
- if (replaceflag) {
- status = PR_Delete(NULL, id);
- if (status)
- prserror(status, "deleting group %d from prs", id);
- }
- }
- } else if (strcasecmp(g->name, index(entry.name, ':')+1)) {
- printf("> GID %d in prs is %s, but GID %d in moira is %s\n",
- id, entry.name, -id, g->name);
- if (replaceflag) {
- printf("*** Dont' know how to fix this!!!!!\n");
- }
- } else {
- g->flag = 1;
- if (entry.entries[0])
- do_members(&entry, g);
- }
- } else {
- u = (struct user *) hash_lookup(users, abs(id));
- if (u == NULL) {
- printf("> User %s, id %d is in prs but not moira\n",
- entry.name, id);
- if (replaceflag) {
- status = PR_Delete(NULL, id);
- if (status)
- prserror(status, "while deleting user %d from prs", id);
- }
- } else if (strcasecmp(u->login, entry.name)) {
- printf("> User id %d in prs is %s, but UID %d in moira is %s\n",
- id, entry.name, id, u->login);
- if (replaceflag) {
- printf("*** don't know how to fix this!!!!!\n");
- }
- } else
- u->flag = 1;
- }
- }
- return(ntohl(entry.nextID));
-}
-
-
-do_members(e, g)
-struct prentry *e;
-struct group *g;
-{
- register int i;
- int offset;
- struct contentry prco;
-
- for (i = 0; i < PRSIZE; i++) {
- if (e->entries[i] == 0)
- return;
- mark_member(g, ntohl(e->entries[i]));
- }
- offset = ntohl(e->next);
- while (offset) {
- pr_Read(NULL, 0, offset, &prco, sizeof(struct contentry));
- for (i = 0; i < COSIZE; i++) {
- if (prco.entries[i] == 0)
- return;
- mark_member(g, ntohl(prco.entries[i]));
- }
- offset = ntohl(prco.next);
- }
-}
-
-
-mark_member(g, uid)
-struct group *g;
-int uid;
-{
- register int i, j, status;
-
- if (uid == PRBADID)
- return;
- if (g->members >= CHUNKSIZE) {
- short *s = NULL, s1;
- struct chunk *c = (struct chunk *)&(g->ch);
-
- for (i = 0; i < g->members; i++) {
- j = i % CHUNKSIZE;
- if (c->member[j] == uid) {
- s = &(c->member[j]);
- }
- if (j == CHUNKSIZE - 1) {
- s1 = c->member[CHUNKSIZE - 1];
- c = c->xmem;
- }
- }
- if (j != CHUNKSIZE - 1)
- s1 = c->member[j];
- if (s) {
- *s = s1;
- g->members--;
- return;
- }
- printf("> Group %s contains user %d in prs but not in Moira\n", g->name,
- uid);
- if (replaceflag) {
- status = PR_RemoveFromGroup(NULL, uid, -g->gid);
- if (status)
- prserror(status, "While removing user %d from group %d in prs",
- uid, g->gid);
- }
- return;
- }
- for (i = 0; i < g->members; i++) {
- if (g->ch.member[i] == uid) {
- if (g->members == i + 1)
- g->ch.member[i] = 0;
- else {
- g->ch.member[i] = g->ch.member[g->members];
- g->ch.member[g->members] = 0;
- }
- g->members--;
- return;
- }
- }
- printf("> Group %s contains user %d in prs but not in Moira\n", g->name,
- uid);
- if (replaceflag) {
- status = PR_RemoveFromGroup(NULL, uid, -g->gid);
- if (status)
- prserror(status, "While removing user %d from group %d in prs",
- uid, g->gid);
- }
-}
-
-
-#define MALLOC_BLOCK 102400
-
-char *perm_malloc(size)
-unsigned size;
-{
- static char *pool = NULL;
- static unsigned pool_size = 0;
- register char *ret;
-
- if (size > pool_size) {
- pool = (char *) malloc(MALLOC_BLOCK);
- pool_size = MALLOC_BLOCK;
- }
- ret = pool;
- pool += size;
- pool = (char *)(((unsigned) (pool + 1)) & ~1);
- pool_size -= (pool - ret);
- return(ret);
-}
-
+++ /dev/null
-/* $Header$
- *
- *
- * (c) Copyright 1989 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- */
-
-#include <mit-copyright.h>
-#include <stdio.h>
-#include <sys/file.h>
-
-#include <rx/xdr.h>
-#include "ptint.h"
-#include "ptserver.h"
-#include "pterror.h"
-
-#include <moira.h>
-#include <moira_site.h>
-#include <ctype.h>
-
-#define min(x,y) ((x) < (y) ? (x) : (y))
-char *whoami = "sync";
-
-char *malloc(), *strsave();
-int dbase_fd;
-
-long pos; /* cheader.eofPtr */
-long usercount; /* cheader.usercount */
-long groupcount; /* cheader.groupcount */
-
-struct hash *users;
-struct hash *groups;
-
-struct member {
- struct entry *user;
- struct entry *group;
- struct member *unext;
- struct member *gnext;
-};
-
-struct entry {
- long id;
- long pos;
- struct member *members;
-};
-
-main(argc, argv)
-int argc;
-char **argv;
-{
-## char db[9];
-
- int status;
- int ingerr();
-
- strcpy(db, "sms");
-
- if (!strcmp(argv[1], "-db")) {
- strncpy(db, argv[2], sizeof(db)-1);
- argc -= 2;
- argv += 2;
- }
- if (argc != 2) {
- fprintf(stderr, "usage: %s [-db sms] outfile\n", whoami);
- exit(MR_ARGS);
- }
-
- dbase_fd = open(argv[1], O_RDWR|O_CREAT|O_TRUNC, 0660);
- if (dbase_fd < 0) {
- perror("opening file %s", argv[1]);
- exit(1);
- }
- IIseterr(ingerr);
-
- initialize_sms_error_table();
- initialize_pt_error_table();
- Initdb(); /* Initialize prdb */
-
- users = create_hash(10000);
- groups = create_hash(15000);
-
- pos = ntohl(cheader.eofPtr);
- usercount = ntohl(cheader.usercount);
- groupcount = ntohl(cheader.groupcount);
-
-## ingres db
-## set lockmode session where level = table
-## begin transaction
-
- do_passwd();
- do_groups();
-
-## end transaction
-## exit
-
- exit(MR_SUCCESS);
-}
-
-
-do_passwd()
-##{
-## char login[9];
-## int uid, id;
- int t, i, status;
- struct prentry tentry;
- struct entry *u;
-
- t = time(0);
- fprintf(stderr, "Doing users: %s", ctime(&t));
-
-## range of u is users
-## retrieve (login = u.#login, uid = u.#uid, id = u.users_id)
-## where u.#uid > 0 and (u.#status = 1 or u.#status = 2) {
- lowercase(strtrim(login));
-
- if (uid==ANONYMOUSID)
- status = PRIDEXIST;
- else {
- bzero(&tentry, sizeof(tentry));
- strcpy(tentry.name, login);
- tentry.id = htonl(uid);
- tentry.owner = htonl(SYSADMINID);
- tentry.creator = htonl(SYSADMINID);
- tentry.flags = htonl(PRQUOTA);
- tentry.ngroups = tentry.nusers = htonl(20);
- if (uid > ntohl(cheader.maxID))
- cheader.maxID = tentry.id;
- usercount++;
-
- i = IDHash(uid);
- tentry.nextID = cheader.idHash[i];
- cheader.idHash[i] = htonl(pos);
-
- i = NameHash(tentry.name);
- tentry.nextName = cheader.nameHash[i];
- cheader.nameHash[i] = htonl(pos);
-
- pr_Write(0, 0, pos, &tentry, sizeof(tentry));
-
- u = (struct entry *)malloc(sizeof(struct entry));
- u->id = uid;
- u->pos = pos;
- u->members = 0;
-
- pos += ENTRYSIZE;
- status = 0;
- }
-
- if (status)
- fprintf(stderr, "Error adding user %s uid %d: %s\n",
- login, uid, error_message(status));
- else
- hash_store(users, id, u);
-## }
-##}
-
-
-
-do_groups()
-##{
- long status;
- struct prentry gentry, uentry;
- struct entry *u, *g;
- struct bucket **p, *b;
- struct member *m;
- char namebuf[41];
- int aid, t, i;
-## char name[33];
-## int gid, id, lid, hide;
-
- t = time(0);
- fprintf(stderr, "Doing groups: %s", ctime(&t));
-
-## range of l is list
-## range of m is imembers
-
- /* get lock records */
-## retrieve (name = l.modtime) where l.list_id = 0
-## retrieve (name = users.modtime) where users.users_id = 0
-## retrieve (name = l.#name, gid = l.#gid, lid = l.list_id, hide = l.hidden)
-## where l.group != 0 and l.active != 0 and l.#gid > 0 {
- lowercase(strtrim(name));
- sprintf(namebuf, "system:%s", name);
- aid = -gid;
-
- if (aid==ANYUSERID || aid==AUTHUSERID || aid==SYSADMINID)
- status = PRIDEXIST;
- else {
- bzero(&gentry, sizeof(gentry));
- strcpy(gentry.name, namebuf);
- gentry.id = htonl(aid);
- gentry.owner = htonl(SYSADMINID);
- gentry.creator = htonl(SYSADMINID);
- if (hide)
- gentry.flags = htonl(PRGRP|PRACCESS|PRP_STATUS_ANY);
- else
- gentry.flags = htonl(PRGRP);
- if (aid < ntohl(cheader.maxGroup))
- cheader.maxGroup = gentry.id;
- groupcount++;
-
- i = IDHash(aid);
- gentry.nextID = cheader.idHash[i];
- cheader.idHash[i] = htonl(pos);
-
- i = NameHash(gentry.name);
- gentry.nextName = cheader.nameHash[i];
- cheader.nameHash[i] = htonl(pos);
-
- pr_Write(0, 0, pos, &gentry, sizeof(gentry));
- AddToOwnerChain(0, aid, SYSADMINID);
-
- g = (struct entry *)malloc(sizeof(struct entry));
- g->id = aid;
- g->pos = pos;
- g->members = 0;
-
- pos += ENTRYSIZE;
- status = 0;
- }
- if (status)
- fprintf(stderr, "Error adding group %s id %d: %s\n",
- namebuf, aid, error_message(status));
- if (status==0 || (status==PRIDEXIST && aid==SYSADMINID))
- hash_store(groups, lid, g);
-
-## }
-
- cheader.groupcount = htonl(groupcount);
- cheader.usercount = htonl(usercount);
- cheader.eofPtr = htonl(pos);
- pr_Write(0, 0, 0, &cheader, sizeof(cheader));
-
- t = time(0);
- fprintf(stderr, "Doing members: %s", ctime(&t));
-
-## retrieve (lid = m.list_id, id = m.member_id)
-## where m.member_type = "USER" {
- if ((u = (struct entry *)hash_lookup(users, id)) &&
- (g = (struct entry *)hash_lookup(groups, lid))) {
- m = (struct member *)malloc(sizeof(struct member));
- m->user = u;
- m->group = g;
- m->unext = u->members;
- m->gnext = g->members;
- u->members = g->members = m;
- }
-## }
-
- for (p = &(users->data[users->size - 1]); p >= users->data; p--) {
- for (b = *p; b; b = b->next) {
- if ((u = (struct entry *)b->data)->members == 0)
- continue;
- pr_Read(0, 0, u->pos, &uentry, sizeof(uentry));
- for (i=0, m=u->members; m && i<PRSIZE; m=m->unext, i++)
- uentry.entries[i] = htonl(m->group->id);
- uentry.count = htonl(i);
- pr_Write(0, 0, u->pos, &uentry, sizeof(uentry));
- if (m) {
- pr_ReadEntry(0, 0, u->pos, &uentry);
- while (m) {
- AddToEntry(0, &uentry, u->pos, m->group->id);
- m = m->unext;
- }
- }
- }
- }
- for (p = &(groups->data[groups->size - 1]); p >= groups->data; p--) {
- for (b = *p; b; b = b->next) {
- if ((g = (struct entry *)b->data)->members == 0)
- continue;
- pr_Read(0, 0, g->pos, &gentry, sizeof(gentry));
- for (i=0, m=g->members; m && i<PRSIZE; m=m->gnext, i++)
- gentry.entries[i] = htonl(m->user->id);
- gentry.count = htonl(i);
- pr_Write(0, 0, g->pos, &gentry, sizeof(gentry));
- if (m) {
- pr_ReadEntry(0, 0, g->pos, &gentry);
- while (m) {
- AddToEntry(0, &gentry, g->pos, m->user->id);
- m = m->gnext;
- }
- }
- }
- }
-
- t = time(0);
- fprintf(stderr, "Done: %s", ctime(&t));
-
-##}
-
-
-/*
- * ingerr: (supposedly) called when Ingres indicates an error.
- * I have not yet been able to get this to work to intercept a
- * database open error.
- */
-#define INGRES_DEADLOCK 4700
-
-static int ingerr(num)
- int *num;
-{
- char buf[256];
- int ingres_errno;
-
- switch (*num) {
- case INGRES_DEADLOCK:
- ingres_errno = MR_DEADLOCK;
- break;
- default:
- ingres_errno = MR_INGRES_ERR;
- }
- com_err(whoami, MR_INGRES_ERR, " code %d\n", *num);
- exit(ingres_errno);
-}
+++ /dev/null
-/* $Header$
- *
- *
- * (c) Copyright 1989 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- */
-
-#include <mit-copyright.h>
-#include <stdio.h>
-#include <sys/file.h>
-
-#include <rx/xdr.h>
-#include "ptint.h"
-#include "ptserver.h"
-#include "pterror.h"
-
-#include <moira.h>
-#include <moira_site.h>
-#include <ctype.h>
-
-#define min(x,y) ((x) < (y) ? (x) : (y))
-char *whoami = "sync";
-
-char *malloc(), *strsave();
-int dbase_fd;
-
-int ucount = 0;
-int gcount = 0;
-int mcount = 0;
-
-struct hash *users;
-struct hash *groups;
-
-struct member {
- struct entry *user;
- struct entry *group;
- struct member *unext;
- struct member *gnext;
-};
-struct entry {
- long id;
- struct member *members;
-};
-
-main(argc, argv)
-int argc;
-char **argv;
-{
-## char db[9];
-
- int status;
- int ingerr();
- long t;
-
- strcpy(db, "sms");
-
- if (!strcmp(argv[1], "-db")) {
- strncpy(db, argv[2], sizeof(db)-1);
- argc -= 2;
- argv += 2;
- }
- if (argc != 2) {
- fprintf(stderr, "usage: %s [-db sms] outfile\n", whoami);
- exit(MR_ARGS);
- }
-
- dbase_fd = open(argv[1], O_RDWR|O_CREAT|O_TRUNC, 0660);
- if (dbase_fd < 0) {
- perror("opening file %s", argv[1]);
- exit(1);
- }
- IIseterr(ingerr);
-
- initialize_sms_error_table();
- initialize_pt_error_table();
- Initdb(); /* Initialize prdb */
-
- users = create_hash(10000);
- groups = create_hash(15000);
-
-## ingres db
-## set lockmode session where level = table
-## begin transaction
-
- do_passwd();
- do_groups();
-
- t = time(0);
- fprintf(stderr, "Done (%d users, %d groups, %d members): %s",
- ucount, gcount, mcount, ctime(&t));
-
-## end transaction
-## exit
-
- exit(MR_SUCCESS);
-}
-
-
-do_passwd()
-##{
-## char login[9];
-## int uid, id, status;
- long t;
- struct prentry tentry;
- struct entry *u;
-
- t = time(0);
- fprintf(stderr, "Doing users: %s", ctime(&t));
-
-## range of u is users
-## retrieve (login = u.#login, uid = u.#uid, id = u.users_id)
-## where u.#uid > 0 and (u.#status = 1 or u.#status = 2) {
- lowercase(strtrim(login));
-
- if (FindByID(0,uid))
- status = PRIDEXIST;
- else
- status = CreateEntry(0,login,&uid,1/*idflag*/,0/*gflag*/,
- SYSADMINID/*oid*/, SYSADMINID/*cid*/);
- if (status)
- fprintf(stderr, "Error adding user %s uid %d: %s\n",
- login, uid, error_message(status));
- else {
- u = (struct entry *)malloc(sizeof(struct entry));
- u->id = uid;
- u->members = 0;
- hash_store(users, id, u);
- ucount++;
- }
-## }
-##}
-
-
-
-do_groups()
-##{
- long status, pos;
- struct prentry gentry, uentry;
- struct entry *u, *g;
- struct member *m;
- struct bucket **p, *b;
- char namebuf[40];
- long aid, t;
-## char name[33];
-## int gid, id, lid, hide;
-
- t = time(0);
- fprintf(stderr, "Doing groups: %s", ctime(&t));
-
-## range of l is list
-## range of m is imembers
- /* get lock records */
-## retrieve (name = l.modtime) where l.list_id = 0
-## retrieve (name = users.modtime) where users.users_id = 0
-
-## retrieve (name = l.#name, gid = l.#gid, lid = l.list_id, hide = l.hidden)
-## where l.group != 0 and l.active != 0 and l.#gid > 0 {
- lowercase(strtrim(name));
- sprintf(namebuf, "system:%s", name);
- aid = -gid;
-
- if (FindByID(0, aid))
- status = PRIDEXIST;
- else
- status = CreateEntry(0,namebuf,&aid,1/*idflag*/,PRGRP/*gflag*/,
- SYSADMINID/*oid*/, SYSADMINID/*cid*/);
- if (status)
- fprintf(stderr, "Error adding group %s id %d: %s\n",
- namebuf, aid, error_message(status));
-
- if ((status==0 || status==PRIDEXIST) &&
- (aid!=ANYUSERID && aid!=AUTHUSERID)) {
-
- g = (struct entry *)malloc(sizeof(struct entry));
- g->id = aid;
- g->members = 0;
- hash_store(groups, lid, g);
- gcount++;
-
- /* Set modes on hidden lists (S----) */
- if (hide) {
- pos = FindByID(0, aid);
- status = pr_Read(0, 0, pos, &gentry, sizeof(gentry));
- if (!status) {
- gentry.flags = htonl(PRGRP|PRACCESS|PRP_STATUS_ANY);
- status = pr_Write(0, 0, pos, &gentry, sizeof(gentry));
- }
- if (status)
- fprintf(stderr,
- "Error setting flags on group %s: %s\n",
- namebuf, error_message(status));
- }
- }
-## }
-
- t = time(0);
- fprintf(stderr, "Doing members: %s", ctime(&t));
-
-## retrieve (lid = m.list_id, id = m.member_id)
-## where m.member_type = "USER" {
- if ((u = (struct entry *)hash_lookup(users, id)) &&
- (g = (struct entry *)hash_lookup(groups, lid))) {
- m = (struct member *)malloc(sizeof(struct member));
- m->user = u;
- m->group = g;
- m->unext = u->members;
- m->gnext = g->members;
- u->members = g->members = m;
- mcount++;
- }
-## }
-
- /* Do the bulk of the membership quickly.
- * Add PRSIZE members into the user/group record. After that, we
- * require the use of continuation records, but we assume this is
- * few enough that we do this the slow way (AddToEntry).
- */
- for (p = &(users->data[users->size - 1]); p >= users->data; p--) {
- for (b = *p; b; b = b->next) {
- if ((u = (struct entry *)b->data)->members == 0)
- continue;
- pos = FindByID(0, u->id);
- pr_Read(0, 0, pos, &uentry, sizeof(uentry));
- for (t=0, m=u->members; m && t<PRSIZE; m=m->unext, t++)
- uentry.entries[t] = htonl(m->group->id);
- uentry.count = htonl(t);
- pr_Write(0, 0, pos, &uentry, sizeof(uentry));
- if (m) {
- pr_ReadEntry(0, 0, pos, &uentry);
- while (m) {
- AddToEntry(0, &uentry, pos, m->group->id);
- m = m->unext;
- }
- }
- }
- }
- for (p = &(groups->data[groups->size - 1]); p >= groups->data; p--) {
- for (b = *p; b; b = b->next) {
- if ((g = (struct entry *)b->data)->members == 0)
- continue;
- pos = FindByID(0, g->id);
- pr_Read(0, 0, pos, &gentry, sizeof(gentry));
- for (t=0, m=g->members; m && t<PRSIZE; m=m->gnext, t++)
- gentry.entries[t] = htonl(m->user->id);
- gentry.count = htonl(t);
- pr_Write(0, 0, pos, &gentry, sizeof(gentry));
- if (m) {
- pr_ReadEntry(0, 0, pos, &gentry);
- while (m) {
- AddToEntry(0, &gentry, pos, m->user->id);
- m = m->gnext;
- }
- }
- }
- }
-##}
-
-#if 0
-do_kerberos()
-##{
- long status, pos;
- struct prentry gentry, uentry;
- struct entry *u, *g;
- struct member *m;
- struct bucket **p, *b;
- char namebuf[40];
- int aid, t;
-## char name[129];
-## int gid, id, lid, hide;
-
- t = time(0);
- fprintf(stderr, "Doing kerberos members: %s", ctime(&t));
-
-## range of s is strings
-## range of m is imembers
- /* get lock records */
-## retrieve (name = list.modtime) where list.list_id = 0
-## retrieve (name = s.modtime) where s.string_id = 0
-
-## retrieve (lid = m.list_id, id = m.member_id)
-## where m.member_type = "KERBEROS" {
- xxx;
- {
- }
-## }
-
-##}
-#endif
-
-
-/*
- * ingerr: (supposedly) called when Ingres indicates an error.
- * I have not yet been able to get this to work to intercept a
- * database open error.
- */
-#define INGRES_DEADLOCK 4700
-
-static int ingerr(num)
- int *num;
-{
- char buf[256];
- int ingres_errno;
-
- switch (*num) {
- case INGRES_DEADLOCK:
- ingres_errno = MR_DEADLOCK;
- break;
- default:
- ingres_errno = MR_INGRES_ERR;
- }
- com_err(whoami, MR_INGRES_ERR, " code %d\n", *num);
- exit(ingres_errno);
-}
+++ /dev/null
-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- *
- * This program dumps the SMS database to a series of output files
- * which can be later read back into SMS in the event of a crash.
- *
- */
-
-#ifndef lint
-static char *rcsid_dump_db_c = "$Header$";
-#endif lint
-
-#include <stdio.h>
-#include <sys/file.h>
-#include <ctype.h>
-#include <mit-copyright.h>
-#include "dump_db.h"
-
-/* putc without the line buffer hair */
-
-#define putc1(x, p) (--(p)->_cnt >= 0 ?\
- (int)(*(unsigned char *)(p)->_ptr++ = (x)) :\
- _flsbuf((unsigned char)(x), p))
-
-FILE *open_file();
-
-char act[128];
-
-main(argc, argv)
- int argc;
- char **argv;
-{
- char *prefix;
- register int i;
-
- if (argc != 2) {
- fprintf(stderr, "Usage: smsbackup prefix\n");
- exit(1);
- }
- prefix = argv[1];
-
- bzero(act, 128);
-
- act[SEP_CHAR]=1;
- act['\\']=1;
- act[127]=2;
- for (i=0; i<' '; i++) act[i]=2;
-
-## ingres sms
-## set lockmode session where level = table
-## begin transaction
-
- do_backups(prefix);
-
-## end transaction
-## exit
- exit(0);
-}
-
-dump_int(f, n)
- FILE *f;
- int n;
-{
- char buf[1024];
- (void) sprintf(buf, "%d", n);
- dump_str(f, buf);
-}
-
-wpunt()
-{
- punt("can't write backup file");
-}
-
-dump_str(f, str)
- register FILE *f;
- register char *str;
-{
- char *strtrim();
- register char *ibp = strtrim(str);
- register int c; /* PCC doesn't put chars in registers.. */
- for (; c = *ibp; ibp++) {
- c = toascii(c); /* punt 8th bit */
- switch(act[c]) {
- register int t;
- case 1:
- if (putc1('\\', f) < 0) wpunt();
- /* fall thru.. */
- case 0:
- if (putc1(c, f) < 0) wpunt();
-
- break;
- case 2:
- if (putc1('\\', f) < 0) wpunt();
- t = ((c>>6)&7) + '0';
- if (putc1(t,f) < 0) wpunt();
- t = ((c>>3)&7) + '0';
- if (putc1(t,f) < 0) wpunt();
- t = (c&7) + '0';
- if (putc1(t,f) < 0) wpunt();
- break;
-
- default:
- punt("Can't get here");
- }
- }
-}
-
-safe_close(stream)
- FILE *stream;
-{
- if (fflush(stream) == EOF)
- punt("Unable to fflush");
- if (fsync(fileno(stream)) != 0)
- punt("Unable to fsync");
- (void) fclose(stream);
-}
-
-FILE *open_file(prefix, suffix)
- char *prefix, *suffix;
-{
- char name[BUFSIZ];
- int fd;
- FILE *f;
-
- (void) strcpy(name, prefix);
- (void) strcat(name, suffix);
-
- fd = open(name, O_CREAT|O_WRONLY|O_EXCL, 0644);
- if (fd < 0) {
- punt(name);
- }
- f = fdopen(fd, "w");
- if (f == NULL) {
- fprintf(stderr, "fdopen of ");
- punt(name);
- }
- fprintf(stderr, "Working on %s\n", name);
- return(f);
-}
-
-
-/*
- * Trim whitespace off both ends of a string.
- */
-char *strtrim(save)
- register char *save;
-{
- register char *t, *s;
-
- s = save;
- while (isspace(*s)) s++;
- /* skip to end of string */
- if (*s == '\0') {
- *save = '\0';
- return(save);
- }
-
- for (t = s; *t; t++) continue;
- while (t > s) {
- --t;
- if (!isspace(*t)) {
- t++;
- break;
- }
- }
- *t = '\0';
- return s;
-}
+++ /dev/null
-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- *
- */
-
-#ifndef lint
-static char *rcsid_dumprest_qc = "$Header$";
-#endif lint
-
-#include <stdio.h>
-#include <sys/file.h>
-#include <strings.h>
-#include <mit-copyright.h>
-
-punt(msg)
- char *msg;
-{
- perror(msg);
-## exit
- exit(1);
-}
-
-
-
-
-/*
- * Local Variables:
- * mode: c
- * c-indent-level: 4
- * c-continued-statement-offset: 4
- * c-brace-offset: -4
- * c-argdecl-indent: 4
- * c-label-offset: -4
- * End:
- */
+++ /dev/null
-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- *
- */
-
-#ifndef lint
-static char *rcsid_rest_db_qc = "$Header$";
-#endif lint
-
-#include <sys/file.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <mit-copyright.h>
-#include "dump_db.h"
-
-
-/*ARGSUSED*/
-main(argc, argv)
- int argc;
- char **argv;
-{
- char buf[BUFSIZ];
- char *prefix;
-
- if (!yes_or_no("Do you *REALLY* want to wipe the SMS database?")) {
- printf("I didn't think so\n");
- exit(1);
- }
- if (!yes_or_no("Have you initialized an empty database named smstemp?")) {
- printf("You should have\n");
- exit(1);
- }
-
- printf("Opening database: ");
- (void) fflush(stdout);
-## ingres smstemp
-
- printf(" done\n");
-
- printf("Prefix of backup to restore: ");
- (void) fflush(stdout);
- if (gets(buf) == NULL) {
- return 1;
- }
- prefix = buf;
-
- if (!yes_or_no("Are you SURE?")) {
- printf("I didn't think so\n");
- exit(1);
- }
- do_restores(prefix);
- printf("Restore complete\n");
-## exit
- exit(0);
- /*NOTREACHED*/
-}
-
-yes_or_no(prompt)
- char *prompt;
-{
- char buf[BUFSIZ];
- int ret;
-
- int tt = open("/dev/tty", O_RDWR, 0);
- FILE *o, *i;
-
- register char *cp;
-
- if (tt < 0) return 0;
-
- (void) fflush(stdout);
- (void) fflush(stderr);
- o = fdopen(dup(tt), "w");
- i = fdopen(dup(tt), "r");
- (void) close(tt);
-
- for (;;) {
- fprintf(o, "%s (yes or no): ", prompt);
- (void) fflush(o);
- if (fgets(buf, BUFSIZ, i) == NULL) goto err;
- for (cp = buf; *cp; cp++) {
- if (isupper(*cp)) *cp=tolower(*cp);
- }
- if (strcmp(buf, "yes\n") == 0) {
- ret = 1; goto out;
- }
- if (strcmp(buf, "no\n") == 0) {
- ret = 0; goto out;
- }
- }
-
-err:
- ret = 0;
-
-out:
- (void) fclose(o);
- (void) fclose(i);
- return ret;
-}
-
-int parse_int(f)
- register FILE *f;
-{
- register int c;
- register int val = 0;
- register int sign = 1;
- while ((c = getc(f)) != EOF && c != SEP_CHAR && c != '\n') {
- if (c == '-') sign = -1;
- else if (isdigit(c)) {
- val *= 10;
- val += (c - '0');
- } else (void) fprintf(stderr,"non-digit in numeric field\n");
- }
- (void) ungetc(c, f);
- return(val * sign);
-}
-
-void parse_str(f, buf, len)
- register FILE *f;
- register char *buf;
- register int len; /* incl trailing NULL */
-{
- register int c;
-
- while ((c = getc(f)) != EOF && c != SEP_CHAR && c != '\n' && len > 0) {
- if (c == '\\') {
- c = getc(f);
- if (isdigit(c)) {
- /* Expect three-digit octal number.. */
- register int c1, c2;
- c1 = getc(f);
- c2 = getc(f);
- if (!isdigit(c1) || !isdigit(c2))
- punt("Broken \\###");
- /* Convert to ASCII code: */
- *buf++ = (((c-'0')<<6) + ((c1-'0')<<3) + c2-'0');
- } else if (c == '\\' || c == SEP_CHAR) {
- *buf++ = c;
- --len;
- } else punt ("Broken '\\'");
- } else {
- *buf++ = c;
- --len;
- }
- }
- if (c == EOF)
- return;
-
- if (c != EOF && c != SEP_CHAR && c != '\n') {
- fprintf(stderr, "Field too wide, truncated\n");
- while ((c = getc(f)) != EOF && c != SEP_CHAR && c != '\n');
- (void) ungetc(c, f);
- } else {
- *buf++ = 0;
- (void) ungetc(c, f);
- }
-}
-
-void parse_sep(f)
- FILE *f;
-{
- if (getc(f) != SEP_CHAR) punt("Expected Separator");
-}
-void parse_nl(f)
- FILE *f;
-{
- if (getc(f) != '\n') punt("Expected newline");
-}
-
-
-FILE *open_file(prefix, suffix)
- char *prefix, *suffix;
-{
- char name[BUFSIZ];
- int fd;
- FILE *f;
-
- (void) strcpy(name, prefix);
- (void) strcat(name, suffix);
-
- fd = open(name, O_RDONLY, 0);
- if (fd < 0) {
- punt(name);
- }
- f = fdopen(fd, "r");
- if (f == NULL) {
- fprintf(stderr, "fdopen of ");
- punt(name);
- }
- fprintf(stderr, "Working on %s\n", name);
- return(f);
-}
+++ /dev/null
-# Makefile for SMS 2.0 clients.
-#
-# $Source$
-# $Header$
-# $Author$
-#
-# (c) Copyright 1988 by the Massachusetts Institute of Technology.
-# For copying and distribution information, please see the file
-# <mit-copyright.h>.
-
-DESTDIR=
-
-SUBDIRS= mailmaint passwd moira userreg blanche mrcheck
-
-all:
- for i in ${SUBDIRS}; do \
- (cd $$i; make ${MFLAGS} all); done
-
-install:
- for i in ${SUBDIRS}; do \
- (cd $$i; make ${MFLAGS} DESTDIR=${DESTDIR} install); done
-
-clean:
- rm -f *~ *.bak
- for i in ${SUBDIRS}; do \
- (cd $$i; make ${MFLAGS} clean); done
-
-depend:
- for i in ${SUBDIRS}; do \
- (cd $$i; make ${MFLAGS} depend); done
+++ /dev/null
-# Makefile for Moira clients blanche
-#
-# MIT Project Athena
-#
-# $Source$
-# $Header$
-# $Author$
-#
-# (c) Copyright 1988 by the Massachusetts Institute of Technology.
-# For copying and distribution information, please see the file
-# <mit-copyright.h>.
-#
-
-DESTDIR=
-DEFINES = -O
-CFLAGS = -I../../include ${DEFINES}
-BINDIR = ${DESTDIR}/bin
-
-MOIRALIB = -L../../lib -lmoira -lgdb -lcom_err -lkrb -ldes -lhesiod
-
-PROGS= blanche
-
-all: ${PROGS}
-
-blanche: blanche.o
- rm -f blanche
- cc -o blanche blanche.o ${MOIRALIB}
-
-lint:
- lint *.c
-
-clean:
- rm -f *.o *~
- rm -f ${PROGS}
-
-install: ${PROGS}
- install -c -s blanche ${DESTDIR}/usr/athena/blanche
-
-depend:
- mkdep ${CFLAGS} blanche.c
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-
-blanche.o: blanche.c ../../include/mit-copyright.h /usr/include/stdio.h
-blanche.o: /usr/include/ctype.h ../../include/Moira.h /usr/include/Moira_et.h
-blanche.o: ../../include/Moira_app.h
+++ /dev/null
-#
-# $Source$
-# $Header$
-#
-# (c) Copyright 1988 by the Massachusetts Institute of Technology.
-# For copying and distribution information, please see the file
-# <mit-copyright.h>.
-
-# Makefile for Moira client mailmaint
-#
-#
-DESTDIR=
-CFLAGS = -I../../include -O
-CONFDIR = ${DESTDIR}/usr/athena
-BINDIR = ${DESTDIR}/bin
-
-MOIRALIB = -L../../lib -lmoira -lgdb -lcom_err
-
-SRCS = mailmaint.c
-
-OBJECTS = mailmaint.o
-
-all: mailmaint
-
-mailmaint: ${OBJECTS}
- cc ${CFLAGS} -o mailmaint ${OBJECTS} ${MOIRALIB} \
- -lcurses -ltermcap -lkrb -ldes -lhesiod
-
-mailmaint.o: mailmaint.c
- cc -c ${CFLAGS} mailmaint.c
-
-lint:
- lint -I../../include ${SRCS}
-
-clean:
- rm -f *.o *~ core \#*
- rm -f mailmaint
-
-install: ${PROGS}
- install -c -s mailmaint ${DESTDIR}/usr/athena/mailmaint
-
-depend:
- mkdep ${CFLAGS} ${SRCS}
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-
-mailmaint.o: mailmaint.c /usr/include/stdio.h /usr/include/pwd.h
-mailmaint.o: /usr/include/signal.h /usr/include/strings.h
-mailmaint.o: /usr/include/curses.h /usr/include/sgtty.h
-mailmaint.o: /usr/include/sys/ioctl.h /usr/include/sys/ttychars.h
-mailmaint.o: /usr/include/sys/ttydev.h /usr/include/sys/types.h
-mailmaint.o: /usr/include/varargs.h ../../include/com_err.h
-mailmaint.o: /usr/include/ctype.h ../../include/moira.h ../../include/mr_et.h
-mailmaint.o: ../../include/moira_site.h ../../include/mit-copyright.h
--- /dev/null
+22 Insensitive text fields don't gray out
+
+24 Have delete* track down references
+
+26 When adding quota, if you click on OK while locker field is
+active, get a quota in callback error
+
+28 If you invoke the DCM (setting "are you sure" to true), then try
+again, that boolean is initialized incorrectly.
+
+31. put an initial member on lists
+
+32. XFILESEARCHPATH problems
+
+33. Coredumps on modifications
+
+34. problems deleting machine
+
+35. Looking up Karen Schiller by name gets bad signature, by login
+gets good signature
+
+
+++ /dev/null
-# $Header$
-
-CFLAGS = -I/mit/motif/include -g -D_NO_PROTO
-LIBS = -L/mit/motif/$(MACHINE)lib -lXm -lXt -lX11 \
- -lmoira -lmrgdb -lhesiod -lkrb -ldes -lcom_err
-
-OBJS = form_data.o form_setup.o menu_data.o main.o formup.o \
- queries.o help.o stubs.o display.o
-
-mmoira: $(OBJS)
- $(CC) -o mmoira $(OBJS) $(LIBS)
-
-form_data.c: forms.txt forms.awk
- awk -f forms.awk forms.txt > form_data.c
-
-menu_data.c: menus.txt menus.awk
- awk -f menus.awk menus.txt > menu_data.c
-
-clean:
- rm -f *.o mmoira form_data.c menu_data.c
+++ /dev/null
-/* $Header$
- */
-
-#include <stdio.h>
-#include <moira.h>
-#include <moira_site.h>
-#include <sys/types.h>
-#include <netdb.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <Xm/Xm.h>
-#include "mmoira.h"
-
-
-/******* temporary ********/
-char *atot(s) char *s; { return s; }
-
-
-
-int DisplayCallback(argc, info, form)
-int argc;
-char **info;
-EntryForm *form;
-{
- char buf[1024], name[128];
- char *MOD_FORMAT = "Modified by %s at %s with %s\n";
- int i;
-
- switch (form->menu->operation) {
- case MM_SHOW_USER:
- sprintf(name, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]);
- sprintf(buf, "Login name: %-20s Full name: %s\n", info[U_NAME], name);
- add_to_display(buf);
- sprintf(buf, "User id: %-23s Login shell %-10s Class: %s\n",
- info[U_UID], info[U_SHELL], info[U_CLASS]);
- add_to_display(buf);
- sprintf(buf, "Account is: %-20s Encrypted MIT ID number: %s\n",
- user_states[atoi(info[U_STATE])], info[U_MITID]);
- add_to_display(buf);
- sprintf(buf, MOD_FORMAT,
- info[U_MODBY], info[U_MODTIME],info[U_MODWITH]);
- add_to_display(buf);
- break;
- case MM_SHOW_FINGER:
- sprintf(buf, "Nickname: %-29s Department: %s\n", info[F_NICKNAME],
- info[F_MIT_DEPT]);
- add_to_display(buf);
- sprintf(buf, "finger %s =>\n", info[F_NAME]);
- add_to_display(buf);
- sprintf(buf, "Login name: %-27s In real life: %s\n", info[F_NAME],
- info[F_FULLNAME]);
- add_to_display(buf);
- sprintf(buf, "Home: %-33s Home phone: %s\n", info[F_HOME_ADDR],
- info[F_HOME_PHONE]);
- add_to_display(buf);
- sprintf(buf, "Office: %-31s Office phone: %s\n", info[F_OFFICE_ADDR],
- info[F_OFFICE_PHONE]);
- add_to_display(buf);
- break;
- case MM_SHOW_POBOX:
- sprintf(buf, "Address: %-10s Box: %-35s Type: %s\n", info[PO_NAME],
- info[PO_BOX], info[PO_TYPE]);
- add_to_display(buf);
- sprintf(buf, MOD_FORMAT, info[4], info[3], info[5]);
- add_to_display(buf);
- break;
- case MM_SHOW_KRBMAP:
- sprintf(buf, "User: %-9s Principal: %s\n",
- info[KMAP_USER], info[KMAP_PRINCIPAL]);
- add_to_display(buf);
- break;
- case MM_SHOW_FILSYS:
- case MM_SHOW_FSGROUP:
- if (!strcmp(info[FS_TYPE], "FSGROUP")) {
- int stat;
-/* struct qelem *elem = NULL; */
-
- sprintf(buf,"%20s Filesystem Group: %s\n", " ", info[FS_NAME]);
- add_to_display(buf);
-
- sprintf(buf,"Comments: %s\n",info[FS_COMMENTS]);
- add_to_display(buf);
- sprintf(buf, MOD_FORMAT, info[FS_MODBY], info[FS_MODTIME],
- info[FS_MODWITH]);
- add_to_display(buf);
- add_to_display("Containing the filesystems (in order):");
-/*
- if ((stat = do_moira_query("get_fsgroup_members", 1, &info[FS_NAME],
- StoreInfo, (char *)&elem)) != 0) {
- if (stat == MR_NO_MATCH)
- add_to_display(" [no members]");
- else
- com_err(program_name, stat, NULL);
- } else {
- fsgCount = 1;
- Loop(QueueTop(elem), (void *) PrintFSGMembers);
- FreeQueue(elem);
- }
-*/
- } else {
- sprintf(buf,"%20s Filesystem: %s\n", " ", info[FS_NAME]);
- add_to_display(buf);
- sprintf(buf,"Type: %-40s Machine: %-15s\n",
- info[FS_TYPE], info[FS_MACHINE]);
- add_to_display(buf);
- sprintf(buf,"Default Access: %-2s Packname: %-17s Mountpoint %s \n",
- info[FS_ACCESS], info[FS_PACK], info[FS_M_POINT]);
- add_to_display(buf);
- sprintf(buf,"Comments: %s\n",info[FS_COMMENTS]);
- add_to_display(buf);
- sprintf(buf, "User Ownership: %-30s Group Ownership: %s\n",
- info[FS_OWNER], info[FS_OWNERS]);
- add_to_display(buf);
- sprintf(buf, "Auto Create: %-34s Locker Type: %s\n",
- atoi(info[FS_CREATE]) ? "ON" : "OFF",
- info[FS_L_TYPE]);
- add_to_display(buf);
- sprintf(buf, MOD_FORMAT, info[FS_MODBY], info[FS_MODTIME],
- info[FS_MODWITH]);
- add_to_display(buf);
- }
- break;
- case MM_SHOW_NFS:
- sprintf(buf,"Machine: %-20s Directory: %-15s Device: %s\n",
- info[NFS_NAME], info[NFS_DIR], info[NFS_DEVICE]);
- add_to_display(buf);
-
- sprintf(buf, "Status: %s\n",
- format_filesys_type(atoi(info[NFS_STATUS])));
- add_to_display(buf);
- sprintf(buf, "Quota Allocated: %-17s Size: %s\n",
- info[NFS_ALLOC], info[NFS_SIZE]);
- add_to_display(buf);
- sprintf(buf, MOD_FORMAT, info[NFS_MODBY], info[NFS_MODTIME],
- info[NFS_MODWITH]);
- add_to_display(buf);
- break;
- case MM_SHOW_QUOTA:
- if (!strcmp(info[Q_TYPE], "ANY"))
- sprintf(buf, "Filesystem: %s\n", info[Q_FILESYS]);
- else
- sprintf(buf, "Filesystem: %-45s %s %s\n", info[Q_FILESYS],
- info[Q_TYPE], info[Q_NAME]);
- add_to_display(buf);
- sprintf(buf, "Machine: %-20s Directory: %-15s\n",
- info[Q_MACHINE], info[Q_DIRECTORY]);
- add_to_display(buf);
- sprintf(buf, "Quota: %s\n", info[Q_QUOTA]);
- add_to_display(buf);
- sprintf(buf, MOD_FORMAT, info[Q_MODBY], info[Q_MODTIME], info[Q_MODWITH]);
- add_to_display(buf);
- break;
- case MM_SHOW_LIST:
- (void) sprintf(buf, "%20sList: %s\n", "", info[L_NAME]);
- add_to_display(buf);
- (void) sprintf(buf, "Description: %s\n", info[L_DESC]);
- add_to_display(buf);
- if ( atoi(info[L_MAILLIST]))
- add_to_display("This list is a mailing list.\n");
- else
- add_to_display("This list is NOT a mailing list.\n");
- if (atoi(info[L_GROUP])) {
- (void) sprintf(buf,"This list is a Group and its ID number is %s\n",
- info[L_GID]);
- add_to_display(buf);
- } else
- add_to_display("This list is NOT a Group.\n");
- if (strcmp(info[L_ACE_TYPE],"NONE") == 0)
- add_to_display("This list has no Administrator, how strange?!\n");
- else {
- sprintf(buf, "The Administrator of this list is the %s: %s\n",
- info[L_ACE_TYPE], info[L_ACE_NAME]);
- add_to_display(buf);
- }
- (void) sprintf(buf, "This list is: %s, %s, and %s\n",
- atoi(info[L_ACTIVE]) ? "active" : "inactive",
- atoi(info[L_PUBLIC]) ? "public" : "private",
- atoi(info[L_HIDDEN]) ? "hidden" : "visible");
- add_to_display(buf);
- sprintf(buf, MOD_FORMAT, info[L_MODBY], info[L_MODTIME], info[L_MODWITH]);
- add_to_display(buf);
- break;
- case MM_SHOW_MACH:
- sprintf(buf, "Machine: %-30s Type: %s\n", info[M_NAME], info[M_TYPE]);
- add_to_display(buf);
- sprintf(buf, MOD_FORMAT, info[M_MODBY], info[M_MODTIME], info[M_MODWITH]);
- add_to_display(buf);
- break;
- case MM_SHOW_CLUSTER:
- sprintf(buf, "Cluster: %s\n", info[C_NAME]);
- add_to_display(buf);
- sprintf(buf, "Description: %s\n", info[C_DESCRIPT]);
- add_to_display(buf);
- sprintf(buf, "Location: %s\n", info[C_LOCATION]);
- add_to_display(buf);
- sprintf(buf, MOD_FORMAT, info[C_MODBY], info[C_MODTIME], info[C_MODWITH]);
- add_to_display(buf);
- break;
- case MM_SHOW_CLDATA:
- sprintf(buf, "Cluster: %-20s Label: %-15s Data: %s\n",
- info[CD_NAME], info[CD_LABEL], info[CD_DATA]);
- add_to_display(buf);
- break;
- case MM_SHOW_MEMBERS:
- if (argc == 2)
- sprintf(buf, "%-9s %s\n", info[0], info[1]);
- else
- sprintf(buf, "%s\n", info[0]);
- add_to_display(buf);
- break;
- case MM_STATS:
- sprintf(buf, "Table: %-20s Modified: %s\n", info[0], info[5]);
- add_to_display(buf);
- sprintf(buf, " %-8D appends, %-8d updates, %-8d deletes\n",
- info[2], info[3], info[4]);
- add_to_display(buf);
- break;
- case MM_CLIENTS:
- {
- unsigned long host_address;
- struct hostent *host_entry;
-
- host_address = inet_addr(info[1]);
- if (host_address != NULL) {
- host_entry = gethostbyaddr((char *)&host_address, 4, AF_INET);
- if (host_entry != NULL) {
- free(info[1]);
- info[1] = strsave(host_entry->h_name);
- }
- }
- }
- sprintf(buf, "Principal %s on %s (%s)\n", info[0], info[1], info[2]);
- add_to_display(buf);
- sprintf(buf, " Connected at %s, client %s\n", info[3], info[4]);
- add_to_display(buf);
- break;
- case MM_SHOW_VALUE:
- sprintf(buf, "Variable: %-20s Value: %s\n", stringval(form, 0),
- info[0]);
- add_to_display(buf);
- break;
- case MM_SHOW_ALIAS:
- sprintf(buf, "Alias: %-20s Type: %-8s Value: %s\n",
- info[0], info[1], info[2]);
- add_to_display(buf);
- break;
- case MM_SHOW_HOST:
- sprintf(buf, "%s:%s mod by %s on %s with %s\n", info[SH_MACHINE],
- info[SH_SERVICE], info[SH_MODBY], info[SH_MODTIME],
- info[SH_MODWITH]);
- Put_message(buf);
- if (atoi(info[SH_HOSTERROR]))
- sprintf(name, "Error %d: %s", atoi(info[SH_HOSTERROR]),
- info[SH_ERRMSG]);
- else
- strcpy(name, "No error");
- sprintf(buf, " %s/%s/%s/%s/%s\n",
- atoi(info[SH_ENABLE]) ? "Enabled" : "Disabled",
- atoi(info[SH_SUCCESS]) ? "Success" : "Failure",
- atoi(info[SH_INPROGRESS]) ? "InProgress" : "Idle",
- atoi(info[SH_OVERRIDE]) ? "Override" : "Normal", name);
- Put_message(buf);
- Put_message(" Last Try Last Success Value1 Value2 Value3\n");
- strcpy(name, atot(info[SH_LASTTRY]));
- sprintf(buf, " %-20s %-20s %-9d %-9d %s\n", name,
- atot(info[SH_LASTSUCCESS]), atoi(info[SH_VALUE1]),
- atoi(info[SH_VALUE2]), info[SH_VALUE3]);
- Put_message(buf);
- break;
- case MM_SHOW_DQUOTA:
- sprintf(buf, "The default quota is %s Kbytes.\n", info[0]);
- Put_message(buf);
- break;
- case MM_SHOW_DCM:
- if (argc == 2)
- sprintf(buf, "%s:%s\n", info[0], info[1]);
- else
- sprintf(buf, "%s\n", info[0]);
- Put_message(buf);
- break;
- default:
- for (i = 0; i < argc; i++) {
- if (i != 0) add_to_display(", ");
- add_to_display(info[i]);
- }
- add_to_display("\n");
- }
- return(MR_CONT);
-}
-
-
-/* Called with moira data that is to be modified. */
-
-int ModifyCallback(argc, argv, form)
-int argc;
-char **argv;
-EntryForm *form;
-{
- EntryForm *f;
- char *fn;
- int count, i, offset;
-
- count = -1;
- offset = 0;
- switch (form->menu->operation) {
- case MM_MOD_USER:
- fn = "mod_user";
- count = U_MODTIME;
- break;
- case MM_MOD_FINGER:
- fn = "mod_finger";
- count = F_MODTIME - 1;
- offset = 1;
- break;
- case MM_REGISTER:
- if (form->extrastuff)
- form->extrastuff = NULL;
- else
- form->extrastuff = strsave(argv[U_UID]);
- return;
- break;
- case MM_MOD_LIST:
- fn = "mod_list";
- count = L_MODTIME;
- break;
- case MM_MOD_FILSYS:
- fn = "mod_filsys";
- count = FS_MODTIME;
- break;
- }
-
- if (count > 0) {
- f = GetAndClearForm(fn);
- if (f == NULL) {
- display_error("Unknown form in ModifyCallback!\n");
- return;
- }
- f->extrastuff = form->extrastuff;
- f->menu = form->menu;
- for (i = 0; i < count; i++)
- if (f->inputlines[i]->type == FT_BOOLEAN)
- f->inputlines[i]->returnvalue.boolean =
- strcmp(argv[i + offset], "0") ? 1 : 0;
- else
- StoreField(f, i, argv[i + offset]);
- } else {
- display_error("Unknown function in ModifyCallback!\n");
- return;
- }
-}
-
-
-
-/* callback when form is complete to process the data */
-
-MoiraFormComplete(dummy1, form)
-int dummy1;
-EntryForm *form;
-{
- char *qy, *argv[32], buf[256];
- int (*retfunc)(), argc, i;
- EntryForm *f;
-
- retfunc = DisplayCallback;
- argc = -1;
-
- for (i = 0; form->inputlines[i]; i++)
- if (form->inputlines[i]->type == FT_BOOLEAN)
- argv[i] = boolval(form, i) ? "1" : "0";
- else
- argv[i] = stringval(form, i);
-
- switch (form->menu->operation) {
- case MM_SHOW_USER:
- if (*stringval(form, 0)) {
- qy = "get_user_by_login";
- argv[0] = stringval(form, 0);
- argc = 1;
- } else if (*stringval(form, 3)) {
- qy = "get_user_by_uid";
- argv[0] = stringval(form, 3);
- argc = 1;
- } else if (*stringval(form, 4)) {
- qy = "get_user_by_class";
- argv[0] = stringval(form, 4);
- argc = 1;
- } else if (*stringval(form, 1) == 0 &&
- *stringval(form, 2) == 0) {
- DisplayError("Must fill in at least one blank.");
- return;
- } else {
- if (*stringval(form, 1) == 0)
- StoreField(form, 1, "*");
- if (*stringval(form, 2) == 0)
- StoreField(form, 2, "*");
- qy = "get_user_by_name";
- argv[0] = stringval(form, 1);
- argv[1] = stringval(form, 2);
- argc = 2;
- }
- break;
- case MM_ADD_USER:
- qy = "add_user";
- argv[U_STATE][1] = 0;
- if (argv[U_MITID][0] == '"')
- strcpy(argv[U_MITID], stringval(form, U_MITID) + 1,
- strlen(stringval(form, U_MITID) - 2));
- else
- EncryptID(argv[U_MITID], argv[U_MITID], argv[U_FIRST], argv[U_LAST]);
- argc = U_MODTIME;
- break;
- case MM_REGISTER:
- if (*stringval(form, 2)) {
- argv[0] = stringval(form, 2);
- } else {
- argv[0] = stringval(form, 0);
- argv[1] = stringval(form, 1);
- form->extrastuff = NULL;
- i = MoiraQuery("get_user_by_name", 2, argv,
- ModifyCallback, (char *)form);
- if (i) {
- com_err(program_name, i, "looking up user by name");
- return;
- }
- if (form->extrastuff == NULL) {
- display_error("Ambiguous user specification");
- return;
- }
- argv[0] = (char *)form->extrastuff;
- }
- qy = "register_user";
- argv[1] = stringval(form, 3);
- argv[2] = "1";
- argc = 3;
- break;
- case MM_MOD_USER:
- if (!strcmp(form->formname, "mod_user")) {
- qy = "update_user";
- for (i = 0; i < U_MODTIME; i++)
- argv[i + 1] = stringval(form, i);
- argv[0] = form->extrastuff;
- argv[U_STATE + 1][1] = 0;
- if (argv[U_MITID + 1][0] == '"') {
- strcpy(argv[U_MITID + 1], stringval(form, U_MITID) + 1);
- stringval(form, U_MITID)[strlen(stringval(form, U_MITID))-1] = 0;
- } else
- EncryptID(argv[U_MITID + 1], argv[U_MITID + 1],
- argv[U_FIRST + 1], argv[U_LAST + 1]);
- argc = U_MODTIME + 1;
- break;
- }
- qy = "get_user_by_login";
- argv[0] = stringval(form, 0);
- argc = 1;
- form->extrastuff = (caddr_t) "mod_user";
- retfunc = ModifyCallback;
- break;
- case MM_DEACTIVATE:
- qy = "update_user_status";
- argv[0] = stringval(form, 0);
- argv[1] = "3";
- argc = 2;
- break;
- case MM_EXPUNGE:
- display_error("Expunge is not yet implemented");
- return;
- break;
- case MM_SHOW_FINGER:
- qy = "get_finger_by_login";
- argc = 1;
- break;
- case MM_MOD_FINGER:
- if (!strcmp(form->formname, "mod_finger")) {
- qy = "update_finger_by_login";
- for (i = 0; i < F_MODTIME - 1; i++)
- argv[i + 1] = stringval(form, i);
- argv[0] = form->extrastuff;
- argc = F_MODTIME;
- break;
- }
- qy = "get_finger_by_login";
- argc = 1;
- form->extrastuff = (caddr_t) "mod_finger";
- retfunc = ModifyCallback;
- break;
- case MM_SHOW_KRBMAP:
- qy = "get_krbmap";
- if (!*stringval(form, 0))
- argv[0] = "*";
- if (!*stringval(form, 1))
- argv[1] = "*";
- argc = 2;
- break;
- case MM_ADD_KRBMAP:
- qy = "add_krbmap";
- argc = 2;
- break;
- case MM_DEL_KRBMAP:
- qy = "delete_krbmap";
- argc = 2;
- break;
- case MM_SHOW_POBOX:
- qy = "get_pobox";
- argc = 1;
- break;
- case MM_SET_POBOX:
- qy = "set_pobox";
- if (!strcmp(argv[1], "POP"))
- argv[2] = stringval(form, 3);
- argc = 3;
- break;
- case MM_RESET_POBOX:
- qy = "set_pobox_pop";
- argc = 1;
- break;
- case MM_DEL_POBOX:
- qy = "set_pobox";
- argv[0] = stringval(form, 0);
- argv[1] = "NONE";
- argv[2] = "";
- argc = 3;
- break;
- case MM_SHOW_LIST:
- qy = "get_list_info";
- argc = 1;
- break;
- case MM_SHOW_ACE_USE:
- qy = "get_ace_use";
- if (boolval(form, 2)) {
- sprintf(buf, "R%s", stringval(form, 0));
- argv[0] = buf;
- }
- argc = 2;
- break;
- case MM_ADD_LIST:
- qy = "add_list";
- argc = L_MODTIME;
- break;
- case MM_MOD_LIST:
- if (!strcmp(form->formname, "mod_list")) {
- qy = "update_list";
- for (i = 0; i < L_MODTIME; i++)
- argv[i + 1] = stringval(form, i);
- argv[0] = form->extrastuff;
- argc = L_MODTIME + 1;
- break;
- }
- qy = "get_list_info";
- argc = 1;
- form->extrastuff = (caddr_t) "mod_list";
- retfunc = ModifyCallback;
- break;
- case MM_DEL_LIST:
- qy = "delete_list";
- argc = 1;
- break;
- case MM_SHOW_MEMBERS:
- if (*stringval(form, 0)) {
- qy = "get_members_of_list";
- argc = 1;
- } else {
- qy = "get_lists_of_member";
- argv[0] = stringval(form, 1);
- if (boolval(form, 3)) {
- sprintf(buf, "R%s", stringval(form, 1));
- argv[0] = buf;
- }
- argv[1] = stringval(form, 2);
- argc = 2;
- }
- break;
- case MM_ADD_MEMBER:
- qy = "add_member_to_list";
- argc = 3;
- break;
- case MM_DEL_MEMBER:
- qy = "delete_member_from_list";
- argc = 3;
- break;
- case MM_DEL_ALL_MEMBER:
- display_error("Not yet implemented.");
- return;
- break;
- case MM_SHOW_FILSYS:
- if (*stringval(form, 0)) {
- qy = "get_filesys_by_label";
- argv[0] = stringval(form, 0);
- argc = 1;
- } else if (*stringval(form, 1)) {
- argv[0] = canonicalize_hostname(stringval(form, 1));
- if (*stringval(form, 2)) {
- qy = "get_filesys_by_nfsphys";
- argv[1] = stringval(form, 2);
- argc = 2;
- } else {
- qy = "get_filesys_by_machine";
- argc = 1;
- }
- } else if (*stringval(form, 3)) {
- qy = "get_filesys_by_group";
- argv[0] = stringval(form, 3);
- argc = 1;
- }
- break;
- case MM_ADD_FILSYS:
- qy = "add_filesys";
- argv[FS_MACHINE] = canonicalize_hostname(stringval(form, FS_MACHINE));
- if (!strcmp(stringval(form, FS_TYPE), "AFS") ||
- !strcmp(stringval(form, FS_TYPE), "FSGROUP"))
- argv[FS_MACHINE] = "\\[NONE\\]";
- argc = FS_MODTIME;
- break;
- case MM_MOD_FILSYS:
- if (!strcmp(form->formname, "mod_filsys")) {
- qy = "update_filsys";
- for (i = 0; i < FS_MODTIME; i++)
- argv[i + 1] = stringval(form, i);
- argv[0] = form->extrastuff;
- argc = FS_MODTIME + 1;
- break;
- }
- qy = "get_filesys_by_label";
- argv[0] = stringval(form, 0);
- argc = 1;
- form->extrastuff = (caddr_t) "mod_filsys";
- retfunc = ModifyCallback;
- break;
- }
-
- if (argc == -1) {
- display_error("Unknown function in form callback.\n");
- return;
- }
- i = MoiraQuery(qy, argc, argv, retfunc, (char *)form);
- if (i) {
- com_err(program_name, i, "executing database query");
- return;
- }
-
- f = NULL;
- if (form->extrastuff && (f = GetForm((char *)(form->extrastuff)))) {
- f->extrastuff = (caddr_t) strsave(stringval(form, 0));
- f->menu = form->menu;
- }
-
- switch (form->menu->operation) {
- case MM_MOD_USER:
- if (f) {
- qy = strsave(stringval(f, U_MITID));
- sprintf(stringval(f, U_MITID), "\"%s\"", qy);
- free(qy);
- f->inputlines[U_STATE]->keywords = user_states;
- StoreField(f, U_STATE, user_states[atoi(stringval(f, U_STATE))]);
- GetKeywords(f, U_CLASS, "class");
- } else
- add_to_display("Done.\n");
- break;
- case MM_MOD_FINGER:
- if (!f)
- add_to_display("Done.\n");
- break;
- case MM_MOD_LIST:
- if (f)
- GetKeywords(f, L_ACE_TYPE, "ace_type");
- else
- add_to_display("Done.\n");
- break;
- case MM_MOD_FILSYS:
- if (f) {
- GetKeywords(f, FS_TYPE, "filesys");
- sprintf(buf, "fs_access_%s", stringval(f, FS_TYPE));
- GetKeywords(f, FS_ACCESS, buf);
- GetKeywords(f, FS_L_TYPE, "lockertype");
- if (!strcmp(stringval(f, FS_MACHINE), "[NONE]"))
- StoreField(f, FS_MACHINE, "\\[NONE\\]");
- } else
- add_to_display("Done.\n");
- break;
- case MM_ADD_HOST:
- case MM_DEL_HOST:
- case MM_CLEAR_HOST:
- case MM_RESET_HOST:
- case MM_ADD_SERVICE:
- case MM_DEL_SERVICE:
- case MM_CLEAR_SERVICE:
- case MM_RESET_SERVICE:
- case MM_ENABLE_DCM:
- case MM_TRIGGER_DCM:
- case MM_ADD_ZEPHYR:
- case MM_DEL_ZEPHYR:
- case MM_ADD_PCAP:
- case MM_DEL_PCAP:
- case MM_ADD_CLDATA:
- case MM_DEL_CLDATA:
- case MM_ADD_MCMAP:
- case MM_DEL_MCMAP:
- case MM_ADD_CLUSTER:
- case MM_DEL_CLUSTER:
- case MM_ADD_MACH:
- case MM_DEL_MACH:
- case MM_ADD_MEMBER:
- case MM_DEL_MEMBER:
- case MM_DEL_ALL_MEMBER:
- case MM_ADD_LIST:
- case MM_DEL_LIST:
- case MM_ADD_QUOTA:
- case MM_DEL_QUOTA:
- case MM_SET_DQUOTA:
- case MM_ADD_NFS:
- case MM_DEL_NFS:
- case MM_ADD_FS_ALIAS:
- case MM_DEL_FS_ALIAS:
- case MM_ADD_FSGROUP:
- case MM_MOV_FSGROUP:
- case MM_DEL_FSGROUP:
- case MM_ADD_FILSYS:
- case MM_DEL_FILSYS:
- case MM_ADD_KRBMAP:
- case MM_DEL_KRBMAP:
- case MM_SET_POBOX:
- case MM_DEL_POBOX:
- case MM_ADD_USER:
- case MM_REGISTER:
- case MM_DEACTIVATE:
- case MM_EXPUNGE:
- add_to_display("Done.\n");
- }
-
- if (f)
- DisplayForm(f);
-}
-
-
-MoiraMenuComplete(m)
-MenuItem *m;
-{
- char *qy, *argv[32];
- int (*retfunc)(), argc, i;
- EntryForm dummy;
-
- retfunc = DisplayCallback;
- argc = -1;
- dummy.menu = m;
-
- switch (m->operation) {
- case MM_SHOW_MAILLIST:
- qy = "qualified_get_lists";
- argv[0] = argv[1] = argv[3] = "TRUE";
- argv[2] = "FALSE";
- argv[4] = "DONTCARE";
- argc = 5;
- break;
- case MM_SHOW_DQUOTA:
- qy = "get_value";
- argv[0] = "def_quota";
- argc = 1;
- break;
- case MM_SHOW_DCM:
- Put_message("Services and Hosts with failed updates:");
- argv[0] = argv[2] = "DONTCARE";
- argv[1] = "TRUE";
- i = MoiraQuery("qualified_get_server", 3, argv, retfunc, NULL);
- if (i && i != MR_NO_MATCH)
- com_err(program_name, i, "executing database query");
- qy = "qualified_get_server_host";
- argv[0] = "*";
- argv[1] = argv[2] = argv[3] = argv[5] = "DONTCARE";
- argv[4] = "TRUE";
- argc = 6;
- break;
- case MM_STATS:
- qy = "get_all_table_stats";
- argc = 0;
- break;
- case MM_CLIENTS:
- qy = "_list_users";
- argc = 0;
- break;
- }
- if (argc == -1) {
- display_error("Unknown function in menu callback.\n");
- return;
- }
- i = MoiraQuery(qy, argc, argv, retfunc, (char *)&dummy);
- if (i)
- com_err(program_name, i, "executing database query");
-}
-
-
-/******* temporary ********/
-DisplayError(msg) char *msg; { fprintf(stderr, "%s\n", msg); }
-Put_message(msg) char *msg; { fputs( msg, stderr); }
-add_to_display(msg) char *msg; { fputs(msg, stderr); }
+++ /dev/null
-# This is the Makefile for allmaint, the Moira client that allows
-# a user to maintaint most important parts of the Moira database.
-# It Contains: The Makefile
-#
-# Created: 5/9/88
-# By: Chris D. Peterson
-#
-# $Source$
-# $Author$
-# $Header$
-#
-# Copyright 1987, 1988 by the Massachusetts Institute of Technology.
-#
-# For further information on copyright and distribution
-# see the file mit-copyright.h
-#
-
-DESTDIR=
-CFLAGS = -I../../include -I. -O
-LDFLAGS = -L../../lib
-CONFDIR = ${DESTDIR}/usr/athena
-BINDIR = ${DESTDIR}/bin
-
-MOIRALIB = -lmoira -lgdb -lcom_err
-LIBS = ${MOIRALIB} -lcurses -ltermcap -lkrb -ldes -lhesiod
-
-
-SRCS = utils.c attach.c cluster.c delete.c globals.c lists.c main.c \
- menu.c menus.c nfs.c pobox.c quota.c user.c dcmmaint.c printer.c \
- misc.c zephyr.c
-OBJS = attach.o cluster.o delete.o globals.o lists.o main.o menu.o \
- menus.o nfs.o pobox.o quota.o user.o utils.o dcmmaint.o printer.o \
- misc.o zephyr.o
-NOBJS = namespace.o globals.o lists.o menu.o \
- pobox.o user.o utils.o misc.o
-
-all: moira namespace
-
-moira: ${OBJS}
- rm -f moira
- cc ${CFLAGS} ${LDFLAGS} -o moira ${OBJS} ${LIBS}
-
-namespace: ${NOBJS}
- rm -f namespace
- cc ${CFLAGS} ${LDFLAGS} -o namespace ${NOBJS} ${LIBS}
-
-lint:
- lint -I../../include *.c
-
-install: moira
- install -c -s moira ${DESTDIR}/usr/athena/moira
- rm -f ${DESTDIR}/usr/athena/usermaint
- rm -f ${DESTDIR}/usr/athena/listmaint
- rm -f ${DESTDIR}/usr/athena/dcmmaint
- ln -s /usr/athena/moira ${DESTDIR}/usr/athena/usermaint
- ln -s /usr/athena/moira ${DESTDIR}/usr/athena/listmaint
- ln -s /usr/athena/moira ${DESTDIR}/usr/athena/dcmmaint
-
-clean:
- rm -f *.o *~
- rm -f moira
- cd Doc; make clean
-
-# Typing 'make saber' at the command line will allow load and link against the
-# correct libraries when using saber C.
-
-saber: ;
- /mit/kaufer/saber -I/mit/moiradev/include -DDEBUG ${LDFLAGS} \
- ${SRCS} ${LIBS}
-
-depend:
- mkdep ${CFLAGS} ${SRCS}
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-
-utils.o: utils.c /usr/include/stdio.h /usr/include/strings.h
-utils.o: ../../include/moira.h ../../include/mr_et.h
-utils.o: ../../include/moira_site.h ../../include/mit-copyright.h menu.h
-utils.o: /usr/include/ctype.h defs.h f_defs.h globals.h /usr/include/netdb.h
-attach.o: attach.c /usr/include/stdio.h /usr/include/strings.h
-attach.o: ../../include/moira.h ../../include/mr_et.h
-attach.o: ../../include/moira_site.h ../../include/mit-copyright.h menu.h
-attach.o: defs.h f_defs.h globals.h
-cluster.o: cluster.c /usr/include/stdio.h /usr/include/strings.h
-cluster.o: ../../include/moira.h ../../include/mr_et.h
-cluster.o: ../../include/moira_site.h ../../include/mit-copyright.h menu.h
-cluster.o: defs.h f_defs.h globals.h
-delete.o: delete.c /usr/include/stdio.h /usr/include/strings.h
-delete.o: ../../include/moira.h ../../include/mr_et.h
-delete.o: ../../include/moira_site.h ../../include/mit-copyright.h menu.h
-delete.o: defs.h f_defs.h globals.h
-globals.o: globals.c ../../include/mit-copyright.h defs.h
-lists.o: lists.c /usr/include/stdio.h /usr/include/strings.h
-lists.o: ../../include/moira.h ../../include/mr_et.h
-lists.o: ../../include/moira_site.h ../../include/mit-copyright.h menu.h
-lists.o: defs.h f_defs.h globals.h
-main.o: main.c /usr/include/pwd.h /usr/include/signal.h /usr/include/stdio.h
-main.o: /usr/include/strings.h /usr/include/sys/types.h ../../include/moira.h
-main.o: ../../include/mr_et.h menu.h ../../include/mit-copyright.h defs.h
-main.o: f_defs.h globals.h
-menu.o: menu.c ../../include/mit-copyright.h /usr/include/sys/types.h
-menu.o: /usr/include/stdio.h /usr/include/signal.h /usr/include/curses.h
-menu.o: /usr/include/sgtty.h /usr/include/sys/ioctl.h
-menu.o: /usr/include/sys/ttychars.h /usr/include/sys/ttydev.h
-menu.o: /usr/include/ctype.h /usr/include/strings.h /usr/include/varargs.h
-menu.o: ../../include/com_err.h menu.h
-menus.o: menus.c /usr/include/stdio.h menu.h ../../include/mit-copyright.h
-menus.o: defs.h f_defs.h globals.h
-nfs.o: nfs.c /usr/include/stdio.h /usr/include/strings.h
-nfs.o: ../../include/moira.h ../../include/mr_et.h ../../include/moira_site.h
-nfs.o: ../../include/mit-copyright.h menu.h defs.h f_defs.h globals.h
-pobox.o: pobox.c /usr/include/stdio.h /usr/include/strings.h
-pobox.o: /usr/include/ctype.h ../../include/moira.h ../../include/mr_et.h
-pobox.o: ../../include/moira_site.h ../../include/mit-copyright.h menu.h
-pobox.o: defs.h f_defs.h globals.h
-quota.o: quota.c /usr/include/stdio.h /usr/include/strings.h
-quota.o: ../../include/moira.h ../../include/mr_et.h
-quota.o: ../../include/moira_site.h ../../include/mit-copyright.h menu.h
-quota.o: defs.h f_defs.h globals.h
-user.o: user.c /usr/include/stdio.h /usr/include/strings.h
-user.o: ../../include/moira.h ../../include/mr_et.h
-user.o: ../../include/moira_site.h ../../include/mit-copyright.h menu.h
-user.o: /usr/include/ctype.h defs.h f_defs.h globals.h
-dcmmaint.o: dcmmaint.c /usr/include/stdio.h /usr/include/strings.h
-dcmmaint.o: /usr/include/ctype.h ../../include/moira.h ../../include/mr_et.h
-dcmmaint.o: ../../include/moira_site.h ../../include/mit-copyright.h menu.h
-dcmmaint.o: defs.h f_defs.h globals.h
-printer.o: printer.c /usr/include/stdio.h /usr/include/strings.h
-printer.o: /usr/include/ctype.h ../../include/moira.h ../../include/mr_et.h
-printer.o: ../../include/moira_site.h ../../include/mit-copyright.h menu.h
-printer.o: defs.h f_defs.h globals.h
-misc.o: misc.c /usr/include/stdio.h /usr/include/strings.h
-misc.o: ../../include/moira.h ../../include/mr_et.h
-misc.o: ../../include/moira_site.h ../../include/mit-copyright.h menu.h
-misc.o: /usr/include/sys/types.h /usr/include/netdb.h
-misc.o: /usr/include/sys/socket.h /usr/include/netinet/in.h defs.h f_defs.h
-misc.o: globals.h
+++ /dev/null
-# $Header$
-# (c) Copyright 1988 by the Massachusetts Institute of Technology.
-# For copying and distribution information, please see the file
-# <mit-copyright.h>.
-
-DESTDIR=
-CFLAGS = -I../../include -O
-LDFLAGS = -L../../lib
-CONFDIR = ${DESTDIR}/usr/athena
-BINDIR = ${DESTDIR}/bin
-
-MOIRALIB = ${LDFLAGS} -lmoira -lgdb -lcom_err
-LIBS = ${MOIRALIB} -lkrb -ldes -lhesiod
-
-
-SRCS = mrcheck.c
-OBJS = mrcheck.o
-
-all: mrcheck
-
-mrcheck: ${OBJS}
- rm -f mrcheck
- cc ${CFLAGS} -o mrcheck ${OBJS} ${LIBS}
-
-mrcheck.o: mrcheck.c
-
-lint:
- lint -I../../include *.c
-
-clean:
- rm -f *.o *~
- rm -f mrcheck
-
-install: ${PROGS}
- install -c -s mrcheck ${DESTDIR}/usr/athena/mrcheck
-
-depend:
- mkdep ${CFLAGS} ${SRCS}
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-
-mrcheck.o: mrcheck.c /usr/include/stdio.h ../../include/moira.h
-mrcheck.o: ../../include/mr_et.h ../../include/moira_site.h
-mrcheck.o: ../../include/mit-copyright.h
+++ /dev/null
-#
-# $Source$
-# $Header$
-#
-# (c) Copyright 1988 by the Massachusetts Institute of Technology.
-# For copying and distribution information, please see the file
-# <mit-copyright.h>.
-
-
-LIBS = ../rpc/libmoira.a ../gdb/libgdb.a
-LLIBS= -L../lib -lhesiod -lkrb -ldes -lhesiod -lss -lcom_err -lm -lc
-
-SRCS= test.c
-
-COPTS= -O
-
-INCDIRS=-I../include
-
-CFLAGS= ${INCDIRS} ${COPTS}
-
-.SUFFIXES: .ct .c .o
-
-.ct.o: ; ../ss/make_commands $*.ct
-
-all: mrtest
-
-mrtest: test_cmds.o test.o ${LIBS}
- rm -f mrtest
- cc ${COPTS} -o $@ test_cmds.o test.o ${LIBS} ${LLIBS}
-
-clean:
- rm -f *.o core \#* *~ gmon.out
- rm -f mrtest
-
-install: mrtest
- install -c -s mrtest ${DESTDIR}/usr/etc/mrtest
-
-depend:
- mkdep ${CFLAGS} ${SRCS}
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-
-test.o: test.c ../include/mit-copyright.h /usr/include/stdio.h
-test.o: /usr/include/sys/file.h /usr/include/ctype.h ../include/moira.h
-test.o: ../include/mr_et.h ../include/ss.h
+++ /dev/null
-# Makefile for MOIRA clients passwd/chfn/chpobox/chsh
-#
-# MIT Project Athena
-#
-# $Source$
-# $Header$
-# $Author$
-#
-# (c) Copyright 1988 by the Massachusetts Institute of Technology.
-# For copying and distribution information, please see the file
-# <mit-copyright.h>.
-#
-
-DESTDIR=
-DEFINES = -O
-CFLAGS = -I../../include ${DEFINES}
-CONFDIR = ${DESTDIR}/usr/athena
-BINDIR = ${DESTDIR}/bin
-
-MOIRALIB = -L../../lib -lmoira -lgdb -lcom_err -lkrb -ldes -lhesiod
-
-PROGS= chfn chsh chpobox
-
-all: ${PROGS}
-
-chfn: chfn.o
- cc -o chfn chfn.o ${MOIRALIB}
-
-chpobox: chpobox.o
- cc -o chpobox chpobox.o ${MOIRALIB}
-
-chsh: chsh.o
- cc -o chsh chsh.o ${MOIRALIB}
-
-lint:
- lint *.c
-
-clean:
- rm -f *.o *~
- rm -f ${PROGS}
-
-install: ${PROGS}
- install -c -s chsh ${DESTDIR}/usr/athena/chsh
- install -c -s chfn ${DESTDIR}/usr/athena/chfn
- install -c -s chpobox ${DESTDIR}/usr/athena/chpobox
-
-depend:
- mkdep ${CFLAGS} chfn.c chpobox.c chsh.c
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-
-chfn.o: chfn.c /usr/include/sys/types.h /usr/include/stdio.h
-chfn.o: /usr/include/strings.h /usr/include/sys/file.h ../../include/krb.h
-chfn.o: ../../include/mit-copyright.h ../../include/des.h
-chfn.o: /usr/include/ctype.h /usr/include/errno.h ../../include/moira.h
-chfn.o: ../../include/mr_et.h ../../include/moira_site.h
-chpobox.o: chpobox.c /usr/include/sys/types.h /usr/include/stdio.h
-chpobox.o: /usr/include/pwd.h /usr/include/strings.h /usr/include/ctype.h
-chpobox.o: /usr/include/errno.h ../../include/moira.h ../../include/mr_et.h
-chpobox.o: ../../include/moira_site.h ../../include/mit-copyright.h
-chsh.o: chsh.c /usr/include/sys/types.h /usr/include/stdio.h
-chsh.o: /usr/include/strings.h /usr/include/sys/file.h ../../include/krb.h
-chsh.o: ../../include/mit-copyright.h ../../include/des.h
-chsh.o: /usr/include/ctype.h /usr/include/errno.h ../../include/moira.h
-chsh.o: ../../include/mr_et.h ../../include/moira_site.h
+++ /dev/null
-#
-# $Source$
-# $Author$
-# $Locker$
-# $Header$
-#
-# (c) Copyright 1988 by the Massachusetts Institute of Technology.
-# For copying and distribution information, please see the file
-# <mit-copyright.h>.
-
-CFLAGS= -O -I../../include
-
-TEXT= welcome network_down username_blurb password_blurb improper_reg \
- deleted_acct not_allowed
-
-all: userreg
-
-userreg: userreg.o display.o reg_stubs.o disable.o
- cc ${CFLAGS} -o $@ userreg.o display.o reg_stubs.o disable.o \
- -L../../lib -lcom_err -lkrb -ldes -lmoira -lcurses \
- -ltermcap -lhesiod -lkadm
-
-userreg.o display.o: userreg.h files.h
-
-clean: /tmp
- rm -f a.out core *.o
- rm -f userreg
-
-install:
-
-install_real: all
- install -c -s userreg ${DESTDIR}/mit/register/userreg.`machtype`
- install -c register ${DESTDIR}/mit/register/register
- for i in ${TEXT}; do \
- install -c -m 444 $$i ${DESTDIR}/mit/register/$$i; \
- done;
-
-depend:
- mkdep ${CFLAGS} userreg.c display.c reg_stubs.c disable.c
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-
-userreg.o: userreg.c ../../include/mit-copyright.h /usr/include/curses.h
-userreg.o: /usr/include/stdio.h /usr/include/sgtty.h /usr/include/sys/ioctl.h
-userreg.o: /usr/include/sys/ttychars.h /usr/include/sys/ttydev.h
-userreg.o: /usr/include/signal.h /usr/include/sys/time.h
-userreg.o: /usr/include/sys/time.h /usr/include/setjmp.h /usr/include/ctype.h
-userreg.o: ../../include/krb.h ../../include/des.h /usr/include/errno.h
-userreg.o: userreg.h files.h ../../include/ureg_err.h
-display.o: display.c ../../include/mit-copyright.h /usr/include/stdio.h
-display.o: /usr/include/curses.h /usr/include/sgtty.h
-display.o: /usr/include/sys/ioctl.h /usr/include/sys/ttychars.h
-display.o: /usr/include/sys/ttydev.h /usr/include/sys/time.h
-display.o: /usr/include/sys/time.h userreg.h /usr/include/ctype.h files.h
-reg_stubs.o: reg_stubs.c ../../include/mit-copyright.h /usr/include/stdio.h
-reg_stubs.o: /usr/include/sys/types.h /usr/include/sys/time.h
-reg_stubs.o: /usr/include/sys/time.h /usr/include/sys/socket.h
-reg_stubs.o: /usr/include/netinet/in.h /usr/include/netdb.h
-reg_stubs.o: ../../include/des.h /usr/include/errno.h ../../include/moira.h
-reg_stubs.o: ../../include/mr_et.h ../../include/moira_site.h
-reg_stubs.o: ../../include/ureg_err.h ../../include/ureg_proto.h
-reg_stubs.o: /usr/include/strings.h
-disable.o: disable.c ../../include/mit-copyright.h /usr/include/stdio.h
-disable.o: /usr/include/ctype.h /usr/include/sys/types.h
-disable.o: /usr/include/sys/time.h /usr/include/sys/time.h
-disable.o: /usr/include/sys/file.h
--- /dev/null
+/*
+** Copyright (c) 1990 David E. Smyth
+**
+** Redistribution and use in source and binary forms are permitted
+** provided that the above copyright notice and this paragraph are
+** duplicated in all such forms and that any documentation, advertising
+** materials, and other materials related to such distribution and use
+** acknowledge that the software was developed by David E. Smyth. The
+** name of David E. Smyth may not be used to endorse or promote products
+** derived from this software without specific prior written permission.
+** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+** WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+*/
+
+/*
+* SCCS_data: @(#)AriRegAll.c 1.0 ( 19 June 1990 )
+*
+* Subsystem_group:
+*
+* Widget Creation Library - Athena Resource Interpreter
+*
+* Module_description:
+*
+* This module contains registration routine for all Athena
+* widget constructors and classes.
+*
+* Module_interface_summary:
+*
+* void AriRegisterAthena ( XtAppContext app )
+*
+* Module_history:
+*
+* mm/dd/yy initials function action
+* -------- -------- -------- ---------------------------------------------
+* 06/19/90 D.Smyth all create.
+*
+* Design_notes:
+*
+*******************************************************************************
+*/
+/*
+*******************************************************************************
+* Include_files.
+*******************************************************************************
+*/
+
+#include <X11/Xatom.h>
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+
+#include <X11/Xaw/AsciiText.h>
+#include <X11/Xaw/Clock.h>
+#include <X11/Xaw/Command.h>
+#include <X11/Xaw/Dialog.h>
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/Label.h>
+#include <X11/Xaw/MenuButton.h>
+#include <X11/Xaw/SimpleMenu.h>
+#include <X11/Xaw/SmeBSB.h>
+#include <X11/Xaw/SmeLine.h>
+
+#ifdef Use_AtLabel /* djf's formatted text stuff... */
+#include "Label.h"
+#endif
+
+
+#include <X11/Xaw/Cardinals.h>
+
+void AriRegisterAthena ( app )
+ XtAppContext app;
+{
+
+#define RCN( name, class ) WcRegisterClassName ( app, name, class );
+
+ /* -- register all Athena widget classes */
+ /* Simple Widgets (Chapt 3) */
+ RCN("Command", commandWidgetClass );
+ RCN("Label", labelWidgetClass );
+
+ /* Menus (Chapt 4) */
+ RCN("SimpleMenu", simpleMenuWidgetClass );
+ RCN("SmeBSB", smeBSBObjectClass );
+ RCN("SmeLine", smeLineObjectClass );
+ RCN("MenuButton", menuButtonWidgetClass );
+
+ /* Text Widgets (Chapt 5) */
+ RCN("AsciiText", asciiTextWidgetClass );
+ RCN("Text", textWidgetClass );
+
+ /* Composite and Constraint Widgets (Chapt 6) */
+ RCN("Dialog", dialogWidgetClass );
+ RCN("Form", formWidgetClass );
+
+ /* Other Interestng Widgets (not in ref manual) */
+ RCN("Clock", clockWidgetClass );
+
+#ifdef Use_AtLabel /* djf's formatted text stuff... */
+ RCN("AtLabel", atLabelWidgetClass );
+#endif
+
+#undef RCN
+}
+++ /dev/null
-# $Header$
-
-# (c) Copyright 1988 by the Massachusetts Institute of Technology.
-# For copying and distribution information, please see the file
-# <mit-copyright.h>.
-
-
-INGLIB=/usr/rtingres/lib/libqlib /usr/rtingres/lib/compatlib
-# SRCS=newmoira.c tables.c imembers.c class.c tables_sql.c
-# OBJS=newmoira.o tables.o tables_sql.o ../server/queries2.o
-SRCS=newmoira.c tables_sql.c imembers.c class.c
-OBJS=newmoira.o tables_sql.o ../server/queries2.o
-CFLAGS= -I../include -O
-.SUFFIXES: .qc
-
-.qc.c:
- rm -f $*.c
- /usr/rtingres/bin/eqc -p $*
-
-all: newmoira class imembers
-
-imembers: imembers.o
- cc -o imembers imembers.o ../lib/libmoira.a ${INGLIB}
-imembers.c: imembers.qc
-
-newmoira: ${OBJS}
- cc -o newmoira ${OBJS} ${INGLIB}
-
-newmoira.c: newmoira.qc
-
-tables.c: newdb db2tbls.awk
- awk -f db2tbls.awk < newdb > tables.c
-
-tables_sql.c: newdb.sql db2tbls_sql.awk
- awk -f db2tbls_sql.awk < newdb.sql > tables_sql.c
-
-class: class.o
- cc -o class class.o ../lib/libmoira.a ${INGLIB}
-
-class.c: class.qc
-
-clean:
- rm -f *.o newmoira.c tables.c newmoira extractdb extract.c class class.c
- rm -f imembers.c imembers
- rm -f tables_sql.c
-
-install: newmoira
- install -c newmoira ../bin
-
-depend: ${SRCS}
- mkdep ${CFLAGS} ${SRCS}
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-
-newmoira.o: newmoira.c ../include/mit-copyright.h /usr/include/stdio.h
-newmoira.o: ../server/query.h
-tables.o: tables.c
-tables_sql.o: tables_sql.c
-imembers.o: imembers.c /usr/include/stdio.h ../include/moira.h
-imembers.o: ../include/mr_et.h
-class.o: class.c ../include/mit-copyright.h ../include/moira.h
-class.o: ../include/mr_et.h
+++ /dev/null
-/* $Header$
- *
- * Counts how many member of each class exist in the database.
- *
- * (c) Copyright 1988 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>
-
-
-main()
-{
-## char class[9], *c;
-## int n;
- struct save_queue *sq, *sq_create();
-
- sq = sq_create();
-
-## ingres sms
-
-## range of u is users
-## retrieve unique (class = trim(u.mit_year)) {
- sq_save_data(sq, strsave(class));
-## }
-
- while (sq_get_data(sq, &c)) {
-## repeat retrieve (n = count(u.login where u.mit_year = @c))
- printf("%8s: %4d\n", c, n);
- }
-
-## exit
-}
+++ /dev/null
-/* $Header$ */
-
-/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/* For copying and distribution information, please see the file */
-/* <mit-copyright.h>. */
-
-
-#include <mit-copyright.h>
-#include <stdio.h>
-#include <sys/file.h>
-#include <ctype.h>
-
-char prefix[256];
-
-main(argc, argv)
-int argc;
-char **argv;
-{
-## char *db;
-
- if (argc == 2)
- db = argv[1];
- else
- db = "sms";
-
- printf("Prefix of backup to restore: ");
- fflush(stdout);
- if (gets(prefix) == NULL) {
- return 1;
- }
-
- printf("Opening database...");
- fflush(stdout);
-## ingres db
- printf("done\n");
-
- do_users();
- do_finger();
- do_mach();
- do_clu();
- do_mcm();
- do_cld();
- do_servers();
- do_serverhosts();
- do_list();
- do_maillists();
- do_groups();
- do_members();
- do_strings();
- do_pobox();
- do_nfsphys();
- do_filesys();
- do_nfsquota();
- do_services();
- do_printcap();
- do_alias();
- do_values();
-
- printf("All done.\n");
-## exit
-}
-
-char field_chars[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* ^@ - ^O */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ^P - ^_ */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* SP - / */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* 0 - ? */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ - O */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* P - _ */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ` - o */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* p - ^? */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-};
-
-
-int parse_int(f)
- register FILE *f;
-{
- register int c;
- register int val = 0;
- register int sign = 1;
- while ((c = getc(f)) != EOF && field_chars[c] == 0) {
- if (c == '-') sign = -1;
- else if (isdigit(c)) {
- val *= 10;
- val += (c - '0');
- } else (void) fprintf(stderr,"non-digit in numeric field\n");
- }
- (void) ungetc(c, f);
- return(val * sign);
-}
-
-void parse_str(f, buf, len)
- register FILE *f;
- register char *buf;
- register int len; /* incl trailing NULL */
-{
- register int c;
-
- while ((c = getc(f)) != EOF && field_chars[c] == 0 && len > 0) {
- if (c == '\\') {
- c = getc(f);
- if (isdigit(c)) {
- /* Expect three-digit octal number.. */
- register int c1, c2;
- c1 = getc(f);
- c2 = getc(f);
- if (!isdigit(c1) || !isdigit(c2))
- punt("Broken \\###");
- /* Convert to ASCII code: */
- *buf++ = (((c-'0')<<6) + ((c1-'0')<<3) + c2-'0');
- } else if (c == '\\' || c == ':') {
- *buf++ = c;
- --len;
- } else punt ("Broken '\\'");
- } else {
- *buf++ = c;
- --len;
- }
- }
- if (c == EOF)
- return;
-
- if (c != EOF && c != ':' && c != '\n') {
- fprintf(stderr, "Field too wide, truncated\n");
- while ((c = getc(f)) != EOF && c != ':' && c != '\n');
- (void) ungetc(c, f);
- } else {
- *buf++ = 0;
- (void) ungetc(c, f);
- }
-}
-
-void parse_sep(f)
- FILE *f;
-{
- if (getc(f) != ':') punt("Expected colon");
-}
-void parse_nl(f)
- FILE *f;
-{
- if (getc(f) != '\n') punt("Expected newline");
-}
-
-
-FILE *open_file(suffix)
- char *suffix;
-{
- char name[BUFSIZ];
- int fd;
- FILE *f;
-
- sprintf(name, "%s/%s", prefix, suffix);
-
- fd = open(name, O_RDONLY, 0);
- if (fd < 0) {
- punt(name);
- }
- f = fdopen(fd, "r");
- if (f == NULL) {
- fprintf(stderr, "fdopen of ");
- punt(name);
- }
- fprintf(stderr, "Working on %s\n", name);
- return(f);
-}
-
-punt(s)
-char *s;
-{
- printf("exiting: %s\n", s);
- exit(1);
-}
-
-static int count;
-static int interval;
-
-start_counter(x)
-int x;
-{
- count = 0;
- interval = x;
-}
-
-inc_count()
-{
- if (count++ % interval == 0) {
- printf("\r%d...", count - 1);
- fflush(stdout);
- }
-}
-
-end_counter()
-{
- printf("\r%d items processed.\n", count);
-}
+++ /dev/null
-/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/* For copying and distribution information, please see the file */
-/* <mit-copyright.h>. */
-
-#include <mit-copyright.h>
-#include <stdio.h>
-##define USERSMS 17069
-
-FILE *open_file();
-char *strsave(), *strtrim();
-
-do_users()
-##{
- register FILE *u;
-## int flag;
-## char t_login[9];
-## int t_users_id;
-## int t_uid;
-## char t_shell[33];
-## char t_home[33];
-## char t_last[17];
-## char t_first[17];
-## char t_middle[17];
-## int t_status;
-## char t_mit_id[14];
-## char t_mit_year[9];
-## char t_expdate[26];
-## char t_modtime[26];
-## int t_acl_id;
-## int err;
-
- u = open_file("users");
- start_counter(10);
-
-## range of u is users
-## delete u where u.users_id > 0
-
- while(!feof(u)) {
- parse_str(u, t_login, 9);
- if (feof(u)) break;
- parse_sep(u);
- t_users_id = parse_int(u);
- parse_sep(u);
- t_uid = parse_int(u);
- parse_sep(u);
- parse_str(u, t_shell, 33);
- parse_sep(u);
- parse_str(u, t_home, 33);
- parse_sep(u);
- parse_str(u, t_last, 17);
- parse_sep(u);
- parse_str(u, t_first, 17);
- parse_sep(u);
- parse_str(u, t_middle, 17);
- parse_sep(u);
- t_status = parse_int(u);
- parse_sep(u);
- parse_str(u, t_mit_id, 14);
- parse_sep(u);
- parse_str(u, t_mit_year, 9);
- parse_sep(u);
- parse_str(u, t_expdate, 26);
- parse_sep(u);
- parse_str(u, t_modtime, 26);
- parse_sep(u);
- t_acl_id = parse_int(u);
- parse_nl(u);
-
- inc_count();
-## append users (
-## login = t_login,
-## users_id = t_users_id,
-## uid = t_uid,
-## shell = t_shell,
-## last = t_last,
-## first = t_first,
-## middle = t_middle,
-## status = t_status,
-## mit_id = t_mit_id,
-## mit_year = t_mit_year,
-## modtime = t_modtime,
-## modwith = "convert",
-## modby = USERSMS,
-## mit_affil = t_mit_year,
-## fmodtime = "now",
-## fmodwith = "convert",
-## fmodby = USERSMS,
-## potype = "NONE",
-## pop_id = 0,
-## box_id = 0,
-## pmodtime = "now",
-## pmodwith = "convert",
-## pmodby = USERSMS
-## )
- }
- (void) fclose(u);
- end_counter();
-## modify users to cbtree unique on users_id
-## inquire_equel(err = "errorno");
- if (err != 0)
- punt("modify on users failed");
-## index on users is i_usr_login (login)
-## inquire_equel(err = "errorno");
- if (err != 0)
- punt("index on users failed");
-## modify i_usr_login to hash
-## inquire_equel(err = "errorno");
- if (err != 0)
- punt("modify on users index failed");
-##}
-
-
-do_finger()
-##{
- register FILE *f;
-## int t_fusers_id;
-## char t_fullname[33];
-## char t_nickname[17];
-## char t_home_addr[81];
-## char t_home_phone[17];
-## char t_office_addr[17];
-## char t_office_phone[13];
-## char t_mit_dept[13];
-## char t_mit_affil[5];
-## char t_modtime[26];
-## int rowcount;
-
- f = open_file("finger");
-## range of u is users
- start_counter(10);
-
- while (!feof(f)) {
- t_fusers_id = parse_int(f);
- if (feof(f))
- break;
- parse_sep(f);
- parse_str(f, t_fullname, 33);
- parse_sep(f);
- parse_str(f, t_nickname, 17);
- parse_sep(f);
- parse_str(f, t_home_addr, 81);
- parse_sep(f);
- parse_str(f, t_home_phone, 17);
- parse_sep(f);
- parse_str(f, t_office_addr, 17);
- parse_sep(f);
- parse_str(f, t_office_phone, 13);
- parse_sep(f);
- parse_str(f, t_mit_dept, 13);
- parse_sep(f);
- parse_str(f, t_mit_affil, 5);
- parse_sep(f);
- parse_str(f, t_modtime, 26);
- parse_nl(f);
-
- inc_count();
-## repeat replace users (
-## fullname = @t_fullname,
-## nickname = @t_nickname,
-## home_addr = @t_home_addr,
-## home_phone = @t_home_phone,
-## office_addr = @t_office_addr,
-## office_phone = @t_office_phone,
-## mit_dept = @t_mit_dept,
-## mit_affil = @t_mit_affil,
-## fmodtime = @t_modtime,
-## fmodwith = "convert",
-## fmodby = USERSMS
-## ) where users.users_id = @t_fusers_id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount == 0)
- printf("\rOrphaned finger entry %d for \"%s\"\n",
- t_fusers_id, t_fullname);
- }
- fclose(f);
- end_counter();
-##}
-
-
-char **machs;
-##int maxmach;
-
-do_mach()
-##{
- register FILE *f;
-## char t_name[33];
-## int t_mach_id;
-## char t_type[13];
- char buf[13];
-
- f = open_file("machine");
-## range of m is machine
- start_counter(25);
-
- while(!feof(f)) {
- parse_str(f, t_name, 33);
- if (feof(f)) break;
- parse_sep(f);
- t_mach_id = parse_int(f);
- parse_sep(f);
- parse_str(f, t_type, 13);
- parse_sep(f);
- parse_str(f, buf, 13);
- parse_sep(f);
- parse_str(f, buf, 13);
- parse_sep(f);
- parse_str(f, buf, 13);
- parse_sep(f);
- parse_str(f, buf, 13);
- parse_nl(f);
-
- inc_count();
-## append machine (name = t_name, mach_id = t_mach_id,
-## type = t_type, modtime = "now",
-## modby = USERSMS, modwith = "convert")
- }
- fclose(f);
- end_counter();
-##}
-
-
-do_clu()
-##{
- register FILE *f;
-## char t_name[33];
-## int t_clu_id;
-## char t_desc[33];
-## char t_location[65];
-## int t_acl_id;
-## int rowcount;
-
- f = open_file("cluster");
-## range of c is cluster
- start_counter(10);
-
- while(!feof(f)) {
- parse_str(f, t_name, 33);
- if (feof(f)) break;
- parse_sep(f);
- t_clu_id = parse_int(f);
- parse_sep(f);
- parse_str(f, t_desc, 33);
- parse_sep(f);
- parse_str(f, t_location, 65);
- parse_sep(f);
- t_acl_id = parse_int(f);
- parse_nl(f);
-
- inc_count();
-## append cluster (
-## name = t_name,
-## clu_id = t_clu_id,
-## desc = t_desc,
-## location = t_location,
-## modtime = "now",
-## modby = USERSMS,
-## modwith = "convert")
- }
- fclose(f);
- end_counter();
-##}
-
-
-do_mcm()
-##{
- register FILE *f;
-## int t_clu_id;
-## int t_mach_id;
-
- f = open_file("machclumap");
- start_counter(25);
-
- while(!feof(f)) {
- t_clu_id = parse_int(f);
- if (feof(f)) break;
- parse_sep(f);
- t_mach_id = parse_int(f);
- parse_nl(f);
-
- inc_count();
-## append mcmap (
-## clu_id = t_clu_id,
-## mach_id = t_mach_id)
- }
- (void) fclose(f);
- end_counter();
-##}
-
-
-do_cld()
-##{
- register FILE *f;
-## int t_clu_id;
-## char t_serv_label[17];
-## char t_serv_cluster[33];
-
- f = open_file("svc");
- start_counter(10);
-
- while(!feof(f)) {
- t_clu_id = parse_int(f);
- if (feof(f)) break;
- parse_sep(f);
- parse_str(f, t_serv_label, 17);
- parse_sep(f);
- parse_str(f, t_serv_cluster, 33);
- parse_nl(f);
-
- inc_count();
-## append svc (
-## clu_id = t_clu_id,
-## serv_label = t_serv_label,
-## serv_cluster = t_serv_cluster)
- }
- (void) fclose(f);
- end_counter();
-##}
-
-
-do_servers()
-##{
- register FILE *f;
-## char t_service[17];
-## int t_update_int;
-## char t_target_file[65];
-## char t_script[129];
-## char t_dfgen[26];
-
- f = open_file("servers");
- start_counter(1);
-
- while(!feof(f)) {
- parse_str(f, t_service, 17);
- if (feof(f)) break;
- parse_sep(f);
- t_update_int = parse_int(f);
- parse_sep(f);
- parse_str(f, t_target_file, 65);
- parse_sep(f);
- parse_str(f, t_script, 129);
- parse_sep(f);
- parse_str(f, t_dfgen, 26);
- parse_nl(f);
-
- inc_count();
-## append servers (
-## name = uppercase(t_service),
-## update_int = t_update_int,
-## target_file = t_target_file,
-## script = t_script,
-## dfgen = 0,
-## type = "UNIQUE",
-## enable = 0,
-## inprogress = 0,
-## harderror = 0,
-## errmsg = "",
-## acl_type = "NONE",
-## acl_id = 0,
-## modtime = "now",
-## modby = USERSMS,
-## modwith = "convert"
-## )
- }
- (void) fclose(f);
- end_counter();
-##}
-
-
-do_serverhosts()
-##{
- register FILE *f;
-## char t_service[17];
-## int t_mach_id;
-## char t_enable[33];
-## int t_overide;
-## char t_ltt[26];
-## char t_success[2];
-## int t_value1;
-## int t_value2;
-## int err;
-
- f = open_file("serverhosts");
- start_counter(5);
-
- while(!feof(f)) {
- parse_str(f, t_service, 17);
- if (feof(f)) break;
- parse_sep(f);
- t_mach_id = parse_int(f);
- parse_sep(f);
- parse_str(f, t_enable, 33);
- parse_sep(f);
- t_overide = parse_int(f);
- parse_sep(f);
- parse_str(f, t_ltt, 26);
- parse_sep(f);
- parse_str(f, t_success, 2);
- parse_sep(f);
- t_value1 = parse_int(f);
- parse_sep(f);
- t_value2 = parse_int(f);
- parse_nl(f);
-
- inc_count();
- if (t_mach_id == 0)
- continue;
-## append serverhosts (
-## service = uppercase(t_service),
-## mach_id = t_mach_id,
-## enable = 0,
-## override = t_overide,
-## ltt = 0,
-## lts = 0,
-## success = int1(t_success),
-## inprogress = 0,
-## hosterror = 0,
-## hosterrmsg = "",
-## value1 = t_value1,
-## value2 = t_value2,
-## modtime = "now",
-## modby = USERSMS,
-## modwith = "convert")
- }
- (void) fclose(f);
- end_counter();
-## modify serverhosts to btree on service
-## inquire_equel(err = "errorno")
- if (err != 0)
- punt("unable to modify serverhosts");
-## index on serverhosts is i_sho_mach (mach_id)
-## inquire_equel(err = "errorno")
- if (err != 0)
- punt("unable to index serverhosts");
-## modify i_sho_mach to cbtree
-## inquire_equel(err = "errorno")
- if (err != 0)
- punt("unable to modify serverhosts index");
-##}
-
-
-do_list()
-##{
- register FILE *f;
-## char t_name[33];
-## int t_list_id;
-## int t_flags;
-## char t_desc[257];
-## int t_created;
-## int t_acl_id;
-## char t_expdate[26];
-## char t_modtime[26];
-## int t_active, t_public, t_hidden, err;
-
-/* delete default & dbadmin */
-## delete list where list.list_id = 1 or list.list_id = 2
-
- f = open_file("list");
- start_counter(5);
-
- while(!feof(f)) {
- parse_str(f, t_name, 33);
- if (feof(f)) break;
- parse_sep(f);
- t_list_id = parse_int(f);
- parse_sep(f);
- t_flags = parse_int(f);
- parse_sep(f);
- parse_str(f, t_desc, 257);
- parse_sep(f);
- t_acl_id = parse_int(f);
- parse_sep(f);
- parse_str(f, t_expdate, 26);
- parse_sep(f);
- parse_str(f, t_modtime, 26);
- parse_nl(f);
-
- t_active = t_flags & 1;
- t_public = (t_flags>>1) & 1;
- t_hidden = (t_flags>>2) & 1;
- inc_count();
-## append list (
-## name = t_name,
-## list_id = t_list_id,
-## active = t_active, public = t_public, hidden = t_hidden,
-## desc = t_desc,
-## acl_type = "LIST",
-## acl_id = t_acl_id,
-## modtime = t_modtime,
-## modby = USERSMS,
-## modwith = "convert")
- }
- (void) fclose(f);
- end_counter();
-
-## modify list to cbtree unique on list_id
-## inquire_equel(err = "errorno")
- if (err != 0)
- punt("unable to modify list");
-## index on list is i_lis_name (name)
-## inquire_equel(err = "errorno")
- if (err != 0)
- punt("unable to index lists by name");
-## modify i_lis_name to hash
-## inquire_equel(err = "errorno")
- if (err != 0)
- punt("unable to modify list name index");
-##}
-
-
-do_maillists()
-##{
- register FILE *f;
-## int t_list_id;
-## int t_ltid;
-## int err;
-
- f = open_file("maillists");
-## range of l is list
- start_counter(5);
-
- while(!feof(f)) {
- t_list_id = parse_int(f);
- if (feof(f)) break;
- parse_sep(f);
- t_ltid = parse_int(f);
- parse_nl(f);
-
- inc_count();
-## repeat replace l (maillist = 1) where l.list_id = @t_list_id
- }
- end_counter();
- (void) fclose(f);
-## index on list is i_lis_mail (maillist)
-## inquire_equel(err = "errorno")
- if (err != 0)
- punt("unable to index lists by maillist");
-##}
-
-
-do_groups()
-##{
- register FILE *f;
-## int t_list_id;
-## int t_ltid;
-## int t_gid;
-## int err;
-
- f = open_file("groups");
-## range of l is list
- start_counter(5);
-
- while(!feof(f)) {
- t_list_id = parse_int(f);
- if (feof(f)) break;
- parse_sep(f);
- t_ltid = parse_int(f);
- parse_sep(f);
- t_gid = parse_int(f);
- parse_nl(f);
-
- inc_count();
-## repeat replace l (group = 1, gid = @t_gid) where l.list_id = @t_list_id
- }
- end_counter();
- (void) fclose(f);
-## index on list is i_lis_group (group)
-## inquire_equel(err = "errorno")
- if (err != 0)
- punt("unable to index lists by group");
-##}
-
-
-do_members()
-##{
- register FILE *f;
-## int t_list_id;
-## char t_member_type[9];
-## int t_member_id;
-
- f = open_file("members");
- start_counter(25);
-
- while(!feof(f)) {
- t_list_id = parse_int(f);
- if (feof(f)) break;
- parse_sep(f);
- parse_str(f, t_member_type, 9);
- parse_sep(f);
- t_member_id = parse_int(f);
- parse_nl(f);
-
- inc_count();
-## append members (
-## list_id = t_list_id,
-## member_type = t_member_type,
-## member_id = t_member_id)
- }
- end_counter();
- (void) fclose(f);
-##}
-
-
-do_strings()
-##{
- register FILE *f;
-## int t_string_id;
-## char t_string[129];
-## int t_refc;
-
- f = open_file("strings");
- start_counter(10);
-
- while(!feof(f)) {
- t_string_id = parse_int(f);
- if (feof(f)) break;
- parse_sep(f);
- parse_str(f, t_string, 129);
- parse_sep(f);
- t_refc = parse_int(f);
- parse_nl(f);
-
- inc_count();
-## append strings (
-## string_id = t_string_id,
-## string = t_string)
- }
- end_counter();
- (void) fclose(f);
-##}
-
-
-do_nfsphys()
-##{
- register FILE *f;
-## int t_mach_id;
-## char t_device[17];
-## char t_dir[17];
-## int t_status;
-## int t_allocated;
-## int t_size;
-## int t_nfsphys_id;
-## int err;
-
- f = open_file("nfsphys");
- start_counter(5);
- t_nfsphys_id = 0;
-
- while(!feof(f)) {
- t_mach_id = parse_int(f);
- if (feof(f)) break;
- parse_sep(f);
- parse_str(f, t_device, 17);
- parse_sep(f);
- parse_str(f, t_dir, 17);
- parse_sep(f);
- t_status = parse_int(f);
- parse_sep(f);
- t_allocated = parse_int(f);
- parse_sep(f);
- t_size = parse_int(f);
- parse_nl(f);
- t_nfsphys_id++;
-
- inc_count();
-## append nfsphys (
-## nfsphys_id = t_nfsphys_id,
-## mach_id = t_mach_id,
-## device = t_device,
-## dir = t_dir,
-## status = t_status,
-## allocated = t_allocated,
-## size = t_size,
-## modtime = "now",
-## modby = USERSMS,
-## modwith = "convert")
- }
- end_counter();
- (void) fclose(f);
-
-## modify nfsphys to cbtree unique on nfsphys_id
-## inquire_equel(err = "errorno")
- if (err != 0)
- punt("cannot modify filesys");
-## index on nfsphys is i_nfs_mach (mach_id)
-## inquire_equel(err = "errorno")
- if (err != 0)
- punt("cannot index filesys");
-## modify i_nfs_mach to btree
-## inquire_equel(err = "errorno")
- if (err != 0)
- punt("cannot modify i_nfs_mach");
-##}
-
-
-do_filesys()
-##{
- register FILE *f;
-## char t_label[33];
-## int t_order;
-## char t_type[9];
-## char t_name[33];
-## int t_mach_id;
-## char t_access[2];
-## char t_mount[33];
-## int t_acl_id;
-## int t_filsys_id;
-## int t_phys_id;
-## int err;
-
- f = open_file("filesys");
- start_counter(5);
- t_filsys_id = 0;
-
- while(!feof(f)) {
- parse_str(f, t_label, 33);
- if (feof(f)) break;
- parse_sep(f);
- parse_str(f, t_type, 9);
- parse_sep(f);
- t_mach_id = parse_int(f);
- parse_sep(f);
- parse_str(f, t_name, 33);
- parse_sep(f);
- parse_str(f, t_mount, 33);
- parse_sep(f);
- parse_str(f, t_access, 2);
- parse_sep(f);
- t_acl_id = parse_int(f);
- parse_nl(f);
- t_filsys_id++;
- if (!strcmp(t_type, "NFS"))
- t_phys_id = match_phys(t_mach_id, t_name);
- else
- t_phys_id = 0;
-
- inc_count();
-## append filesys (
-## filsys_id = t_filsys_id,
-## phys_id = t_phys_id,
-## label = t_label,
-## type = t_type,
-## mach_id = t_mach_id,
-## name = t_name,
-## mount = t_mount,
-## access = t_access,
-## owner = USERSMS,
-## owners = t_acl_id,
-## createflg = 0,
-## lockertype = "UNKNOWN",
-## modtime = "now",
-## modby = USERSMS,
-## modwith = "convert")
- }
- end_counter();
- (void) fclose(f);
-## modify filesys to cbtree unique on filsys_id
-## inquire_equel(err = "errorno")
- if (err != 0)
- punt("cannot modify filesys");
-## index on filesys is i_fil_name (label)
-## inquire_equel(err = "errorno")
- if (err != 0)
- punt("cannot index filesys on label");
-## modify i_fil_name to hash
-## inquire_equel(err = "errorno")
- if (err != 0)
- punt("cannot modify i_fil_name");
-## index on filesys is i_fil_mach (mach_id)
-## inquire_equel(err = "errorno")
- if (err != 0)
- punt("cannot index filesys on mach_id");
-## modify i_fil_mach to btree
-## inquire_equel(err = "errorno")
- if (err != 0)
- punt("cannot modify i_fil_mach");
-## index on filesys is i_fil_phys (phys_id)
-## inquire_equel(err = "errorno")
- if (err != 0)
- punt("cannot index filesys on phys_id");
-## modify i_fil_phys to btree
-## inquire_equel(err = "errorno")
- if (err != 0)
- punt("cannot modify i_fil_phys");
-##}
-
-
-do_nfsquota()
-##{
- register FILE *f;
-## int t_users_id;
-## int t_mach_id;
-## char t_device[17];
-## int t_quota;
-## int t_filsys_id;
-
- f = open_file("nfsquota");
- start_counter(1);
-## range of f is filesys
-## range of u is users
-## range of n is nfsphys
-
- while(!feof(f)) {
- t_users_id = parse_int(f);
- if (feof(f)) break;
- parse_sep(f);
- t_mach_id = parse_int(f);
- parse_sep(f);
- parse_str(f, t_device, 17);
- parse_sep(f);
- t_quota = parse_int(f);
- parse_nl(f);
- t_filsys_id = match_filsys(t_mach_id, t_device, t_users_id);
-
- inc_count();
-## append nfsquota (
-## users_id = t_users_id,
-## filsys_id = t_filsys_id,
-## quota = t_quota,
-## modtime = "now",
-## modby = USERSMS,
-## modwith = "convert")
- }
- end_counter();
- (void) fclose(f);
-##}
-
-
-do_pobox()
-##{
- register FILE *f;
-## int t_users_id;
-## char t_type[9];
-## int t_mach_id;
-## char t_box[33];
-## char t_created[26];
-## char t_string[129];
-## int t_string_id;
-## char t_machine[65];
-## int rowcount;
-
- f = open_file("pobox");
-## range of u is users
-## range of m is machine
- start_counter(5);
-## retrieve (t_string_id = max(strings.string_id))
- t_string_id++;
-
- while (!feof(f)) {
- t_users_id = parse_int(f);
- if (feof(f)) break;
- parse_sep(f);
- parse_str(f, t_type, 9);
- parse_sep(f);
- t_mach_id = parse_int(f);
- parse_sep(f);
- parse_str(f, t_box, 33);
- parse_sep(f);
- parse_str(f, t_created, 26);
- parse_nl(f);
-
- inc_count();
- if (!strcmp(t_type, "POP")) {
-## repeat replace users (
-## potype = @t_type,
-## pop_id = @t_mach_id,
-## pmodtime = @t_created,
-## pmodwith = "convert",
-## pmodby = USERSMS
-## ) where users.users_id = @t_users_id
- } else if (!strcmp(t_type, "LOCAL")) {
-## repeat retrieve (t_machine = machine.name)
-## where machine.mach_id = @t_mach_id
-## repeat replace users (
-## potype = "SMTP",
-## pop_id = 0,
-## box_id = @t_string_id,
-## pmodtime = @t_created,
-## pmodwith = "convert",
-## pmodby = USERSMS
-## ) where users.users_id = @t_users_id
-## append strings (string_id = t_string_id,
-## string = t_box + "@" + t_machine)
- t_string_id++;
- } else if (!strcmp(t_type, "FOREIGN")) {
-## repeat retrieve (t_string = strings.string)
-## where strings.string_id = @t_mach_id
-## repeat replace users (
-## potype = "SMTP",
-## pop_id = 0,
-## box_id = @t_string_id,
-## pmodtime = @t_created,
-## pmodwith = "convert",
-## pmodby = USERSMS
-## ) where users.users_id = @t_users_id
-## append strings (string_id = t_string_id,
-## string = t_box + "@" + t_string)
- t_string_id++;
- } else {
- printf("Unknown pobox type: %s\n", t_type);
- }
- }
- end_counter();
- fclose(f);
-##}
-
-
-do_services()
-##{
- register FILE *f;
-## char t_name[17];
-## char t_protocol[9];
-## int t_port;
-## char t_desc[65];
-
- f = open_file("services");
- start_counter(5);
-
- while(!feof(f)) {
- parse_str(f, t_name, 17);
- if (feof(f)) break;
- parse_sep(f);
- parse_str(f, t_protocol, 9);
- parse_sep(f);
- t_port = parse_int(f);
- parse_sep(f);
- parse_str(f, t_desc, 65);
- parse_nl(f);
-
- inc_count();
-## append services (
-## name = t_name,
-## protocol = t_protocol,
-## port = t_port,
-## desc = t_desc,
-## modtime = "now",
-## modby = USERSMS,
-## modwith = "convert")
- }
- (void) fclose(f);
- end_counter();
-##}
-
-
-do_printcap()
-##{
- register FILE *f;
-## char t_name[17];
-## char t_pcap[513];
-
- f = open_file("printcap");
- start_counter(1);
-
- while(!feof(f)) {
- parse_str(f, t_name, 17);
- if (feof(f)) break;
- parse_sep(f);
- parse_str(f, t_pcap, 513);
- parse_nl(f);
-
- inc_count();
-## append printcap (
-## name = t_name,
-## mach_id = 0,
-## dir = "/usr/spool/printer/" + t_name,
-## rp = t_name,
-## modtime = "now",
-## modby = USERSMS,
-## modwith = "convert")
- }
- end_counter();
- (void) fclose(f);
-##}
-
-
-do_values()
-##{
- register FILE *f;
-## char t_name[33];
-## int t_value;
-
- f = open_file("values");
- while(!feof(f)) {
- parse_str(f, t_name, 33);
- if (feof(f)) break;
- parse_sep(f);
- t_value = parse_int(f);
- parse_nl(f);
-
- if (strcmp(t_name, "def_quota") &&
- strcmp(t_name, "gid") &&
- strcmp(t_name, "uid"))
- continue;
-
-## replace values (value = t_value) where values.name = t_name
- }
- (void) fclose(f);
-##}
-
-
-do_alias()
-##{
- register FILE *f;
-## char t_name[33];
-## char t_type[17];
-## char t_trans[129];
-
- f = open_file("alias");
- start_counter(5);
- while(!feof(f)) {
- parse_str(f, t_name, 33);
- if (feof(f)) break;
- parse_sep(f);
- parse_str(f, t_type, 17);
- parse_sep(f);
- parse_str(f, t_trans, 129);
- parse_nl(f);
- inc_count();
-
- if (!strcmp(t_type, "TYPE") ||
- !strcmp(t_type, "TYPEDATA"))
- continue;
-
-## append alias (
-## name = t_name,
-## type = t_type,
-## trans = t_trans)
- }
- end_counter();
- (void) fclose(f);
-##}
-
+++ /dev/null
-# $Source$
-# $Header$
-#
-# This converts the file used to originally create the database
-# into a list of tables.
-
-BEGIN { print "/* This file is automatically generated */";
- print "/* Do not edit */";
- print "char *tables[] = {";
-}
-
-/^CREATE TABLE/ { printf " \"%s\",\n", $3; }
-
-END { print " 0,";
- print "};"; }
+++ /dev/null
-index on users is i_usr_name (first, last)
-modify i_usr_name to hash
-index on users is i_usr_uid (uid)
-modify i_usr_uid to btree
-index on users is i_usr_pop (pop_id)
-modify i_usr_pop to btree
-
-modify machine to cbtree unique on mach_id
-index on machine is i_mac_name (name)
-modify i_mac_name to btree
-
-modify cluster to cbtree unique on clu_id
-index on cluster is i_clu_name (name)
-modify i_clu_name to btree
-
-modify mcmap to cbtree on clu_id
-index on mcmap is i_mcm_mach (mach_id)
-modify i_mcm_mach to cbtree
-
-modify svc to cbtree on clu_id
-
-modify servers to btree on name
-
-index on list is i_lis_gid (gid)
-modify i_lis_gid to btree
-
-modify members to hash on member_id, member_type
-index on members is i_mem_list (list_id)
-modify i_mem_list to hash
-
-modify strings to cbtree unique on string_id
-index on strings is i_str_name (string)
-modify i_str_name to hash
-
-index on filesys is i_fil_grp (owners)
-modify i_fil_grp to btree
-
-modify quota to cbtree on entity_id
-index on quota is i_qot_fil (filsys_id)
-modify i_qot_fil to cbtree
-index on quota is i_qot_phys (phys_id)
-modify i_qot_phys to cbtree
-
-modify zephyr to cbtree unique on class
-
-modify hostaccess to cbtree unique on mach_id
-
-modify printcap to cbtree on name
-index on printcap is i_pcp_mach (mach_id)
-
-modify capacls to cbtree on tag
+++ /dev/null
-CREATE INDEX i_usr_login ON users (login)
-CREATE INDEX i_usr_name ON users (first, last)
-CREATE INDEX i_usr_last ON users (last, first)
-CREATE INDEX i_usr_uid ON users (uid)
-CREATE INDEX i_usr_pop ON users (pop_id)
-CREATE INDEX i_krb_str ON krbmap (string_id)
-CREATE INDEX i_mac_name ON machine (name)
-CREATE INDEX i_clu_name ON cluster (name)
-CREATE INDEX i_mcm_mach ON mcmap (mach_id)
-CREATE INDEX i_sho_mach ON serverhosts (mach_id)
-CREATE INDEX i_lis_name ON list(name)
-CREATE INDEX i_lis_mail ON list (maillist)
-CREATE INDEX i_lis_group ON list (group)
-CREATE INDEX i_lis_gid ON list (gid)
-CREATE INDEX i_imem_list ON imembers (list_id)
-CREATE INDEX i_str_name ON strings (string)
-CREATE INDEX i_nfs_mach ON nfsphys (mach_id)
-CREATE INDEX i_fil_name ON filesys (label)
-CREATE INDEX i_fil_mach ON filesys (mach_id)
-CREATE INDEX i_fil_phys ON filesys (phys_id)
-CREATE INDEX i_fil_grp ON filesys (owners)
-CREATE INDEX i_fil_user ON filesys (owner)
-CREATE INDEX i_fsg_filsys ON fsgroup (filsys_id)
-CREATE INDEX i_qot_fil ON quota (filsys_id)
-CREATE INDEX i_qot_phys ON quota (phys_id)
-CREATE INDEX i_pcp_mach ON printcap (mach_id)
+++ /dev/null
-
-#include <stdio.h>
-#include <moira.h>
-
-struct mem {
- int parent;
- int child;
- short ref;
- char direct;
- char ctype;
-};
-
-
-main()
-{
- struct save_queue *sq, *load_members();
-
-## ingres sms
- printf("Loading LIST members...\n");
- sq = load_members();
- printf("Computing LIST memberships...\n");
- do_members(sq);
- printf("Computing full memberships...\n");
- do_all_members(sq);
- printf("Done\n");
- exit(0);
-}
-
-struct save_queue *load_members()
-##{
- register struct mem *m;
- struct mem *new_mem();
- struct save_queue *sq;
-## int lid, mid;
-## char mtype[9];
-
- sq = sq_create();
-## range of m is members
-## retrieve (lid = m.list_id, mid = m.member_id, mtype = m.member_type) {
- m = new_mem();
- m->parent = lid;
- m->child = mid;
- m->ref = 0;
- m->direct = 1;
- m->ctype = mtype[0];
- sq_save_data(sq, m);
-## }
- return(sq);
-##}
-
-struct mem *new_mem()
-{
- static int count = 0;
- static struct mem *m = NULL;
- struct mem *ret;
-
- if (m == NULL || count <= 0) {
- m = malloc(100 * sizeof(struct mem));
- if (m == NULL)
- printf("Out of memory!\n");
- count = 100;
- }
- ret = m++;
- count--;
- return(ret);
-}
-
-
-#define MAXLINK 100
-
-do_members(sq)
-struct save_queue *sq;
-##{
- struct mem *m;
-## int cid, pid, id, exists;
- int descendants[MAXLINK], ancestors[MAXLINK];
- int dcount, acount, a, d;
-
-## range of m is imembers
- while (sq_get_data(sq, &m)) {
- if (m->ctype != 'L')
- continue;
- cid = m->child;
- pid = m->parent;
- dcount = 0;
- descendants[dcount++] = cid;
-## repeat retrieve (id = m.member_id)
-## where m.list_id = @cid {
- descendants[dcount++] = id;
-## }
- acount = 0;
- ancestors[acount++] = pid;
-## repeat retrieve (id = m.list_id)
-## where m.member_id = @pid {
- ancestors[acount++] = id;
-## }
- if (dcount >= MAXLINK | acount >= MAXLINK)
- printf("too many links working on %d -> %d\n", cid, pid);
- for (d = 0; d < dcount; d++) {
- for (a = 0; a < acount; a++) {
- if ((cid = descendants[d]) == (pid = ancestors[a]))
- printf("LOOP! on %d\n", cid);
-## repeat retrieve (exists = any(m.ref_count where m.list_id = @pid
-## and m.member_id = @cid
-## and m.member_type = "LIST"))
- if (exists) {
- if (a == 0 && d == 0)
-## replace m (ref_count = m.ref_count+1, direct = 1)
-## where m.list_id = pid and m.member_id = cid
- else
-## replace m (ref_count = m.ref_count+1)
-## where m.list_id = pid and m.member_id = cid
- } else {
- if (a == 0 && d == 0)
-## append imembers (list_id=pid, member_id = cid, direct = 1,
-## member_type="LIST", ref_count = 1)
- else
-## append imembers (list_id=pid, member_id = cid,
-## member_type="LIST", ref_count = 1)
- }
- }
- }
- }
-##}
-
-
-
-do_all_members(sq)
-struct save_queue *sq;
-##{
- struct mem *mem;
- register struct mem *m;
-## int cid, pid, id, exists;
-## char *ctype;
- int descendants[MAXLINK], ancestors[MAXLINK];
- int dcount, acount, a, d;
-
-## range of m is imembers
- sq->q_lastget = 0; /* rewind queue */
- while (sq_get_data(sq, &mem)) {
- m = mem;
- switch (m->ctype) {
- case 'L':
- continue;
- case 'S':
- ctype = "STRING";
- break;
- case 'U':
- ctype = "USER";
- break;
- case 'K':
- ctype = "KERBEROS";
- break;
- default:
- printf("bad type %c on member %d\n", m->ctype, m->child);
- }
-
- cid = m->child;
- pid = m->parent;
- acount = 0;
- ancestors[acount++] = pid;
-## repeat retrieve (id = m.list_id)
-## where m.member_id = @pid and m.member_type = "LIST" {
- ancestors[acount++] = id;
-## }
- if (acount >= MAXLINK)
- printf("too many links working on %d -> %d\n", cid, pid);
- for (a = 0; a < acount; a++) {
- pid = ancestors[a];
-## repeat retrieve (exists = any(m.ref_count where m.list_id = @pid
-## and m.member_id = @cid
-## and m.member_type = @ctype))
- if (exists) {
- if (a == 0)
-## replace m (ref_count = m.ref_count+1, direct = 1)
-## where m.list_id = pid and m.member_id = cid
- else
-## replace m (ref_count = m.ref_count+1)
-## where m.list_id = pid and m.member_id = cid
- } else {
- if (a == 0)
-## append imembers (list_id=pid, member_id = cid, direct = 1,
-## member_type=ctype, ref_count = 1)
- else
-## append imembers (list_id=pid, member_id = cid,
-## member_type=ctype, ref_count = 1)
- }
- }
- }
-##}
+++ /dev/null
-/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/* For copying and distribution information, please see the file */
-/* <mit-copyright.h>. */
-
-#include <mit-copyright.h>
-#include <stdio.h>
-
-char *malloc(), *strsave();
-
-struct np {
- struct np *next; /* this must be the first field */
- int id;
- char *dir;
-};
-struct np **nfsphys = NULL;
-
-int match_phys(mach, directory)
-int mach;
-char *directory;
-{
- struct np *p, *n;
-
- if (nfsphys == NULL)
-## {
-## int id, maxmach, mid;
-## char dir[65];
-
- printf("Building NFSphys table\n");
-## range of n is nfsphys
-## retrieve (maxmach = max(machine.mach_id))
- maxmach++;
- nfsphys = (struct np **) malloc(maxmach * sizeof(struct np *));
- bzero(nfsphys, maxmach * sizeof(struct np *));
-## retrieve (id = n.nfsphys_id, mid = n.mach_id, dir = n.#dir)
-## sort by #dir:d {
- n = (struct np *) malloc(sizeof(struct np));
- n->next = NULL;
- n->id = id;
- n->dir = strsave(strtrim(dir));
- p = (struct np *)&nfsphys[mid];
- while (p->next)
- p = p->next;
- p->next = n;
-## }
-## }
-
- if ((n = nfsphys[mach]) == NULL)
- return(0);
- while (n) {
- if (!strncmp(directory, n->dir, strlen(n->dir)))
- return(n->id);
- n = n->next;
- }
- return(0);
-}
-
-
-##int match_filsys(mach, device, user)
-##int mach;
-##char *device;
-##int user;
-##{
-## int mid, fid;
-## char dev[33];
-
-## repeat retrieve (fid = f.filsys_id, mid = f.mach_id, dev = n.#device)
-## where f.label = u.login and n.nfsphys_id = f.phys_id and
-## u.users_id = @user
- if (mid == mach && !strcmp(device, strtrim(dev)))
- return(fid);
- fid = 0;
-## repeat retrieve unique (fid = f.filsys_id) where f.mach_id = @mach and
-## f.name = @device
- if (fid == 0) {
-## repeat retrieve unique (fid = f.filsys_id) where f.mach_id = @mach and
-## f.phys_id = n.nfsphys_id and n.#device = @device
- }
- return(fid);
-##}
+++ /dev/null
-/* $Header$
- *
- * Creates a new sms database
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- */
-
-#include <mit-copyright.h>
-#include <stdio.h>
-#include "../server/query.h"
-
-static int ingres_errno = 0;
-int ingerr();
-
-extern char *tables[];
-extern struct query Queries2[];
-extern int QueryCount2;
-
-char *values[] = { "users_id", "mach_id", "clu_id", "list_id",
- "nfsphys_id", "filsys_id", "strings_id", "dcm_enable",
- 0 };
-
-struct alias { char *name;
- char *type;
- char *trans;
- } aliases[] = {
- {"ace_type", "TYPE", "KERBEROS"},
- {"ace_type", "TYPE", "LIST"},
- {"ace_type", "TYPE", "NONE"},
- {"ace_type", "TYPE", "USER"},
- {"alias", "TYPE", "FILESYS"},
- {"alias", "TYPE", "PALLADIUM"},
- {"alias", "TYPE", "TYPE"},
- {"alias", "TYPE", "SERVICE"},
- {"alias", "TYPE", "TYPEDATA"},
- {"alias", "TYPE", "VALUE"},
- {"boolean", "TYPE", "FALSE"},
- {"boolean", "TYPE", "DONTCARE"},
- {"boolean", "TYPE", "TRUE"},
- {"class", "TYPE", "STAFF"},
- {"class", "TYPE", "1990"},
- {"class", "TYPE", "1991"},
- {"class", "TYPE", "1992"},
- {"class", "TYPE", "1993"},
- {"class", "TYPE", "FACULTY"},
- {"class", "TYPE", "G"},
- {"class", "TYPE", "GUEST"},
- {"class", "TYPE", "TEST"},
- {"class", "TYPE", "SYSTEM"},
- {"filesys", "TYPE", "ERR"},
- {"filesys", "TYPE", "FSGROUP"},
- {"filesys", "TYPE", "NFS"},
- {"filesys", "TYPE", "RVD"},
- {"filesys", "TYPE", "AFS"},
- {"fs_access_AFS", "TYPE", "w"},
- {"fs_access_AFS", "TYPE", "n"},
- {"fs_access_NFS", "TYPE", "r"},
- {"fs_access_NFS", "TYPE", "n"},
- {"fs_access_NFS", "TYPE", "w"},
- {"fs_access_RVD", "TYPE", "r"},
- {"fs_access_RVD", "TYPE", "x"},
- {"gaus", "TYPE", "LIST"},
- {"gaus", "TYPE", "USER"},
- {"gaus", "TYPE", "RLIST"},
- {"gaus", "TYPE", "RUSER"},
- {"lockertype", "TYPE", "COURSE"},
- {"lockertype", "TYPE", "HOMEDIR"},
- {"lockertype", "TYPE", "OTHER"},
- {"lockertype", "TYPE", "PROJECT"},
- {"lockertype", "TYPE", "SYSTEM"},
- {"mac_type", "TYPE", "MAC"},
- {"mac_type", "TYPE", "NEXT"},
- {"mac_type", "TYPE", "PMAX"},
- {"mac_type", "TYPE", "RT"},
- {"mac_type", "TYPE", "VAX"},
- {"member", "TYPE", "KERBEROS"},
- {"member", "TYPE", "LIST"},
- {"member", "TYPE", "STRING"},
- {"member", "TYPE", "USER"},
- {"pobox", "TYPE", "SMTP"},
- {"pobox", "TYPE", "NONE"},
- {"pobox", "TYPE", "POP"},
- {"quota_type", "TYPE", "USER"},
- {"quota_type", "TYPE", "GROUP"},
- {"quota_type", "TYPE", "ANY"},
- {"rmember", "TYPE", "LIST"},
- {"rmember", "TYPE", "STRING"},
- {"rmember", "TYPE", "USER"},
- {"rmember", "TYPE", "KERBEROS"},
- {"rmember", "TYPE", "RLIST"},
- {"rmember", "TYPE", "RSTRING"},
- {"rmember", "TYPE", "RUSER"},
- {"rmember", "TYPE", "RKERBEROS"},
- {"service", "TYPE", "REPLICAT"},
- {"service", "TYPE", "REPLICATED"},
- {"service", "TYPE", "UNIQUE"},
- {"slabel", "TYPE", "LPR"},
- {"slabel", "TYPE", "KERBEROS"},
- {"slabel", "TYPE", "USRLIB"},
- {"slabel", "TYPE", "SYSLIB"},
- {"slabel", "TYPE", "ZEPHYR"},
- {"ANY", "TYPEDATA", "none"},
- {"KERBEROS", "TYPEDATA", "string"},
- {"GROUP", "TYPEDATA", "list"},
- {"LIST", "TYPEDATA", "list"},
- {"NONE", "TYPEDATA", "none"},
- {"POP", "TYPEDATA", "machine"},
- {"RLIST", "TYPEDATA", "list"},
- {"RSTRING", "TYPEDATA", "string"},
- {"RUSER", "TYPEDATA", "user"},
- {"SMTP", "TYPEDATA", "string"},
- {"STRING", "TYPEDATA", "string"},
- {"USER", "TYPEDATA", "user"},
- 0 };
-
-
-main(argc, argv)
-int argc;
-char **argv;
-{
- char buffer[256];
-## char *table, *user, *value, *query, *trans, *type, *db;
-## int i, flag;
-
- if (argc == 2)
- db = argv[1];
- else
- db = "sms";
- IIseterr(ingerr);
-## ingres db
- if (ingres_errno) {
- printf("Unable to open the database\n");
- exit(1);
- }
-
- strcpy(buffer, "root");
- user = buffer;
- while (buffer[0]) {
- for (i = 0; table = tables[i]; i++) {
-## define permit all on table to user
- if (ingres_errno) {
- printf("Unable to give %s permission to access table %s\n",
- user, table);
- exit(1);
- }
- }
- printf("Enter the name of another user to be given direct access to\n");
- printf("the database, or [RETURN] if none: ");
- fflush(stdout);
- gets(user);
- }
-
- for (i = 0; table = tables[i]; i++) {
-## repeat append tblstats (#table = @table, modtime = "now")
- if (ingres_errno) {
- printf("Unable to initialize tblstats for %s\n", table);
- exit(1);
- }
- }
-
- for (i = 0; value = values[i]; i++) {
-## repeat append values (#name = @value, #value = 1)
- if (ingres_errno) {
- printf("Unable to install initial value of %s\n", value);
- exit(1);
- }
- }
-
- printf("What is the starting UID to assign: ");
- fflush(stdout);
- gets(buffer);
- i = atoi(buffer);
-## append values (#name = "uid", #value = i)
- if (ingres_errno) {
- printf("Unable to install value for uid\n");
- exit(1);
- }
-
- printf("What is the starting GID to assign: ");
- fflush(stdout);
- gets(buffer);
- i = atoi(buffer);
-## append values (#name = "gid", #value = i)
- if (ingres_errno) {
- printf("Unable to install value for gid\n");
- exit(1);
- }
-
- printf("What is the default NFS quota to assign: ");
- fflush(stdout);
- gets(buffer);
- i = atoi(buffer);
-## append values (#name = "def_quota", #value = i)
- if (ingres_errno) {
- printf("Unable to install value for def_quota\n");
- exit(1);
- }
-
- /* place holder records */
-## append users (login = "[nobody]", potype="NONE")
- if (ingres_errno) {
- printf("Unable to install 0 user\n");
- exit(1);
- }
-## append machine (name = "[NONE]", #type="NONE")
- if (ingres_errno) {
- printf("Unable to install 0 machine\n");
- exit(1);
- }
-## append cluster (name = "[unassigned]")
- if (ingres_errno) {
- printf("Unable to install 0 cluster\n");
- exit(1);
- }
-## append list (name = "[none]", acl_type = "NONE")
- if (ingres_errno) {
- printf("Unable to install 0 list\n");
- exit(1);
- }
-## append filesys (label = "[none]", #type = "NONE")
- if (ingres_errno) {
- printf("Unable to install 0 filesys\n");
- exit(1);
- }
-## append nfsphys (device = "/dev/null")
- if (ingres_errno) {
- printf("Unable to install 0 nfsphys\n");
- exit(1);
- }
-
- /* magic for ALL_USERS */
-## append users (login = "default", users_id = 1, potype="NONE")
- if (ingres_errno) {
- printf("Unable to install default user\n");
- exit(1);
- }
-## append list (name = "default", list_id = 1, acl_type = "NONE")
- if (ingres_errno) {
- printf("Unable to install default list\n");
- exit(1);
- }
-## append imembers (list_id = 1, member_type = "USER", member_id = 1,
-## ref_count = 1, direct = 1)
- if (ingres_errno) {
- printf("Unable to install default user on default list\n");
- exit(1);
- }
-
- /* Privileged users */
-## append users (login = "root", users_id = 2, potype="NONE")
- if (ingres_errno) {
- printf("Unable to install root user\n");
- exit(1);
- }
-## append list (name = "dbadmin", list_id = 2, acl_type = "LIST", acl_id = 2)
- if (ingres_errno) {
- printf("Unable to install default dbadmin list\n");
- exit(1);
- }
-
- printf("What is the name of a privileged user: ");
- fflush(stdout);
- gets(buffer);
- user = buffer;
-## append users (login = user, users_id = 3, potype="NONE")
- if (ingres_errno) {
- printf("Unable to install user %s\n", buffer);
- exit(1);
- }
-## append imembers (list_id = 2, member_type = "USER", member_id = 2,
-## ref_count = 1, direct = 1)
- if (ingres_errno) {
- printf("Unable to put user root on list dbadmin\n");
- exit(1);
- }
-## append imembers (list_id = 2, member_type = "USER", member_id = 3,
-## ref_count = 1, direct = 1)
- if (ingres_errno) {
- printf("Unable to put user %s on list dbadmin\n", buffer);
- exit(1);
- }
-
- /* And the capacls */
- for (i = 0; i < QueryCount2; i++) {
- query = Queries2[i].name;
- value = Queries2[i].shortname;
-## repeat append capacls (capability = @query, tag = @value, list_id = 2)
- if (ingres_errno) {
- printf("Unable to install query ACL for %s (%s)\n", query, value);
- exit(1);
- }
- }
-## append capacls (capability = "trigger_dcm", tag = "tdcm", list_id = 2)
-
- /* and the aliases */
- for (i = 0; aliases[i].name ; i++) {
- value = aliases[i].name;
- type = aliases[i].type;
- trans = aliases[i].trans;
-## repeat append alias (#name = @value, #type = @type, #trans = @trans)
- }
-
-## exit
- printf("done.\n");
- exit(0);
-}
-
-
-/*
- * ingerr: (supposedly) called when Ingres indicates an error.
- * I have not yet been able to get this to work to intercept a
- * database open error.
- */
-
-int ingerr(num)
- int *num;
-{
- ingres_errno = *num;
- return *num;
-}
-
-
-/* dummy routines */
-int access_user() {}
-int access_login() {}
-int access_list() {}
-int access_visible_list() {}
-int access_vis_list_by_name() {}
-int access_member() {}
-int access_qgli() {}
-int access_service() {}
-int access_filesys() {}
-int setup_ausr() {}
-int setup_dusr() {}
-int setup_spop() {}
-int setup_dpob() {}
-int setup_dmac() {}
-int setup_dclu() {}
-int setup_alis() {}
-int setup_dlis() {}
-int setup_dsin() {}
-int setup_dshi() {}
-int setup_afil() {}
-int setup_ufil() {}
-int setup_dfil() {}
-int setup_dnfp() {}
-int setup_dqot() {}
-int setup_sshi() {}
-int setup_akum() {}
-int followup_fix_modby() {}
-int followup_ausr() {}
-int followup_gpob() {}
-int followup_glin() {}
-int followup_aqot() {}
-int followup_gzcl() {}
-int followup_gsha() {}
-int followup_gqot() {}
-int set_modtime() {}
-int set_modtime_by_id() {}
-int set_finger_modtime() {}
-int set_pobox_modtime() {}
-int set_uppercase_modtime() {}
-int set_mach_modtime_by_id() {}
-int set_cluster_modtime_by_id() {}
-int set_serverhost_modtime() {}
-int set_nfsphys_modtime() {}
-int set_filesys_modtime() {}
-int set_zephyr_modtime() {}
-int set_pobox() {}
-int get_list_info() {}
-int add_member_to_list() {}
-int delete_member_from_list() {}
-int get_ace_use() {}
-int qualified_get_lists() {}
-int get_members_of_list() {}
-int qualified_get_server() {}
-int qualified_get_serverhost() {}
-int trigger_dcm() {}
-int count_members_of_list() {}
-int get_lists_of_member() {}
-int register_user() {}
-int followup_gpce() {}
+++ /dev/null
-#! /bin/sh
-
-# $Header$
-#
-# Ingres does not come with a utility to rename a database, so we do
-# it this way. First, rename the directory containing the datafiles.
-# Then run the program to restore after a system crash. It will cause
-# the dbdb directory to match where the files are, renaming the
-# database.
-
-if (test $# != 2) then
- echo Usage: $0 oldname newname
- exit 1
-fi
-
-OLDNAME=$1
-NEWNAME=$2
-INGRES=/usr/rtingres/data/default
-
-if (test ! -d $INGRES/$OLDNAME) then
- echo Database $OLDNAME does not exist!
- exit 1
-fi
-
-if (test -r $INGRES/$NEWNAME) then
- echo Database $NEWNAME already exists!
- exit 1
-fi
-
-if (mv $INGRES/$OLDNAME $INGRES/$NEWNAME) then
- true
-else
- echo Unable to move database
- exit 1
-fi
-
-echo | /usr/rtingres/bin/finddbs -r
+++ /dev/null
-#! /bin/sh
-
-PATH=/etc:/usr/ucb:/bin:/usr/bin:.:/etc/athena:/bin/athena
-
-DATADIR=$1
-TMPDIR=/tmp/report.tmp
-mkdir ${TMPDIR}
-cd ${TMPDIR}
-
-awk -F\| '$8 != 3 {print $10} \
- ($8==1 || $8==6) && $26=="POP" {pop += 1} \
- ($8==1 || $8==6) && $26=="SMTP" {smtp += 1} \
- ($8==1 || $8==6) && $26=="NONE" {nopob += 1} \
- END { nopob -= 1; total = pop + smtp + nopob; \
- printf("%5d Active users by pobox:\n", total) > "pobox.summary"; \
- printf("\t%5d POP boxes\t\t%2d%%\n", pop, (100 * pop + total/2)/total) > "pobox.summary"; \
- printf("\t%5d foreign boxes\t%2d%%\n", smtp, (100 * smtp + total/2)/total) > "pobox.summary"; \
- printf("\t%5d without boxes\t%2d%%\n", nopob, (100 * nopob + total/2)/total) > "pobox.summary";} \
-' < ${DATADIR}/users | sort | uniq -c | sort -r -n > ./users.all
-awk -F\| '$8==1 {print $10}' < ${DATADIR}/users | sort | uniq -c | sort -r -n > ./users.active
-
-cat ./users.active ./users.all | awk \
-' BEGIN {all=0; lastx=100000;}
- all==0 && lastx<$1 {all += 1} \
- all==0 && NF==2 {active[$2]=$1; lastx=$1} \
- all==1 && NF==2 {printf("\t%-8s %5d %5d %3d\n", $2, $1, active[$2], (100 * active[$2] + $1/2)/$1)} \
-' | grep -v "%" | sort +2rn | (echo " class total active %"; cat - -) > ./users.summary
-
-awk '{total+=$2;active+=$3}\
-END {printf("\t%-8s %5d %5d\n", "Totals", total, active)}' < ./users.summary > ./users.summary1
-cat users.summary1 >> users.summary
-
-awk -F\| ' \
- NR != 1 {total += 1; active += $3; public += $4; \
- hidden += $5; maillist += $6; group += $7;} \
- END { printf("%d Lists:\n", total); \
- printf("\t%5d active\t%2d%%\n", active, (100 * active)/total); \
- printf("\t%5d public\t%2d%%\n", public, (100 * public)/total); \
- printf("\t%5d hidden\t%2d%%\n", hidden, (100 * hidden)/total); \
- printf("\t%5d maillists\t%2d%%\n", maillist, (100 * maillist)/total); \
- printf("\t%5d groups\t%2d%%\n", group, (100 * group)/total);} \
-' < ${DATADIR}/list > ./list.summary
-
-awk '{total+=1}\
-END {printf("%5d Clusters\n", total)}' < ${DATADIR}/cluster > ./cluster.summary
-
-
-awk -F\| ' \
- NR != 1 {total += 1; t[$5] += 1; l[$14] += 1;} \
- $2!=0 {printf("%s\n",$2) > "filesys.phys" } \
- END{ printf("%d Filesystems by protocol type:\n", total); \
- printf("\t%5d NFS\t%2d%%\n", t["NFS"], (100 * t["NFS"] + total/2)/total); \
- printf("\t%5d AFS\t%2d%%\n", t["AFS"], (100 * t["AFS"] + total/2)/total); \
- printf("\t%5d RVD\t%2d%%\n", t["RVD"], (100 * t["RVD"] + total/2)/total); \
- printf("\t%5d FSGROUP\t%2d%%\n", t["FSGROUP"], (100 * t["FSGROUP"] + total/2)/total); \
- printf("\t%5d MUL\t%2d%%\n", t["MUL"], (100 * t["MUL"] + total/2)/total); \
- printf("\t%5d ERROR\t%2d%%\n\n", t["ERR"], (100 * t["ERR"] + total/2)/total); \
- printf("%d Filesystems by locker type:\n", total); \
- printf("\t%5d HOMEDIR\t%2d%%\n", l["HOMEDIR"], (100 * l["HOMEDIR"] + total/2)/total); \
- printf("\t%5d SYSTEM\t%2d%%\n", l["SYSTEM"], (100 * l["SYSTEM"])/total); \
- printf("\t%5d PROJECT\t%2d%%\n", l["PROJECT"], (100 * l["PROJECT"] + total/2)/total); \
- printf("\t%5d COURSE\t%2d%%\n", l["COURSE"], (100 * l["COURSE"])/total); \
- printf("\t%5d PERSONAL\t%2d%%\n", l["PERSONAL"], (100 * l["PERSONAL"] + total/2)/total); \
- printf("\t%5d ACTIVITY\t%2d%%\n", l["ACTIVITY"], (100 * l["ACTIVITY"] + total/2)/total); \
- printf("\t%5d EXTERN\t%2d%%\n", l["EXTERN"], (100 * l["EXTERN"] + total/2)/total); \
- printf("\t%5d OTHER\t%2d%%\n", l["OTHER"], (100 * l["OTHER"])/total); \
- } \
-' < ${DATADIR}/filesys > ./filesys.summary
-
-awk -F\| 'NR!=1 {total += 1; print $3} \
- END {printf("%5d Machines by type (workstations and servers):\n", total)>"machine.summary"} \
-'< ${DATADIR}/machine | sort | uniq -c | sort -r -n > machine.types
-awk '{printf("\t%-8s %4d\n", $2, $1)}' < machine.types >> machine.summary
-
-sort ./filesys.phys | uniq -c | awk '{printf("%s %s\n", $2, $1)}' > phys.num
-awk -F\| '{printf("%s %s\n", $2, $1)}' < ${DATADIR}/machine | sort > machine.num
-sed 's/\|/ /g' < ${DATADIR}/nfsphys | sort | join - phys.num | awk '{printf("%s %s %s %s\n", $2, $4, $6, $12)}' | sort | join - machine.num | awk '$3>0&&$4>0{printf("\t%8d %4d %s:%s\n", $3, $4, $5, $2)}' | sort -n -r > phys.usage
-
-awk -F\| ' \
- NR != 1 {total += 1; auth += $6} \
- END { printf("%5d Printers, %d with authentication (%d%%)\n", \
- total, auth, (100 * auth)/total) } \
-' < ${DATADIR}/printcap > ./printcap.summary
-
-echo " MOIRA SUMMARY" for `ls -ls ${DATADIR}/values | awk '{printf("%s %s", $6, $7)}'` > ./report.out
-echo "" >> report.out
-cat machine.summary >> report.out
-echo "" >> report.out
-cat cluster.summary >> report.out
-echo "" >> report.out
-cat printcap.summary >> report.out
-echo "" >> report.out
-awk '{printf("%5d Users by class (total in database, registered for use, %% registered):\n", $2)}' < users.summary1 >> report.out
-cat users.summary >> report.out
-echo "" >> report.out
-cat pobox.summary >> report.out
-echo "" >> report.out
-cat list.summary >> report.out
-echo "" >> report.out
-cat filesys.summary >> report.out
-echo "" >> report.out
-awk '{total+=1}\
-END {printf("%5d NFS Physical partitions in use (only those with quota shown):\n", total)}' < ${DATADIR}/nfsphys >> report.out
-echo ' allocated| no. of | Server and partition' >> report.out
-echo ' quota |lockers |' >> report.out
-cat phys.usage >> report.out
-
-cp report.out ${DATADIR}/report
-
-cd /
-rm -rf ${TMPDIR}
-
-exit 0
+++ /dev/null
-/* $Header$
- *
- * Moira database consistency checker
- *
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- */
-
-#include <mit-copyright.h>
-#include <stdio.h>
-#include <strings.h>
-#include <signal.h>
-#include "dbck.h"
-
-
-static char dbck_qc_rcsid[] = "$Header$";
-
-
-int debug = 0;
-int mode = MODE_ASK;
-int fast = 0;
-int warn = 1;
-int abort = 0;
-struct hash *users, *machines, *clusters, *lists, *filesys, *nfsphys;
-struct hash *strings, *members;
-##int dcmenable;
-struct save_queue *modtables, *sq_create();
-int interrupt();
-
-
-main(argc, argv)
-int argc;
-char **argv;
-{
- char **arg = argv;
-## char *database;
- int ingerr();
- int countonly = 0;
-
- database = "sms";
-
- while (++arg - argv < argc) {
- if (**arg == '-')
- switch ((*arg)[1]) {
- case 'd':
- debug = atoi((*arg)[2] ? *arg+2 : *++arg);
- break;
- case 'n':
- mode = MODE_NO;
- break;
- case 'y':
- mode = MODE_YES;
- break;
- case 'p':
- mode = MODE_PREEN;
- break;
- case 'a':
- mode = MODE_ASK;
- break;
- case 'c':
- countonly++;
- break;
- case 'f':
- fast++;
- break;
- case 'w':
- warn = 0;
- break;
- default:
- printf("Usage: %s [-d level] [-n] [-y] [-p] [-a] [-c] [-f] [-w] [database]\n",
- argv[0]);
- exit(1);
- }
- else
- database = *arg;
- }
- if (countonly)
- printf("Only doing counts\n");
- else if (fast)
- printf("Doing fast version (skipping some checks)\n");
- if (mode == MODE_NO)
- printf("Will NOT modify the database\n");
- else if (mode == MODE_PREEN)
- printf("Will fix simple things without asking\n");
- else if (mode == MODE_YES)
- printf("Will fix everything without asking\n");
- if (debug)
- printf("Debug level is %d\n", debug);
-
- setlinebuf(stdout);
-
- signal(SIGHUP, interrupt);
- signal(SIGQUIT, interrupt);
- signal(SIGINT, interrupt);
- modtables = sq_create();
-
- IIseterr(ingerr);
- printf("Opening database %s...", database);
- fflush(stdout);
-## ingres database
- printf("done\n");
-## retrieve (dcmenable = values.value) where values.name = "dcm_enable"
- dprintf("DCM disabled (was %d)\n", dcmenable);
-## replace values (value = 0) where values.name = "dcm_enable"
-
-## begin transaction
-
- if (!countonly) {
- phase1();
- phase2();
- phase3();
- } else {
- count_only_setup();
- }
- phase4();
-
-## end transaction
- cleanup();
- printf("Done.\n");
- exit(0);
-}
-
-ingerr(num)
-int *num;
-{
- printf("An ingres error occuurred, code %d\n", *num);
- printf("Aborting...\n");
- if (!abort) {
- abort++;
-## abort
- }
- exit(1);
-}
-
-
-int interrupt()
-##{
- printf("Signal caught\n");
- if (prompt("Save database changes")) {
- /* break out of a retrieve loop */
- IIbreak();
-## end transaction
- cleanup();
- exit(0);
- }
- printf("Aborting transaction\n");
- if (!abort) {
- abort++;
- /* break out of a retrieve loop */
- IIbreak();
-## abort
- }
-## replace values (value = dcmenable) where values.name = "dcm_enable"
-## exit
- exit(0);
-##}
-
-
-modified(table)
-char *table;
-{
- sq_save_unique_string(modtables, table);
-}
-
-cleanup()
-##{
-## char *tab;
-
- while (sq_get_data(modtables, &tab)) {
-## replace tblstats (modtime = "now") where tblstats.table = tab
- }
-## replace values (value = dcmenable) where values.name = "dcm_enable"
-## exit
-##}
-
-
-out_of_mem(msg)
-char *msg;
-{
- fprintf(stderr, "Out of memory while %s\n", msg);
-## end transaction
- cleanup();
- exit(1);
-}
+++ /dev/null
-/* $Header$
- *
- * User interface routines for dbck (Moira database consistency checker)
- *
- * (c) Copyright 1988 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 <stdio.h>
-#include "dbck.h"
-
-static char fix_qc_rcsid[] = "$Header$";
-
-
-##char *_table;
-##char *_idfield;
-
-##generic_ffunc(id)
-##int id;
-##{
-## int rowcount;
-
-## delete _table where _table._idfield = id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount > 0)
- printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
- else
- printf("Not deleted\n");
- modified(_table);
-##}
-
-
-generic_delete(sq, pfunc, table, idfield, preen)
-struct save_queue *sq;
-void (*pfunc)();
-char *table, *idfield;
-int preen;
-{
- _table = table;
- _idfield = idfield;
- generic_fix(sq, pfunc, "Delete", generic_ffunc, preen);
-}
-
-
-single_delete(table, idfield, id)
-char *table, *idfield;
-int id;
-{
- _table = table;
- _idfield = idfield;
- generic_ffunc(id);
-}
-
-
-##zero_fix(table, zrfield, idfield, id)
-##char *table, *zrfield, *idfield;
-##int id;
-##{
-## int rowcount;
-
-## replace table (zrfield = 0) where table.idfield = id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount > 0)
- printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
- else
- printf("Not fixed\n");
- modified(table);
-##}
-
-
-int single_fix(msg, preen)
-char *msg;
-int preen;
-{
- if (mode == MODE_PREEN)
- return(preen);
-
- switch (mode) {
- case MODE_ASK:
- if (!prompt(msg))
- break;
- case MODE_YES:
- return(1);
- break;
- case MODE_NO:
- ;
- }
- return(0);
-}
-
-
-generic_fix(sq, pfunc, msg, ffunc, preen)
-struct save_queue *sq;
-char *msg;
-int (*pfunc)(), (*ffunc)();
-int preen;
-{
- int id;
-
- while (sq_get_data(sq, &id)) {
- if ((*pfunc)(id) == 0 && single_fix(msg, preen))
- (*ffunc)(id);
- }
- sq_destroy(sq);
-}
-
-
-int prompt(msg)
-char *msg;
-{
- char buf[BUFSIZ];
-## extern int dcmenable;
-
- while (1) {
- printf("%s (Y/N/Q)? ", msg);
- fflush(stdout);
- gets(buf);
- if (buf[0] == 'Y' || buf[0] == 'y')
- return(1);
- if (buf[0] == 'N' || buf[0] == 'n')
- return(0);
- if (buf[0] == 'Q' || buf[0] == 'q') {
- if (prompt("Are you sure you want to quit")) {
- if (prompt("Save database changes")) {
-## end transaction
- cleanup();
- exit(0);
- } else {
-## abort
-## replace values (value = dcmenable)
-## where values.name = "dcm_enable"
-## exit
- exit(1);
- }
- }
- }
- }
-}
-
-
-/**
- ** set_next_object_id - set next object id in values table
- **
- ** Inputs: object - object name in values table and in objects
- ** table - name of table objects are found in
- **
- ** - called before an APPEND operation to set the next object id to
- ** be used for the new record to the next free value
- **
- **/
-
-int set_next_object_id(object, table)
- char *object;
- char *table;
-##{
-## char *name, *tbl;
-## int rowcount, exists, value;
-
- name = object;
- tbl = table;
-## range of v is values
-## repeat retrieve (value = v.#value) where v.#name = @name
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- return(MR_NO_ID);
-
-## retrieve (exists = any(tbl.name where tbl.name = value))
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- return(MR_NO_ID);
- while (exists) {
- value++;
- if (value > MAX_ID_VALUE)
- value = MIN_ID_VALUE;
-## retrieve (exists = any(tbl.name where tbl.name = value))
- }
-
- printf("setting ID %s to %d\n", name, value);
-## repeat replace v (#value = @value) where v.#name = @name
- modified("values");
- return(MR_SUCCESS);
-##}
-
-
-##generic_fix_id(table, idfield, txtfield, oldid, name)
-##char *table;
-##char *idfield;
-##char *txtfield;
-##int oldid;
-##char *name;
-##{
-## int rowcount, id;
-
- set_next_object_id(table, idfield);
-## retrieve (id = values.value) where values.#name = idfield
-## replace table (idfield = values.value) where values.#name = idfield and
-## table.idfield = oldid and table.txtfield = name
-## inquire_equel(rowcount = "rowcount")
- if (rowcount == 1)
- printf("Fixed\n");
- else
- printf("Not fixed, rowcount = %d\n", rowcount);
- modified(table);
- return(id);
-##}
+++ /dev/null
-/* $Header$
- */
-
-#include <stdio.h>
-#include <signal.h>
-#include <moira.h>
-
-#define FIXERRORS
-
-#define max(x, y) ((x) > (y) ? (x) : (y))
-
-struct member {
- int list_id;
- int member_id;
- union {
- short all;
- struct {
- short u_ref_count:12;
- unsigned short u_direct:1;
- unsigned short u_baddirect:1;
- unsigned short u_found:1;
- unsigned short u_scanned:1;
- } u_flags;
- } flags;
-} *find_member(), *allocmember();
-#define frefc flags.u_flags.u_ref_count
-#define fdirect flags.u_flags.u_direct
-#define fbaddirect flags.u_flags.u_baddirect
-#define ffound flags.u_flags.u_found
-#define fscanned flags.u_flags.u_scanned
-#define fall flags.all
-
-#define member2id(c, id) (((c & 0xff) << 24) | (id & 0xffffff))
-#define id2type(id) ((id >> 24) & 0xff)
-#define id2id(id) (id & 0xffffff)
-
-struct member_list {
- struct member_list *next;
- struct member *member;
-};
-
-struct hash *lists, *members;
-void fix_member(), display_member();
-int debug = 0, records = 0;
-
-
-main(argc, argv)
-int argc;
-char **argv;
-##{
- char buf[256];
-
-#ifdef DEBUG
- if (argc > 1)
- debug = atoi(argv[1]);
-#endif DEBUG
-
-## ingres sms
-## begin transaction
-## range of m is imembers
-
- lists = create_hash(10000);
- members = create_hash(10000);
- records = 0;
-
- load_members();
-#ifdef DEBUG
- if (debug > 3)
- hash_step(lists, display_member, NULL);
-#endif DEBUG
- verify_members();
- fix_members();
-
-#ifdef FIXERRORS
- printf("Commit changes (Y/N)?");
- fflush(stdout);
- fgets(buf, sizeof(buf), stdin);
- if (buf[0] == 'Y' || buf[0] == 'y') {
- printf("Ending transaction\n");
-## end transaction
- } else {
-#endif FIXERRORS
- printf("Aborting transaction\n");
-## abort
-#ifdef FIXERRORS
- }
-#endif FIXERRORS
-
-## exit
- printf("Done.\n");
-
- exit(0);
-##}
-
-
-
-load_members()
-##{
- struct member *m, *m1, *md, *ma;
- struct member_list *descendants, *ancestors, *desc, *ance, la, ld;
-## int list_id, member_id, ref_count, ref;
-## char mtype[9];
- struct save_queue *sq;
-
- printf("Loading members\n");
- sq = sq_create();
-
-## retrieve (list_id = m.#list_id, member_id = m.#member_id,
-## mtype = m.#member_type, ref_count = m.#ref_count)
-## where m.direct = 1 {
-#ifdef DEBUG
- if (debug > 5)
- printf("Working on list %d member %s %d refc %d\n",
- list_id, mtype, member_id, ref_count);
-#endif DEBUG
- if ((m = find_member(list_id, member2id(mtype[0], member_id))) == NULL) {
- m = allocmember();
- m->list_id = list_id;
- m->member_id = member2id(mtype[0], member_id);
- insert_list(m);
- insert_member(m);
- }
- m->fdirect = 1;
- la.next = (struct member_list *) hash_lookup(members,
- member2id('L', list_id));
- la.member = m;
- if (isinchain(m, la.next))
- ance = la.next;
- else
- ance = &la;
- if (mtype[0] == 'L')
- ld.next = (struct member_list *) hash_lookup(lists, member_id);
- else
- ld.next = NULL;
- ld.member = m;
- if (isinchain(m, ld.next))
- desc = ld.next;
- else
- desc = &ld;
-#ifdef DEBUG
- if (debug > 5)
- printf("%d ancestors, %d descendants\n",
- chainlen(ance), chainlen(desc));
-#endif DEBUG
- for (ancestors = ance; ancestors; ancestors = ancestors->next) {
- ma = ancestors->member;
- for (descendants = desc; descendants; descendants=descendants->next) {
- md = descendants->member;
- if (member2id('L', ma->list_id) == md->member_id)
- fprintf(stderr, "Loop detected! list %d member %d\n",
- md->list_id, ma->member_id);
- ref = md->frefc * ma->frefc;
- if (ref == 0) {
- ref = max(md->frefc, ma->frefc);
- if (ref == 0)
- ref = 1;
- }
-#ifdef DEBUG
- if (debug > 5)
- printf("Checking list %d member %d, ref = %d\n",
- ma->list_id, id2id(md->member_id), ref);
-#endif DEBUG
- if (m1 = find_member(ma->list_id, md->member_id)) {
- m1->frefc += ref;
-#ifdef DEBUG
- if (debug > 5)
- printf("set refc to %d (%d) on list %d, member %d\n",
- m1->frefc, ref, m1->list_id, id2id(m1->member_id));
-#endif DEBUG
- if (ma == m && md == m)
- m1->fdirect = 1;
- } else {
- m1 = allocmember();
- m1->list_id = ma->list_id;
- m1->member_id = md->member_id;
- m1->frefc = ref;
-#ifdef DEBUG
- if (debug > 5)
- printf("set new refc to %d (%d) on list %d, member %d\n",
- m1->frefc, ref, m1->list_id, id2id(m1->member_id));
-#endif DEBUG
- sq_save_data(sq, m1);
- }
- }
- }
- while (sq_get_data(sq, &m)) {
- insert_list(m);
- insert_member(m);
- }
- sq_destroy(sq);
- sq = sq_create();
-## }
- printf("created %d records\n", records);
-##}
-
-verify_members()
-##{
- struct member *m;
- struct save_queue *sq;
-## int list_id, member_id, ref_count, dflag;
-## char mtype[9];
- int errxtra, errbref, errbdir;
-#ifdef DEBUG
- int ref0, ref1, ref2, ref3, refg;
- int db0, db1, db2, db3, dbg;
-#endif DEBUG
-
- /* verify members from database */
- printf("Verifying members\n");
- errxtra = errbref = errbdir = 0;
-#ifdef DEBUG
- ref0 = ref1 = ref2 = ref3 = refg = 0;
- db0 = db1 = db2 = db3 = dbg = 0;
-#endif DEBUG
- sq = sq_create();
-## retrieve (list_id = m.#list_id, member_id = m.#member_id,
-## mtype = m.member_type, ref_count = m.#ref_count,
-## dflag = m.#direct) {
-#ifdef DEBUG
- if (debug > 1)
- switch (ref_count) {
- case 0: db0++; break;
- case 1: db1++; break;
- case 2: db2++; break;
- case 3: db3++; break;
- default: dbg++;
- }
-#endif DEBUG
- m = find_member(list_id, member2id(mtype[0], member_id));
- if (m == NULL) {
- m = allocmember();
- m->list_id = list_id;
- m->member_id = member2id(mtype[0], member_id);
- m->fdirect = dflag;
- m->frefc = ref_count;
- sq_save_data(sq, m);
- errxtra++;
- } else {
- m->ffound = 1;
-#ifdef DEBUG
- if (debug > 1)
- switch (m->frefc) {
- case 0: ref0++; break;
- case 1: ref1++; break;
- case 2: ref2++; break;
- case 3: ref3++; break;
- default: refg++;
- }
-#endif DEBUG
- m->frefc -= ref_count;
- if (m->frefc != 0)
- errbref++;
- if (m->fdirect != dflag) {
- m->fbaddirect = 1;
- errbdir++;
- }
- }
-## }
- printf("Found %d extra records, %d bad ref counts, %d bad direct flags\n",
- errxtra, errbref, errbdir);
-#ifdef DEBUG
- if (debug > 1) {
- printf("Found in db: %d 0; %d 1; %d 2; %d 3; %d > 3\n",
- db0, db1, db2, db3, dbg);
- printf("Found refs: %d 0; %d 1; %d 2; %d 3; %d > 3\n",
- ref0, ref1, ref2, ref3, refg);
- }
-#endif DEBUG
-##}
-
-
-fix_members()
-##{
- struct member *m;
- struct save_queue *sq;
- int errmis = 0;
-## int list_id, member_id, rowcount;
-## char mtype[9];
- char buf[512];
-
- /* fix any errors */
- printf("Fixing errors\n");
- hash_step(lists, fix_member, &errmis);
- while (sq_get_data(sq, &m)) {
- printf("Extraneous member record, deleting:\n");
- list_id = m->list_id;
- member_id = id2id(m->member_id);
- switch (id2type(m->member_id)) {
- case 'U': strcpy(mtype, "USER"); break;
- case 'L': strcpy(mtype, "LIST"); break;
- case 'S': strcpy(mtype, "STRING"); break;
- case 'K': strcpy(mtype, "KERBEROS"); break;
- default:
- mtype[0] = id2type(m->member_id);
- mtype[1] = 0;
- }
- printf(" List: %d, Member: %s %d, Refc: %d, Direct %d\n",
- list_id, mtype, member_id, m->frefc, m->fdirect);
-#ifdef FIXERRORS
-## delete m where m.#list_id = list_id and m.#member_id = member_id
-## and m.member_type = mtype
-## inquire_equel(rowcount = "rowcount")
- printf(" %d rows deleted\n", rowcount);
-#endif FIXERRORS
- }
- if (errmis > 0)
- printf("Added %d missing records\n", errmis);
-##}
-
-
-insert_list(m)
-struct member *m;
-{
- register struct member_list *l, *l1;
-
- l = (struct member_list *) hash_lookup(lists, m->list_id);
- if (l == NULL) {
- l = (struct member_list *)malloc(sizeof(struct member_list));
- if (l == NULL) {
- fprintf(stderr, "No memory for insert_list\n");
- exit(1);
- }
- l->next = NULL;
- l->member = m;
- hash_store(lists, m->list_id, l);
- return;
- }
- for (l1 = l; l1; l1 = l1->next)
- if (l1->member->member_id == m->member_id) {
- fprintf(stderr, "Found 2nd copy of list record for\n");
- fprintf(stderr, "List: %d, Member: %c %d, Refc: %d, Direct %d\n",
- m->list_id, id2type(m->member_id), id2id(m->member_id),
- m->frefc, m->fdirect);
- kill(getpid(), SIGQUIT);
- exit(2);
- }
-
- l1 = (struct member_list *)malloc(sizeof(struct member_list));
- if (l1 == NULL) {
- fprintf(stderr, "No memory for insert_list\n");
- exit(1);
- }
- l1->next = l->next;
- l->next = l1;
- l1->member = m;
-}
-
-
-insert_member(m)
-struct member *m;
-{
- register struct member_list *l, *l1;
-
- l = (struct member_list *) hash_lookup(members, m->member_id);
- if (l == NULL) {
- l = (struct member_list *)malloc(sizeof(struct member_list));
- if (l == NULL) {
- fprintf(stderr, "No memory for insert_member\n");
- exit(1);
- }
- l->next = NULL;
- l->member = m;
- hash_store(members, m->member_id, l);
- return;
- }
-
- for (l1 = l; l1; l1 = l1->next)
- if (l1->member->list_id == m->list_id) {
- fprintf(stderr, "Found 2nd copy of member record for\n");
- fprintf(stderr, "List: %d, Member: %c %d, Refc: %d, Direct %d\n",
- m->list_id, id2type(m->member_id), id2id(m->member_id),
- m->frefc, m->fdirect);
- kill(getpid(), SIGQUIT);
- exit(2);
- }
-
- l1 = (struct member_list *)malloc(sizeof(struct member_list));
- if (l1 == NULL) {
- fprintf(stderr, "No memory for insert_member\n");
- exit(1);
- }
- l1->next = l->next;
- l->next = l1;
- l1->member = m;
-}
-
-
-struct member *find_member(listid, memberid)
-int listid;
-int memberid;
-{
- register struct member_list *l;
-
- for (l = (struct member_list *) hash_lookup(lists, listid); l; l = l->next)
- if (l->member->member_id == memberid)
- return(l->member);
- return(NULL);
-}
-
-
-/*ARGSUSED*/
-void fix_member(dummy, l, errmis)
-int dummy;
-struct member_list *l;
-int *errmis;
-##{
-## int list_id, member_id, ref_count, dflag, rowcount;
-## char *mtype;
- char buf[2];
- register struct member *m;
-
- for (; l; l = l->next) {
- m = l->member;
-
- if (m->fscanned)
- continue;
- m->fscanned = 1;
- if (m->fbaddirect == 0 && m->frefc == 0 && m->ffound == 1)
- continue;
- if (m->ffound == 0) {
- printf("Missing member record, adding:\n");
- list_id = m->list_id;
- member_id = id2id(m->member_id);
- ref_count = m->frefc;
- dflag = m->fdirect;
- switch (id2type(m->member_id)) {
- case 'U': mtype = "USER"; break;
- case 'L': mtype = "LIST"; break;
- case 'S': mtype = "STRING"; break;
- case 'K': mtype = "KERBEROS"; break;
- default:
- mtype = buf;
- buf[0] = id2type(m->member_id);
- buf[1] = 0;
- }
- printf(" List: %d, Member: %s %d, Refc: %d, Direct %d\n",
- list_id, mtype, member_id, ref_count, dflag);
- (*errmis)++;
-#ifdef FIXERRORS
-## append imembers (#list_id = list_id, #member_id = member_id,
-## member_type = mtype, #ref_count = ref_count,
-## direct = dflag);
-## inquire_equel(rowcount = "rowcount")
- printf(" %d rows added\n", rowcount);
-#endif FIXERRORS
- continue;
- }
- printf("Member record has bad ref_count and/or direct flag, fixing\n");
- list_id = m->list_id;
- member_id = id2id(m->member_id);
- ref_count = m->frefc;
- dflag = m->fdirect;
- switch (id2type(m->member_id)) {
- case 'U': mtype = "USER"; break;
- case 'L': mtype = "LIST"; break;
- case 'S': mtype = "STRING"; break;
- case 'K': mtype = "KERBEROS"; break;
- default:
- mtype = buf;
- buf[0] = id2type(m->member_id);
- buf[1] = 0;
- }
- printf(" List: %d, Member: %s %d, Refc: %d, Direct %d\n",
- list_id, mtype, member_id, ref_count, dflag);
-#ifdef FIXERRORS
-## replace m (#ref_count = m.#ref_count + ref_count, direct = dflag)
-## where m.#list_id = list_id and m.#member_id = member_id and
-## m.member_type = mtype
-## inquire_equel(rowcount = "rowcount");
- printf(" %d rows fixed\n", rowcount);
-#endif FIXERRORS
- }
-##}
-
-
-struct member *allocmember()
-{
- register struct member *m;
-
- m = (struct member *) malloc(sizeof(struct member));
- if (m == NULL) {
- fprintf(stderr, "No memory for new member\n");
- exit(1);
- }
- m->fall = 0;
- records++;
- return(m);
-}
-
-
-int isinchain(m, l)
-struct member *m;
-register struct member_list *l;
-{
- for (; l; l = l->next)
- if (l->member == m)
- return(1);
- return(0);
-}
-
-
-int chainlen(l)
-register struct member_list *l;
-{
- register int i;
- for (i = 0; l; l = l->next, i++);
- return(i);
-}
-
-
-#ifdef DEBUG
-
-/*ARGSUSED*/
-void display_member(key, l, dummy1)
-int key, dummy1;
-struct member_list *l;
-{
- struct member *m;
- char *mtype;
-
- printf("%d*", key);
- for(; l; l = l->next) {
- m = l->member;
- switch (id2type(m->member_id)) {
- case 'U': mtype = "USER"; break;
- case 'L': mtype = "LIST"; break;
- case 'S': mtype = "STRING"; break;
- case 'K': mtype = "KERBEROS"; break;
- default: mtype = "???"; break;
- }
- printf("List: %d, Member: %s %d, Refc: %d, Direct %d\n",
- m->list_id, mtype, id2id(m->member_id), m->frefc,
- m->fdirect);
- }
-}
-
-#endif DEBUG
+++ /dev/null
-/* $Header$
- *
- * (c) Copyright 1988 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 "dbck.h"
-
-static char phase1_qc_rcsid[] = "$Header$";
-
-
-show_user_id(u)
-struct user *u;
-{
- printf("User %s (%s, status %d) has duplicate ID\n",
- u->login, u->fullname, u->status);
- return(0);
-}
-
-handle_duplicate_logins(sq)
-struct save_queue *sq;
-{
- struct user *u, *uu, *tmp;
-
- uu = (struct user *)0;
- while (sq_get_data(sq, &u)) {
- if (!strcmp(u->login, uu->login)) {
- if (uu->status == 1 || u->status == 0) {
- tmp = u;
- u = uu;
- uu = tmp;
- }
- printf("User %s (%s, status %d) and\n",
- u->login, u->fullname, u->status);
- printf("User %s (%s, status %d) have duplicate logins\n",
- uu->login, uu->fullname, uu->status);
- if (!strcmp(u->fullname, uu->fullname) &&
- single_fix("Delete the second one")) {
- single_delete("users", "users_id", uu->users_id);
- } else if (single_fix("Unregister the second one"))
-## {
-## int id = uu->users_id, rowcount;
-
-## replace users (login = "#"+text(users.uid), status = 0)
-## where users.users_id = id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount > 0)
- printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
- else
- printf("Not fixed\n");
- modified("users");
-## }
- } else {
- uu = u;
- }
- }
-}
-
-fix_user_id(u)
-struct user *u;
-{
- u->users_id = generic_fix_id("users", "users_id", "login",
- u->users_id, u->login);
-}
-
-
-cant_fix(id)
-int id;
-{
- printf("Sorry, don't know how to fix that\n");
-}
-
-show_mach_id(m)
-struct machine *m;
-{
- printf("Machine %s has duplicate ID %d\n", m->name, m->mach_id);
- return(0);
-}
-
-show_mach_name(m)
-struct machine *m;
-{
- printf("Machine %s (%d) has duplicate name\n", m->name, m->mach_id);
- return(0);
-}
-
-fix_mach_id(m)
-struct machine *m;
-{
- m->mach_id = generic_fix_id("machine", "mach_id", "name",
- m->mach_id, m->name);
-}
-
-show_clu_id(c)
-struct cluster *c;
-{
- printf("Cluster %s has duplicate ID %d\n", c->name, c->clu_id);
- return(0);
-}
-
-show_clu_name(c)
-struct cluster *c;
-{
- printf("Cluster %s (%d) has duplicate name\n", c->name, c->clu_id);
- return(0);
-}
-
-fix_clu_id(c)
-struct cluster *c;
-{
- c->clu_id = generic_fix_id("cluster", "clu_id", "name", c->clu_id, c->name);
-}
-
-show_list_id(l)
-struct list *l;
-{
- printf("List %s has duplicate ID %d\n", l->name, l->list_id);
- return(0);
-}
-
-show_list_name(l)
-struct list *l;
-{
- printf("List %s (%d) has duplicate name\n", l->name, l->list_id);
- return(0);
-}
-
-fix_list_id(l)
-struct list *l;
-{
- l->list_id = generic_fix_id("list", "list_id", "name", l->list_id, l->name);
-}
-
-show_fs_id(f)
-struct filesys *f;
-{
- printf("Filesys %s has duplicate ID %d\n", f->name, f->filsys_id);
- return(0);
-}
-
-fix_fs_id(f)
-struct filesys *f;
-{
- f->filsys_id = generic_fix_id("filesys", "filsys_id", "label",
- f->filsys_id, f->name);
-}
-
-
-show_np_id(n)
-struct nfsphys *n;
-{
- printf("NfsPhys %s:%s has duplicate ID %d\n",
- ((struct machine *)hash_lookup(machines, n->mach_id))->name,
- n->dir, n->nfsphys_id);
- return(0);
-}
-
-fix_np_id(n)
-struct nfsphys *n;
-{
- n->nfsphys_id = generic_fix_id("nfsphys", "nfsphys_id", "dir",
- n->nfsphys_id, n->dir);
-}
-
-show_str_id(s)
-struct string *s;
-{
- printf("String %s has duplicate ID %d\n", s->name, s->string_id);
- return(0);
-}
-
-
-phase1()
-##{
-## char name[81], name1[81], last[17], first[17], buf[257];
-## int id, id2, id3, aid, aid2, status, sid, sid2, sid3, sid4, sid5;
- struct save_queue *sq;
- struct user *u;
- struct machine *m;
- struct list *l;
- struct cluster *c;
- struct string *s;
- struct filesys *f;
- struct nfsphys *n;
-
- printf("Phase 1 - Looking for duplicates\n");
-
- dprintf("Loading strings...\n");
- sq = sq_create();
- strings = create_hash(5000);
-## range of s is strings
-## retrieve (id = s.string_id, buf = s.string) {
- s = (struct string *) malloc(sizeof(struct string));
- if (s == NULL)
- out_of_mem("storing strings");
- s->name = strsave(strtrim(buf));
- s->string_id = id;
- s->refc = 0;
- if (hash_store(strings, id, s)) {
- sq_save_data(sq, hash_lookup(strings, id));
- sq_save_data(sq, s);
- }
-## }
- generic_delete(sq, show_str_id, "strings", "string_id", 0);
- string_check(0);
-
- dprintf("Loading users...\n");
- sq = sq_create();
- users = create_hash(10000);
-## range of u is users
-## retrieve (id = u.users_id, name = u.login, last = u.#last,
-## first = u.#first, status = u.#status, buf = u.potype,
-## id2 = u.pop_id, id3 = u.box_id, sid = u.modby, sid2 = u.fmodby,
-## sid3 = u.pmodby, sid4 = u.comment, sid5 = u.sigwho) {
- u = (struct user *) malloc(sizeof(struct user));
- if (u == NULL)
- out_of_mem("storing users");
- strcpy(u->login, strtrim(name));
- u->potype = buf[0];
- sprintf(buf, "%s, %s", strtrim(last), strtrim(first));
- u->fullname = strsave(buf);
- u->status = status;
- u->users_id = id;
- switch (u->potype) {
- case 'P':
- u->pobox_id = id2;
- break;
- case 'S':
- u->pobox_id = id3;
- break;
- default:
- u->pobox_id = 0;
- }
- if (hash_store(users, id, u)) {
- sq_save_data(sq, hash_lookup(users, id));
- sq_save_data(sq, u);
- }
- if (sid < 0)
- string_check(-sid);
- if (sid2 < 0)
- string_check(-sid2);
- if (sid3 < 0)
- string_check(-sid3);
- if (sid4)
- string_check(sid4);
- if (sid5)
- string_check(sid5);
-## }
- generic_fix(sq, show_user_id, "Change ID", fix_user_id, 0);
-
- if (!fast) {
- sq = sq_create();
-## retrieve (id = u.users_id)
-## where u.login = users.login and u.tid != users.tid {
- sq_save_data(sq, hash_lookup(users, id));
-## }
- handle_duplicate_logins(sq);
- }
-
- dprintf("Loading machines...\n");
- machines = create_hash(1000);
- sq = sq_create();
-## range of m is machine
-## retrieve (id = m.mach_id, name = m.#name, sid = m.modby) {
- m = (struct machine *) malloc(sizeof(struct machine));
- if (m == NULL)
- out_of_mem("storing machines");
- strcpy(m->name, strtrim(name));
- m->mach_id = id;
- m->clucount = 0;
- if (hash_store(machines, id, m)) {
- sq_save_data(sq, hash_lookup(machines, id));
- sq_save_data(sq, m);
- }
- if (sid < 0)
- string_check(-sid);
-## }
- generic_fix(sq, show_mach_id, "Change ID", fix_mach_id, 0);
-
- if (!fast) {
- sq = sq_create();
-## retrieve (id = m.mach_id)
-## where m.#name = machine.#name and m.tid != machine.tid {
- sq_save_data(sq, hash_lookup(machines, id));
-## }
- generic_fix(sq, show_mach_name, "Change name", cant_fix, 0);
- }
-
- dprintf("Loading clusters...\n");
- sq = sq_create();
- clusters = create_hash(100);
-## range of c is cluster
-## retrieve (id = c.clu_id, name = c.#name, sid = c.modby) {
- c = (struct cluster *) malloc(sizeof(struct cluster));
- if (c == NULL)
- out_of_mem("storing clusters");
- strcpy(c->name, strtrim(name));
- c->clu_id = id;
- if (hash_store(clusters, id, c)) {
- sq_save_data(sq, hash_lookup(clusters, id));
- sq_save_data(sq, c);
- }
- if (sid < 0)
- string_check(-sid);
-## }
- generic_fix(sq, show_clu_id, "Change ID", fix_clu_id, 0);
-
- if (!fast) {
- sq = sq_create();
-## retrieve (id = c.clu_id)
-## where c.#name = cluster.#name and c.tid != cluster.tid {
- sq_save_data(sq, hash_lookup(clusters, id));
-## }
- generic_fix(sq, show_clu_name, "Change name", cant_fix, 0);
- }
-
- dprintf("Loading lists...\n");
- sq = sq_create();
- lists = create_hash(10000);
-## range of l is list
-## retrieve (id = l.list_id, name = l.#name,
-## aid = l.acl_id, buf = l.acl_type, sid = l.modby) {
- l = (struct list *) malloc(sizeof(struct list));
- if (l == NULL)
- out_of_mem("storing lists");
- strcpy(l->name, strtrim(name));
- l->acl_type = buf[0];
- l->acl_id = aid;
- l->list_id = id;
- l->members = 0;
- if (hash_store(lists, id, l)) {
- sq_save_data(sq, hash_lookup(lists, id));
- sq_save_data(sq, l);
- }
- if (sid < 0)
- string_check(-sid);
-## }
- generic_fix(sq, show_list_id, "Change ID", fix_list_id, 0);
-
- if (!fast) {
- sq = sq_create();
-## retrieve (id = l.list_id)
-## where l.#name = list.#name and l.tid != list.tid {
- sq_save_data(sq, hash_lookup(lists, id));
-## }
- generic_fix(sq, show_list_name, "Change name", cant_fix, 0);
- }
-
- dprintf("Loading filesys...\n");
- sq = sq_create();
- filesys = create_hash(10000);
-## retrieve (id = filesys.filsys_id, name = filesys.label, aid = filesys.owner,
-## aid2 = filesys.owners, id2 = filesys.phys_id,
-## id3 = filesys.mach_id, buf = filesys.type,
-## name1 = filesys.#name, sid = filesys.modby) {
- f = (struct filesys *) malloc(sizeof(struct filesys));
- if (f == NULL)
- out_of_mem("storing filesystems");
- strcpy(f->name, strtrim(name));
- strcpy(f->dir, strtrim(name1));
- f->filsys_id = id;
- f->owner = aid;
- f->owners = aid2;
- f->phys_id = id2;
- f->mach_id = id3;
- f->type = buf[0];
- if (hash_store(filesys, id, f)) {
- sq_save_data(sq, hash_lookup(filesys, id));
- sq_save_data(sq, f);
- }
- if (sid < 0)
- string_check(-sid);
-## }
- generic_fix(sq, show_fs_id, "Change ID", fix_fs_id, 0);
-
- dprintf("Loading nfsphys...\n");
- sq = sq_create();
- nfsphys = create_hash(500);
-## retrieve (id = nfsphys.nfsphys_id, name = nfsphys.dir,
-## id2 = nfsphys.mach_id, id3 = nfsphys.allocated,
-## sid = nfsphys.modby) {
- n = (struct nfsphys *) malloc(sizeof(struct nfsphys));
- if (n == NULL)
- out_of_mem("storing nfsphys");
- strcpy(n->dir, strtrim(name));
- n->mach_id = id2;
- n->nfsphys_id = id;
- n->allocated = id3;
- n->count = 0;
- if (hash_store(nfsphys, id, n)) {
- sq_save_data(sq, hash_lookup(nfsphys, id));
- sq_save_data(sq, n);
- }
- if (sid < 0)
- string_check(-sid);
-## }
- generic_fix(sq, show_np_id, "Change ID", fix_np_id, 0);
-
- if (!fast) {
-## range of s is strings
-## retrieve (id = s.string_id, buf = s.string)
-## where s.string = strings.string and s.tid != strings.tid {
- printf("String %s(%d) is a duplicate!\n", strtrim(buf), id);
- printf("Not fixing this error\n");
-## }
- }
-
- if (!fast) {
- dprintf("Scanning krbmap...\n");
-## range of k is krbmap
-## retrieve (id = k.users_id)
-## where k.users_id = krbmap.users_id and k.tid != krbmap.tid {
- printf("User %d is in the krbmap more than once!\n", id);
- printf("Not fixing this error\n");
-## }
-## retrieve (id = k.string_id)
-## where k.string_id = krbmap.string_id and k.tid != krbmap.tid {
- printf("Principal %d is in the krbmap more than once!\n", id);
- printf("Not fixing this error\n");
-## }
- }
-##}
-
+++ /dev/null
-/* $Header$
- *
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- */
-
-#include <mit-copyright.h>
-#include <stdio.h>
-#include <moira.h>
-#include "dbck.h"
-
-static char phase2_qc_rcsid[] = "$Header$";
-
-
-show_mcm_mach(id)
-int id;
-##{
-## int iid = id, found = 1;
-## char name[33];
-
-## retrieve (name = cluster.#name) where cluster.clu_id = mcmap.clu_id
-## and mcmap.mach_id = iid {
- strtrim(name);
- found = 0;
- printf("Cluster %s, non-existant machine %d in cluster map\n", name, id);
-## }
- return(found);
-##}
-
-show_mcm_clu(id)
-int id;
-##{
-## int iid = id, found = 1;
-## char name[33];
-
-## retrieve (name = machine.#name) where machine.mach_id = mcmap.mach_id
-## and mcmap.clu_id = iid {
- strtrim(name);
- found = 0;
- printf("Machine %s, non-existant cluster %d in cluster map\n", name, id);
-## }
- return(found);
-##}
-
-pobox_check(id, u, hint)
-int id;
-struct user *u;
-int hint;
-{
- switch (u->potype) {
- case 'P':
- if (!hash_lookup(machines, u->pobox_id)) {
- printf("User %s(%s) has P.O.Box on non-existant machine %d\n",
- u->login, u->fullname, u->pobox_id);
- if (single_fix("Delete", 0)) {
- remove_pobox(u->users_id);
- u->potype = 'N';
- }
- }
- break;
- case 'S':
- if (!string_check(u->pobox_id)) {
- printf("User %s(%s) has P.O.Box with non-existant string %d\n",
- u->login, u->fullname, u->pobox_id);
- if (single_fix("Delete", 0)) {
- remove_pobox(u->users_id);
- u->potype = 'N';
- }
- }
- break;
- default:
- ;
- }
-}
-
-
-remove_pobox(id)
-int id;
-##{
-## int rowcount, iid = id;
-## replace users (potype = "NONE") where users.users_id = iid
-## inquire_equel(rowcount = "rowcount")
- if (rowcount > 0)
- printf("%d entr%s removed\n", rowcount, rowcount==1?"y":"ies");
- else
- printf("Not removed\n");
- modified("users");
-##}
-
-show_svc(id)
-int id;
-##{
-## int iid = id, found = 1;
-## char label[17], data[33];
-
-## retrieve (label = svc.serv_label, data = svc.serv_cluster)
-## where svc.clu_id = iid {
- strtrim(label);
- strtrim(data);
- found = 0;
- printf("Cluster data [%s] %s for non-existant cluster %d\n",
- label, data, id);
-## }
- return(found);
-##}
-
-list_check(id, l, hint)
-int id;
-struct list *l;
-int hint;
-{
- switch (l->acl_type) {
- case 'L':
- if (!hash_lookup(lists, l->acl_id)) {
- printf("List %s has bad LIST acl %d\n", l->name, l->acl_id);
- if (single_fix("Patch", 1)) {
- fix_list_acl(l->list_id);
- }
- }
- break;
- case 'U':
- if (!hash_lookup(users, l->acl_id)) {
- printf("List %s has bad USER acl %d\n", l->name, l->acl_id);
- if (single_fix("Patch", 1)) {
- fix_list_acl(l->list_id);
- }
- }
- break;
- }
-}
-
-fix_list_acl(id)
-int id;
-##{
-## int rowcount, iid = id;
-## replace list (acl_id = iid, acl_type = "LIST") where list.list_id = iid
-## inquire_equel(rowcount = "rowcount")
- if (rowcount > 0)
- printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
- else
- printf("Not fixed\n");
- modified("list");
-##}
-
-
-show_member_list(id)
-int id;
-##{
-## int mid, iid = id, found = 1;
-## char mtype[9], *name = "";
-
-## retrieve (mtype = imembers.member_type, mid = imembers.member_id)
-## where imembers.list_id = iid and imembers.direct = 1 {
- strtrim(mtype);
- found = 0;
- if (mtype[0] == 'L')
- name = ((struct list *) hash_lookup(lists, mid))->name;
- else if (mtype[0] == 'U')
- name = ((struct user *) hash_lookup(users, mid))->login;
- else if (mtype[0] == 'S' || mtype[0] == 'K')
- name = ((struct string *) hash_lookup(strings, mid))->name;
- printf("Non-existant list %d has member %s %s\n", iid, mtype, name);
-## }
- return(found);
-##}
-
-show_mem_user(id)
-int id;
-##{
-## int lid, iid = id, found = 1;
-## char name[33];
-
-## retrieve (lid = imembers.list_id)
-## where imembers.member_id = iid and imembers.member_type = "USER" and
-## imembers.direct = 1 {
- found = 0;
- printf("List %s has non-existant user member, id %d\n",
- ((struct list *)hash_lookup(lists, lid))->name, iid);
-## }
- return(found);
-##}
-
-show_mem_list(id)
-int id;
-##{
-## int lid, iid = id, found = 1;
-## char name[33];
-
-## retrieve (lid = imembers.list_id)
-## where imembers.member_id = iid and imembers.member_type = "LIST" and
-## imembers.direct = 1 {
- found = 0;
- printf("List %s has non-existant list member, id %d\n",
- ((struct list *)hash_lookup(lists, lid))->name, iid);
-## }
- return(found);
-##}
-
-show_mem_str(id)
-int id;
-##{
-## int lid, iid = id, found = 1;
-## char name[33];
-
-## retrieve (lid = imembers.list_id)
-## where imembers.member_id = iid and imembers.member_type = "STRING" and
-## imembers.direct = 1 {
- found = 0;
- printf("List %s has non-existant string member, id %d\n",
- ((struct list *)hash_lookup(lists, lid))->name, iid);
-## }
- return(found);
-##}
-
-
-show_mem_krb(id)
-int id;
-##{
-## int lid, iid = id, found = 1;
-## char name[33];
-
-## retrieve (lid = imembers.list_id)
-## where imembers.member_id = iid and imembers.member_type = "KERBEROS" and
-## imembers.direct = 1 {
- found = 0;
- printf("List %s has non-existant kerberos member, id %d\n",
- ((struct list *)hash_lookup(lists, lid))->name, iid);
-## }
- return(found);
-##}
-
-
-##del_mem_user(id)
-##int id;
-##{
-## int rowcount;
-
-## delete imembers where imembers.member_type = "USER" and
-## imembers.member_id = id and imembers.direct = 1
-## inquire_equel(rowcount = "rowcount");
- if (rowcount > 0)
- printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
- else
- printf("Not deleted\n");
- modified("imembers");
-##}
-
-##del_mem_list(id)
-##int id;
-##{
-## int rowcount;
-
-## delete imembers where imembers.member_type = "LIST" and
-## imembers.member_id = id and imembers.direct = 1
-## inquire_equel(rowcount = "rowcount");
- if (rowcount > 0)
- printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
- else
- printf("Not deleted\n");
- modified("imembers");
-##}
-
-##del_mem_str(id)
-##int id;
-##{
-## int rowcount;
-
-## delete imembers where imembers.member_type = "STRING" and
-## imembers.member_id = id and imembers.direct = 1
-## inquire_equel(rowcount = "rowcount");
- if (rowcount > 0)
- printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
- else
- printf("Not deleted\n");
- modified("imembers");
-##}
-
-
-##del_mem_krb(id)
-##int id;
-##{
-## int rowcount;
-
-## delete imembers where imembers.member_type = "KERBEROS" and
-## imembers.member_id = id and imembers.direct = 1
-## inquire_equel(rowcount = "rowcount");
- if (rowcount > 0)
- printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
- else
- printf("Not deleted\n");
- modified("imembers");
-##}
-
-
-##show_sh(id)
-##int id;
-##{
-## char name[33];
- int found = 1;
-
-## retrieve (name = serverhosts.service) where serverhosts.mach_id = id {
- found = 0;
- printf("ServerHost entry for service %s non-existant host %d\n",
- name, id);
-## }
- return(found);
-##}
-
-##del_sh_mach(id)
-##int id;
-##{
-## int rowcount;
-
-## delete serverhosts where serverhosts.mach_id = id
-## inquire_equel(rowcount = "rowcount");
- if (rowcount > 0)
- printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
- else
- printf("Not deleted\n");
- modified("serverhosts");
-##}
-
-
-static int fnchecklen;
-
-fsmatch(id, n, f)
-int id;
-struct nfsphys *n;
-struct filesys *f;
-{
- if (n->mach_id == f->mach_id &&
- !strncmp(f->dir, n->dir, strlen(n->dir)) &&
- strlen(n->dir) > fnchecklen) {
- f->phys_id = id;
- fnchecklen = strlen(n->dir);
- }
-}
-
-
-##check_fs(id, f, hint)
-##int id;
-register struct filesys *f;
-int hint;
-##{
-## int id1, id2, id3, rowcount;
-## char *dir;
- struct nfsphys *n;
- struct machine *m;
-
- if (!hash_lookup(machines, f->mach_id)) {
- printf("Filesys %s with bad machine %d\n", f->name, f->mach_id);
- if (single_fix("Fix", 0)) {
-## replace filesys (mach_id = 0) where filesys.filsys_id = id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount > 0)
- printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
- else
- printf("Not fixed\n");
- modified("filesys");
- f->mach_id = 0;
- }
- }
-
- if (!hash_lookup(users, f->owner)) {
- printf("Filesys %s with bad owning user %d\n", f->name, f->owner);
- if (single_fix("Fix", 1)) {
- zero_fix("filesys", "owner", "filsys_id", f->filsys_id);
- f->owner = 0;
- }
- }
- if (!hash_lookup(lists, f->owners)) {
- printf("Filesys %s with bad owning group %d\n", f->name, f->owners);
- if (single_fix("Fix", 1)) {
- zero_fix("filesys", "owners", "filsys_id", f->filsys_id);
- f->owners = 0;
- }
- }
-
- if (f->type == 'N') {
- if (!hash_lookup(nfsphys, f->phys_id)) {
- m = (struct machine *)hash_lookup(machines, f->mach_id);
- printf("Filesys %s with bad phys_id %d\n", f->name, f->phys_id);
- if (single_fix("Fix", 1)) {
- fnchecklen = 0;
- hash_step(nfsphys, fsmatch, f);
- if (fnchecklen != 0) {
- id1 = f->phys_id;
- id2 = f->filsys_id;
- id3 = f->mach_id;
-## replace filesys (phys_id = id1) where filesys.filsys_id = id2
-## inquire_equel(rowcount = "rowcount")
- if (rowcount > 0)
- printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
- else
- printf("Not fixed\n");
- modified("filesys");
- } else {
- printf("No NFSphys exsits for %s:%s\n", m->name, f->dir);
- if (single_fix("Create", 0)) {
- dir = f->dir;
- id1 = f->phys_id;
- id2 = f->filsys_id;
- id3 = f->mach_id;
- if (set_next_object_id("nfsphys_id", "nfsphys") !=
- MR_SUCCESS) {
- printf("Unable to assign unique ID\n");
- return;
- }
-## retrieve (id1 = values.value)
-## where values.name = "nfsphys_id"
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1) {
- printf("Unable to retrieve unique ID\n");
- return;
- }
-## append nfsphys (nfsphys_id = id1, mach_id = id3,
-## device = "???", #dir = dir, status = 0,
-## allocated = 0, size = 0,
-## modtime = "now", modby = 0,
-## modwith = "dbck")
-## inquire_equel(rowcount = "rowcount")
- if (rowcount > 0)
- printf("%d entr%s created\n", rowcount,
- rowcount==1?"y":"ies");
- else
- printf("Not created\n");
- modified("nfsphys");
- n = (struct nfsphys *)malloc(sizeof(struct nfsphys));
- if (n == NULL)
- out_of_mem("storing new nfsphys");
- strcpy(n->dir, dir);
- n->mach_id = id3;
- n->nfsphys_id = id1;
- n->allocated = 0;
- n->count = 0;
- hash_store(nfsphys, id1, n);
-## replace filesys (phys_id = id1)
-## where filesys.filsys_id = id2
-## inquire_equel(rowcount = "rowcount")
- if (rowcount > 0)
- printf("%d filesys entr%s fixed\n", rowcount,
- rowcount==1?"y":"ies");
- else
- printf("Not fixed\n");
- modified("filesys");
- }
- }
- }
- }
- }
-##}
-
-
-check_nfsphys(id, n, hint)
-int id;
-struct nfsphys *n;
-int hint;
-{
- if (!hash_lookup(machines, n->mach_id)) {
- printf("NFSphys %d(%s) on non-existant machine %d\n",
- id, n->dir, n->mach_id);
- if (single_fix("Delete", 0))
- single_delete("nfsphys", "nfsphys_id", id);
- }
-}
-
-##show_fsg_missing(id)
-##int id;
-##{
-## int id1, found = 1;
- struct filesys *f;
-
-## retrieve (id1 = fsgroup.filsys_id) where fsgroup.group_id = id {
- found = 0;
- if (f = (struct filesys *) hash_lookup(filesys, id1))
- printf("Missing fsgroup %d has member filesystem %s\n", id, f->name);
- else
- printf("Missing fsgroup %d has member filesystem %d\n", id, id1);
-## }
- return(found);
-##}
-
-show_fsg_type(f)
-struct filesys *f;
-{
- char *t;
-
- switch (f->type) {
- case 'N':
- t = "NFS";
- break;
- case 'R':
- t = "RVD";
- break;
- case 'A':
- t = "AFS";
- break;
- case 'E':
- t = "ERR";
- break;
- case 'F':
- t = "FSGROUP";
- break;
- case 'M':
- t = "MUL";
- break;
- default:
- t = "???";
- }
- printf("FSGroup %s has type %s instead of FSGROUP\n", f->name, t);
- return(0);
-}
-
-fix_fsg_type(f)
-struct filesys *f;
-##{
-## int rowcount, id = f->filsys_id;
-
-## replace filesys (type = "FSGROUP") where filesys.filsys_id = id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount > 0)
- printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
- else
- printf("Not fixed\n");
- modified("filesys");
-##}
-
-##show_fsg_nomember(id)
-##int id;
-##{
-## int id1, found = 1;
- struct filesys *f;
-
-## retrieve (id1 = fsgroup.group_id) where fsgroup.filsys_id = id {
- found = 0;
- if (f = (struct filesys *) hash_lookup(filesys, id1))
- printf("FSGroup %s has missing member %d\n", f->name, id);
- else
- printf("FSGroup %d has missing member %d\n", id1, id);
-## }
- return(found);
-##}
-
-##show_quota_nouser(id)
-##int id;
-##{
-## int id1, found = 1;
-
-## retrieve (id1 = quota.filsys_id) where quota.entity_id = id and
-## quota.type = "USER" {
- found = 0;
- printf("Quota on fs %d for non-existant user %d\n", id1, id);
-## }
- return(found);
-##}
-
-##show_quota_nolist(id)
-##int id;
-##{
-## int id1, found = 1;
-
-## retrieve (id1 = quota.filsys_id) where quota.entity_id = id and
-## quota.type = "GROUP" {
- found = 0;
- printf("Quota on fs %d for non-existant list %d\n", id1, id);
-## }
- return(found);
-##}
-
-##fix_quota_nouser(id)
-##int id;
-##{
-## int rowcount, id1;
-
- id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
-## delete quota where quota.entity_id = id and quota.type = "USER"
-## inquire_equel(rowcount = "rowcount")
- if (rowcount > 0)
- printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies");
- else
- printf("Not deleted\n");
- modified("quota");
-##}
-
-##fix_quota_nolist(id)
-##int id;
-##{
-## int rowcount, id1;
-
- id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
-## delete quota where quota.entity_id = id and quota.type = "GROUP"
-## inquire_equel(rowcount = "rowcount")
- if (rowcount > 0)
- printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies");
- else
- printf("Not deleted\n");
- modified("quota");
-##}
-
-##show_quota_nofs(id)
-##int id;
-##{
-## int id1, found = 1;
-## char type[9];
-
-## retrieve (id1 = quota.entity_id, type = quota.#type)
-## where quota.filsys_id = id {
- found = 0;
- printf("Quota for %s %d on non-existant filesys %d\n", type, id1, id);
-## }
- return(found);
-##}
-
-fix_quota_nofs(id)
-{
- single_delete("quota", "filsys_id", id);
-}
-
-##show_quota_wrongpid(id)
-##int id;
-##{
-## int id1, found = 1;
-## char type[9];
- struct user *u;
- struct filesys *f;
-
- f = (struct filesys *)hash_lookup(filesys, id);
-## retrieve (id1 = quota.entity_id, type = quota.#type)
-## where quota.filsys_id = id {
- found = 0;
- printf("Quota for %s %d on filesys %s has wrong phys_id %d\n",
- type, id1, f->name, id);
-## }
- return(found);
-##}
-
-##fix_quota_physid(id)
-##int id;
-##{
-## int rowcount, id1;
-
- id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
-## replace quota (phys_id = id1) where quota.filsys_id = id and
-## quota.phys_id != id1
-## inquire_equel(rowcount = "rowcount")
- if (rowcount > 0)
- printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
- else
- printf("Not fixed\n");
- modified("quota");
-##}
-
-##show_srv_user(id)
-##int id;
-##{
-## char name[33];
- int found = 1;
-
-## retrieve (name = s.#name) where s.acl_type = "USER" and s.acl_id = id {
- strtrim(name);
- printf("Service %s has acl non-existant user %d\n", name, id);
- found = 0;
-## }
- return(found);
-##}
-
-##show_srv_list(id)
-##int id;
-##{
-## char name[33];
- int found = 1;
-
-## retrieve (name = s.#name) where s.acl_type = "LIST" and s.acl_id = id {
- strtrim(name);
- printf("Service %s has acl non-existant list %d\n", name, id);
- found = 0;
-## }
- return(found);
-##}
-
-##zero_srv_user(id)
-##int id;
-##{
-## int rowcount;
-
-## replace servers (acl_id = 0) where servers.acl_id = id and
-## servers.acl_type = "USER"
-## inquire_equel(rowcount = "rowcount")
- if (rowcount > 0)
- printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
- else
- printf("Not fixed\n");
- modified("servers");
-##}
-
-##zero_srv_list(id)
-##int id;
-##{
-## int rowcount;
-
-## replace servers (acl_id = 0) where servers.acl_id = id and
-## servers.acl_type = "LIST"
-## inquire_equel(rowcount = "rowcount")
- if (rowcount > 0)
- printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
- else
- printf("Not fixed\n");
- modified("servers");
-##}
-
-
-##show_krb_usr(id)
-##int id;
-##{
-## int found = 1, id1;
- struct string *s;
- char *ss;
-
-## retrieve (id1 = krbmap.string_id) where krbmap.users_id = id {
- if (s = ((struct string *)hash_lookup(strings, id1)))
- ss = s->name;
- else
- ss = "[unknown]";
- found = 0;
- printf("Kerberos map for non-existant user %d to principal %s\n",
- id, s);
-## }
- return(found);
-##}
-
-
-##show_krb_str(id)
-##int id;
-##{
-## int found = 1, id1;
- struct user *u;
- char *s;
-
-## retrieve (id1 = krbmap.users_id) where krbmap.string_id = id {
- if (u = ((struct user *)hash_lookup(users, id1)))
- s = u->login;
- else
- s = "[???]";
- found = 0;
- printf("Kerberos map for user %s (%d) to non-existant string %d\n",
- s, id1, id);
-## }
- return(found);
-##}
-
-
-##show_pdm_mach(id)
-##int id;
-##{
-## char name[33];
- int found = 1;
-
-## retrieve (name = palladium.#name) where palladium.mach_id = id {
- strtrim(name);
- printf("Palladium server/supervisor %s is on non-existant machine %d\n",
- name, id);
- found = 0;
-## }
- return(found);
-##}
-
-
-phase2()
-##{
-## int id1, id2, id3, id4, id5;
-## char type[9], name[33];
- struct save_queue *sq, *sq1, *sq2, *sq3, *sq4, *sq5;
- struct filesys *f;
- struct list *l;
- struct nfsphys *n;
- struct machine *m;
-
- printf("Phase 2 - Checking references\n");
-
- dprintf("Checking users...\n");
- hash_step(users, pobox_check, NULL);
-
- dprintf("Checking mcmap...\n");
- sq1 = sq_create();
- sq2 = sq_create();
-## retrieve (id1 = mcmap.mach_id, id2 = mcmap.clu_id) {
- if (!(m = (struct machine *)hash_lookup(machines, id1)))
- sq_save_unique_data(sq1, id1);
- if (!hash_lookup(clusters, id2))
- sq_save_unique_data(sq2, id2);
- if (m) m->clucount++;
-## }
- generic_delete(sq1, show_mcm_mach, "mcmap", "mach_id", 1);
- generic_delete(sq2, show_mcm_clu, "mcmap", "clu_id", 1);
-
- dprintf("Checking service clusters...\n");
- sq1 = sq_create();
-## retrieve (id1 = svc.clu_id) {
- if (!hash_lookup(clusters, id1))
- sq_save_unique_data(sq1, id1);
-## }
- generic_delete(sq1, show_svc, "svc", "clu_id", 1);
-
- dprintf("Checking lists...\n");
- hash_step(lists, list_check, NULL);
-
- dprintf("Checking members...\n");
- sq1 = sq_create();
- sq2 = sq_create();
- sq3 = sq_create();
- sq4 = sq_create();
- sq5 = sq_create();
-## range of m is imembers
-## retrieve (id1 = m.list_id, type = m.member_type, id2 = m.member_id,
-## id3 = m.ref_count, id4 = m.direct) {
- if ((l = (struct list *) hash_lookup(lists, id1)) == NULL)
- sq_save_unique_data(sq1, id1);
- else if (type[0] == 'U' && !hash_lookup(users, id2))
- sq_save_unique_data(sq2, id2);
- else if (type[0] == 'L' && !hash_lookup(lists, id2))
- sq_save_unique_data(sq3, id2);
- else if (type[0] == 'S' && !string_check(id2))
- sq_save_unique_data(sq4, id2);
- else if (type[0] == 'K' && !string_check(id2))
- sq_save_unique_data(sq5, id2);
- else
- l->members++;
-## }
- generic_delete(sq1, show_member_list, "imembers", "list_id", 1);
- generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1);
- generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1);
- generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1);
- generic_fix(sq5, show_mem_krb, "Delete", del_mem_krb, 1);
-
- dprintf("Checking servers...\n");
- sq1 = sq_create();
- sq2 = sq_create();
-## range of s is servers
-## retrieve (name = s.#name, type = s.acl_type, id1 = s.acl_id) {
- strtrim(type);
- if (!strcmp(type, "USER") && !hash_lookup(users, id1)) {
- sq_save_data(sq1, id1);
- } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id1)) {
- sq_save_data(sq2, id1);
- }
-## }
- generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
- generic_fix(sq2, show_srv_list, "Fix", zero_srv_list, 1);
-
- dprintf("Checking servershosts...\n");
- sq = sq_create();
-## retrieve (id1 = serverhosts.mach_id) {
- if (!hash_lookup(machines, id1))
- sq_save_data(sq, id1);
-## }
- generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
-
- dprintf("Checking nfsphys...\n");
- hash_step(nfsphys, check_nfsphys, NULL);
-
- dprintf("Checking filesys...\n");
- hash_step(filesys, check_fs, NULL);
-
- dprintf("Checking filesystem groups...\n");
- sq1 = sq_create();
- sq2 = sq_create();
- sq3 = sq_create();
-## retrieve (id1 = fsgroup.group_id, id2 = fsgroup.filsys_id) {
- if (!(f = (struct filesys *) hash_lookup(filesys, id1)))
- sq_save_data(sq1, id1);
- if (!hash_lookup(filesys, id2))
- sq_save_data(sq3, id2);
-## }
- generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0);
- generic_delete(sq3, show_fsg_nomember, "fsgroup", "filsys_id", 1);
-
- dprintf("Checking quotas...\n");
- sq1 = sq_create();
- sq2 = sq_create();
- sq3 = sq_create();
- sq4 = sq_create();
-## retrieve (id1 = quota.entity_id, type = quota.#type, id2 = quota.filsys_id,
-## id3 = quota.phys_id, id4 = quota.quota) {
- if (type[0] == 'U' && id1 != 0 && !hash_lookup(users, id1))
- sq_save_data(sq1, id1);
- else if (type[0] == 'G' && !hash_lookup(lists, id1))
- sq_save_data(sq4, id1);
- else if (!(f = (struct filesys *) hash_lookup(filesys, id2)))
- sq_save_data(sq2, id2);
- else if (id3 != f->phys_id ||
- ((n = (struct nfsphys*) hash_lookup(nfsphys, id3)) ==
- (struct nfsphys *)NULL))
- sq_save_data(sq3, id2);
- else
- n->count += id4;
-## }
- generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1);
- generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0);
- generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1);
- generic_fix(sq4, show_quota_nolist, "Delete", fix_quota_nolist, 1);
-
- dprintf("Not checking zephyr.\n");
-
- dprintf("Checking hostaccess...\n");
-## range of h is hostaccess
-## retrieve (id1 = h.mach_id, type = h.acl_type, id2 = h.acl_id) {
- strtrim(type);
- if (!hash_lookup(machines, id1)) {
- printf("Hostaccess for non-existant host %d\n", id1);
- printf("Not fixing this error\n");
- }
- if (!strcmp(type, "USER") && !hash_lookup(users, id2)) {
- printf("Hostaccess for %d is non-existant user %d\n", id1, id2);
- printf("Not fixing this error\n");
- } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2)) {
- printf("Hostaccess for %d is non-existant list %d\n", id1, id2);
- printf("Not fixing this error\n");
- }
-## }
-
- dprintf("Checking palladium...\n");
- sq1 = sq_create();
-## range of p is palladium
-## retrieve (id1 = p.mach_id) {
- if (!hash_lookup(machines, id1)) {
- sq_save_unique_data(sq1, id1);
- }
-## }
- generic_delete(sq1, show_pdm_mach, "palladium", "mach_id", 1);
-
- dprintf("Checking krbmap...\n");
- sq1 = sq_create();
- sq2 = sq_create();
-## range of k is krbmap
-## retrieve (id1 = k.users_id, id2 = k.string_id) {
- if (!hash_lookup(users, id1))
- sq_save_unique_data(sq1, id1);
- if (!string_check(id2))
- sq_save_unique_data(sq2, id2);
-## }
- generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1);
- generic_delete(sq2, show_krb_str, "krbmap", "string_id", 1);
-
- dprintf("Checking capacls...\n");
-## retrieve (id1 = capacls.list_id, name = capacls.tag) {
- if (!hash_lookup(lists, id1)) {
- printf("Capacl for %s is non-existant list %d\n", name, id1);
- printf("Not fixing this error\n");
- }
-## }
-
-##}
-
+++ /dev/null
-/* $Header$
- *
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- */
-
-#include <mit-copyright.h>
-#include "dbck.h"
-
-#define NULL 0
-
-static char phase3_qc_rcsid[] = "$Header$";
-
-
-empty_list_check(id, l, hint)
-int id, hint;
-struct list *l;
-{
- if (l->members == 0 && l->list_id != 0)
- printf("Warning: List %s is empty\n", l->name);
-}
-
-
-/* Used by other parts of the program to check that a string_id is good.
- * This returns TRUE if it is, or FALSE if it is not, and as a side effect
- * increments the string reference count.
- */
-
-struct string *string_check(id)
-int id;
-{
- register struct string *s;
-
- s = (struct string *) hash_lookup(strings, id);
- if (s == NULL)
- return(s);
- s->refc++;
- return(s);
-}
-
-
-unref_string_check(id, s, hint)
-int id, hint;
-struct string *s;
-{
- if (s->refc == 0) {
- printf("Unreferenced string %s id %d\n", s->name, id);
- if (single_fix("Delete", 1))
- single_delete("strings", "string_id", id);
- }
-}
-
-
-noclu_mach_check(id, m, hint)
-int id, hint;
-struct machine *m;
-{
- if (m->clucount == 0 && m->mach_id != 0)
- printf("Warning: machine %s is not in any clusters\n", m->name);
-}
-
-
-phase3()
-##{
- printf("Phase 3 - Finding unused objects\n");
-
- if (warn) {
- dprintf("Checking machines...\n");
- hash_step(machines, noclu_mach_check, NULL);
-
- dprintf("Checking lists...\n");
- hash_step(lists, empty_list_check, NULL);
- }
-
- dprintf("Checking strings...\n");
- hash_step(strings, unref_string_check, NULL);
-
-##}
-
+++ /dev/null
-/* $Header$
- *
- * (c) Copyright 1988 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 "dbck.h"
-
-static char phase4_qc_rcsid[] = "$Header$";
-
-
-count_boxes(id, u, boxes)
-int id;
-struct user *u;
-struct hash *boxes;
-{
- int i;
-
- if (u->potype == 'P') {
- if (i = (int) hash_lookup(boxes, u->pobox_id))
- hash_store(boxes, u->pobox_id, i+1);
- else {
- printf("User %s(%s) has pobox on non-POP server %d\n",
- u->fullname, u->login, u->pobox_id);
- printf("Not fixing this error\n");
- }
- }
-}
-
-
-##check_box_counts(id, cnt, counts)
-##int id, cnt;
-struct hash *counts;
-##{
-## int oldval, rowcount;
-
- oldval = (int) hash_lookup(counts, id);
- cnt--;
- if (oldval != cnt) {
- printf("Count wrong on POBox machine %s; is %d in db, counted %d\n",
- ((struct machine *) hash_lookup(machines, id))->name,
- oldval, cnt);
- if (single_fix("Update", 1)) {
-## range of s is serverhosts
-## replace s (value1 = cnt) where
-## s.service = "POP" and s.mach_id = id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount > 0)
- printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
- else
- printf("Not fixed\n");
- modified("serverhosts");
- }
- }
-##}
-
-
-##check_nfs_counts(id, n, hint)
-##int id, hint;
-struct nfsphys *n;
-##{
-## int val, rowcount;
-
- val = n->count;
- if (n->allocated != val) {
- printf("Count wrong on NFSphys %s:%s; is %d in db, counted %d\n",
- ((struct machine *) hash_lookup(machines, n->mach_id))->name,
- n->dir, n->allocated, val);
- if (single_fix("Update", 1)) {
-## replace nfsphys (allocated = val) where nfsphys.nfsphys_id = id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount > 0)
- printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
- else
- printf("Not fixed\n");
- modified("nfsphys");
- }
- }
-##}
-
-
-phase4()
-##{
- struct hash *boxes, *counts;
-## int id, cnt;
-
- printf("Phase 4 - Checking counts\n");
-
- dprintf("Doing POBoxes...\n");
- boxes = create_hash(10);
- counts = create_hash(10);
-## retrieve (id = serverhosts.mach_id, cnt = serverhosts.value1)
-## where serverhosts.service = "POP" {
- hash_store(boxes, id, 1);
- hash_store(counts, id, cnt);
-## }
- hash_step(users, count_boxes, boxes);
- hash_step(boxes, check_box_counts, counts);
-
- dprintf("Doing NFSphys...\n");
- hash_step(nfsphys, check_nfs_counts, 0);
-##}
-
-
-count_only_setup()
-##{
-## int id, status, id2, id3;
-## char name[33], last[17], first[17], buf[257];
- struct save_queue *sq;
- struct user *u;
- struct nfsphys *n;
- struct machine *m;
-
- dprintf("Loading users...\n");
- users = create_hash(10000);
-## range of u is users
-## retrieve (id = u.users_id, name = u.login, last = u.#last,
-## first = u.#first, status = u.#status, buf = u.potype,
-## id2 = u.pop_id, id3 = u.box_id)
-## where u.potype = "POP" {
- u = (struct user *) malloc(sizeof(struct user));
- if (u == NULL)
- out_of_mem("storing users");
- strcpy(u->login, strtrim(name));
- u->potype = buf[0];
- sprintf(buf, "%s, %s", strtrim(last), strtrim(first));
- u->fullname = strsave(buf);
- u->status = status;
- u->users_id = id;
- switch (u->potype) {
- case 'P':
- u->pobox_id = id2;
- break;
- case 'S':
- u->pobox_id = id3;
- break;
- default:
- u->pobox_id = 0;
- }
- hash_store(users, id, u);
-## }
-
- dprintf("Loading machines...\n");
- machines = create_hash(1000);
-## range of m is machine
-## retrieve (id = m.mach_id, name = m.#name) {
- m = (struct machine *) malloc(sizeof(struct machine));
- if (m == NULL)
- out_of_mem("storing machines");
- strcpy(m->name, strtrim(name));
- m->mach_id = id;
- hash_store(machines, id, m);
-## }
-
- dprintf("Loading nfsphys...\n");
- nfsphys = create_hash(500);
-## retrieve (id = nfsphys.nfsphys_id, name = nfsphys.dir,
-## id2 = nfsphys.mach_id, id3 = nfsphys.allocated) {
- n = (struct nfsphys *) malloc(sizeof(struct nfsphys));
- if (n == NULL)
- out_of_mem("storing nfsphys");
- strcpy(n->dir, strtrim(name));
- n->mach_id = id2;
- n->nfsphys_id = id;
- n->allocated = id3;
- n->count = 0;
- hash_store(nfsphys, id, n);
-## }
-
- dprintf("Counting quotas...\n");
-## retrieve (id = quota.phys_id, id2 = quota.quota) {
- if (n = (struct nfsphys *) hash_lookup(nfsphys, id)) {
- n->count += id2;
- }
-## }
-##}
+++ /dev/null
-#
-# $Source$
-# $Author$
-# $Header$
-#
-# Revised makefile for GDB library.
-#
-
-GDBCSRCS= gdb_struct.c gdb_stype.c gdb.c gdb_trans.c gdb_trans2.c \
- gdb_conn.c gdb_serv.c gdb_fserv.c gdb_db.c gdb_debug.c gdb_ops.c
-
-GDBNONCSRCS= gdb.h gdb_lib.h dbserv.qc
-
-OTHERSRCS= test.c samp1a.c \
- tst.c tst2.c tcl.c tdbcl.c tsr.c tfsr.c\
- tst3.c tst4.c tst5.c tst6.c
-
-LIBOBJS = gdb.o gdb_struct.o gdb_stype.o gdb_trans.o gdb_trans2.o \
- gdb_conn.o gdb_ops.o gdb_serv.o gdb_fserv.o gdb_db.o gdb_debug.o
-
-DOCS= library.mss gdb.mss gdb.prob gdb_ugd.mss slides.mss
-
-SAMPLES= samp1.c
-
-MISC= Makefile README gdb_version
-
-CFLAGS= -O -I../include
-
-CCPROF= ${CC}
-
-INGLIBS= /usr/rtingres/lib/libqlib /usr/rtingres/lib/compatlib
-
-LINTFLAGS= -uhv -I../include
-
-.c.o:
-# ${CCPROF} -c -pg ${CFLAGS} $*.c
-# mv $*.o profiled/$*.o
- ${CC} -c ${CFLAGS} $*.c
-
-OPTS=
-
-all: libgdb.a llib-lgdb.ln # libgdb_p.a
-
-libgdb.a: ${LIBOBJS}
- ar uv libgdb.a ${LIBOBJS}; ranlib libgdb.a
-
-libgdb_p.a: ${LIBOBJS}
- (cd profiled; ar uv ../libgdb_p.a ${LIBOBJS}; ranlib ../libgdb_p.a)
-
-lint:
- lint ${LINTFLAGS} ${GDBCSRCS} | \
- egrep -v "warning: possible pointer alignment problem"
-
-llib-lgdb.ln: ${LIBSRC}
- lint ${LINTFLAGS} -Cgdb ${GDBCSRCS}
-
-install:
- install -c -m 644 libgdb.a ${DESTDIR}/usr/athena/lib/libmrgdb.a
- ranlib ${DESTDIR}/usr/athena/lib/libmrgdb.a
-# install -c -m 644 libgdb_p.a ${DESTDIR}/usr/athena/lib/libmrgdb_p.a
-# ranlib ${DESTDIR}/usr/athena/lib/libmrgdb_p.a
- install -c -m 644 llib-lgdb.ln ${DESTDIR}/usr/lib/lint/llib-lmrgdb.ln
-
-#
-# Random demo programs
-#
-tst: tst.o libgdb.a
- cc ${OPTS} -o tst tst.o libgdb.a
-
-tsr: tsr.o libgdb.a
- cc ${OPTS} -o tsr tsr.o libgdb.a
-
-tfsr: tfsr.o libgdb.a
- cc ${OPTS} -o tfsr tfsr.o libgdb.a
-
-tcl: tcl.o libgdb.a
- cc ${OPTS} -o tcl tcl.o libgdb.a
-
-tdbcl: tdbcl.o libgdb.a
- cc ${OPTS} -o tdbcl tdbcl.o libgdb.a
-
-samp1a: samp1a.o libgdb.a
- cc ${OPTS} -o samp1a samp1a.o libgdb.a
-
-#
-# Documentation.
-#
-
-slides.PS: slides.mss
- scribe slides
-
-gdb_ugd.PS: gdb_ugd.mss
- scribe gdb_ugd
-
-library.PS: library.mss
- scribe library
-
-ugdprint: gdb_ugd.PS
- lpr -Pln03-bldge40-4 gdb_ugd.PS
- echo 'GDB User Guide sent to PostScript printer'
-
-libraryprint: library.PS
- lpr -Pln03-bldge40-4 library.PS
- echo 'GDB Library Reference Manual sent to PostScript printer'
-
-slideprint: slides.PS
- lpr -Pln03-bldge40-4 slides.PS
- echo 'GDB slides sent to PostScript printer'
-
-#
-# Cleanup.
-#
-
-clean:
- rm -f *.o libgdb.a libgdb_p.a tar.file *.PS *.err \#* *~ profiled/*.o
- rm -f llib-lgdb.ln TAGS
-
-depend: $(GDBCSRCS)
- mkdep ${CFLAGS} ${GDBCSRCS}
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-
-gdb_struct.o: gdb_struct.c ../include/mit-copyright.h /usr/include/stdio.h
-gdb_struct.o: /usr/include/strings.h ../include/gdb.h
-gdb_struct.o: /usr/include/sys/types.h /usr/include/sys/time.h
-gdb_struct.o: /usr/include/sys/time.h
-gdb_stype.o: gdb_stype.c ../include/mit-copyright.h /usr/include/stdio.h
-gdb_stype.o: /usr/include/strings.h ../include/gdb.h /usr/include/sys/types.h
-gdb_stype.o: /usr/include/sys/time.h /usr/include/sys/time.h
-gdb_stype.o: /usr/include/netinet/in.h
-gdb.o: gdb.c /usr/include/stdio.h /usr/include/strings.h
-gdb.o: /usr/include/signal.h /usr/include/pwd.h ../include/gdb.h
-gdb.o: /usr/include/sys/types.h /usr/include/sys/time.h
-gdb.o: /usr/include/sys/time.h gdb_lib.h /usr/include/errno.h
-gdb_trans.o: gdb_trans.c ../include/mit-copyright.h /usr/include/sys/types.h
-gdb_trans.o: /usr/include/strings.h /usr/include/stdio.h
-gdb_trans.o: /usr/include/varargs.h /usr/include/errno.h ../include/gdb.h
-gdb_trans.o: /usr/include/sys/time.h /usr/include/sys/time.h
-gdb_trans2.o: gdb_trans2.c ../include/mit-copyright.h
-gdb_trans2.o: /usr/include/sys/types.h /usr/include/errno.h
-gdb_trans2.o: /usr/include/stdio.h ../include/gdb.h /usr/include/sys/time.h
-gdb_trans2.o: /usr/include/sys/time.h /usr/include/sys/uio.h
-gdb_trans2.o: /usr/include/sys/socket.h
-gdb_conn.o: gdb_conn.c ../include/mit-copyright.h /usr/include/stdio.h
-gdb_conn.o: /usr/include/strings.h ../include/gdb.h /usr/include/sys/types.h
-gdb_conn.o: /usr/include/sys/time.h /usr/include/sys/time.h
-gdb_conn.o: /usr/include/sys/uio.h /usr/include/sys/socket.h
-gdb_conn.o: /usr/include/sys/ioctl.h /usr/include/sys/ttychars.h
-gdb_conn.o: /usr/include/sys/ttydev.h /usr/include/netinet/in.h
-gdb_conn.o: /usr/include/netdb.h /usr/include/errno.h
-gdb_serv.o: gdb_serv.c ../include/mit-copyright.h /usr/include/stdio.h
-gdb_serv.o: /usr/include/strings.h ../include/gdb.h /usr/include/sys/types.h
-gdb_serv.o: /usr/include/sys/time.h /usr/include/sys/time.h
-gdb_serv.o: /usr/include/sys/ioctl.h /usr/include/sys/ttychars.h
-gdb_serv.o: /usr/include/sys/ttydev.h
-gdb_fserv.o: gdb_fserv.c ../include/mit-copyright.h /usr/include/stdio.h
-gdb_fserv.o: /usr/include/sys/types.h /usr/include/sys/uio.h
-gdb_fserv.o: /usr/include/sys/socket.h /usr/include/sys/wait.h
-gdb_fserv.o: /usr/include/sys/signal.h ../include/gdb.h
-gdb_fserv.o: /usr/include/sys/time.h /usr/include/sys/time.h
-gdb_fserv.o: /usr/include/sys/resource.h
-gdb_db.o: gdb_db.c ../include/mit-copyright.h /usr/include/stdio.h
-gdb_db.o: /usr/include/strings.h ../include/gdb.h /usr/include/sys/types.h
-gdb_db.o: /usr/include/sys/time.h /usr/include/sys/time.h
-gdb_debug.o: gdb_debug.c ../include/mit-copyright.h /usr/include/stdio.h
-gdb_debug.o: ../include/gdb.h /usr/include/sys/types.h
-gdb_debug.o: /usr/include/sys/time.h /usr/include/sys/time.h
-gdb_ops.o: gdb_ops.c ../include/mit-copyright.h /usr/include/stdio.h
-gdb_ops.o: ../include/gdb.h /usr/include/sys/types.h /usr/include/sys/time.h
-gdb_ops.o: /usr/include/sys/time.h /usr/include/netinet/in.h
-gdb_ops.o: /usr/include/sys/ioctl.h /usr/include/sys/ttychars.h
-gdb_ops.o: /usr/include/sys/ttydev.h
+++ /dev/null
-# $Header$
-
-SRCS= passwd.c aliases.c hesiod.c nfs.c mailhub.c mitdir.c util.c setquota.c
-LIBS= -L../lib -lmoira -lcom_err -lzephyr -lkrb -ldes \
- /usr/rtingres/lib/libqlib /usr/rtingres/lib/compatlib
-CFLAGS= -I../include -O
-.SUFFIXES: .qc
-
-.qc.c:
- rm -f $*.c
- /usr/rtingres/bin/eqc -p $*
-
-all: passwd.gen aliases.gen hesiod.gen nfs.gen mailhub.gen mitdir.gen setquota
-
-passwd.gen: passwd.o util.o
- cc -o passwd.gen passwd.o util.o ${LIBS}
-
-passwd.o: passwd.c
-
-aliases.gen: aliases.o util.o
- cc -o aliases.gen aliases.o util.o ${LIBS}
-
-aliases.o: aliases.c
-
-hesiod.gen: hesiod.o util.o
- cc -o hesiod.gen hesiod.o util.o ${LIBS}
-
-hesiod.o: hesiod.c
-
-nfs.gen: nfs.o util.o
- cc -o nfs.gen nfs.o util.o ${LIBS}
-
-nfs.o: nfs.c
-
-mailhub.gen: mailhub.o util.o
- cc -o mailhub.gen mailhub.o util.o ${LIBS}
-
-mailhub.o: mailhub.c
-
-mitdir.gen: mitdir.o util.o
- cc -o mitdir.gen mitdir.o util.o ${LIBS}
-
-mitdir.o: mitdir.c
-
-setquota: setquota.o
- cc -o setquota setquota.o
-
-clean:
- rm -f *.o
- rm -f passwd.c passwd.gen
- rm -f aliases.c aliases.gen
- rm -f hesiod.c hesiod.gen
- rm -f nfs.c nfs.gen
- rm -f mailhub.c mailhub.gen
- rm -f mitdir.c mitdir.gen
-
-install: all
- install -c passwd.gen ../bin
- install -c aliases.gen ../bin
- install -c hesiod.gen ../bin
- install -c nfs.gen ../bin
- install -c aliases.sh ../bin
- install -c hesiod.sh ../bin
- install -c install_dirs ../bin
- install -c install_quotas ../bin
- install -c nfs.sh ../bin
- install -c passwd.sh ../bin
- install -c zero_quotas ../bin
-
-depend: ${SRCS}
- mkdep ${CFLAGS} ${SRCS}
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-
-passwd.o: passwd.c ../include/mit-copyright.h /usr/include/stdio.h
-passwd.o: ../include/moira.h ../include/mr_et.h /usr/include/sys/types.h
-passwd.o: /usr/include/sys/stat.h /usr/include/sys/time.h
-passwd.o: /usr/include/sys/time.h
-aliases.o: aliases.c ../include/mit-copyright.h /usr/include/stdio.h
-aliases.o: /usr/include/string.h /usr/include/strings.h ../include/moira.h
-aliases.o: ../include/mr_et.h ../include/moira_site.h
-aliases.o: /usr/include/sys/types.h /usr/include/sys/stat.h
-aliases.o: /usr/include/sys/time.h /usr/include/sys/time.h
-hesiod.o: hesiod.c ../include/mit-copyright.h /usr/include/stdio.h
-hesiod.o: ../include/moira.h ../include/mr_et.h ../include/moira_site.h
-hesiod.o: /usr/include/sys/types.h /usr/include/sys/stat.h
-hesiod.o: /usr/include/sys/time.h /usr/include/sys/time.h
-hesiod.o: /usr/include/ctype.h
-nfs.o: nfs.c ../include/mit-copyright.h /usr/include/stdio.h
-nfs.o: ../include/moira.h ../include/mr_et.h ../include/moira_site.h
-nfs.o: /usr/include/sys/types.h /usr/include/sys/stat.h
-nfs.o: /usr/include/sys/time.h /usr/include/sys/time.h
-mailhub.o: mailhub.c ../include/mit-copyright.h /usr/include/stdio.h
-mailhub.o: /usr/include/string.h /usr/include/strings.h /usr/include/ctype.h
-mailhub.o: ../include/moira.h ../include/mr_et.h ../include/moira_site.h
-mailhub.o: /usr/include/sys/types.h /usr/include/sys/stat.h
-mailhub.o: /usr/include/sys/time.h /usr/include/sys/time.h
-mitdir.o: mitdir.c ../include/mit-copyright.h /usr/include/stdio.h
-mitdir.o: /usr/include/string.h /usr/include/strings.h ../include/moira.h
-mitdir.o: ../include/mr_et.h ../include/moira_site.h /usr/include/sys/types.h
-mitdir.o: /usr/include/sys/stat.h /usr/include/sys/time.h
-mitdir.o: /usr/include/sys/time.h
-util.o: util.c ../include/mit-copyright.h /usr/include/stdio.h
-util.o: /usr/include/sys/time.h /usr/include/sys/time.h ../include/moira.h
-util.o: ../include/mr_et.h ../include/moira_site.h
-setquota.o: setquota.c /usr/include/stdio.h /usr/include/ctype.h
-setquota.o: /usr/include/mntent.h /usr/include/sys/file.h
-setquota.o: /usr/include/sys/param.h /usr/include/machine/machparam.h
-setquota.o: /usr/include/sys/signal.h /usr/include/sys/types.h
-setquota.o: /usr/include/sys/time.h /usr/include/sys/time.h
-setquota.o: /usr/include/ufs/quota.h
+++ /dev/null
-/* $Header$
- *
- * This generates the /usr/lib/aliases mail aliases file for the mailhub.
- * The aliases file will contain:
- * user pobox entries
- * maillist expansions
- * sublists of maillists
- *
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- */
-
-
-#include <mit-copyright.h>
-#include <stdio.h>
-#include <string.h>
-#include <moira.h>
-#include <moira_site.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-
-
-#define ML_WID 72
-#define AL_MAX_WID 896
-
-char *divide = "########################################################################";
-extern int errno;
-char *whoami = "aliases.gen";
-char *ingres_date_and_time();
-FILE *out;
-
-main(argc, argv)
-int argc;
-char **argv;
-{
- long tm = time(NULL);
- char filename[64], *targetfile;
- struct stat sb;
-## int flag1, flag2, flag3;
-## char *filetime;
- int ingerr();
-
- out= stdout;
- IIseterr(ingerr);
- initialize_sms_error_table();
-## ingres sms
-## set lockmode session where level = table
-
- if (argc == 2) {
- if (stat(argv[1], &sb) == 0) {
- filetime = ingres_date_and_time(sb.st_mtime);
-## retrieve (flag1 = int4(interval("min",tblstats.modtime - filetime)))
-## where tblstats.table = "list"
-## retrieve (flag2 = int4(interval("min",tblstats.modtime - filetime)))
-## where tblstats.table = "imembers"
-## retrieve (flag3 = int4(interval("min",tblstats.modtime - filetime)))
-## where tblstats.table = "users"
- if (flag1 < 0 && flag2 < 0 && flag3 < 0) {
- fprintf(stderr, "File %s does not need to be rebuilt.\n",
- argv[1]);
- exit(MR_NO_CHANGE);
- }
- }
- targetfile = argv[1];
- sprintf(filename, "%s~", targetfile);
- if ((out = fopen(filename, "w")) == NULL) {
- fprintf(stderr, "unable to open %s for output\n", filename);
- exit(MR_OCONFIG);
- }
- } else if (argc != 1) {
- fprintf(stderr, "usage: %s [outfile]\n", argv[0]);
- exit(MR_ARGS);
- }
-
- fprintf(out, "%s\n# Aliases File Extract of %s", divide, ctime(&tm));
- fprintf(out, "# This file is automatically generated, do not edit it directly.\n%s\n\n", divide);
-
-## begin transaction
- get_info();
-## end transaction
-## exit
-
- fprintf(stderr, "Dumping information\n");
- do_mlists(out);
- do_poboxes(out);
-
- fprintf(out, "\n%s\n# End of aliases file\n%s\n", divide, divide);
-
-
- if (fclose(out)) {
- perror("close failed");
- exit(MR_CCONFIG);
- }
-
- if (argc == 2)
- fix_file(targetfile);
- exit(MR_SUCCESS);
-}
-
-
-/*
- * ingerr: (supposedly) called when Ingres indicates an error.
- * I have not yet been able to get this to work to intercept a
- * database open error.
- */
-#define INGRES_DEADLOCK 4700
-
-static int ingerr(num)
- int *num;
-{
- int ingres_errno;
-
- switch (*num) {
- case INGRES_DEADLOCK:
- ingres_errno = MR_DEADLOCK;
- break;
- default:
- ingres_errno = MR_INGRES_ERR;
- }
- com_err(whoami, MR_INGRES_ERR, " code %d\n", *num);
- critical_alert("DCM", "Alias build encountered INGRES ERROR %d", *num);
- exit(ingres_errno);
-}
-
-
-struct hash *users, *machines, *strings, *lists;
-struct user {
- char login[9];
- char *pobox;
-};
-struct member {
- struct member *next;
- char *name;
- int list_id;
-};
-struct list {
- char *name;
- char maillist;
- char acl_t;
- char *description;
- int acl_id;
- struct member *m;
-};
-
-
-get_info()
-##{
-## int id, maillistp, acl, pid, bid, mid;
-## char name[129], type[9], buf[257];
- char *s;
- register struct user *u;
- register struct list *l;
- register struct member *m;
- register struct list *memberlist;
-
- /* get locks */
-## retrieve (buf = list.modtime) where list.list_id = 0
-## retrieve (buf = users.modtime) where users.users_id = 0
-
- fprintf(stderr, "Loading machines\n");
- machines = create_hash(1000);
-## retrieve (id = machine.mach_id, name = machine.#name) {
- if (s = index(name, '.'))
- *s = 0;
-#ifdef ATHENA
- strcat(name, ".LOCAL");
-#endif
- hash_store(machines, id, strsave(name));
-## }
-
- fprintf(stderr, "Loading strings\n");
- strings = create_hash(2000);
-## retrieve (id = strings.string_id, name = strings.string) {
- hash_store(strings, id, strsave(strtrim(name)));
-## }
-
- fprintf(stderr, "Loading users\n");
- users = create_hash(12001);
-## range of u is users
-## retrieve (id = u.users_id, name = u.login, type = u.potype,
-## pid = u.pop_id, bid = u.box_id)
-## where u.status = 1 or u.status = 5 or u.status = 6 {
- u = (struct user *) malloc(sizeof(struct user));
- strcpy(u->login, strtrim(name));
- if (type[0] == 'P') {
- if (s = hash_lookup(machines, pid)) {
- sprintf(buf, "%s@%s", name, s);
- u->pobox = strsave(buf);
- } else {
- u->pobox = (char *) NULL;
- fprintf(stderr, "User %s's pobox is on a missing machine!\n",
- u->login);
- }
- } else if (type[0] == 'S') {
- if ((u->pobox = hash_lookup(strings, bid)) == NULL) {
- u->pobox = (char *) NULL;
- fprintf(stderr, "User %s's pobox string is missing!\n",
- u->login);
- }
- } else
- u->pobox = (char *) NULL;
- hash_store(users, id, u);
-## }
-
- fprintf(stderr, "Loading lists\n");
- lists = create_hash(15001);
-## range of l is list
-## retrieve (id = l.list_id, name = l.#name, maillistp = l.maillist,
-## buf = l.desc, type = l.acl_type, acl = l.acl_id)
-## where l.active != 0 {
- l = (struct list *) malloc(sizeof(struct list));
- l->name = strsave(strtrim(name));
- l->maillist = maillistp;
- l->description = strsave(strtrim(buf));
- l->acl_t = type[0];
- l->acl_id = acl;
- l->m = (struct member *) NULL;
- hash_store(lists, id, l);
-## }
-
-
- fprintf(stderr, "Loading members\n");
-## range of m is imembers
-## retrieve (id = m.list_id, type = m.member_type, mid = m.member_id)
-## where m.direct = 1 {
- if (l = (struct list *) hash_lookup(lists, id)) {
- m = (struct member *) malloc(sizeof(struct member));
- if (type[0] == 'U' &&
- (u = (struct user *) hash_lookup(users, mid))) {
- m->list_id = 0;
- m->name = u->login;
- m->next = l->m;
- l->m = m;
- } else if (type[0] == 'L' &&
- (memberlist = (struct list *) hash_lookup(lists, mid))) {
- m->list_id = mid;
- m->name = memberlist->name;
- m->next = l->m;
- l->m = m;
- } else if (type[0] == 'S' &&
- (s = hash_lookup(strings, mid))) {
- m->list_id = 0;
- m->name = s;
- m->next = l->m;
- l->m = m;
- }
- }
-## }
-##}
-
-
-save_mlist(id, l, force)
-int id;
-register struct list *l;
-int force;
-{
- register struct member *m;
- struct list *l1;
-
- if (l->maillist == 2 ||
- (l->maillist == 0 && !force))
- return;
-
- if (l->m && l->m->next == NULL &&
- !strcasecmp(l->name, l->m->name)) {
- l->maillist = 0;
- return;
- }
- l->maillist = 2;
- output_mlist(id, l);
-
- if (l->acl_t == 'L' && (l1 = (struct list *)hash_lookup(lists, l->acl_id)))
- save_mlist(0, l1, 1);
-
- for (m = l->m; m; m = m->next) {
- if (m->list_id && (l1 = (struct list *)hash_lookup(lists, m->list_id)))
- save_mlist(0, l1, 1);
- }
-}
-
-
-int lwid, bol, awid;
-
-output_mlist(id, l)
-int id;
-register struct list *l;
-{
- struct list *l1;
- register struct member *m;
- struct user *u;
-
- put_fill(out, l->description);
- if (l->acl_t == 'L') {
- if (l1 = (struct list *) hash_lookup(lists, l->acl_id))
- fprintf(out, "owner-%s: %s\n", l->name, l1->name);
- } else if (l->acl_t == 'U') {
- if (u = (struct user *) hash_lookup(users, l->acl_id))
- fprintf(out, "owner-%s: %s\n", l->name, u->login);
- }
-
- fprintf(out, "%s: ", l->name);
- lwid = strlen(l->name) + 2;
- bol = 1;
- for (m = l->m; m; m = m->next)
- do_member(out, m->name);
- if (l->m == (struct member *)NULL)
- fprintf(out, "/dev/null");
- fprintf(out, "\n\n");
-}
-
-
-/* Extract mailing lists. Make a list of all mailinglists, then
- * process them, adding any sub-lists or acl lists to the list of lists
- * to be processed. If further sublists are encountered, repeat...
- */
-
-do_mlists(out)
-FILE *out;
-{
- fprintf(out, "\n%s\n# Mailing lists\n%s\n", divide, divide);
- hash_step(lists, save_mlist, 0);
-}
-
-
-/* print out strings separated by commas, doing line breaks as appropriate */
-
-do_member(out, s)
-FILE *out;
-register char *s;
-{
- register wwid;
- static int cont = 1;
-
- wwid = strlen(s);
-
- if (!bol && awid + wwid + 2 > AL_MAX_WID) {
- fprintf(out, ",\n\tcontinuation-%d\ncontinuation-%d: ", cont, cont);
- cont++;
- awid = lwid = 17 + wwid;
- fputs(s, out);
- return;
- }
-
- if (bol) {
- lwid += wwid;
- awid = lwid;
- fputs(s, out);
- bol = 0;
- return;
- }
- if (lwid + wwid + 2 > ML_WID) {
- fprintf(out, ",\n\t%s", s);
- awid += lwid + wwid + 2;
- lwid = wwid + 8;
- return;
- }
- lwid += wwid + 2;
- fprintf(out, ", %s", s);
-}
-
-do_pobox(id, u, out)
-int id;
-register struct user *u;
-FILE *out;
-{
- if (u->pobox)
- fprintf(out, "%s: %s\n", u->login, u->pobox);
-}
-
-
-/* Do user poboxes. Just step through the users table, and print any
- * we extracted earlier.
- */
-
-do_poboxes(out)
-FILE *out;
-{
- fprintf(out, "\n%s\n# User Poboxes\n%s\n", divide, divide);
-
- hash_step(users, do_pobox, out);
-}
-
-
-put_fill(aliases, string)
-FILE *aliases;
-register char *string;
-{
- register char *c;
- register int lwid;
- register int wwid;
-
- if (*string == 0) return;
- fputs("# ", aliases);
- lwid = 3;
-
- while (1) {
- while (*string && *string == ' ') string++;
- c = (char *)index(string, ' ');
- if (c == 0) {
- wwid = strlen(string);
- } else {
- wwid = c - string;
- *c = 0;
- }
-
- if ((lwid + wwid) > ML_WID) {
- fputs("\n# ", aliases);
- lwid = 3;
- fputs(string, aliases);
- } else {
- fputs(string, aliases);
- }
-
- if (c == (char *)0) break;
- /* add a space after the word */
- (void) fputc(' ', aliases);
- wwid++;
- lwid += wwid;
- string += wwid;
- /* add another if after a period */
- if (*--c == '.') {
- (void) fputc(' ', aliases);
- lwid++;
- }
- }
-
- (void) fputc('\n', aliases);
-}
+++ /dev/null
-/* $Header$
- *
- * This generates the zone files necessary to load a hesiod server.
- * The following zones are generated: passwd, uid, pobox, group,
- * grplist, gid, filsys, cluster, pcap, sloc, service.
- *
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- */
-
-#include <mit-copyright.h>
-#include <stdio.h>
-#include <moira.h>
-#include <moira_site.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <ctype.h>
-
-
-#ifdef ATHENA
-#define HTYPE "UNSPECA"
-#else
-#define HTYPE "TXT"
-#endif
-
-char hesiod_dir[64];
-
-#define min(x,y) ((x) < (y) ? (x) : (y))
-struct hash *machines = NULL;
-struct hash *users = NULL;
-char *whoami = "hesiod.gen";
-
-struct grp {
- struct grp *next;
- char *lid;
-};
-struct user {
- char name[9];
- struct grp *lists;
-};
-
-char *malloc(), *strsave();
-char *ingres_date_and_time(), *ingres_time(), *ingres_date();
-
-main(argc, argv)
-int argc;
-char **argv;
-{
- char cmd[64];
- struct stat sb;
- int changed = 0;
- int ingerr();
-
- if (argc > 2) {
- fprintf(stderr, "usage: %s [outfile]\n", argv[0]);
- exit(MR_ARGS);
- }
-
- IIseterr(ingerr);
- initialize_sms_error_table ();
- sprintf(hesiod_dir, "%s/hesiod", DCM_DIR);
-
-## ingres sms
-## set lockmode session where level = table
-
- changed = do_passwd();
- changed += do_filsys();
- changed += do_cluster();
- changed += do_printcap();
- changed += do_palladium();
- changed += do_sloc();
- changed += do_service();
- changed += do_groups();
-
-## exit
-
- if (!changed) {
- fprintf(stderr, "No files updated.\n");
- if (argc == 2 && stat(argv[1], &sb) == 0)
- exit(MR_NO_CHANGE);
- }
-
- if (argc == 2) {
- fprintf(stderr, "Building tar file.\n");
- sprintf(cmd, "cd %s; tar cf %s .", hesiod_dir, argv[1]);
- if (system(cmd))
- exit(MR_TAR_FAIL);
- }
-
- exit(MR_SUCCESS);
-}
-
-
-/*
- * ingerr: (supposedly) called when Ingres indicates an error.
- * I have not yet been able to get this to work to intercept a
- * database open error.
- */
-#define INGRES_DEADLOCK 4700
-
-static int ingerr(num)
- int *num;
-{
- int ingres_errno;
-
- switch (*num) {
- case INGRES_DEADLOCK:
- ingres_errno = MR_DEADLOCK;
- break;
- default:
- ingres_errno = MR_INGRES_ERR;
- }
- com_err(whoami, MR_INGRES_ERR, " code %d\n", *num);
- critical_alert("DCM", "Hesiod build encountered INGRES ERROR %d", *num);
- exit(ingres_errno);
-}
-
-
-get_mach()
-##{
-## int id;
-## char name[33];
-
- if (machines)
- return;
-
- machines = create_hash(1000);
-## retrieve (name = machine.#name, id = machine.mach_id) {
- hash_store(machines, id, strsave(strtrim(name)));
-## }
-##}
-
-
-do_passwd()
-##{
- FILE *pout, *uout, *bout;
- char poutf[64], uoutf[64], poutft[64], uoutft[64], boutf[64], boutft[64];
- struct stat psb, usb, bsb;
- time_t ftime;
- struct user *u;
- char *mach;
-## char login[9], shell[33], fullname[33], oa[17], op[13], hp[17], *filetime;
-## char nn[17], ptype[9];
-## int uid, flag1, flag2, id, pid;
-
- sprintf(poutf, "%s/passwd.db", hesiod_dir);
- sprintf(uoutf, "%s/uid.db", hesiod_dir);
- sprintf(boutf, "%s/pobox.db", hesiod_dir);
-
- if (stat(poutf, &psb) == 0 && stat(uoutf, &usb) == 0 &&
- stat(boutf, &bsb) == 0) {
- ftime = min(min(psb.st_mtime, usb.st_mtime), bsb.st_mtime);
- filetime = ingres_date_and_time(ftime);
-## retrieve (flag1 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "users"
-## retrieve (flag2 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "machine"
- if (flag1 < 0 && flag2 < 0) {
- fprintf(stderr, "Files passwd.db, uid.db, and pobox.db do not need to be rebuilt.\n");
- return(0);
- }
- }
-
- sprintf(poutft, "%s~", poutf);
- pout = fopen(poutft, "w");
- if (!pout) {
- perror("cannot open passwd.db~ for write");
- exit(MR_OCONFIG);
- }
- sprintf(uoutft, "%s~", uoutf);
- uout = fopen(uoutft, "w");
- if (!uout) {
- perror("cannot open uid.db~ for write");
- exit(MR_OCONFIG);
- }
- sprintf(boutft, "%s~", boutf);
- bout = fopen(boutft, "w");
- if (!bout) {
- perror("cannot open pobox.db for write");
- exit(MR_OCONFIG);
- }
-
- fprintf(stderr, "Building passwd.db, uid.db, and pobox.db\n");
- get_mach();
-
- users = create_hash(12001);
-## range of u is users
-## retrieve (login = u.#login, uid = u.#uid, shell = u.#shell,
-## fullname = u.#fullname, nn = u.nickname, oa = u.office_addr,
-## op = u.office_phone, hp = u.home_phone, id = u.users_id,
-## pid = u.pop_id, ptype = u.potype)
-## where u.status = 1 {
- strtrim(login);
- dequote(fullname);
- dequote(nn);
- dequote(oa);
- dequote(op);
- dequote(hp);
- dequote(shell);
- u = (struct user *) malloc(sizeof(struct user));
- strcpy(u->name, login);
- u->lists = NULL;
- hash_store(users, id, u);
- fprintf(pout, "%s.passwd\tHS %s \"%s:*:%d:101:%s,%s,%s,%s,%s:/mit/%s:%s\"\n",
- login, HTYPE, login, uid, fullname, nn, oa, op, hp, login, shell);
- fprintf(uout, "%d.uid\tHS CNAME %s.passwd\n", uid, login);
- if (ptype[0] == 'P' && (mach = hash_lookup(machines, pid))) {
- fprintf(bout, "%s.pobox\tHS %s \"POP %s %s\"\n",
- login, HTYPE, mach, login);
- }
-## }
-
- if (fclose(pout) || fclose(uout) || fclose(bout)) {
- fprintf(stderr, "Unsuccessful file close of passwd.db, uid.db, or pobox.db\n");
- exit(MR_CCONFIG);
- }
- fix_file(poutf);
- fix_file(uoutf);
- fix_file(boutf);
- return(1);
-##}
-
-
-do_groups()
-##{
- FILE *iout, *gout, *lout;
- char ioutf[64], goutf[64], loutf[64], buf[2048], *l;
- struct hash *groups;
- register struct bucket *b, **p;
- struct grp *g;
- struct user *u;
- struct stat isb, gsb, lsb;
- time_t ftime;
-## char name[33], *filetime;
-## int gid, id, lid, flag1, flag2, flag3;
-
- /* open files */
- sprintf(ioutf, "%s/gid.db", hesiod_dir);
- sprintf(goutf, "%s/group.db", hesiod_dir);
- sprintf(loutf, "%s/grplist.db", hesiod_dir);
-
- if (stat(ioutf, &isb) == 0 && stat(goutf, &gsb) == 0 && stat(loutf, &lsb) == 0) {
- ftime = min(isb.st_mtime, min(gsb.st_mtime, lsb.st_mtime));
- filetime = ingres_date_and_time(ftime);
-## retrieve (flag1 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "users"
-## retrieve (flag2 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "list"
-## retrieve (flag3 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "imembers"
- if (flag1 < 0 && flag2 < 0 && flag3 < 0) {
- fprintf(stderr, "Files gid.db, group.db and grplist.db do not need to be rebuilt.\n");
- return(0);
- }
- }
-
- sprintf(buf, "%s~", ioutf);
- iout = fopen(buf, "w");
- if (!iout) {
- perror("cannot open gid.db for write");
- exit(MR_OCONFIG);
- }
- sprintf(buf, "%s~", goutf);
- gout = fopen(buf, "w");
- if (!gout) {
- perror("cannot open group.db for write");
- exit(MR_OCONFIG);
- }
- sprintf(buf, "%s~", loutf);
- lout = fopen(buf, "w");
- if (!lout) {
- perror("cannot open grplist.db for write");
- exit(MR_OCONFIG);
- }
-
- fprintf(stderr, "Building gid.db, group.db, and grplist.db\n");
-
- /* make space for group list */
- groups = create_hash(15001);
-
- /* retrieve simple groups */
-## range of l is list
-## range of m is imembers
-## begin transaction
- /* get lock records */
-## retrieve (name = l.modtime) where l.list_id = 0
-## retrieve (name = users.modtime) where users.users_id = 0
-
-## retrieve (name = l.#name, gid = l.#gid, lid = l.list_id)
-## where l.group != 0 and l.active != 0 {
- strtrim(name);
- sprintf(buf, "%s:%d", name, gid);
- hash_store(groups, lid, strsave(buf));
- fprintf(iout, "%d.gid\tHS CNAME %s.group\n", gid, name);
- fprintf(gout, "%s.group\tHS %s \"%s:*:%d:\"\n",
- name, HTYPE, name, gid);
-## }
-
- fflush(iout);
- fflush(gout);
-
- /* now do grplists */
- if (users == NULL) {
- users = create_hash(12001);
-## range of u is users
-## retrieve (id = u.users_id, name = u.login) where u.status = 1 {
- u = (struct user *) malloc(sizeof(struct user));
- strcpy(u->name, strtrim(name));
- u->lists = NULL;
- hash_store(users, id, u);
-## }
- }
-
-## repeat retrieve (lid = m.list_id, id = m.member_id)
-## where m.member_type = "USER" {
- if (((l = hash_lookup(groups, lid)) != NULL) &&
- (u = (struct user *) hash_lookup(users, id))) {
- g = (struct grp *) malloc(sizeof(struct grp));
- g->next = u->lists;
- u->lists = g;
- g->lid = l;
- }
-## }
-## end transaction
-
- for (p = &(users->data[users->size - 1]); p >= users->data; p--) {
- for (b = *p; b; b = b->next) {
- if ((g = ((struct user *)b->data)->lists) == NULL)
- continue;
- fprintf(lout, "%s.grplist\tHS %s \"",
- ((struct user *)b->data)->name, HTYPE);
- for (; g; g = g->next) {
- fputs(g->lid, lout);
- if (g->next)
- putc(':', lout);
- }
- fputs("\"\n", lout);
- }
- }
-
- if (fclose(iout) || fclose(gout) || fclose(lout)) {
- fprintf(stderr, "Unsuccessful close of gid.db, group.db, or grplist.db\n");
- exit(MR_CCONFIG);
- }
- fix_file(ioutf);
- fix_file(goutf);
- fix_file(loutf);
- return(1);
-##}
-
-
-do_filsys()
-##{
- FILE *out;
- char outf[64], outft[64], *mach, machbuf[128], *group;
- register char *p;
- struct stat sb;
- time_t ftime;
- struct save_queue *sq, *sq_create();
-## char name[33], type[9], loc[81], access[2], mount[33], trans[257];
-## char *filetime, comments[65];
-## int flag1, flag2, flag3, flag4, id, fid;
- char *index();
-
- sprintf(outf, "%s/filsys.db", hesiod_dir);
-
- if (stat(outf, &sb) == 0) {
- ftime = sb.st_mtime;
- filetime = ingres_date_and_time(ftime);
-## retrieve (flag1 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "filesys"
-## retrieve (flag2 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "machine"
-## retrieve (flag3 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "alias"
-## retrieve (flag4 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "fsgroup"
- if (flag1 < 0 && flag2 < 0 && flag3 < 0 && flag4 < 0) {
- fprintf(stderr, "File filsys.db does not need to be rebuilt.\n");
- return(0);
- }
- }
-
- sprintf(outft, "%s~", outf);
- out = fopen(outft, "w");
- if (!out) {
- perror("cannot open filsys.db for write");
- exit(MR_OCONFIG);
- }
-
- fprintf(stderr, "Building filsys.db\n");
- get_mach();
- sq = sq_create();
-
-## range of f is filesys
-## retrieve (name = f.label, type = f.#type, loc = f.#name, id = f.mach_id,
-## access = f.#access, mount = f.#mount, comments = f.#comments,
-## fid = f.filsys_id) {
- strtrim(type);
- if (!strcmp(type, "NFS") || !strcmp(type, "RVD")) {
- if (mach = hash_lookup(machines, id)) {
- for (p = machbuf; *mach && *mach != '.'; mach++) {
- if (isupper(*mach))
- *p++ = tolower(*mach);
- else
- *p++ = *mach;
- }
- *p = 0;
- fprintf(out, "%s.filsys\tHS %s \"%s %s %s %s %s\"\n",
- strtrim(name), HTYPE, type, strtrim(loc), machbuf,
- strtrim(access), strtrim(mount));
- }
- } else if (!strcmp(type, "AFS")) {
- fprintf(out, "%s.filsys\tHS %s \"AFS %s %s %s\"\n",
- strtrim(name), HTYPE, strtrim(loc), strtrim(access),
- strtrim(mount));
- } else if (!strcmp(type, "ERR")) {
- fprintf(out, "%s.filsys\tHS %s \"ERR %s\"\n",
- name, HTYPE, strtrim(comments));
- } else if (!strcmp(type, "FSGROUP")) {
- sprintf(trans, "%s:%d", strtrim(name), fid);
- sq_save_data(sq, strsave(trans));
- }
-## }
-
-## range of g is fsgroup
- while (sq_get_data(sq, &group)) {
- fid = atoi(index(group, ':')+1);
- *index(group, ':') = 0;
-## retrieve (type = f.#type, loc = f.#name, id = f.mach_id,
-## access = f.#access, mount = f.#mount, comments = f.#comments,
-## name = f.#label, trans = g.#key)
-## where f.filsys_id = g.filsys_id and g.group_id = fid
-## sort by #trans, #name {
- strtrim(type);
- if (!strcmp(type, "NFS") || !strcmp(type, "RVD")) {
- if (mach = hash_lookup(machines, id)) {
- for (p = machbuf; *mach && *mach != '.'; mach++) {
- if (isupper(*mach))
- *p++ = tolower(*mach);
- else
- *p++ = *mach;
- }
- *p = 0;
- fprintf(out, "%s.filsys\tHS %s \"%s %s %s %s %s\"\n",
- group, HTYPE, type, strtrim(loc), machbuf,
- strtrim(access), strtrim(mount));
- }
- } else if (!strcmp(type, "AFS")) {
- fprintf(out, "%s.filsys\tHS %s \"AFS %s %s %s\"\n",
- group, HTYPE, strtrim(loc), strtrim(access),
- strtrim(mount));
- } else if (!strcmp(type, "ERR")) {
- fprintf(out, "%s.filsys\tHS %s \"ERR %s\"\n",
- group, HTYPE, strtrim(comments));
- }
-## }
- free(group);
- }
- sq_destroy(sq);
-
-## range of a is alias
-## retrieve (name = a.#name, trans = a.#trans) where a.#type = "FILESYS" {
- fprintf(out, "%s.filsys\tHS CNAME %s.filsys\n",
- strtrim(name), strtrim(trans));
-## }
-
- if (fclose(out)) {
- fprintf(stderr, "Unsuccessful close of filsys.db\n");
- exit(MR_CCONFIG);
- }
- fix_file(outf);
- return(1);
-##}
-
-
-/*
- * Modified from sys/types.h:
- */
-int setsize; /* = howmany(setbits, NSETBITS) */
-
-typedef long set_mask;
-#define NSETBITS (sizeof(set_mask) * NBBY) /* bits per mask */
-#ifndef howmany
-#define howmany(x, y) (((x)+((y)-1))/(y))
-#endif
-
-#define SET_SET(n, p) ((p)[(n)/NSETBITS] |= (1 << ((n) % NSETBITS)))
-#define SET_CLR(n, p) ((p)[(n)/NSETBITS] &= ~(1 << ((n) % NSETBITS)))
-#define SET_ISSET(n, p) ((p)[(n)/NSETBITS] & (1 << ((n) % NSETBITS)))
-#define SET_CREATE() ((set_mask *)malloc(setsize * sizeof(set_mask)))
-#define SET_ZERO(p) bzero((char *)(p), setsize * sizeof(set_mask))
-#define SET_CMP(p1, p2) (bcmp((p1), (p2), setsize * sizeof(set_mask)))
-
-int nbitsset(set)
-set_mask *set;
-{
- int i, ret;
-
- ret = 0;
- for (i = 0; i < setsize * NSETBITS; i++)
- if (SET_ISSET(i, set))
- ret++;
- return(ret);
-}
-
-
-do_cluster()
-##{
- FILE *out;
- char outf[64], outft[64], *mach, machbuf[33], *p;
- struct stat sb;
- time_t ftime;
-## int flag1, flag2, flag3, flag4, maxmach, maxclu, mid, cid, id;
-## char name[33], label[17], data[33], *filetime;
- set_mask **machs, *ms, *ps;
- int oneclu;
-
- sprintf(outf, "%s/cluster.db", hesiod_dir);
-
- if (stat(outf, &sb) == 0) {
- ftime = sb.st_mtime;
- filetime = ingres_date_and_time(ftime);
-## retrieve (flag1 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "cluster"
-## retrieve (flag2 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "machine"
-## retrieve (flag3 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "mcmap"
-## retrieve (flag4 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "svc"
- if (flag1 < 0 && flag2 < 0 && flag3 < 0 && flag4 < 0) {
- fprintf(stderr, "File cluster.db does not need to be rebuilt.\n");
- return(0);
- }
- }
-
- sprintf(outft, "%s~", outf);
- out = fopen(outft, "w");
- if (!out) {
- perror("cannot open cluster.db for write");
- exit(MR_OCONFIG);
- }
-
- fprintf(stderr, "Building cluster.db\n");
- get_mach();
-
-## range of c is cluster
-## begin transaction
-## retrieve (maxclu = max(c.clu_id))
- maxclu++;
- setsize = howmany(maxclu, NSETBITS);
-## range of m is machine
-## retrieve (maxmach = max(m.mach_id))
- maxmach++;
- machs = (set_mask **)malloc((maxmach + 1) * sizeof(set_mask **));
- bzero(machs, (maxmach + 1) * sizeof(int));
-
-## range of p is mcmap
-## retrieve (mid = p.mach_id, cid = p.clu_id) {
- if (!(ms = machs[mid])) {
- ms = machs[mid] = SET_CREATE();
- SET_ZERO(ms);
- }
- SET_SET(cid, ms);
-## }
-
-## range of d is svc
- for (mid = 1; mid < maxmach; mid++) {
- if (!machs[mid])
- continue;
- ms = machs[mid];
- if (nbitsset(ms) > 1) {
- oneclu = 0;
- for (cid = 1; cid < maxclu; cid++) {
- if (SET_ISSET(cid, ms)) {
-## repeat retrieve (label = d.serv_label, data = d.serv_cluster)
-## where d.clu_id = @cid {
- strtrim(label);
- strtrim(data);
- fprintf(out,
- "mrinternal-%d.cluster\tHS %s \"%s %s\"\n",
- mid, HTYPE, label, data);
-## }
- }
- }
- } else {
- oneclu = 1;
- for (cid = 1; cid < maxclu; cid++)
- if (SET_ISSET(cid, ms)) break;
-## repeat retrieve (name = c.#name) where c.clu_id = @cid
- strtrim(name);
- }
-
- if (mach = hash_lookup(machines, mid)) {
- for (p = machbuf; *mach && *mach != '.'; mach++)
- *p++ = *mach;
- *p = 0;
- if (oneclu)
- fprintf(out, "%s.cluster\tHS CNAME %s.cluster\n",
- machbuf, name);
- else
- fprintf(out, "%s.cluster\tHS CNAME mrinternal-%d.cluster\n",
- machbuf, mid);
- }
- for (id = mid + 1; id < maxmach; id++) {
- if ((ps = machs[id]) && !SET_CMP(ms, ps)) {
- free(ps);
- machs[id] = NULL;
- if (mach = hash_lookup(machines, id)) {
- for (p = machbuf; *mach && *mach != '.'; mach++)
- *p++ = *mach;
- *p = 0;
- if (oneclu)
- fprintf(out, "%s.cluster\tHS CNAME %s.cluster\n",
- machbuf, name);
- else
- fprintf(out,
- "%s.cluster\tHS CNAME mrinternal-%d.cluster\n",
- machbuf, mid);
- }
- }
- }
- free(ms);
- machs[mid] = NULL;
- }
-
-## retrieve (name = c.#name, label = d.serv_label, data = d.serv_cluster)
-## where c.clu_id = d.clu_id {
- strtrim(name);
- strtrim(label);
- strtrim(data);
- fprintf(out, "%s.cluster\tHS %s \"%s %s\"\n",
- name, HTYPE, label, data);
-## }
-## end transaction
- free(machs);
-
- if (fclose(out)) {
- fprintf(stderr, "Unsuccessful close of cluster.db\n");
- exit(MR_CCONFIG);
- }
- fix_file(outf);
- return(1);
-##}
-
-
-do_printcap()
-##{
- FILE *out;
- char outf[64], outft[64];
- struct stat sb;
- time_t ftime;
-## char name[17], rp[17], sd[33], rm[33], rq[33], *filetime;
-## int flag, ka, pc;
-
- sprintf(outf, "%s/printcap.db", hesiod_dir);
-
- if (stat(outf, &sb) == 0) {
- ftime = sb.st_mtime;
- filetime = ingres_date_and_time(ftime);
-## retrieve (flag = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "printcap"
- if (flag < 0) {
- fprintf(stderr, "File printcap.db does not need to be rebuilt.\n");
- return(0);
- }
- }
-
- sprintf(outft, "%s~", outf);
- out = fopen(outft, "w");
- if (!out) {
- perror("cannot open printcap.db for write");
- exit(MR_OCONFIG);
- }
-
- fprintf(stderr, "Building printcap.db\n");
-
-## range of p is printcap
-## range of m is machine
-## retrieve (name = p.#name, rp = p.#rp, sd = p.dir, rm = machine.#name,
-## ka = p.auth, pc = p.price, rq = m.#name)
-## where machine.mach_id = p.mach_id and m.mach_id = p.quotaserver {
- strtrim(name);
- strtrim(rp);
- strtrim(sd);
- strtrim(rm);
- strtrim(rq);
- fprintf(out, "%s.pcap\tHS %s \"%s:rp=%s:rm=%s:sd=%s:ka#%d:pc#%d",
- name, HTYPE, name, rp, rm, sd, ka, pc);
- if (strcmp(rq, "[NONE]"))
- fprintf(out, ":rq=%s\"\n", rq);
- else
- fputs("\"\n", out);
-## }
-
- if (fclose(out)) {
- fprintf(stderr, "Unsuccessful close of pcap.db\n");
- exit(MR_CCONFIG);
- }
- fix_file(outf);
- return(1);
-##}
-
-
-do_palladium()
-##{
- FILE *out;
- char outf[64], outft[64];
- struct stat sb;
- time_t ftime;
-## char name[33], rm[33], trans[129], *filetime;
-## int flag, flag1, ident;
-
- sprintf(outf, "%s/palladium.db", hesiod_dir);
-
- if (stat(outf, &sb) == 0) {
- ftime = sb.st_mtime;
- filetime = ingres_date_and_time(ftime);
-## retrieve (flag = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "palladium"
-## retrieve (flag1 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "alias"
- if (flag < 0 && flag1 < 0) {
- fprintf(stderr, "File palladium.db does not need to be rebuilt.\n");
- return(0);
- }
- }
-
- sprintf(outft, "%s~", outf);
- out = fopen(outft, "w");
- if (!out) {
- perror("cannot open palladium.db for write");
- exit(MR_OCONFIG);
- }
-
- fprintf(stderr, "Building palladium.db\n");
-
-## range of p is palladium
-## retrieve (name = p.#name, ident = p.#ident, rm = machine.#name)
-## where machine.mach_id = p.mach_id {
- strtrim(name);
- strtrim(rm);
- fprintf(out,
- "%s.palladium\tHS %s \"%s %d %s interface directory\"\n",
- name, HTYPE, rm, ident, name);
-## }
-## range of a is alias
-## retrieve (name = a.#name, trans = a.#trans) where a.#type = "PALLADIUM" {
- strtrim(name);
- strtrim(trans);
- fprintf(out, "%s.palladium\tHS %s \"%s\"\n", name, HTYPE, trans);
-## }
-
- if (fclose(out)) {
- fprintf(stderr, "Unsuccessful close of palladium.db\n");
- exit(MR_CCONFIG);
- }
- fix_file(outf);
- return(1);
-##}
-
-
-do_sloc()
-##{
- FILE *out;
- char outf[64], outft[64], *mach;
- struct stat sb;
- time_t ftime;
-## char service[17], *filetime;
-## int flag1, flag2, id;
-
- sprintf(outf, "%s/sloc.db", hesiod_dir);
-
- if (stat(outf, &sb) == 0) {
- ftime = sb.st_mtime;
- filetime = ingres_date_and_time(ftime);
-## retrieve (flag1 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "serverhosts"
-## retrieve (flag2 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "machine"
- if (flag1 < 0 && flag2 < 0) {
- fprintf(stderr, "File sloc.db does not need to be rebuilt.\n");
- return(0);
- }
- }
-
- sprintf(outft, "%s~", outf);
- out = fopen(outft, "w");
- if (!out) {
- perror("cannot open sloc.db for write");
- exit(MR_OCONFIG);
- }
-
- fprintf(stderr, "Building sloc.db\n");
- get_mach();
-
-## range of s is serverhosts
-## retrieve (service = s.#service, id = s.mach_id)
-## sort by #service {
- strtrim(service);
- if (mach = hash_lookup(machines, id))
- fprintf(out, "%s.sloc\tHS %s %s\n", service, HTYPE, mach);
-## }
-
- if (fclose(out)) {
- fprintf(stderr, "Unsuccessful close of sloc.db\n");
- exit(MR_CCONFIG);
- }
-
- fix_file(outf);
- return(1);
-##}
-
-do_service()
-##{
- FILE *out;
- char outf[64], outft[64];
- struct stat sb;
- time_t ftime;
-## char service[33], protocol[9], altserv[129], *filetime;
-## int port, flag1;
-
- sprintf(outf, "%s/service.db", hesiod_dir);
-
- if (stat(outf, &sb) == 0) {
- ftime = sb.st_mtime;
- filetime = ingres_date_and_time(ftime);
-## retrieve (flag1 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "services"
- if (flag1 < 0) {
- fprintf(stderr, "File service.db does not need to be rebuilt.\n");
- return(0);
- }
- }
-
- sprintf(outft, "%s~", outf);
- out = fopen(outft, "w");
- if (!out) {
- perror("cannot open service.db for write");
- exit(MR_OCONFIG);
- }
-
- fprintf(stderr, "Building service.db\n");
-
-## range of s is services
-## retrieve (service = s.name, protocol = lowercase(s.#protocol),
-## port = s.#port) {
- strtrim(service);
- strtrim(protocol);
- fprintf(out, "%s.service\tHS %s \"%s %s %d\"\n",
- service, HTYPE, service, protocol, port);
-## }
-
-## range of a is alias
-## retrieve (service = a.name, altserv = a.trans) where a.type = "SERVICE" {
- strtrim(service);
- strtrim(altserv);
- fprintf(out, "%s.service\tHS CNAME %s.service\n", service, altserv);
-## }
-
- if (fclose(out)) {
- fprintf(stderr, "Unsuccessful close of service.db\n");
- exit(MR_CCONFIG);
- }
- fix_file(outf);
- return(1);
-##}
+++ /dev/null
-#!/moira/bin/perl
-# $Header$
-# This script prints the letters confirming registration for the extra
-# kerberos principal.
-
-# The algorithm consists of first checking to see that the previous
-# day's job printed. If so, the cached copy is deleted. Otherwise,
-# today's is appended to yesterday's and we continue working with that.
-
-$printer = "linus";
-$newfile = "/tmp/letter.out";
-$savefile = "/u1/letter.save";
-$holdfile = "/u1/letter.hold";
-
-$printed =`lpquota -l | tail -2`;
-@printed = split(/\s+/, $printed);
-
-$filed = `ls -l $savefile`;
-@filed = split(/\s+/, $filed);
-
-if ($printed[1] eq $filed[4] && $printed[2] eq $filed[5]) {
- system("mv $newfile $savefile");
-} else {
- if ( -s $savefile) {
- if ( ! -f $holdfile) {
- open(MAIL, "|/bin/mail dbadmin thorne");
- print MAIL "To: dbadmin, thorne\n";
- print MAIL "Subject: reg_extra printing error\n";
- print MAIL "Reg_extra letters failed to print yesterday\n";
- print MAIL $filed;
- print MAIL $printed;
- close(MAIL);
- }
- system("cat $newfile >> $savefile");
- } else {
- system("mv $newfile $savefile");
- }
-}
-
-unlink($holdfile);
-
-open(OUT, "lpr -P$printer -h $savefile|");
-$msg = <OUT>;
-close(OUT);
-
-if ($msg eq "Printer queue is disabled.") {
- open(FOO, $holdfile);
- close(FOO);
-}
-
-exit 0;
/Times-Roman findfont 10 scalefont setfont
92 708 moveto(Athena User Accounts)show
-92 696 moveto(MIT Room 11-124H)show
+92 696 moveto(MIT Room 11-124G)show
92 684 moveto(77 Massachusetts Ave)show
92 672 moveto(Cambridge, MA 02139)show
/Times-Roman findfont 12 scalefont setfont
+++ /dev/null
-
-/* $Header$
- *
- * This generates the /usr/lib/aliases file for the mailhub.
- *
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- */
-
-#include <mit-copyright.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <moira.h>
-#include <moira_site.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-
-
-extern int errno;
-char *whoami = "mailhub.gen";
-char *ingres_date_and_time();
-char *perm_malloc();
-char *pstrsave();
-char *divide = "##############################################################";
-
-#define ML_WID 72
-#define AL_MAX_WID 896
-
-#define FALSE 0
-#define TRUE (!FALSE)
-
-FILE *out= stdout;
-
-
-main(argc, argv)
-int argc;
-char **argv;
-{
- long tm = time(NULL);
- char filename[64], *targetfile;
- struct stat sb;
-## int flag;
-## char *filetime;
- int ingerr();
-
- IIseterr(ingerr);
-## ingres sms
-## set lockmode session where level = table
-
- if (argc == 2) {
- if (stat(argv[1], &sb) == 0) {
- filetime = ingres_date_and_time(sb.st_mtime);
-## retrieve (flag = int4(interval("min",tblstats.modtime - filetime)))
-## where tblstats.table = "users"
- if (flag < 0) {
- fprintf(stderr, "File %s does not need to be rebuilt.\n",
- argv[1]);
- exit(MR_NO_CHANGE);
- }
- }
- targetfile = argv[1];
- sprintf(filename, "%s~", targetfile);
- if ((out = fopen(filename, "w")) == NULL) {
- fprintf(stderr, "unable to open %s for output\n", filename);
- exit(MR_OCONFIG);
- }
- } else if (argc != 1) {
- fprintf(stderr, "usage: %s [outfile]\n", argv[0]);
- exit(MR_ARGS);
- }
-
- fprintf(out, "%s\n# Aliases File Extract of %s", divide, ctime(&tm));
- fprintf(out, "# This file is automatically generated, do not edit it directly.\n%s\n\n", divide);
-
-## begin transaction
- get_info();
-## end transaction
-## exit
-
- fprintf(stderr, "Sorting Info\n");
- sort_info();
-
- fprintf(stderr, "Dumping information\n");
- do_people();
-
- fprintf(out, "\n%s\n# End of aliases file\n", divide);
-
- if (fclose(out)) {
- perror("close failed");
- exit(MR_CCONFIG);
- }
-
- if (argc == 2)
- fix_file(targetfile);
- exit(MR_SUCCESS);
-}
-
-
-/*
- * ingerr: (supposedly) called when Ingres indicates an error.
- * I have not yet been able to get this to work to intercept a
- * database open error.
- */
-#define INGRES_DEADLOCK 4700
-
-static int ingerr(num)
- int *num;
-{
- char buf[256];
- int ingres_errno;
-
- switch (*num) {
- case INGRES_DEADLOCK:
- ingres_errno = MR_DEADLOCK;
- break;
- default:
- ingres_errno = MR_INGRES_ERR;
- }
- com_err(whoami, MR_INGRES_ERR, " code %d\n", *num);
- critical_alert("DCM", "Alias build encountered INGRES ERROR %d", *num);
- exit(ingres_errno);
-}
-
-struct hash *users, *machines, *strings, *lists, *names;
-struct user {
- char *login;
- char *first;
- char *last;
- char mi;
- char *pobox;
-};
-struct member {
- struct member *next;
- char *name;
- int list_id;
-};
-struct list {
- char *name;
- char maillist;
- char acl_t;
- int acl_id;
- struct member *m;
-};
-struct names {
- char *name;
- struct names *next;
- int keep:1;
- int id:31;
-};
-
-
-get_info()
-##{
-## int id, pid, bid, stat, cnt, maillistp, acl, mid;
-## char name[129], type[9], fname[17], mname[17], lname[17], buf[257];
- char *s;
- register struct user *u;
- struct list *l, *memberlist;
- register struct member *m;
-
- /* get locks */
-## retrieve (buf = users.modtime) where users.users_id = 0
-## retrieve (buf = list.modtime) where list.list_id = 0
-
- cnt = 0;
- machines = create_hash(10);
-## retrieve (id = machine.mach_id, name = machine.#name)
-## where machine.mach_id = users.pop_id {
- if (s = index(name, '.'))
- *s = 0;
- else
- strtrim(name);
-#ifdef ATHENA
- strcat(name, ".LOCAL");
-#endif
- if (hash_store(machines, id, pstrsave(name)) < 0) {
- fprintf(stderr, "Out of memory!\n");
- exit(MR_NO_MEM);
- }
- cnt++;
-## }
- fprintf(stderr, "Loaded %d machines\n", cnt);
-
- cnt = 0;
- strings = create_hash(4000);
-## retrieve (id = strings.string_id, name = strings.string) {
- if (hash_store(strings, id, pstrsave(strtrim(name))) < 0) {
- fprintf(stderr, "Out of memory!\n");
- exit(MR_NO_MEM);
- }
- cnt++;
-## }
- fprintf(stderr, "Loaded %d strings\n", cnt);
-
- cnt = 0;
- users = create_hash(12001);
-## range of u is users
-## retrieve (id = u.users_id, name = u.login, fname = u.first,
-## mname = u.middle, lname = u.last,
-## type = u.potype, pid = u.pop_id, bid = u.box_id)
-## where u.status != 3 {
- u = (struct user *) perm_malloc(sizeof(struct user));
- u->login = pstrsave(strtrim(name));
- u->first = pstrsave(strtrim(fname));
- u->last = pstrsave(strtrim(lname));
- if (mname[0] != ' ')
- u->mi = mname[0];
- else
- u->mi = 0;
-
- if (type[0] == 'P' && (s = hash_lookup(machines, pid))) {
- sprintf(buf, "%s@%s", u->login, s);
- u->pobox = pstrsave(buf);
- } else if (type[0] == 'S') {
- u->pobox = hash_lookup(strings, bid);
- } else
- u->pobox = (char *) NULL;
- if (hash_store(users, id, u) < 0) {
- fprintf(stderr, "Out of memory!\n");
- exit(MR_NO_MEM);
- }
- cnt++;
-## }
- fprintf(stderr, "Loaded %d users\n", cnt);
-
- cnt = 0;
- lists = create_hash(15000);
-## range of l is list
-## retrieve (id = l.list_id, name = l.#name, maillistp = l.maillist,
-## type = l.acl_type, acl = l.acl_id)
-## where l.active != 0 {
- l = (struct list *) perm_malloc(sizeof(struct list));
- l->name = pstrsave(strtrim(name));
- l->maillist = maillistp;
- l->acl_t = type[0];
- l->acl_id = acl;
- l->m = (struct member *) NULL;
- if (hash_store(lists, id, l) < 0) {
- fprintf(stderr, "Out of memory!\n");
- exit(MR_NO_MEM);
- }
- cnt++;
-## }
- fprintf(stderr, "Loaded %d lists\n", cnt);
-
- cnt = 0;
-## range of m is imembers
-## retrieve (id = m.list_id, type = m.member_type, mid = m.member_id)
-## where m.direct = 1 {
- cnt++;
- if (l = (struct list *) hash_lookup(lists, id)) {
- m = (struct member *) perm_malloc(sizeof(struct member));
- if (type[0] == 'U' &&
- (u = (struct user *) hash_lookup(users, mid))) {
- m->list_id = 0;
- m->name = u->login;
- m->next = l->m;
- l->m = m;
- } else if (type[0] == 'L' &&
- (memberlist = (struct list *) hash_lookup(lists, mid))) {
- m->list_id = mid;
- m->name = memberlist->name;
- m->next = l->m;
- l->m = m;
- } else if (type[0] == 'S' &&
- (s = hash_lookup(strings, mid))) {
- m->list_id = 0;
- m->next = l->m;
- l->m = m;
- m->name = s;
- }
- }
-## }
- fprintf(stderr, "Loaded %d members\n", cnt);
-##}
-
-
-save_mlist(id, l, force)
-int id;
-struct list *l;
-int force;
-{
- register struct member *m;
- register struct list *l1;
-
- if (l->maillist > 1 ||
- (l->maillist == 0 && !force))
- return;
-
- if (l->m && l->m->next == NULL &&
- !strcasecmp(l->name, l->m->name)) {
- l->maillist = 3;
- return;
- }
- l->maillist = 2;
- insert_name(l->name, -1, TRUE, FALSE);
- output_mlist(id, l);
-
- if (l->acl_t == 'L' && (l1 = (struct list *)hash_lookup(lists, l->acl_id)))
- save_mlist(0, l1, TRUE);
-
- for (m = l->m; m; m = m->next) {
- if (m->list_id && (l1 = (struct list *)hash_lookup(lists, m->list_id)))
- save_mlist(0, l1, TRUE);
- }
-}
-
-
-insert_login(id, u, dummy)
-int id;
-struct user *u;
-int dummy;
-{
- if (u->pobox && u->login[0] != '#')
- insert_name(u->login, id, TRUE, FALSE);
-}
-
-void insert_names(id, u, dummy)
-int id;
-struct user *u;
-int dummy;
-{
- char buffer[256];
-
- insert_name(u->last, id, FALSE, FALSE);
- sprintf(buffer, "%s_%s", u->first, u->last);
- insert_name(buffer, id, FALSE, TRUE);
-/* sprintf(buffer, "%c_%s", u->first[0], u->last);
- insert_name(buffer, id, FALSE, TRUE); */
- if (u->mi) {
- sprintf(buffer, "%s_%c_%s", u->first, u->mi, u->last);
- insert_name(buffer, id, FALSE, TRUE);
- }
-}
-
-int incount = 0;
-
-insert_name(s, id, nodups, copy)
-char *s;
-int id;
-int nodups;
-int copy;
-{
- int code;
- register struct names *ns;
- register int count;
- register struct idblock *ra;
-
- incount++;
- code = hashstr(s);
- ns = (struct names *) hash_lookup(names, code);
- if (ns == NULL) {
- if ((ns = (struct names *) perm_malloc(sizeof(struct names))) == NULL) {
- fprintf(stderr, "ran out of memory inserting name (sorting)\n");
- exit(MR_NO_MEM);
- }
- if (copy)
- ns->name = pstrsave(s);
- else
- ns->name = s;
- ns->keep = nodups;
- ns->id = id;
- ns->next = NULL;
- if (hash_store(names, code, ns) < 0) {
- fprintf(stderr, "Out of memory!\n");
- exit(MR_NO_MEM);
- }
- return;
- }
- if (strcasecmp(ns->name, s)) {
- while (ns->next) {
- ns = ns->next;
- if (!strcasecmp(ns->name, s))
- goto foundns;
- }
- if ((ns->next = (struct names *) perm_malloc(sizeof(struct names)))
- == NULL) {
- fprintf(stderr, "ran out of memory insterting name (sorting)\n");
- exit(MR_NO_MEM);
- }
- ns = ns->next;
- if (copy)
- ns->name = pstrsave(s);
- else
- ns->name = s;
- ns->keep = nodups;
- ns->id = id;
- ns->next = NULL;
- return;
- }
- foundns:
- if (nodups || ns->keep) {
- if (nodups && ns->keep)
- fprintf(stderr, "duplicated named: %s\n", s);
- return;
- }
- ns->id = 0;
-}
-
-
-/* Illegal chars: ! " % ( ) , . / : ; < = > @ [ \ ] ^ { | } */
-
-static int illegalchars[] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ^@ - ^O */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ^P - ^_ */
- 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, /* SPACE - / */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, /* 0 - ? */
- 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ - O */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, /* P - _ */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ` - o */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, /* p - ^? */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-};
-
-
-/* While hashing the string, punt any illegal characters */
-
-int hashstr(s)
-register char *s;
-{
- register int result;
- register int c;
-
- for (result = 0; c = *s; s++) {
- if (illegalchars[c]) {
- register char *p;
- for (p = s; *p; p++)
- *p = p[1];
- continue;
- }
- if (isupper(c))
- c = *s = tolower(c);
-/* result = result * 31 + *s; */
- result = (result << 5) - result + c - '`';
- }
- return(result < 0 ? -result : result);
-}
-
-
-sort_info()
-{
- names = create_hash(20001);
- hash_step(users, insert_login, NULL);
- incount = 0;
- fprintf(out, "\n%s\n# Mailing lists\n%s\n", divide, divide);
- hash_step(lists, save_mlist, FALSE);
- fprintf(stderr, "Output %d lists\n", incount);
- hash_step(users, insert_names, NULL);
- fprintf(stderr, "Inserted %d names\n", incount);
-}
-
-
-output_data(dummy, nms, out)
-int dummy;
-struct names *nms;
-FILE *out;
-{
- register struct names *ns;
- register struct user *u;
-
- incount++;
- for (ns = nms; ns; ns = ns->next) {
- if (ns->name[0] == 0 || ns->name[1] == 0) {
- fprintf(stderr, "punting %s due to short name\n", ns->name);
- continue;
- }
- if (ns->id > 0) {
- u = (struct user *) hash_lookup(users, ns->id);
- if (u->pobox) {
- fprintf(out, "%s: %s\n", ns->name, u->pobox);
- } else {
- fprintf(out, "%s: =%s=@nobox\n", ns->name, ns->name);
- }
- } else if (ns->id == 0) {
- fprintf(out, "%s: =%s=@ambig\n", ns->name, ns->name);
- }
- }
-}
-
-
-int lwid, bol, awid;
-
-output_mlist(id, l)
-int id;
-register struct list *l;
-{
- struct list *l1;
- register struct member *m;
- register struct user *u;
-
- if (l->acl_t == 'L' &&
- (l1 = (struct list *) hash_lookup(lists, l->acl_id)))
- fprintf(out, "owner-%s: %s\n%s: ", l->name, l1->name, l->name);
- else if (l->acl_t == 'U' &&
- (u = (struct user *) hash_lookup(users, l->acl_id)))
- fprintf(out, "owner-%s: %s\n%s: ", l->name, u->login, l->name);
- else
- fprintf(out, "%s: ", l->name);
-
-
- lwid = strlen(l->name) + 2;
- bol = 1;
- for (m = l->m; m; m = m->next) {
- do_member(out, m->name);
- }
- if (l->m == (struct member *)NULL)
- fprintf(out, "/dev/null");
- fprintf(out, "\n\n");
- incount++;
-}
-
-
-/* print out strings separated by commas, doing line breaks as appropriate */
-
-do_member(out, s)
-FILE *out;
-register char *s;
-{
- register wwid;
- static int cont = 1;
-
- wwid = strlen(s);
-
- if (!bol && awid + wwid + 2 > AL_MAX_WID) {
- fprintf(out, ",\n\tcontinuation-%d\ncontinuation-%d: ", cont, cont);
- cont++;
- awid = lwid = 17 + wwid;
- fputs(s, out);
- return;
- }
-
- if (bol) {
- lwid += wwid;
- awid = lwid;
- fputs(s, out);
- bol = 0;
- return;
- }
- if (lwid + wwid + 2 > ML_WID) {
- fprintf(out, ",\n\t%s", s);
- awid += lwid + wwid + 2;
- lwid = wwid + 8;
- return;
- }
- lwid += wwid + 2;
- fprintf(out, ", %s", s);
-}
-
-
-do_people()
-{
- incount = 0;
- fprintf(out, "\n%s\n# People\n%s\n", divide, divide);
- hash_step(names, output_data, out);
- fprintf(stderr, "Output %d entries\n", incount);
-}
-
-
-#define chunk_size 102400
-
-char *perm_malloc(size)
-unsigned size;
-{
- static char *pool = NULL;
- static unsigned pool_size = 0;
- register char *ret;
-
- if (size > pool_size) {
- pool = (char *) malloc(chunk_size);
- pool_size = chunk_size;
- }
- ret = pool;
- pool += size;
- pool = (char *)(((unsigned) (pool + 1)) & ~1);
- pool_size -= (pool - ret);
- return(ret);
-}
-
-
-/*
- * Make a (permenant) copy of a string.
- */
-char *
-pstrsave(s)
- char *s;
-{
- register int len;
- register char *p;
- /* Kludge for sloppy string semantics */
- if (!s) {
- printf("NULL != \"\" !!!!\r\n");
- p = perm_malloc(1);
- *p = '\0';
- return p;
- }
- len = strlen(s) + 1;
- p = perm_malloc((u_int)len);
- if (p) bcopy(s, p, len);
- return p;
-}
-
-#define hash_func(h, key) (key >= 0 ? (key % h->size) : (-key % h->size))
-
-/* Create a hash table. The size is just a hint, not a maximum. */
-
-struct hash *create_hash(size)
-int size;
-{
- struct hash *h;
-
- h = (struct hash *) perm_malloc(sizeof(struct hash));
- if (h == (struct hash *) NULL)
- return((struct hash *) NULL);
- h->size = size;
- h->data = (struct bucket **) perm_malloc(size * sizeof(char *));
- if (h->data == (struct bucket **) NULL) {
- free(h);
- return((struct hash *) NULL);
- }
- bzero(h->data, size * sizeof(char *));
- return(h);
-}
-
-/* Lookup an object in the hash table. Returns the value associated with
- * the key, or NULL (thus NULL is not a very good value to store...)
- */
-
-char *hash_lookup(h, key)
-struct hash *h;
-register int key;
-{
- register struct bucket *b;
-
- b = h->data[hash_func(h, key)];
- while (b && b->key != key)
- b = b->next;
- if (b && b->key == key)
- return(b->data);
- else
- return(NULL);
-}
-
-
-/* Update an existing object in the hash table. Returns 1 if the object
- * existed, or 0 if not.
- */
-
-int hash_update(h, key, value)
-struct hash *h;
-register int key;
-char *value;
-{
- register struct bucket *b;
-
- b = h->data[hash_func(h, key)];
- while (b && b->key != key)
- b = b->next;
- if (b && b->key == key) {
- b->data = value;
- return(1);
- } else
- return(0);
-}
-
-
-/* Store an item in the hash table. Returns 0 if the key was not previously
- * there, 1 if it was, or -1 if we ran out of memory.
- */
-
-int hash_store(h, key, value)
-struct hash *h;
-register int key;
-char *value;
-{
- register struct bucket *b, **p;
-
- p = &(h->data[hash_func(h, key)]);
- if (*p == NULL) {
- b = *p = (struct bucket *) perm_malloc(sizeof(struct bucket));
- if (b == (struct bucket *) NULL)
- return(-1);
- b->next = NULL;
- b->key = key;
- b->data = value;
- return(0);
- }
-
- for (b = *p; b && b->key != key; b = *p)
- p = (struct bucket **) *p;
- if (b && b->key == key) {
- b->data = value;
- return(1);
- }
- b = *p = (struct bucket *) perm_malloc(sizeof(struct bucket));
- if (b == (struct bucket *) NULL)
- return(-1);
- b->next = NULL;
- b->key = key;
- b->data = value;
- return(0);
-}
-
-
-/* Search through the hash table for a given value. For each piece of
- * data with that value, call the callback proc with the corresponding key.
- */
-
-hash_search(h, value, callback)
-struct hash *h;
-register char *value;
-void (*callback)();
-{
- register struct bucket *b, **p;
-
- for (p = &(h->data[h->size - 1]); p >= h->data; p--) {
- for (b = *p; b; b = b->next) {
- if (b->data == value)
- (*callback)(b->key);
- }
- }
-}
-
-
-/* Step through the hash table, calling the callback proc with each key.
- */
-
-hash_step(h, callback, hint)
-struct hash *h;
-void (*callback)();
-char *hint;
-{
- register struct bucket *b, **p;
-
- for (p = &(h->data[h->size - 1]); p >= h->data; p--) {
- for (b = *p; b; b = b->next) {
- (*callback)(b->key, b->data, hint);
- }
- }
-}
-
-
-/* Deallocate all of the memory associated with a table */
-
-hash_destroy(h)
-struct hash *h;
-{
- register struct bucket *b, **p, *b1;
-
- for (p = &(h->data[h->size - 1]); p >= h->data; p--) {
- for (b = *p; b; b = b1) {
- b1 = b->next;
- free(b);
- }
- }
-}
+++ /dev/null
-/* $Header$
- *
- * This generates the input file for the mkdirdb program for the MIT.EDU
- * mailhub.
- *
- * (c) Copyright 1989 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- */
-
-
-#include <mit-copyright.h>
-#include <stdio.h>
-#include <string.h>
-#include <moira.h>
-#include <moira_site.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-
-
-extern int errno;
-char *whoami = "finger.gen";
-char *ingres_date_and_time();
-
-
-main(argc, argv)
-int argc;
-char **argv;
-{
- long tm = time(NULL);
- FILE *out= stdout;
- char filename[64], *targetfile;
- struct stat sb;
-## int flag1;
-## char *filetime;
- int ingerr();
-
- IIseterr(ingerr);
- initialize_sms_error_table();
-## ingres sms
-## set lockmode session where level = table
-
- if (argc == 2) {
- if (stat(argv[1], &sb) == 0) {
- filetime = ingres_date_and_time(sb.st_mtime);
-## retrieve (flag1 = int4(interval("min",tblstats.modtime - filetime)))
-## where tblstats.table = "users"
- if (flag1 < 0) {
- fprintf(stderr, "File %s does not need to be rebuilt.\n",
- argv[1]);
- exit(MR_NO_CHANGE);
- }
- }
- targetfile = argv[1];
- sprintf(filename, "%s~", targetfile);
- if ((out = fopen(filename, "w")) == NULL) {
- fprintf(stderr, "unable to open %s for output\n", filename);
- exit(MR_OCONFIG);
- }
- } else if (argc != 1) {
- fprintf(stderr, "usage: %s [outfile]\n", argv[0]);
- exit(MR_ARGS);
- }
-
-## begin transaction
- get_info(out);
-## end transaction
-## exit
-
- if (fclose(out)) {
- perror("close failed");
- exit(MR_CCONFIG);
- }
-
- if (argc == 2)
- fix_file(targetfile);
- exit(MR_SUCCESS);
-}
-
-
-/*
- * ingerr: (supposedly) called when Ingres indicates an error.
- * I have not yet been able to get this to work to intercept a
- * database open error.
- */
-#define INGRES_DEADLOCK 4700
-
-static int ingerr(num)
- int *num;
-{
- char buf[256];
- int ingres_errno;
-
- switch (*num) {
- case INGRES_DEADLOCK:
- ingres_errno = MR_DEADLOCK;
- break;
- default:
- ingres_errno = MR_INGRES_ERR;
- }
- com_err(whoami, MR_INGRES_ERR, " code %d\n", *num);
- critical_alert("DCM", "Alias build encountered INGRES ERROR %d", *num);
- exit(ingres_errno);
-}
-
-
-get_info(out)
-FILE *out;
-##{
-## int id, pid, bid, mid;
-## char name[129], type[9], buf[257], fname[17], mname[17], lname[17];
-## char year[9], dept[13], oaddr[17], ophone[13], haddr[81], hphone[17];
-## char affil[5];
- int mitroom, mitphone;
- char stuemp, *mhost, *uname, *pob, *tmp;
- struct hash *strings;
-
- /* get locks */
-## retrieve (buf = users.modtime) where users.users_id = 0
-
- strings = create_hash(2000);
-## retrieve (id = strings.string_id, name = strings.string) {
- hash_store(strings, id, strsave(strtrim(name)));
-## }
-
-
-## range of u is users
-## retrieve (id = u.users_id, name = u.login,
-## fname = u.first, mname = u.middle, lname = u.last,
-## year = u.mit_year, dept = u.mit_dept,
-## oaddr = u.office_addr, ophone = u.office_phone,
-## haddr = u.home_addr, hphone = u.home_phone,
-## type = u.potype, bid = u.box_id)
-## where u.status != 3 {
-
- if (id == 0)
- continue;
-
- strtrim(year);
- if (atoi(year) || !strcmp(year, "G"))
- stuemp = 'S';
- else if (!strcmp(year, "FACULTY") || !strcmp(year, "MITS") ||
- !strcmp(year, "STAFF"))
- stuemp = 'E';
- else if (!strcmp(year, "PROJECT") || !strcmp(year, "SYSTEM"))
- continue;
- else
- stuemp = '?';
-
- if (type[0] == 'S' & (pob = hash_lookup(strings, bid)) != NULL) {
- uname = pob;
- mhost = index(pob, '@');
- if (mhost)
- *mhost++ = 0;
- else
- mhost = &uname[strlen(uname) + 1];
- } else if (type[0] == 'N') {
- mhost = "";
- uname = "";
- } else {
- mhost = "ATHENA.MIT.EDU";
- uname = strtrim(name);
- }
-
- strtrim(oaddr);
- if (oaddr[0] != ' ') {
- tmp = &oaddr[strlen(oaddr) - 1];
- if (*tmp == 'm' || *tmp == 'M') {
- *tmp = 0;
- }
- }
-
- if (tmp = index(ophone, '-')) {
- bcopy(tmp+1, tmp, strlen(tmp)-1);
- }
- if (tmp = index(hphone, '-')) {
- bcopy(tmp+1, tmp, strlen(tmp)-1);
- }
-
- fprintf(out, "%c:%s, %s %s:",
- stuemp, strtrim(lname), strtrim(fname), strtrim(mname));
- fprintf(out, "%s:%s:%s:%s::", lname, fname, mname, oaddr);
- if (ophone[0] != ' ')
- fprintf(out, "%010d:::%s:%s:%s:",
- atoi(ophone), strtrim(dept), uname, mhost);
- else
- fprintf(out, ":::%s:%s:%s:",
- strtrim(dept), uname, mhost);
- if (hphone[0] != ' ')
- fprintf(out, "%s:::::%010d::::%s::0\n",
- strtrim(haddr), atoi(hphone), year);
- else
- fprintf(out, "%s:::::::::%s::0\n",
- strtrim(haddr), year);
-## }
-##}
+++ /dev/null
-/* $Header$
- *
- * This generates the files necessary to load an nfs server.
- *
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- */
-
-#include <mit-copyright.h>
-#include <stdio.h>
-#include <moira.h>
-#include <moira_site.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-
-
-#define min(x,y) ((x) < (y) ? (x) : (y))
-
-char *whoami = "nfs.gen";
-char *malloc(), *strsave();
-char *ingres_date_and_time(), *ingres_time(), *ingres_date();
-char nfs_dir[64];
-
-main(argc, argv)
-int argc;
-char **argv;
-{
- char cmd[64];
- struct stat sb;
- int changed = 0;
- int ingerr();
-
- if (argc > 2) {
- fprintf(stderr, "usage: %s [outfile]\n", argv[0]);
- exit(MR_ARGS);
- }
-
- IIseterr(ingerr);
- initialize_sms_error_table();
- sprintf(nfs_dir, "%s/nfs", DCM_DIR);
-
-## ingres sms
-## set lockmode session where level = table
-
- changed = do_nfs();
-
-## exit
-
- if (!changed) {
- fprintf(stderr, "No files updated.\n");
- if (argc == 2 && stat(argv[1], &sb) == 0)
- exit(MR_NO_CHANGE);
- }
-
- if (argc == 2) {
- sprintf(cmd, "cd %s; cp %s/nfs/* .; tar cf %s .",
- nfs_dir, SMS_DIR, argv[1]);
- if (system(cmd))
- exit(MR_TAR_FAIL);
- }
-
- exit(MR_SUCCESS);
-}
-
-
-/*
- * ingerr: (supposedly) called when Ingres indicates an error.
- * I have not yet been able to get this to work to intercept a
- * database open error.
- */
-#define INGRES_DEADLOCK 4700
-
-static int ingerr(num)
- int *num;
-{
- char buf[256];
- int ingres_errno;
-
- switch (*num) {
- case INGRES_DEADLOCK:
- ingres_errno = MR_DEADLOCK;
- break;
- default:
- ingres_errno = MR_INGRES_ERR;
- }
- com_err(whoami, MR_INGRES_ERR, " code %d\n", *num);
- critical_alert("DCM", "NFS build encountered INGRES ERROR %d", *num);
- exit(ingres_errno);
-}
-
-
-/* Generate the files. Returns zero if nothing changed, non-zero otherwise. */
-
-int do_nfs()
-##{
-## char machname[33], listname[33];
- struct save_queue *machs, *lists;
- int changed;
-
- machs = sq_create();
- lists = sq_create();
-## range of s is serverhosts
-## retrieve (machname = machine.name, listname = s.value3)
-## where machine.mach_id = s.mach_id and s.service = "NFS"
-## and s.enable != 0 {
- sq_save_unique_string(machs, strsave(strtrim(machname)));
- sq_save_unique_string(lists, strsave(strtrim(listname)));
-## }
-
- changed = do_lists(lists);
- changed += do_machs(machs);
- return(changed);
-##}
-
-
-/* Make all of the credentials lists that will be needed. Returns 0 if
- * no files were actually changed */
-
-int do_lists(lists)
-struct save_queue *lists;
-##{
- char file[64], *u;
- struct hash *users, *do_everyone();
- struct stat sb;
- FILE *fd;
-## char *listname, *lsname, lname[33], uname[9], *filetime;
-## int uid, id, flag1, flag2, flag3, flag4;
-
- sprintf(file, "%s/list-", nfs_dir);
- if (stat(file, &sb) == 0) {
- filetime = ingres_date_and_time(sb.st_mtime);
-## retrieve (flag1 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "users"
-## retrieve (flag2 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "list"
-## retrieve (flag3 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "imembers"
-## retrieve (flag4 = int4(interval("min", tblstats.modtime - filetime)))
-## where tblstats.table = "serverhosts"
- if (flag1 < 0 && flag2 < 0 && flag3 < 0 && flag4 < 0) {
- fprintf(stderr, "The lists do not need to be rebuilt.\n");
- return(0);
- }
- }
-
-## begin transaction
- /* get locks */
-## retrieve (lname = list.modtime) where list.list_id = 0
-## retrieve (lname = users.modtime) where users.users_id = 0
-
- /* build the list of everyone, and store it in a file whose name
- * corresponds to the empty list.
- */
- users = do_everyone();
-
- fprintf(stderr, "Building specific lists\n");
- /* now do each of the lists used by an NFS server */
-## range of l is list
-## range of l1 is list
-## range of m is imembers
-## range of u is users
- while (sq_get_data(lists, &listname)) {
- if (strlen(listname) == 0)
- continue;
- sprintf(file, "%s/list-%s", nfs_dir, listname);
- fd = fopen(file, "w");
- if (!fd) {
- fprintf(stderr, "cannot open %s for output\n", file);
- exit(MR_OCONFIG);
- }
-## repeat retrieve (id = m.member_id)
-## where m.list_id = l1.list_id and l1.name = @listname and
-## m.member_type = "USER" {
- if (u = hash_lookup(users, id))
- fprintf(fd, "%s\n", u);
-## }
- if (fclose(fd)) {
- fprintf(stderr, "error closing %s\n", file);
- exit(MR_CCONFIG);
- }
- }
-/* don't free here either
- sq_destroy(lists);
- */
-## end transaction
- return(1);
-##}
-
-
-/* Build the list of everybody. */
-struct grp {
- struct grp *next;
- char *lid;
-};
-struct user {
- char name[9];
- int uid;
- struct grp *lists;
-};
-
-struct hash *do_everyone()
-##{
- char buf[BUFSIZ], *l;
- struct hash *groups, *users;
- struct user *u;
- struct grp *g;
- struct bucket *b, **p;
-## char name[33];
-## int gid, id, lid, maxid, uid;
- FILE *fd;
- int i;
- struct save_queue *sq;
-
- fprintf(stderr, "Building the list of everybody\n");
- sprintf(buf, "%s/list-", nfs_dir);
- fd = fopen(buf, "w");
- if (!fd) {
- fprintf(stderr, "cannot open %s for output\n", buf);
- exit(MR_OCONFIG);
- }
-
- /* make space for group list */
- groups = create_hash(15000);
-
- /* retrieve simple groups */
-## range of l is list
-## retrieve (gid = l.#gid, lid = l.list_id)
-## where l.group != 0 and l.active != 0 {
- sprintf(buf, ":%d", gid);
- hash_store(groups, lid, strsave(buf));
-## }
-
- /* now do grplists */
- users = create_hash(10000);
-## range of u is users
-## retrieve (id = u.users_id, name = u.login, uid = u.#uid)
-## where u.status = 1 {
- u = (struct user *) malloc(sizeof(struct user));
- strcpy(u->name, strtrim(name));
- u->uid = uid;
- u->lists = NULL;
- hash_store(users, id, u);
-## }
-
-## range of m is imembers
-## retrieve (lid = m.list_id, id = m.member_id) where m.member_type = "USER" {
- if ((u = (struct user *) hash_lookup(users, id)) &&
- ((l = hash_lookup(groups, lid)) != NULL)) {
- g = (struct grp *) malloc(sizeof(struct grp));
- g->next = u->lists;
- u->lists = g;
- g->lid = l;
- }
-## }
-
- for (p = &(users->data[users->size - 1]); p >= users->data; p--) {
- for (b = *p; b; b = b->next) {
- u = (struct user *)b->data;
- sprintf(buf, "%s:%d", u->name, u->uid);
- for (g = u->lists; g; g = g->next)
- strcat(buf, g->lid);
- b->data = strsave(buf);
- fprintf(fd, "%s\n", buf);
- }
- }
-
- fclose(fd);
- free(groups);
- return(users);
-##}
-
-
-/* Now do each of the servers, linking the credentials list file and
- * compiling the quota and dirs files.
- */
-
-int do_machs(machs)
-struct save_queue *machs;
-##{
-## char *machname, listname[33], dev[33], dir[81], fstype[9];
-## int uid, quota, id, gid, flag1, flag2, flag3, flag4;
- char file[64], f1[64], f2[64], *cp, *index();
- int prevuid, quotasum, olddev, oldmach;
- FILE *fd;
- struct hash *machines;
-
- fprintf(stderr, "Building machine files\n");
-
-## range of s is serverhosts
-## range of m is machine
-## range of n is nfsphys
-## range of q is #quota
-## range of f is filesys
-## range of u is users
-## range of l is list
-
-/* acquire locks on machines & filesystems */
-## begin transaction
-## retrieve (listname = u.modtime) where u.users_id = 0
-## retrieve (listname = m.modtime) where m.mach_id = 0
-## retrieve (listname = f.modtime) where f.filsys_id = 0
-
- machines = create_hash(100);
- while (sq_get_data(machs, &machname)) {
-## repeat retrieve (listname = s.value3, id = m.mach_id)
-## where s.mach_id = m.mach_id and m.name = @machname
- strtrim(machname);
- sprintf(f1, "%s/list-%s", nfs_dir, strtrim(listname));
- sprintf(f2, "%s/%s.cred", nfs_dir, machname);
- unlink(f2); /* ignore errors on this unlink */
- if (link(f1, f2)) {
- fprintf(stderr, "Cannot link %s to %s\n", f1, f2);
- exit(MR_OCONFIG);
- }
- hash_store(machines, id, machname);
- }
-
- olddev = oldmach = -1;
- fd = stdin;
-## retrieve (quota = q.#quota, uid = u.#uid, flag1 = q.phys_id,
-## dev = n.device, flag2 = n.mach_id)
-## where u.users_id = q.entity_id and n.nfsphys_id = q.phys_id and
-## q.phys_id != 0 and n.status < 16 and q.type = "USER"
-## sort by #flag2, #flag1, #uid {
- if (flag1 != olddev || flag2 != oldmach) {
- fclose(fd);
- olddev = flag1;
- oldmach = flag2;
- while (cp = index(dev, '/')) *cp = '@';
- sprintf(file, "%s/%s.%s.quotas", nfs_dir,
- hash_lookup(machines, flag2), strtrim(dev));
- fd = fopen(file, "w");
- if (!fd) {
- fprintf(stderr, "cannot open %s for output\n", file);
- exit(MR_OCONFIG);
- }
- prevuid = -1;
- quotasum = 0;
- }
- if (uid != prevuid) {
- if (quotasum)
- fprintf(fd, "%d %d\n", prevuid, quotasum);
- prevuid = uid;
- quotasum = quota;
- } else {
- quotasum += quota;
- }
-## }
- if (quotasum)
- fprintf(fd, "%d %d\n", prevuid, quotasum);
- if (fd != stdin && fclose(fd)) {
- fprintf(stderr, "error closing %s", file);
- exit(MR_CCONFIG);
- }
-
- olddev = oldmach = -1;
- fd = stdin;
-## retrieve (quota = q.#quota, gid = l.#gid, flag1 = q.phys_id,
-## dev = n.device, flag2 = n.mach_id, flag3 = n.status)
-## where l.list_id = q.entity_id and n.nfsphys_id = q.phys_id and
-## q.phys_id != 0 and n.status > 15 and q.type = "GROUP"
-## sort by #flag2, #flag1, #gid {
- if (flag1 != olddev || flag2 != oldmach) {
- fclose(fd);
- olddev = flag1;
- oldmach = flag2;
- while (cp = index(dev, '/')) *cp = '@';
- sprintf(file, "%s/%s.%s.quotas", nfs_dir,
- hash_lookup(machines, flag2), strtrim(dev));
- fd = fopen(file, "w");
- if (!fd) {
- fprintf(stderr, "cannot open %s for output\n", file);
- exit(MR_OCONFIG);
- }
- prevuid = -1;
- quotasum = 0;
- }
- if (gid != prevuid) {
- if (quotasum)
- fprintf(fd, "%d %d\n", prevuid, quotasum);
- prevuid = gid;
- quotasum = quota;
- } else {
- quotasum += quota;
- }
-## }
- if (quotasum)
- fprintf(fd, "%d %d\n", prevuid, quotasum);
- if (fd != stdin && fclose(fd)) {
- fprintf(stderr, "error closing %s", file);
- exit(MR_CCONFIG);
- }
-
- olddev = oldmach = -1;
-## retrieve (dir = f.#name, fstype = f.lockertype, uid = u.#uid,
-## gid = l.#gid, flag1 = f.phys_id, flag2 = f.mach_id,
-## dev = n.device)
-## where u.users_id = f.owner and l.list_id = f.owners and
-## f.createflg != 0 and f.phys_id != 0 and f.type = "NFS" and
-## f.phys_id = n.nfsphys_id
-## sort by #flag2, #flag1 {
- if (flag1 != olddev || flag2 != oldmach) {
- fclose(fd);
- olddev = flag1;
- oldmach = flag2;
- while (cp = index(dev, '/')) *cp = '@';
- sprintf(file, "%s/%s.%s.dirs", nfs_dir,
- hash_lookup(machines, flag2), strtrim(dev));
- fd = fopen(file, "w");
- if (!fd) {
- fprintf(stderr, "cannot open %s for output\n", file);
- exit(MR_OCONFIG);
- }
- }
- fprintf(fd, "%s %d %d %s\n", strtrim(dir), uid, gid, strtrim(fstype));
-## }
- if (fclose(fd)) {
- fprintf(stderr, "error closing %s", file);
- exit(MR_CCONFIG);
- }
-## end transaction
- return(1);
-##}
+++ /dev/null
-# Makefile for SMS 2.0 include files
-#
-# $Source$
-# $Header$
-# $Author$
-#
-# (c) Copyright 1988, 1990 by the Massachusetts Institute of Technology.
-# For copying and distribution information, please see the file
-# <mit-copyright.h>.
-
-DESTDIR=
-FILES= moira.h moira_site.h mr_et.h
-
-all:
-
-install: ${FILES}
- install -c -m 644 moira.h ${DESTDIR}/usr/include/moira.h
- install -c -m 644 moira_site.h ${DESTDIR}/usr/include/moira_site.h
- install -c -m 644 mr_et.h ${DESTDIR}/usr/include/mr_et.h
-
-depend:
-
+++ /dev/null
-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- *
- * Defines for talking to the kerberos admin_server, for changing
- * passwords, etc.
- *
- * Originally by Jeffery I. Schiller, January 1987.
- *
- * $Log$
- * Revision 1.3 1987-08-22 17:14:58 wesommer
- * Add new request to set initial attributes.
- *
- * Revision 1.2 87/08/09 00:22:52 wesommer
- * Added RCS header.
- *
- */
-
-
-#define PW_SRV_VERSION 2 /* version number */
-#ifndef KERB_HOST
-#define KERB_HOST "kerberos"
-#endif
-#define INSTALL_NEW_PW (1<<0) /* ver, cmd, name, password,
- old_pass, crypt_pass, uid */
-#define ADMIN_NEW_PW (2<<1) /* ver, cmd, name, passwd,
- old_pass (grot), crypt_pass (grot),
- */
-#define ADMIN_SET_KDC_PASSWORD (3<<1) /* ditto */
-#define ADMIN_ADD_NEW_KEY (4<<1) /* ditto */
-#define ADMIN_ADD_NEW_KEY_ATTR (5<<1) /* ver, cmd, name, passwd,
- inst, attr (grot),
- */
-#define INSTALL_REPLY (1<<1) /* ver, cmd, name, password */
-#define RETRY_LIMIT 1
-#define TIME_OUT 30
-#define USER_TIMEOUT 90
-
-#define MAX_KPW_LEN 40 /* hey, seems like a good number */
-
+++ /dev/null
-# $Header$
-
-AFSDIR = /mit/afsdev/bld/dest
-AFSLIBS=$(AFSDIR)/lib/afs/libprot.a $(AFSDIR)/lib/afs/libauth.a \
- $(AFSDIR)/lib/libubik.a $(AFSDIR)/lib/afs/util.a \
- $(AFSDIR)/lib/librxkad.a $(AFSDIR)/lib/afs/libsys.a \
- $(AFSDIR)/lib/librx.a $(AFSDIR)/lib/liblwp.a
-
-SRCS = afs.c ksrvtgt.c
-DEBUG = -O
-CFLAGS = -I../include -I$(AFSDIR)/include $(DEBUG)
-LIBS = -L../lib -lmoira -lzephyr -lgdb -lcom_err -lhesiod -lkrb -ldes
-
-all: afs.incr ksrvtgt
-
-afs.incr: afs.o
- cc -o afs.incr afs.o ${AFSLIBS} ${LIBS}
-
-ksrvtgt: ksrvtgt.o
- cc -o ksrvtgt ksrvtgt.o ${LIBS}
-
-clean:
- rm -f *.o
- rm -f afs.incr ksrvtgt
-
-install: all
- install -c afs.incr ../bin
-
-depend:
- mkdep ${CFLAGS} ${SRCS}
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-
-afs.o: afs.c ../include/moira.h ../include/mr_et.h ../include/moira_site.h
-afs.o: ../include/mit-copyright.h /usr/include/sys/file.h
-ksrvtgt.o: ksrvtgt.c /usr/include/stdio.h /usr/include/sys/param.h
-ksrvtgt.o: /usr/include/machine/machparam.h /usr/include/sys/signal.h
-ksrvtgt.o: /usr/include/sys/types.h ../include/krb.h
-ksrvtgt.o: ../include/mit-copyright.h ../include/des.h
+++ /dev/null
-# $Source$
-# $Author$
-# $Header$
-#
-# Makefile for Moira library.
-#
-LIBSRC=mr_auth.c mr_call.c mr_connect.c mr_data.c mr_init.c \
- mr_query.c mr_param.c mr_access.c mr_ops.c \
- fixname.c strs.c fixhost.c nfsparttype.c sq.c hash.c \
- idno.c critical.c
-
-CFILES=${LIBSRC}
-
-LIBOBJ=mr_auth.o mr_call.o mr_connect.o mr_data.o mr_init.o \
- mr_query.o mr_param.o mr_access.o mr_ops.o \
- fixname.o strs.o fixhost.o nfsparttype.o sq.o hash.o \
- idno.o critical.o mr_et.o ureg_err.o krb_et.o
-
-COPTS= -O
-
-INCDIRS=-I../include
-
-CFLAGS= ${INCDIRS} ${COPTS}
-LINTFLAGS= -uhv
-
-ALL=libmoira.a llib-lmoira.ln # libmoira_p.a
-
-.c.o:
-# ${CC} -c -pg ${CFLAGS} $*.c
-# ld -x -r $*.o
-# mv a.out profiled/$*.o
- ${CC} -c ${CFLAGS} $*.c
- ld -x -r $*.o
- mv a.out $*.o
-
-all: ${ALL}
-
-libmoira.a: ${LIBOBJ}
- ar cruv $@ `lorder ${LIBOBJ} | tsort`
- ranlib $@
-
-libmoira_p.a: ${LIBOBJ}
- (cd profiled; ar cruv ../libmoira_p.a ${LIBOBJ}; ranlib ../libmoira_p.a)
-
-mrlib.dvi: mrlib.tex
- latex mrlib.tex
-
-krb_et.c krb_et.h: krb_et.et ../et/compile_et
- ../et/compile_et krb_et.et
-
-mr_et.c mr_et.h: mr_et.et ../et/compile_et
- ../et/compile_et mr_et.et
-
-ureg_err.c ureg_err.h: ureg_err.et ../et/compile_et
- ../et/compile_et ureg_err.et
-
-../et/compile_et:
- cd ../et; make compile_et
-
-../include/mr_et.h: mr_et.h
-
-clean:
- rm -f ${ALL}
- rm -f *.o *~ mr_et.h krb_et.h ureg_err.h profiled/*.o \#*
- rm -f krb_et.c mr_et.c ureg_err.c
- rm -f *.PS *.aux *.dvi *.log
- rm -f *.bak
-
-
-install:
- install -c -m 644 libmoira.a ${DESTDIR}/usr/athena/lib/libmoira.a
- ranlib ${DESTDIR}/usr/athena/lib/libmoira.a
-# install -c -m 644 libmoira_p.a ${DESTDIR}/usr/athena/lib/libmoira_p.a
-# ranlib ${DESTDIR}/usr/athena/lib/libmoira_p.a
- install -c -m 644 llib-lmoira.ln ${DESTDIR}/usr/lib/lint/llib-lmoira.ln
-
-TAGS: $(CFILES)
- -etags $(CFILES)
-
-lint: ${CFILES} llib-lmoira.ln
- lint ${LINTFLAGS} ${INCDIRS} mr_main.c llib-lmoira.ln
-
-llib-lmoira.ln: ${LIBSRC}
- lint -Cmoira $(LINTFLAGS) $(INCDIRS) ${LIBSRC}
-
-depend: $(CFILES) mr_et.h ureg_err.h krb_et.h
- mkdep ${CFLAGS} ${CFILES}
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-
-mr_auth.o: mr_auth.c ../include/mit-copyright.h mr_private.h
-mr_auth.o: ../include/mr_proto.h /usr/include/stdio.h ../include/gdb.h
-mr_auth.o: /usr/include/sys/types.h /usr/include/sys/time.h
-mr_auth.o: /usr/include/sys/time.h ../include/moira.h mr_et.h
-mr_auth.o: /usr/include/ctype.h ../include/krb.h ../include/des.h krb_et.h
-mr_call.o: mr_call.c ../include/mit-copyright.h mr_private.h
-mr_call.o: ../include/mr_proto.h /usr/include/stdio.h ../include/gdb.h
-mr_call.o: /usr/include/sys/types.h /usr/include/sys/time.h
-mr_call.o: /usr/include/sys/time.h ../include/moira.h mr_et.h
-mr_connect.o: mr_connect.c ../include/mit-copyright.h mr_private.h
-mr_connect.o: ../include/mr_proto.h /usr/include/stdio.h ../include/gdb.h
-mr_connect.o: /usr/include/sys/types.h /usr/include/sys/time.h
-mr_connect.o: /usr/include/sys/time.h ../include/moira.h mr_et.h
-mr_connect.o: ../include/moira_site.h /usr/include/strings.h
-mr_data.o: mr_data.c ../include/mit-copyright.h mr_private.h
-mr_data.o: ../include/mr_proto.h /usr/include/stdio.h ../include/gdb.h
-mr_data.o: /usr/include/sys/types.h /usr/include/sys/time.h
-mr_data.o: /usr/include/sys/time.h ../include/moira.h mr_et.h
-mr_init.o: mr_init.c ../include/mit-copyright.h mr_private.h
-mr_init.o: ../include/mr_proto.h /usr/include/stdio.h ../include/gdb.h
-mr_init.o: /usr/include/sys/types.h /usr/include/sys/time.h
-mr_init.o: /usr/include/sys/time.h ../include/moira.h mr_et.h
-mr_query.o: mr_query.c ../include/mit-copyright.h mr_private.h
-mr_query.o: ../include/mr_proto.h /usr/include/stdio.h ../include/gdb.h
-mr_query.o: /usr/include/sys/types.h /usr/include/sys/time.h
-mr_query.o: /usr/include/sys/time.h ../include/moira.h mr_et.h
-mr_param.o: mr_param.c ../include/mit-copyright.h /usr/include/sys/types.h
-mr_param.o: /usr/include/netinet/in.h mr_private.h ../include/mr_proto.h
-mr_param.o: /usr/include/stdio.h ../include/gdb.h /usr/include/sys/time.h
-mr_param.o: /usr/include/sys/time.h ../include/moira.h mr_et.h
-mr_access.o: mr_access.c ../include/mit-copyright.h mr_private.h
-mr_access.o: ../include/mr_proto.h /usr/include/stdio.h ../include/gdb.h
-mr_access.o: /usr/include/sys/types.h /usr/include/sys/time.h
-mr_access.o: /usr/include/sys/time.h ../include/moira.h mr_et.h
-mr_ops.o: mr_ops.c ../include/mit-copyright.h mr_private.h
-mr_ops.o: ../include/mr_proto.h /usr/include/stdio.h ../include/gdb.h
-mr_ops.o: /usr/include/sys/types.h /usr/include/sys/time.h
-mr_ops.o: /usr/include/sys/time.h ../include/moira.h mr_et.h
-fixname.o: fixname.c ../include/mit-copyright.h /usr/include/strings.h
-fixname.o: /usr/include/ctype.h
-strs.o: strs.c ../include/mit-copyright.h /usr/include/sys/types.h
-strs.o: /usr/include/strings.h /usr/include/ctype.h
-fixhost.o: fixhost.c ../include/mit-copyright.h /usr/include/sys/types.h
-fixhost.o: /usr/include/sys/socket.h /usr/include/netinet/in.h
-fixhost.o: /usr/include/arpa/nameser.h /usr/include/arpa/resolv.h
-fixhost.o: /usr/include/netdb.h /usr/include/stdio.h /usr/include/strings.h
-fixhost.o: /usr/include/ctype.h
-nfsparttype.o: nfsparttype.c ../include/mit-copyright.h ../include/moira.h
-nfsparttype.o: mr_et.h /usr/include/stdio.h /usr/include/strings.h
-nfsparttype.o: /usr/include/ctype.h
-sq.o: sq.c ../include/mit-copyright.h ../include/moira.h mr_et.h
-hash.o: hash.c ../include/mit-copyright.h /usr/include/ctype.h
-hash.o: ../include/moira.h mr_et.h
-idno.o: idno.c ../include/mit-copyright.h /usr/include/strings.h
-idno.o: /usr/include/ctype.h
-critical.o: critical.c ../include/mit-copyright.h /usr/include/stdio.h
-critical.o: /usr/include/sys/file.h ../include/moira_site.h
-critical.o: /usr/include/zephyr/zephyr.h /usr/include/zephyr/mit-copyright.h
-critical.o: /usr/include/zephyr/zephyr_err.h
-critical.o: /usr/include/zephyr/zephyr_conf.h /usr/include/errno.h
-critical.o: /usr/include/sys/types.h /usr/include/netinet/in.h
-critical.o: /usr/include/sys/time.h /usr/include/sys/time.h ../include/krb.h
-critical.o: ../include/des.h
+++ /dev/null
-#
-# $Source$
-# $Header$
-# $Author$
-#
-
-DESTDIR=
-MAN1PAGES= blanche.1 chfn.1 chpobox.1 chsh.1 dcmmaint.1 listmaint.1 \
- mailmaint.1 moira.1 mrcheck.1 usermaint.1 userreg.1
-MAN3PAGES= moira.3
-MAN8PAGES= dcm.8 mrtest.8 reg_svr.8 moirad.8 startdcm.8 startreg.8 \
- startmoira.8 update_server.8
-
-all:
-
-install:
- for i in ${MAN1PAGES}; do \
- install -c -m 0644 $$i ${DESTDIR}/usr/man/man1/$$i; done
- for i in ${MAN3PAGES}; do \
- install -c -m 0644 $$i ${DESTDIR}/usr/man/man3/$$i; done
- for i in ${MAN8PAGES}; do \
- install -c -m 0644 $$i ${DESTDIR}/usr/man/man8/$$i; done
-
-clean:
- rm -f *~
-
-depend:
# <mit-copyright.h>.
-CFLAGS= -O -I../include
+CFLAGS= -O -I../include -I../lib
SRCS = requests.c reg_svr.c startreg.c
OBJS = requests.o reg_svr.o
reg_svr: $(OBJS)
cc ${CFLAGS} -o reg_svr $(OBJS) -L../lib \
- ../server/libmoiraglue.a \
- -lmoira -lkadm -lkrb -ldes -lzephyr -lcom_err \
+ ../server/libmoiraglue.a /mit/gdss/vax/libgdss.a \
+ -lmoira -lkadm -lkrb -ldes -lzephyr -lhesiod -lcom_err \
/usr/rtingres/lib/libqlib /usr/rtingres/lib/compatlib
reg_svr.o requests.o: reg_svr.h
mkdep ${CFLAGS} ${SRCS}
# DO NOT DELETE THIS LINE -- mkdep uses it.
-
-requests.o: requests.c ../include/mit-copyright.h /usr/include/stdio.h
-requests.o: /usr/include/strings.h /usr/include/ctype.h
-requests.o: /usr/include/sys/types.h /usr/include/sys/file.h ../include/krb.h
-requests.o: ../include/des.h /usr/include/errno.h /usr/include/sys/socket.h
-requests.o: /usr/include/netinet/in.h /usr/include/netdb.h ../include/moira.h
-requests.o: ../include/mr_et.h ../include/moira_site.h reg_svr.h
-requests.o: ../include/ureg_err.h ../include/ureg_proto.h
-reg_svr.o: reg_svr.c ../include/mit-copyright.h /usr/include/stdio.h
-reg_svr.o: /usr/include/strings.h /usr/include/ctype.h
-reg_svr.o: /usr/include/sys/types.h /usr/include/sys/file.h ../include/krb.h
-reg_svr.o: ../include/des.h ../include/kadm.h /usr/include/netinet/in.h
-reg_svr.o: /usr/include/kadm_err.h /usr/include/krb_err.h
-reg_svr.o: /usr/include/errno.h ../include/moira.h ../include/mr_et.h
-reg_svr.o: ../include/moira_site.h reg_svr.h ../include/ureg_err.h
-reg_svr.o: ../include/ureg_proto.h
-startreg.o: startreg.c ../include/mit-copyright.h /usr/include/stdio.h
-startreg.o: /usr/include/strings.h /usr/include/sys/types.h
-startreg.o: /usr/include/sys/file.h /usr/include/sys/wait.h
-startreg.o: /usr/include/sys/signal.h /usr/include/sys/ioctl.h
-startreg.o: /usr/include/sys/ttychars.h /usr/include/sys/ttydev.h
-startreg.o: ../include/moira_site.h
+++ /dev/null
-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- *
- * Utility functions for communication with the Kerberos admin_server
- *
- * Original version written by Jeffery I. Schiller, January 1987
- * Completely gutted and rewritten by Bill Sommerfeld, August 1987
- *
- */
-
-#ifndef lint
-static char *rcsid_admin_call_c = "$Header$";
-#endif lint
-
-#include <mit-copyright.h>
-#include <sys/errno.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-#include <netdb.h>
-#include <strings.h>
-#include <ctype.h>
-#include <stdio.h>
-
-#include "admin_err.h"
-#include "admin_server.h"
-#include "prot.h"
-#include "krb.h"
-#include "krb_et.h"
-
-extern int errno; /* System call error numbers */
-
-extern long gethostid();
-
-static u_char *strapp(); /* string append function */
-
-static int inited = 0; /* are we initialized? */
-static int admin_fd = -1; /* socket to talk to admin_server. */
-
-static struct sockaddr_in admin_addr; /* address of admin server. */
-static struct sockaddr_in my_addr; /* address bound to admin_fd. */
-static int my_addr_len; /* size of above address. */
-
-static char krbrlm[REALM_SZ]; /* Local kerberos realm */
-static char krbhost[BUFSIZ]; /* Name of server for local realm */
-char admin_errmsg[BUFSIZ]; /* Server error message */
-
-/*
- * Initialize socket, etc. to use to talk to admin_server.
- */
-
-int admin_call_init()
-{
- register int status = 0;
-
- if (!inited) {
- struct hostent *hp; /* host to talk to */
- struct servent *sp; /* service to talk to */
-
- initialize_kadm_error_table();
- if (status = krb_get_lrealm(krbrlm, 1)) {
- status += ERROR_TABLE_BASE_krb;
- goto punt;
- }
-
- /*
- * Locate server.
- */
-
- if (status = krb_get_krbhst(krbhost, krbrlm, 1)) {
- status += ERROR_TABLE_BASE_krb;
- goto punt;
- }
- hp = gethostbyname(krbhost);
- if (!hp) {
- status = ADMIN_UNKNOWN_HOST;
- goto punt;
- }
- sp = getservbyname("atest3", "udp");
- if (!sp) {
- status = ADMIN_UNKNOWN_SERVICE;
- goto punt;
- }
- bzero((char *)&admin_addr, sizeof(admin_addr));
- admin_addr.sin_family = hp->h_addrtype;
- bcopy((char *)hp->h_addr, (char *)&admin_addr.sin_addr, hp->h_length);
- admin_addr.sin_port = sp->s_port;
-
- /* lowercase & truncate hostname becuase it will be used as an
- * instance name.
- */
- {
- char *s;
- for (s = krbhost; *s && *s != '.'; s++)
- if (isupper(*s))
- *s = tolower(*s);
- *s = 0;
- }
- inited = 1;
- }
- return 0;
-
-punt:
- (void) close(admin_fd);
- admin_fd = -1;
- return status;
-}
-
-/*
- * Build and transmit request to admin_server, and wait for
- * response from server. Returns a standard error code.
- */
-
-int
-admin_call(opcode, pname, old_passwd, new_passwd, crypt_passwd)
- int opcode;
- char *pname;
- char *old_passwd;
- char *new_passwd;
- char *crypt_passwd;
-{
- int status;
- register u_char *bp; /* Pointer into buffer. */
- u_char *ep; /* End of buffer pointer. */
-
- u_char pvt_buf[BUFSIZ]; /* private message plaintext */
- int pvt_len; /* length of valid data in pvt_buf */
-
- u_char sealed_buf[BUFSIZ]; /* sealed version of private message */
- int sealed_len; /* length of valid data in sealed_buf */
-
- u_long checksum; /* quad_cksum of sealed request. */
-
- C_Block sess_key; /* Session key. */
- Key_schedule sess_sched; /* Key schedule for above. */
-
- CREDENTIALS cred; /* Kerberos credentials. */
- KTEXT_ST authent; /* Authenticator */
- KTEXT_ST reply; /* Reply from admin_server */
- MSG_DAT msg_data; /* Decrypted message */
- int attempts; /* Number of retransmits so far */
-
- struct sockaddr rec_addr; /* Address we got reply from */
- int rec_addr_len; /* Length of that address */
- int on = 1; /* ioctl argument */
-
-
- if (!inited) {
- status = admin_call_init();
- if (status) goto bad;
- }
-
- /*
- * assemble packet:
- *
- * sealed message consists of:
- * version number (one byte).
- * request code (one byte).
- * principal name (null terminated).
- * new password (in the clear, null terminated).
- * old password or instance (null terminated)
- * crypt(new password, seed) (null terminated).
- * an extra null.
- * a '\001' character.
- * This is all sealed inside a private_message, with an
- * authenticator tacked on in front.
- */
-
- bp = pvt_buf;
- ep = pvt_buf + sizeof(pvt_buf);
-
- *bp++ = PW_SRV_VERSION;
- *bp++ = opcode;
- if ((bp = strapp(bp, (u_char *)pname, ep)) &&
- (bp = strapp(bp, (u_char *)new_passwd, ep)) &&
- (bp = strapp(bp, (u_char *)old_passwd, ep)) &&
- (bp = strapp(bp, (u_char *)crypt_passwd, ep))) {
- *bp++ = '\0';
- *bp++ = '\1';
- pvt_len = bp - pvt_buf;
- } else {
- status = ADMIN_TOO_LONG;
- goto bad;
- }
-
- /*
- * find our session key.
- */
-
- if (status = krb_get_cred("changepw", krbhost, krbrlm, &cred)) {
- status += ERROR_TABLE_BASE_krb;
- goto bad;
- }
-
- bcopy((char *)cred.session, (char *)sess_key, sizeof(sess_key));
- bzero((char *)cred.session, sizeof(sess_key)); /* lest we remember */
-
- if(key_sched(sess_key, sess_sched)) {
- status = ADMIN_BAD_KEY;
- goto bad;
- }
-
- /*
- * Set up socket.
- */
-
- admin_fd = socket(admin_addr.sin_family, SOCK_DGRAM, 0);
- if (admin_fd < 0) {
- status = errno;
- goto bad;
- }
-
- bzero((char *)&my_addr, sizeof(my_addr));
-
- my_addr.sin_family = admin_addr.sin_family;
- my_addr.sin_addr.s_addr = gethostid();
-
- if (bind(admin_fd, &my_addr, sizeof(my_addr)) < 0) {
- status = errno;
- goto bad;
- }
-
- my_addr_len = sizeof(my_addr);
-
- if (getsockname(admin_fd, (struct sockaddr *)&my_addr,
- &my_addr_len) < 0) {
- status = errno;
- goto bad;
- }
-
- if (ioctl(admin_fd, FIONBIO, (char *)&on) < 0) {
- status = errno;
- goto bad;
- }
-
- /*
- * Encrypt the message using the session key.
- * Since this contains passwords, it must be kept from prying eyes.
- */
-
- sealed_len = krb_mk_priv(pvt_buf, sealed_buf, pvt_len,
- sess_sched, sess_key, &my_addr,
- &admin_addr);
- if (sealed_len < 0) {
- status = ADMIN_CANT_ENCRYPT;
- goto bad;
- }
-
- /*
- * Checksum the cypher text, to guard against tampering in flight.
- */
-
- checksum = quad_cksum(sealed_buf, NULL, sealed_len, 0, sess_key);
-
- /*
- * Make an authenticator, so the server can learn the session key
- * and know who we are.
- */
-
- if (status = krb_mk_req(&authent, "changepw", krbhost, krbrlm,
- checksum)) {
- status += ERROR_TABLE_BASE_krb;
- goto bad;
- }
-
- /*
- * Add the sealed message to the end of the authenticator.
- */
-
- if ((authent.length + sealed_len) > MAX_KTXT_LEN) {
- status = ADMIN_TOO_LONG;
- goto bad;
- }
-
- bcopy(sealed_buf, authent.dat + authent.length, sealed_len);
- authent.length += sealed_len;
-
- /*
- * send it off, and wait for a reply.
- */
-
- attempts = 0;
-
- while (attempts++ < RETRY_LIMIT) {
- int active; /* number of active fds (from select). */
- fd_set set; /* interesting fd's. */
- struct timeval timeout; /* timeout on select. */
-
- if (sendto(admin_fd, (char *)authent.dat, authent.length,
- 0, &admin_addr, sizeof(admin_addr)) != authent.length) {
- status = errno;
- goto bad;
- }
-
- FD_ZERO(&set);
- FD_SET(admin_fd, &set);
-
- timeout.tv_sec = USER_TIMEOUT;
- timeout.tv_usec = 0;
-
- active = select(admin_fd+1, &set, (fd_set *)0, (fd_set *)0, &timeout);
- if (active < 0) {
- status = errno;
- goto bad;
- } else if (active == 0) continue;
- else {
- reply.length = recvfrom(admin_fd, (char *)reply.dat,
- sizeof(reply.dat), 0,
- &rec_addr, &rec_addr_len);
- if (reply.length < 0) continue;
-#ifdef notdef
- if (!bcmp(&rec_addr, &admin_addr, sizeof(admin_addr)))
- /* the spoofers are out in force.. */
- continue;
-#endif notdef
- break; /* got one.. */
- }
- }
-
- if (attempts > RETRY_LIMIT) {
- status = ETIMEDOUT;
- goto bad;
- }
-
- if (pkt_version((&reply)) != KRB_PROT_VERSION) {
- status = ADMIN_BAD_VERSION;
- goto bad;
- }
-
- if ((pkt_msg_type((&reply)) & ~1) != AUTH_MSG_PRIVATE) {
- bp = reply.dat;
- if (*bp++ != KRB_PROT_VERSION) {
- status = ADMIN_BAD_VERSION;
- goto bad;
- }
- if (*bp++ != AUTH_MSG_ERR_REPLY) {
- status = ADMIN_UNKNOWN_CODE;
- goto bad;
- }
- bp += strlen((char *)bp) + 1; /* Skip name */
- bp += strlen((char *)bp) + 1; /* Skip instance */
- bp += strlen((char *)bp) + 1; /* Skip realm */
-
- /* null-terminate error string */
- reply.dat[reply.length] = '\0';
-
- if (*bp++ == 126) {
- status = ADMIN_SERVER_ERROR;
- strcpy(admin_errmsg, bp);
- goto bad;
- } else {
- status = ADMIN_UNKNOWN_CODE;
- goto bad;
- }
- }
- status = krb_rd_priv(reply.dat, reply.length,
- sess_sched, sess_key,
- &admin_addr, &my_addr,
- &msg_data);
- if (status) {
- status += ERROR_TABLE_BASE_krb;
- goto bad;
- }
- bp = msg_data.app_data;
-
- if (*bp++ != PW_SRV_VERSION) {
- status = ADMIN_BAD_VERSION;
- goto bad;
- }
- if (*bp++ != INSTALL_REPLY) {
- status = ADMIN_UNKNOWN_CODE;
- goto bad;
- }
-
- status = 0;
- /* fall through into cleanup */
-
-bad:
- /*
- * Paranoia: shred all the incriminating evidence.
- * We'll let the caller shred the arguments.
- */
- bzero((char *)sess_key, sizeof(sess_key));
- bzero((char *)sess_sched, sizeof(sess_sched));
- bzero(pvt_buf, sizeof(pvt_buf));
-
- if (admin_fd >= 0) {
- (void) close(admin_fd);
- admin_fd = -1;
- }
-
- return status;
-}
-
-/*
- * Copies characters from source to dest, returning a pointer to the
- * point in dest after the last character copied from source.
- * If this would be greater than end, no characters are copied, and NULL
- * is returned instead.
- */
-
-static u_char *strapp(dest, source, end)
- register u_char *dest, *source, *end;
-{
- register int length = strlen(source) + 1;
- if (dest+length > end) return NULL;
- else {
- bcopy(source, dest, length);
- return dest + length;
- }
-}
+++ /dev/null
- et kadm
- ec ADMIN_NO_SVC, "admin_svc unknown."
- ec ADMIN_TOO_LONG, "Total length of arguments too large"
- ec ADMIN_BAD_KEY, "Can't create key schedule"
- ec ADMIN_CANT_ENCRYPT, "Can't make private message"
- ec ADMIN_BAD_VERSION, "Requested version is not supported"
- ec ADMIN_SERVER_ERROR, "admin_server reports error"
- ec ADMIN_UNKNOWN_CODE, "Can't parse reply from admin_server"
- ec ADMIN_UNKNOWN_HOST, "Unknown host kerberos"
- ec ADMIN_UNKNOWN_SERVICE, "Unknown service atest3"
- ec ADMIN_UNKNOWN_USER, "I can't figure out who you are"
- end
+++ /dev/null
-/*
- * Run the salvager after doing this!!
- */
-
-main()
-{
-
-## ingres sms
-## range of u is users
-## range of f is filesys
-## range of p is pobox
-## range of l is list
-## range of nq is nfsquota
-
-## replace u (status = 0, login="#1003") where u.login = "tau"
-
-## delete f where f.label = "tau"
-## delete p where p.box = "tau"
-## delete l where l.name = "tau"
-## delete nq where nq.users_id = 14651
-
-}
+++ /dev/null
-#
-# $Source$
-# $Header$
-#
-
-#
-# Makefile for the moira stuff --mark roman 7/6/87
-#
-CFILES = rafnu.c students.c employee.c
-
-LIBS = -L../lib -lmoira -lgdb -lcom_err -lzephyr -lkrb -ldes \
- /usr/rtingres/lib/libqlib /usr/rtingres/lib/compatlib
-CFLAGS = -I../include
-
-.SUFFIXES: .qc
-
-.qc.c:
- rm -f $*.c
- /usr/rtingres/bin/eqc -p $*
-
-all: students employee
-
-students: students.o rafnu.o
- cc -o students students.o rafnu.o $(LIBS)
-
-employee: employee.o rafnu.o
- cc -o employee employee.o rafnu.o $(LIBS)
-
-clean:
- rm -f regtape students employee core
- rm -f students.c employee.c
- rm -f *~ *.o
-
-lint:
- lint $(CFILES)
-
-install: students employee
- install -c students ../bin/students
- install -c employee ../bin/employee
-
-depend: ${CFILES}
- mkdep ${CFLAGS} ${CFILES}
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-
-rafnu.o: rafnu.c /usr/include/stdio.h /usr/include/ctype.h
-students.o: students.c /usr/include/stdio.h /usr/include/strings.h
-students.o: /usr/include/ctype.h /usr/include/sys/time.h
-students.o: /usr/include/sys/time.h ../include/moira.h ../include/mr_et.h
-students.o: ../include/moira_site.h ../include/mit-copyright.h
-employee.o: employee.c /usr/include/stdio.h /usr/include/strings.h
-employee.o: /usr/include/ctype.h /usr/include/sys/time.h
-employee.o: /usr/include/sys/time.h ../include/moira.h ../include/mr_et.h
-employee.o: ../include/moira_site.h ../include/mit-copyright.h
+++ /dev/null
-/* $Header$
- */
-
-#include <stdio.h>
-#include <strings.h>
-#include <ctype.h>
-#include <sys/time.h>
-#include <moira.h>
-#include <moira_site.h>
-
-
-##define WHO 11859 /* root */
-##define PROG "emp-tape"
-
-#define MAX_ID_VALUE 32766
-#define MIN_ID_VALUE 101
-
-/* File format is:
-
-0-8 id number
-9-38 name
-39-62 office address
-63-74 phone1
-75-86 phone2
-87-106 dept
-107-156 title
-157-186 username
-187-241 host
-
-*/
-
-#define LOC_ID 0
-#define LOC_NAME 9
-#define LOC_OFFICE 39
-#define LOC_PHONE 63
-#define LOC_PHONE2 75
-#define LOC_DEPT 87
-#define LOC_TITLE 107
-#define LOC_USERNAME 157
-#define LOC_HOST 187
-
-#define LEN_ID 9
-#define LEN_NAME 30
-#define LEN_OFFICE 24
-#define LEN_PHONE 12
-#define LEN_PHONE2 12
-#define LEN_DEPT 20
-#define LEN_TITLE 50
-#define LEN_USERNAME 30
-#define LEN_HOST 55
-
-
-struct entry {
- char *name;
- char *last;
- char *first;
- char *middle;
- char *title;
- char *class;
- char *id;
- char *eid;
- char *dept;
- char *address;
- char *phone;
- char *phone2;
- char *email;
-};
-
-
-char *whoami;
-int newfinger = 0;
-int addxuser = 0;
-
-
-main(argc, argv)
-int argc;
-char **argv;
-##{
- FILE *in;
- struct entry *e, *get_next_entry();
- int i, wait = 0;
- char buf[BUFSIZ], *file = NULL;
-
- whoami = rindex(argv[0], '/');
- if (whoami)
- whoami++;
- else
- whoami = argv[0];
-
- for (i = 1; i < argc; i++) {
- if (!strcmp(argv[i], "-w"))
- wait++;
- else if (!strcmp(argv[i], "-D"))
- setenv("ING_SET", "set printqry");
- else if (!strcmp(argv[i], "-n"))
- newfinger++;
- else if (!strcmp(argv[i], "-u"))
- addxuser++;
- else if (file != NULL)
- fprintf(stderr, "Usage: %s [-w] [-D] [-n] [-u] inputfile\n", whoami);
- else
- file = argv[i];
- }
-
- in = fopen(file, "r");
- if (in == NULL) {
- fprintf(stderr, "Unable to open %s for input\n", file);
- exit(1);
- }
-
-## ingres sms
-## range of u is users
-
- while (e = get_next_entry(in)) {
- process_entry(e);
- if (wait) {
- printf("Next");
- fflush(stdout);
- gets(buf);
- }
- }
-
-## exit
- exit(0);
-##}
-
-
-char *substr(buf, key)
-char *buf;
-char *key;
-{
- int l;
-
- for (l = strlen(key); *buf; buf++)
- if (!strncmp(buf, key, l))
- return(buf);
- return(NULL);
-}
-
-
-struct entry *get_next_entry(in)
-FILE *in;
-{
- static struct entry e;
- static char buf[BUFSIZ], mid[16], eid[16], email[256];
- static char name[LEN_NAME+1], sname[LEN_NAME+1], id[LEN_ID+1];
- static char office[LEN_OFFICE+1], phone[LEN_PHONE+1], phone2[LEN_PHONE2+1];
- static char dept[LEN_DEPT+1], title[LEN_TITLE+1], username[LEN_USERNAME+1];
- static char host[LEN_HOST+1];
- int ends_sr, ends_jr, ends_iii, ends_iv;
- char *p;
-
- if (fgets(buf, sizeof(buf), in) == NULL)
- return((struct entry *)NULL);
-
- strncpy(id, &buf[LOC_ID], LEN_ID); id[LEN_ID] = 0;
- strncpy(name, &buf[LOC_NAME], LEN_NAME); name[LEN_NAME] = 0;
- strncpy(office, &buf[LOC_OFFICE], LEN_OFFICE); office[LEN_OFFICE] = 0;
- strncpy(phone, &buf[LOC_PHONE], LEN_PHONE); phone[LEN_PHONE] = 0;
- strncpy(phone2, &buf[LOC_PHONE2], LEN_PHONE2); phone2[LEN_PHONE2] = 0;
- strncpy(dept, &buf[LOC_DEPT], LEN_DEPT); dept[LEN_DEPT] = 0;
- strncpy(title, &buf[LOC_TITLE], LEN_TITLE); title[LEN_TITLE] = 0;
- strncpy(username, &buf[LOC_USERNAME], LEN_USERNAME); username[LEN_USERNAME] = 0;
- strncpy(host, &buf[LOC_HOST], LEN_HOST); host[LEN_HOST] = 0;
-
- strcpy(sname, name);
- e.name = strtrim(sname);
- p = index(name, ',');
- if (p)
- *p = 0;
- e.last = strtrim(name);
- if (p) {
- p++;
- while (isspace(*p))
- p++;
- e.first = p;
- if (p = index(e.first, ' ')) {
- *p = 0;
- e.first = strtrim(e.first);
- e.middle = strtrim(p + 1);
- } else {
- e.first = strtrim(e.first);
- e.middle = "";
- }
- } else {
- e.first = "";
- e.middle = "";
- }
- ends_sr = ends_jr = ends_iii = ends_iv = 0;
- LookForSt(e.last);
- LookForO(e.last);
- LookForJrAndIII(e.last, &ends_sr, &ends_jr, &ends_iii, &ends_iv);
- LookForJrAndIII(e.first, &ends_sr, &ends_jr, &ends_iii, &ends_iv);
- FixCase(e.last);
- FixCase(e.first);
- FixCase(e.middle);
-
- e.id = id;
- e.eid = eid;
- EncryptID(e.eid, e.id, e.first, e.last);
-
- e.address = strtrim(office);
- e.phone = strtrim(phone);
- e.phone2 = strtrim(phone2);
- e.dept = strtrim(dept);
- e.title = strtrim(title);
-
- e.class = "MITS";
- if (!strcmp(e.dept, "PROJECT ATHENA"))
- e.class = "STAFF";
- else if (substr(e.title, "PROF") || substr(e.title, "LECTURE"))
- e.class = "FACULTY";
- else if (!strcmp(e.title, "VISITING SCIENTIST"))
- e.class = "VSCIENTI";
-
- strcpy(email, strtrim(username));
- if (host[0] == '@')
- strncat(email, strtrim(host));
- e.email = email;
-
- return(&e);
-}
-
-
-process_entry(e)
-struct entry *e;
-##{
- int changed, nochange;
- char buf[BUFSIZ], *from, *to;
-## char *first, *last, *eid, *sid, *name, *title, *phone2;
-## char class[9], oaddr[25], ophone[17], dept[128];
-## int id, status;
-
- first = e->first;
- if (strlen(first) > 16)
- first[16] = 0;
- last = e->last;
- if (strlen(last) > 16)
- last[16] = 0;
- eid = e->eid;
- id = 0;
-## repeat retrieve (id = u.users_id, class = u.mit_year, oaddr = u.office_addr,
-## ophone = u.office_phone, dept = u.mit_dept, status = u.#status)
-## where u.#last = @last and u.#first = @first and u.mit_id = @eid
- if (id == 0) {
- com_err(whoami, 0, "New user found: %s %s\n", first, last);
- return;
- }
- eid = e->id;
-## repeat replace u (mit_id=@eid) where u.users_id = @id
- sid = e->id;
- name = e->name;
- strcpy(dept, e->dept);
- title = e->title;
- strcpy(oaddr, e->address);
- phone2 = e->phone2;
-## repeat replace u (xname = @name, xdept = @dept, xtitle = @title,
-## xaddress = @oaddr, xphone1 = @ophone, xphone2 = @phone2,
-## xmodtime = "now")
-## where u.users_id = @id
-##}
-
--- /dev/null
+888209554AALERUD, ROBERT W 38-045 3-2547 RSCH LAB OF ELECT INSTRUMENT MAKER
+888523206AARSET, TIMOTHY C LIN-PC-105 1810499 LINCOLN STAFF
+888484889ABBATE, MATTHEW E39-215 3-2080 MIT PRESS EDITOR
+888461996ABBOT, RICHARD I MILLSTONE 1815604 LINCOLN STAFF
+868026428ABE, MASANOBU NE43-639 3-0081 LAB FOR COMP SCI VISITING SCIENTIST AVE @GOLDILOCKS.LCS.MIT.EDU
+888265338ABELL, DOROTHY F ENDICOTT HSE 326-5151 ENDICOTT HOUSE HOUSEKEEPER
+888363287ABEL, HOWARD NE43-410 3-5856 ELEC ENG & COMP SCI ASSOCIATE PROFESSOR MURREN @ZURICH.AI.MIT.EDU
+888506122ABEND, WILLIAM K E25-534 3-0771 3-0772BRAIN & COG SCI VISITING SCIENTIST
+888763144ABERNETHY, CRAIG W 66-570 3-4533 CHEMICAL ENG SENIOR SECRETARY
+888424227ABERT, CHARLES E LIN-B-325 1812380 LINCOLN ADMINISTRATIVE STAFF
--- /dev/null
+AALBERTS, DANIEL P 888988312 8 G 93 BROOKLINE ST APT#3 CAMBRIDGE MA 868-8668 3922 ROXBURY DRIVE NW CEDAR RAPIDS IA 258-6451
+ABBAMONDI, JOHN G 888491942 5 1 405 MEMORIAL DRIVE ATO CAMBRIDGE MA 775 BUCKWOOD DR CHOCTAW OK 253-2200
+ABBOTT, FREELAND K 888546516 63 2 BURTON HOUSE RM 454D 225-8414 104 MADISON AVE ARLINGTON MA
+ABBOTT, JAMES F 888566359 8 G ASHDOWN HOUSE RM 108C 225-9670 305 MEMORIAL DRIVE CAMBRIDGE MA
+ABBOTT, JAMES R 888335960 10 G 60 BROADWAY #1 ARLINGTON MA 641-2518 253-5513
+ABBOTT, JOAN D 888042219 1 4 BEXLEY HALL RM 106 225-9616 3600 60TH STREET NORTH ST PETERSBURG FL
+ABBOTT, LYNORE M 888546540 3 3 BURTON HOUSE RM 313A 225-8272 4619 BUCKNALL RD SAN JOSE CA 253-5411
+ABBOTT, NICHOLAS L 888043926 10 G 35 FAIRMONT STREET #2 ARLINGTON MA 643-1048 54 KINGTON TERRACE, NORTH S. AUSTRALIA 5006 AU 253-4548
+ABDALLA, KARIM M 888041973 6 G 550 MEMORIAL DR., APT.#22D3 RM 209 CAMBRIDGE MA 20 SARAY EL GERZIRA, ZAMALEK CAIRO EG 253-7350
+ABDO, RUDAYNA T 888042234 4 4 BURTON HOUSE RM 554B 225-8486 16 ARISTOTELOUS STREET POLITEA 14563 GR
+++ /dev/null
-/* $Header$
- *
- * This program will bulk resign user records in the database.
- */
-
-#include <stdio.h>
-#include <strings.h>
-#include <ctype.h>
-#include <sys/time.h>
-#include <moira.h>
-#include <moira_site.h>
-#include <des.h>
-#include <krb.h>
-#include <krb_err.h>
-#include <gdss.h>
-
-
-char *program;
-
-main(argc, argv)
-int argc;
-char **argv;
-##{
- char buf[BUFSIZ], *data, *p;
- struct save_queue *sq;
- SigInfo si;
- int found, status, i, wait;
-## char login[10], mid[32], rawsig[256];
-## int id, timestamp, sms, moira;
-
- program = "resign";
- init_krb_err_tbl();
- init_sms_err_tbl();
-
- /* Set the name of our kerberos ticket file */
- krb_set_tkt_string("/tmp/tkt_sign");
- status = 1;
- while (status) {
- printf("Authenticating as moira.extra:\n");
- status = krb_get_pw_in_tkt("moira", "extra", "ATHENA.MIT.EDU",
- "krbtgt", "ATHENA.MIT.EDU",
- DEFAULT_TKT_LIFE, 0);
- if (status != 0)
- com_err(program, status + krb_err_base, " in krb_get_pw_in_tkt");
- }
-
- for (i = 1; i < argc; i++) {
- if (!strcmp(argv[i], "-w"))
- wait++;
- else if (!strcmp(argv[i], "-D"))
- setenv("ING_SET", "set printqry");
- else
- fprintf(stderr, "Usage: %s [-w] [-D]\n", argv[0]);
- }
-
-
-## ingres #sms
-## range of u is users
-## range of s is strings
-
- sms = 0;
-## retrieve (sms = s.string_id) where s.string="sms@ATHENA.MIT.EDU"
- if (sms == 0) {
- com_err(program, 0, " failed to find string sms@ATHENA.MIT.EDU in database");
- dest_tkt();
- exit(1);
- }
- moira = 0;
-## retrieve (moira = s.string_id) where s.string="moira.extra@ATHENA.MIT.EDU"
- if (moira == 0) {
- com_err(program, 0, " failed to find string moira.extra@ATHENA.MIT.EDU in database");
- dest_tkt();
- exit(1);
- }
-
- found = 0;
- sq = sq_create();
-
-## retrieve (id = u.users_id, login = u.#login, mid = u.mit_id)
-## where u.sigwho = sms {
- sprintf(buf, "%d:%s:%s", id, strtrim(login), strtrim(mid));
- sq_save_data(sq, strsave(buf));
- found++;
-## }
-
- printf("Found %d users to resign.\n", found);
-
- si.rawsig = (unsigned char *) &rawsig[0];
-
- while (sq_get_data(sq, &data)) {
- p = index(data, ':');
- if (!p) {
- com_err(program, 0, " malformatted data");
- continue;
- }
- *p++ = 0;
- id = atoi(data);
- data = p;
- status = GDSS_Sign(data, strlen(data), buf);
- if (status) {
- com_err(program, gdss2et(status), "resigning data");
- continue;
- }
- status = GDSS_Verify(data, strlen(data), buf, &si);
- if (status) {
- com_err(program, gdss2et(status), "verifying data");
- continue;
- }
-
- timestamp = si.timestamp;
-## replace u (signature = rawsig, sigwho = moira, sigdate = timestamp)
-## where u.users_id = id
- if (wait) {
- printf("Next");
- fflush(stdout);
- gets(buf);
- }
- }
-## exit
- dest_tkt();
- exit(0);
-##}
+++ /dev/null
-/* $Header$
- */
-
-#include <stdio.h>
-#include <strings.h>
-#include <ctype.h>
-#include <sys/time.h>
-#include <moira.h>
-#include <moira_site.h>
-
-
-##define WHO 11859 /* root */
-##define PROG "stu-tape"
-
-#define MAX_ID_VALUE 32766
-#define MIN_ID_VALUE 101
-
-/* File format is:
-
-0-29 name
-30-38 id number
-50-54 school code
-55-79 year
-80-109 address
-110-124 room
-125-144 city
-145-158 state
-159-168 dorm phone
-169-212 home address
-213-232 home city
-243-251 mit phone (?)
-*/
-
-#define LOC_NAME 0
-#define LOC_ID 30
-#define LOC_COURSE 50
-#define LOC_YEAR 55
-#define LOC_ADDRESS 80
-#define LOC_DORM_ROOM 110
-#define LOC_CITY 125
-#define LOC_STATE 145
-#define LOC_DPHONE 155
-#define LOC_MPHONE 243
-
-#define LEN_NAME 30
-#define LEN_ID 9
-#define LEN_COURSE 5
-#define LEN_YEAR 25
-#define LEN_ADDRESS 30
-#define LEN_DORM_ROOM 15
-#define LEN_CITY 20
-#define LEN_STATE 10
-#define LEN_DPHONE 12
-#define LEN_MPHONE 10
-
-struct entry {
- char *name;
- char *last;
- char *first;
- char *middle;
- char *title;
- char *id;
- char *eid;
- char *course;
- char *year;
- char *address;
- char *dorm;
- char *city;
- char *state;
- char *dphone;
- char *mphone;
- char *class;
-};
-
-
-char *whoami;
-int newfinger = 0;
-int addxuser = 0;
-
-
-main(argc, argv)
-int argc;
-char **argv;
-##{
- FILE *in;
- struct entry *e, *get_next_entry();
- int i, wait = 0;
- char buf[BUFSIZ], *file = NULL;
-
- whoami = rindex(argv[0], '/');
- if (whoami)
- whoami++;
- else
- whoami = argv[0];
-
- for (i = 1; i < argc; i++) {
- if (!strcmp(argv[i], "-w"))
- wait++;
- else if (!strcmp(argv[i], "-D"))
- setenv("ING_SET", "set printqry");
- else if (!strcmp(argv[i], "-n"))
- newfinger++;
- else if (!strcmp(argv[i], "-u"))
- addxuser++;
- else if (file != NULL)
- fprintf(stderr, "Usage: %s [-w] [-D] [-n] [-u] inputfile\n", whoami);
- else
- file = argv[i];
- }
-
- in = fopen(file, "r");
- if (in == NULL) {
- fprintf(stderr, "Unable to open %s for input\n", file);
- exit(1);
- }
-
-## ingres sms
-## range of u is users
-
- while (e = get_next_entry(in)) {
- process_entry(e);
- if (wait) {
- printf("Next");
- fflush(stdout);
- gets(buf);
- }
- }
-
-## exit
- exit(0);
-##}
-
-
-struct entry *get_next_entry(in)
-FILE *in;
-{
- static struct entry e;
- static char buf[BUFSIZ], eid[16], classbuf[10], titlebuf[12];
- static char name[LEN_NAME+1], id[LEN_ID+1], course[LEN_COURSE+1];
- static char year[LEN_YEAR+1], address[LEN_ADDRESS+1];
- static char dorm_room[LEN_DORM_ROOM+1], city[LEN_CITY+1];
- static char state[LEN_STATE+1], dphone[LEN_DPHONE+1], mphone[LEN_MPHONE+1];
- static char sname[LEN_NAME+1], title[128];
- static int nyear = 0;
- int ends_jr, ends_iii, ends_iv, ends_sr;
- char *p;
-
- if (nyear == 0) {
- struct tm *tm;
- struct timeval tv;
-
- gettimeofday(&tv, NULL);
- tm = localtime(&tv.tv_sec);
- nyear = tm->tm_year;
- if (tm->tm_mon > 5)
- nyear++;
- }
-
- if (fgets(buf, sizeof(buf), in) == NULL)
- return((struct entry *)NULL);
-
- strncpy(name, &buf[LOC_NAME], LEN_NAME); name[LEN_NAME] = 0;
- strncpy(id, &buf[LOC_ID], LEN_ID); id[LEN_ID] = 0;
- strncpy(course, &buf[LOC_COURSE], LEN_COURSE); course[LEN_COURSE] = 0;
- strncpy(year, &buf[LOC_YEAR], LEN_YEAR); year[LEN_YEAR] = 0;
- strncpy(address, &buf[LOC_ADDRESS], LEN_ADDRESS); address[LEN_ADDRESS] = 0;
- strncpy(dorm_room, &buf[LOC_DORM_ROOM], LEN_DORM_ROOM); dorm_room[LEN_DORM_ROOM] = 0;
- strncpy(city, &buf[LOC_CITY], LEN_CITY); city[LEN_CITY] = 0;
- strncpy(state, &buf[LOC_STATE], LEN_STATE); state[LEN_STATE] = 0;
- strncpy(dphone, &buf[LOC_DPHONE], LEN_DPHONE); dphone[LEN_DPHONE] = 0;
- strncpy(mphone, &buf[LOC_MPHONE], LEN_MPHONE); mphone[LEN_MPHONE] = 0;
-
- strcpy(sname, name);
- e.name = strtrim(sname);
- p = index(name, ',');
- if (p)
- *p = 0;
- e.last = strtrim(name);
- if (p) {
- p++;
- while (isspace(*p))
- p++;
- e.first = p;
- if (p = index(e.first, ' ')) {
- *p = 0;
- e.first = strtrim(e.first);
- e.middle = strtrim(p + 1);
- } else {
- e.first = strtrim(e.first);
- e.middle = "";
- }
- } else {
- e.first = "";
- e.middle = "";
- }
- ends_jr = ends_iii = ends_iv = ends_sr = 0;
- LookForSt(e.last);
- LookForO(e.last);
- LookForJrAndIII(e.last, &ends_sr, &ends_jr, &ends_iii, &ends_iv);
- LookForJrAndIII(e.first, &ends_sr, &ends_jr, &ends_iii, &ends_iv);
- FixCase(e.last);
- FixCase(e.first);
- FixCase(e.middle);
-
- e.id = id;
- e.id[LEN_ID] = 0;
- e.eid = eid;
- EncryptID(e.eid, e.id, e.first, e.last);
-
- e.year = strtrim(year);
- e.title = title;
- if (e.year[0] == 'G') {
- e.class = "G";
- sprintf(title, "Grad Student");
- } else {
- e.class = classbuf;
- sprintf(classbuf, "%d", nyear + 4 - atoi(e.year) + 1900);
- sprintf(title, "Undergrad (class of %s)", classbuf);
- }
-
- e.course = strtrim(course);
- e.address = strtrim(address);
- e.dorm = strtrim(dorm_room);
- e.city = strtrim(city);
- e.state = strtrim(state);
- e.dphone = strtrim(dphone);
- e.mphone = strtrim(mphone);
- return(&e);
-}
-
-
-process_entry(e)
-struct entry *e;
-##{
- int changed, nochange;
- char buf[BUFSIZ], *from, *to;
-## char *first, *last, *eid, *title, *sid, *name;
-## char class[9], haddr[128], hphone[17], ophone[13], dept[24];
-## int id, status;
-
- first = e->first;
- if (strlen(first) > 16)
- first[16] = 0;
- last = e->last;
- if (strlen(last) > 16)
- last[16] = 0;
- eid = e->eid;
- id = 0;
-## repeat retrieve (id = u.users_id)
-## where u.#last = @last and u.#first = @first and u.mit_id = @eid
- if (id == 0) {
- com_err(whoami, 0, "New user found: %s %s\n", first, last);
- return;
- }
- eid = e->id;
-## repeat replace u (mit_id=@eid) where u.users_id = @id
-
- sid = e->id;
- name = e->name;
- strcpy(dept, e->course);
- title = e->title;
- strcpy(haddr, e->address);
- if (*e->dorm) {
- strcat(haddr, " ");
- strcat(haddr, e->dorm);
- }
- if (*e->city) {
- strcat(haddr, " ");
- strcat(haddr, e->city);
- }
- FixCase(haddr);
- if (*e->state) {
- strcat(haddr, " ");
- strcat(haddr, e->state);
- }
- strcpy(hphone, e->dphone);
- strcpy(ophone, e->mphone);
-## repeat replace u (xname = @name, xdept = @dept, xtitle = @title,
-## xaddress = @haddr, xphone1 = @hphone, xphone2 = @ophone,
-## xmodtime = "now")
-## where u.users_id = @id
-##}
-
-
-set_next_object_id(object, limit)
- char *object;
- int limit;
-##{
-## char *name;
-## int rowcount, exists, value;
-
- name = object;
-## begin transaction
-## repeat retrieve (value = values.#value) where values.#name = @name
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1) {
-## abort
- return(0);
- }
-
-## retrieve (exists = any(users.name where users.name = value))
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1) {
-## abort
- return(0);
- }
- while (exists) {
- value++;
- if (limit && value > MAX_ID_VALUE)
- value = MIN_ID_VALUE;
-## retrieve (exists = any(users.name where users.name = value))
- }
-
-## repeat replace values (#value = @value) where values.#name = @name
-## end transaction
- return(value);
-##}
-
-
+++ /dev/null
-/* $Header$
- *
- * This program will change UIDs on users who are not active so that
- * no UIDs are > 32000.
- */
-
-#include <stdio.h>
-#include <strings.h>
-#include <ctype.h>
-#include <sys/time.h>
-#include <moira.h>
-#include <moira_site.h>
-
-#define MAX_ID_VALUE 31999
-#define MIN_ID_VALUE 101
-
-
-char *program;
-
-main(argc, argv)
-int argc;
-char **argv;
-##{
- char buf[BUFSIZ], *p;
- struct save_queue *sq;
- int found, status, wait, i;
-## int id, uid;
-
- program = "uidfix";
- init_krb_err_tbl();
- init_sms_err_tbl();
-
- for (i = 1; i < argc; i++) {
- if (!strcmp(argv[i], "-w"))
- wait++;
- else if (!strcmp(argv[i], "-D"))
- setenv("ING_SET", "set printqry");
- else
- fprintf(stderr, "Usage: %s [-w] [-D]\n", argv[0]);
- }
-
-## ingres sms
-## range of u is users
-
- found = 0;
- sq = sq_create();
-
-## retrieve (id = u.users_id)
-## where u.#uid >= 32000 and (u.status = 0 or u.status = 4) {
- sq_save_data(sq, id);
- found++;
-## }
-
- printf("Found %d users to change.\n", found);
-
- while (sq_get_data(sq, &id)) {
- uid = set_next_object_id("uid", 1);
-## replace u (#uid = uid) where u.users_id = id
- if (wait) {
- printf("Next");
- fflush(stdout);
- gets(buf);
- }
- }
-## exit
- exit(0);
-##}
-
-
-set_next_object_id(object, limit)
- char *object;
- int limit;
-##{
-## char *name;
-## int rowcount, exists, value;
-
- name = object;
-## begin transaction
-## repeat retrieve (value = values.#value) where values.#name = @name
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1) {
-## abort
- return(0);
- }
-
-## retrieve (exists = any(users.name where users.name = value))
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1) {
-## abort
- return(0);
- }
- while (exists) {
- value++;
- if (limit && value > MAX_ID_VALUE)
- value = MIN_ID_VALUE;
-## retrieve (exists = any(users.name where users.name = value))
- }
-
-## repeat replace values (#value = @value) where values.#name = @name
-## end transaction
- return(value);
-##}
+++ /dev/null
-# $Source$
-# $Author$
-# $Header$
-#
-
-CFILES = startmoira.c mr_main.c mr_sauth.c mr_scall.c \
- mr_srvdata.c mr_shutdown.c mr_util.c qrtn.c \
- qsupport.c qsubs.c queries2.c mr_sbrk.c mr_smalloc.c \
- meinitlst.c increment.c cache.c
-
-SRVOBJ=mr_main.o mr_sauth.o mr_scall.o mr_srvdata.o mr_shutdown.o \
- mr_util.o qrtn.o queries2.o qsupport.o qsubs.o mr_sbrk.o \
- mr_smalloc.o meinitlst.o increment.o cache.o
-
-GLUOBJS=mr_glue.o qrtn.o queries2.o qsupport.o qsubs.o \
- ../rpc/mr_et.o mr_srvdata.o mr_smalloc.o meinitlst.o mr_sbrk.o \
- ../rpc/krb_et.o mr_util.o increment.o cache.o
-
-GLUPOBJS=mr_glue.o qrtn.o queries2.o qsupport.o qsubs.o \
- ../../rpc/profiled/mr_et.o mr_srvdata.o mr_smalloc.o \
- meinitlst.o mr_sbrk.o ../../rpc/profiled/krb_et.o mr_util.o \
- increment.o cache.o
-
-INGRESDIR=/usr/ingres
-
-LIBS=../rpc/libmoira.a ../gdb/libgdb.a
-PLIBS=../../rpc/libmoira_p.a ../../gdb/libgdb_p.a
-
-LLIBS= -L../lib -lzephyr -lkrb -ldes -lcom_err -lm
-PLLIBS= -L../../lib -lzephyr -lkrb -ldes -lcom_err_p -lm
-
-SLIBS= ${INGRESDIR}/lib/libqlib ${INGRESDIR}/lib/compatlib
-
-COPTS= -O
-
-INCDIRS=-I../include
-
-CFLAGS= ${INCDIRS} ${COPTS}
-LINTFLAGS= -uhv
-
-ALL=moirad startmoira libmoiraglue.a # libmoiraglue_p.a
-
-.c.o:
-# ${CC} -c -pg ${CFLAGS} $*.c
-# mv $*.o profiled/$*.o
- ${CC} -c ${CFLAGS} $*.c
-
-.SUFFIXES: .dc .qc
-
-.qc.c:
- rm -f $*.c
- ${INGRESDIR}/bin/eqc -p $*
-
-.dc.c:
- rm -f $*.c
- awk -f ingres.awk < $< > $*.sc
- ${INGRESDIR}/bin/esqlc -p $*
-
-all: ${ALL}
-
-moirad: ${SRVOBJ} ${LIBS}
- rm -f moirad
- cc -o moirad ${COPTS} ${SRVOBJ} ${SLIBS} ${LIBS} ${LLIBS}
-
-moirad_p: ${SRVOBJ} ${LIBS}
- (cd profiled; cc -pg -o moirad_p ${COPTS} ${SRVOBJ} ${SLIBS} ${PLIBS} \
- ${PLLIBS})
-
-libmoiraglue.a: ${GLUOBJS}
- ar cruv libmoiraglue.a ${GLUOBJS}
- ranlib libmoiraglue.a
-
-libmoiraglue_p.a: ${GLUOBJS}
- cd profiled; ar cruv ../libmoiraglue_p.a ${GLUPOBJS}
- ranlib libmoiraglue_p.a
-
-restart: moirad startmoira
- ./startmoira
-
-startmoira: startmoira.o
- cc -o startmoira ${COPTS} startmoira.o
-
-install: moirad startmoira
- install -c moirad ../bin/moirad
- install -c startmoira ../bin/startmoira
-
-clean:
- rm -f ${ALL} libmoiraglue_p.a
- rm -f *.o *~ *.sc qrtn.c qsupport.c qoldsup.c increment.c
- rm -f profiled/*.o
- rm -f *.err
-
-TAGS: $(CFILES)
- -etags $(CFILES)
-
-lint:
- lint ${INCDIRS} mr_*.c q*.c ../rpc/llib-lmoira.ln
-
-depend: $(CFILES)
- mkdep $(CFLAGS) $(CFILES)
-
-# the last constant line in the makefile should be...
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-
-startmoira.o: startmoira.c ../include/mit-copyright.h /usr/include/stdio.h
-startmoira.o: /usr/include/strings.h /usr/include/sys/types.h
-startmoira.o: /usr/include/sys/file.h /usr/include/sys/wait.h
-startmoira.o: /usr/include/sys/signal.h /usr/include/sys/ioctl.h
-startmoira.o: /usr/include/sys/ttychars.h /usr/include/sys/ttydev.h
-startmoira.o: ../include/moira_site.h
-mr_main.o: mr_main.c ../include/mit-copyright.h /usr/include/strings.h
-mr_main.o: /usr/include/sys/types.h /usr/include/sys/errno.h
-mr_main.o: /usr/include/sys/signal.h /usr/include/sys/wait.h
-mr_main.o: /usr/include/sys/stat.h mr_server.h /usr/include/sys/uio.h
-mr_main.o: /usr/include/sys/socket.h /usr/include/netinet/in.h
-mr_main.o: ../include/mr_proto.h /usr/include/stdio.h ../include/gdb.h
-mr_main.o: /usr/include/sys/time.h /usr/include/sys/time.h ../include/moira.h
-mr_main.o: ../include/mr_et.h ../include/moira_site.h ../include/krb.h
-mr_main.o: ../include/des.h ../include/krb_et.h
-mr_sauth.o: mr_sauth.c ../include/mit-copyright.h /usr/include/strings.h
-mr_sauth.o: mr_server.h /usr/include/sys/types.h /usr/include/sys/uio.h
-mr_sauth.o: /usr/include/sys/socket.h /usr/include/netinet/in.h
-mr_sauth.o: ../include/mr_proto.h /usr/include/stdio.h ../include/gdb.h
-mr_sauth.o: /usr/include/sys/time.h /usr/include/sys/time.h
-mr_sauth.o: ../include/moira.h ../include/mr_et.h ../include/moira_site.h
-mr_sauth.o: ../include/krb.h ../include/des.h /usr/include/ctype.h
-mr_sauth.o: ../include/krb_et.h
-mr_scall.o: mr_scall.c ../include/mit-copyright.h /usr/include/sys/types.h
-mr_scall.o: /usr/include/sys/stat.h /usr/include/sys/file.h ../include/krb.h
-mr_scall.o: ../include/des.h /usr/include/errno.h query.h mr_server.h
-mr_scall.o: /usr/include/sys/uio.h /usr/include/sys/socket.h
-mr_scall.o: /usr/include/netinet/in.h ../include/mr_proto.h
-mr_scall.o: /usr/include/stdio.h ../include/gdb.h /usr/include/sys/time.h
-mr_scall.o: /usr/include/sys/time.h ../include/moira.h ../include/mr_et.h
-mr_scall.o: ../include/moira_site.h
-mr_srvdata.o: mr_srvdata.c ../include/mit-copyright.h mr_server.h
-mr_srvdata.o: /usr/include/sys/types.h /usr/include/sys/uio.h
-mr_srvdata.o: /usr/include/sys/socket.h /usr/include/netinet/in.h
-mr_srvdata.o: ../include/mr_proto.h /usr/include/stdio.h ../include/gdb.h
-mr_srvdata.o: /usr/include/sys/time.h /usr/include/sys/time.h
-mr_srvdata.o: ../include/moira.h ../include/mr_et.h ../include/moira_site.h
-mr_srvdata.o: ../include/krb.h ../include/des.h
-mr_shutdown.o: mr_shutdown.c ../include/mit-copyright.h
-mr_shutdown.o: /usr/include/strings.h /usr/include/sys/errno.h mr_server.h
-mr_shutdown.o: /usr/include/sys/types.h /usr/include/sys/uio.h
-mr_shutdown.o: /usr/include/sys/socket.h /usr/include/netinet/in.h
-mr_shutdown.o: ../include/mr_proto.h /usr/include/stdio.h ../include/gdb.h
-mr_shutdown.o: /usr/include/sys/time.h /usr/include/sys/time.h
-mr_shutdown.o: ../include/moira.h ../include/mr_et.h ../include/moira_site.h
-mr_shutdown.o: ../include/krb.h ../include/des.h
-mr_util.o: mr_util.c ../include/mit-copyright.h mr_server.h
-mr_util.o: /usr/include/sys/types.h /usr/include/sys/uio.h
-mr_util.o: /usr/include/sys/socket.h /usr/include/netinet/in.h
-mr_util.o: ../include/mr_proto.h /usr/include/stdio.h ../include/gdb.h
-mr_util.o: /usr/include/sys/time.h /usr/include/sys/time.h ../include/moira.h
-mr_util.o: ../include/mr_et.h ../include/moira_site.h ../include/krb.h
-mr_util.o: ../include/des.h /usr/include/ctype.h /usr/include/strings.h
-qrtn.o: qrtn.c ../include/mit-copyright.h query.h mr_server.h
-qrtn.o: /usr/include/sys/types.h /usr/include/sys/uio.h
-qrtn.o: /usr/include/sys/socket.h /usr/include/netinet/in.h
-qrtn.o: ../include/mr_proto.h /usr/include/stdio.h ../include/gdb.h
-qrtn.o: /usr/include/sys/time.h /usr/include/sys/time.h ../include/moira.h
-qrtn.o: ../include/mr_et.h ../include/moira_site.h ../include/krb.h
-qrtn.o: ../include/des.h
-qsupport.o: qsupport.c ../include/mit-copyright.h query.h sql_defs.h
-qsupport.o: mr_server.h
-qsupport.o: /usr/include/sys/types.h /usr/include/sys/uio.h
-qsupport.o: /usr/include/sys/socket.h /usr/include/netinet/in.h
-qsupport.o: ../include/mr_proto.h /usr/include/stdio.h ../include/gdb.h
-qsupport.o: /usr/include/sys/time.h /usr/include/sys/time.h
-qsupport.o: ../include/moira.h ../include/mr_et.h ../include/moira_site.h
-qsupport.o: ../include/krb.h ../include/des.h /usr/include/ctype.h
-qsubs.o: qsubs.c ../include/mit-copyright.h ../include/moira.h
-qsubs.o: ../include/mr_et.h query.h
-queries2.o: queries2.c ../include/mit-copyright.h query.h ../include/mr_et.h
-mr_sbrk.o: mr_sbrk.c ../include/mit-copyright.h /usr/include/sys/types.h
-mr_smalloc.o: mr_smalloc.c /usr/include/stdio.h /usr/include/signal.h
-mr_smalloc.o: /usr/include/sys/time.h /usr/include/sys/time.h
-mr_smalloc.o: /usr/include/sys/resource.h
-meinitlst.o: meinitlst.c ../include/mit-copyright.h /usr/include/sys/errno.h
-meinitlst.o: /usr/include/sys/types.h
-increment.o: increment.c ../include/mit-copyright.h ../include/moira.h
-increment.o: ../include/mr_et.h query.h mr_server.h /usr/include/sys/types.h
-increment.o: /usr/include/sys/uio.h /usr/include/sys/socket.h
-increment.o: /usr/include/netinet/in.h ../include/mr_proto.h
-increment.o: /usr/include/stdio.h ../include/gdb.h /usr/include/sys/time.h
-increment.o: /usr/include/sys/time.h ../include/moira_site.h ../include/krb.h
-increment.o: ../include/des.h
-cache.o: cache.c ../include/mit-copyright.h query.h mr_server.h
-cache.o: /usr/include/sys/types.h /usr/include/sys/uio.h
-cache.o: /usr/include/sys/socket.h /usr/include/netinet/in.h
-cache.o: ../include/mr_proto.h /usr/include/stdio.h ../include/gdb.h
-cache.o: /usr/include/sys/time.h /usr/include/sys/time.h ../include/moira.h
-cache.o: ../include/mr_et.h ../include/moira_site.h ../include/krb.h
-cache.o: ../include/des.h
+++ /dev/null
-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright (C) 1989 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- *
- */
-
-#ifndef lint
-static char *rcsid_qsupport_qc = "$Header$";
-#endif lint
-
-#include <mit-copyright.h>
-#include "query.h"
-#include "mr_server.h"
-
-
-extern char *whoami, *strsave();
-extern int ingres_errno, mr_errcode;
-
-
-/*** NOTE **************************************************************
- *
- * This code depends on each type starting with a unique letter. If
- * any new types are added to the system that begin with the same
- * letter as one of the existing types:
- * User
- * List
- * String
- * Machine
- * Cluster
- * Filesystem
- * then we will have to rework the code that only looks at the first
- * letter of the types.
- *
- ***********************************************************************
- */
-
-/* Cache parameters: */
-#define CACHESIZE 101 /* number of cache slots */
-#define NAMESZ 257 /* max size of a name */
-
-struct item {
- char name[NAMESZ];
- char type[9];
- int nhash;
- int id;
- struct item *next;
- struct item *prev;
-};
-
-static struct item cachehead;
-static int cachesize;
-
-/* statistics counters */
-int cachehits = 0, cachemisses = 0;
-
-
-/* Name hash function. */
-
-int hashname(name, type)
-register char *name;
-char *type;
-{
- register int val = *type;
-
- while (*name)
- val = val<<5 - val + *name++ - '`';
- return(val);
-}
-
-
-/* Initialize the cache, flushing any old data, and report the statistics
- * if the cache was previously in use.
- */
-
-flush_cache()
-{
- register struct item *i;
-
- if (cachehits + cachemisses != 0)
- com_err(whoami, 0, "Flushing cache; %d hits, %d misses, %d%% hit rate",
- cachehits, cachemisses,
- (100 * cachehits) / (cachehits + cachemisses));
- else
- cachehead.next = cachehead.prev = &cachehead;
- cachehits = cachemisses = cachesize = 0;
- for (i = cachehead.next; i != &cachehead; i = i->next) {
- if (i->prev != &cachehead)
- free(i->prev);
- }
- if (cachehead.prev != &cachehead)
- free(cachehead.prev);
- cachehead.next = cachehead.prev = &cachehead;
-}
-
-
-/* Do a name to ID translation. id will be updated with the answer if
- * it is available, and as a side effect the cache is updated.
- */
-
-int name_to_id(name, type, id)
-char *name;
-char *type;
-int *id;
-##{
- register struct item *i;
-## char *iname;
-## int j, rowcount;
- int h, ctr;
-
- h = hashname(name, type);
- for (i = cachehead.next; i != &cachehead; i = i->next) {
- if (i->nhash != h ||
- strcmp(name, i->name) ||
- strcasecmp(type, i->type))
- continue;
- *id = i->id;
- cachehits++;
- i->next->prev = i->prev;
- i->prev->next = i->next;
- i->next = cachehead.next;
- i->prev = &cachehead;
- cachehead.next->prev = i;
- cachehead.next = i;
- return(MR_SUCCESS);
- }
-
- cachemisses++;
- iname = name;
-
- switch (*type) {
- case 'U':
- case 'u':
-## repeat retrieve (j = users.users_id) where users.#login=@iname
- break;
- case 'L':
- case 'l':
-## repeat retrieve (j = list.list_id) where list.#name=@iname
- break;
- case 'M':
- case 'm':
-## repeat retrieve (j = machine.mach_id) where machine.#name=uppercase(@iname)
- break;
- case 'C':
- case 'c':
-## repeat retrieve (j = cluster.clu_id) where cluster.#name=@iname
- break;
- case 'F':
- case 'f':
-## repeat retrieve (j = filesys.filsys_id) where filesys.#label=@iname
- break;
- case 'S':
- case 's':
-## repeat retrieve (j = strings.string_id) where strings.#string=@iname
- break;
- default:
- return(MR_INTERNAL);
- }
-## inquire_equel(rowcount = "rowcount")
- if (ingres_errno) return(mr_errcode);
- if (rowcount == 0)
- return(MR_NO_MATCH);
- if (rowcount > 1)
- return(MR_NOT_UNIQUE);
- *id = j;
- if (name[0] == '#' && !strcasecmp(type, "USER"))
- return(MR_SUCCESS);
- if (cachesize < CACHESIZE) {
- i = (struct item *) malloc(sizeof(struct item));
- cachesize++;
- } else {
- i = cachehead.prev;
- cachehead.prev = i->prev;
- i->prev->next = &cachehead;
- }
- strcpy(i->name, name);
- strcpy(i->type, type);
- i->nhash = h;
- i->id = j;
- i->next = cachehead.next;
- i->prev = &cachehead;
- cachehead.next->prev = i;
- cachehead.next = i;
- return(MR_SUCCESS);
-##}
-
-
-/* Perform an ID to name mapping. name should be a pointer to a pointer to
- * malloc'ed data. The buffer it refers to will be freed, and a new buffer
- * allocated with the answer.
- */
-
-int id_to_name(id, type, name)
-int id;
-char *type;
-char **name;
-##{
- register struct item *i;
-## char iname[NAMESZ];
-## int j, rowcount;
- int ctr;
-
- for (i = cachehead.next; i != &cachehead; i = i->next) {
- if (i->id != id || strcasecmp(type, i->type)) continue;
- free(*name);
- *name = strsave(i->name);
- cachehits++;
- i->next->prev = i->prev;
- i->prev->next = i->next;
- i->next = cachehead.next;
- i->prev = &cachehead;
- cachehead.next->prev = i;
- cachehead.next = i;
- return(MR_SUCCESS);
- }
-
- cachemisses++;
- j = id;
-
- switch (*type) {
- case 'U':
- case 'u':
-## repeat retrieve (iname = users.login) where users.users_id=@j
- break;
- case 'L':
- case 'l':
-## repeat retrieve (iname = list.name) where list.list_id=@j
- break;
- case 'M':
- case 'm':
-## repeat retrieve (iname = machine.name) where machine.mach_id=@j
- break;
- case 'C':
- case 'c':
-## repeat retrieve (iname = cluster.name) where cluster.clu_id=@j
- break;
- case 'F':
- case 'f':
-## repeat retrieve (iname = filesys.label) where filesys.filsys_id=@j
- break;
- case 'S':
- case 's':
-## repeat retrieve (iname = strings.string) where strings.string_id=@j
- break;
- default:
- return(MR_INTERNAL);
- }
-## inquire_equel(rowcount = "rowcount")
- if (ingres_errno) return(mr_errcode);
- if (rowcount == 0) {
- free(*name);
- sprintf(iname, "#%d", j);
- *name = strsave(iname);
- return(MR_NO_MATCH);
- }
- if (rowcount != 1)
- return(MR_INTERNAL);
- free(*name);
- *name = strsave(strtrim(iname));
- if (**name == '#' && !strcasecmp(type, "USER"))
- return(MR_SUCCESS);
- if (cachesize < CACHESIZE) {
- i = (struct item *) malloc(sizeof(struct item));
- cachesize++;
- } else {
- i = cachehead.prev;
- cachehead.prev = i->prev;
- i->prev->next = &cachehead;
- }
- strcpy(i->name, *name);
- strcpy(i->type, type);
- i->nhash = hashname(*name, type);
- i->id = id;
- i->next = cachehead.next;
- i->prev = &cachehead;
- cachehead.next->prev = i;
- cachehead.next = i;
- return(MR_SUCCESS);
-##}
-
-
-/* Explicitly add something to the cache without doing a lookup in the
- * database.
- */
-
-cache_entry(name, type, id)
-char *name;
-char *type;
-int id;
-{
- register struct item *i;
-
- for (i = cachehead.next; i != &cachehead; i = i->next)
- if (i->id == id && !strcmp(i->type, type))
- return(MR_SUCCESS);
- if (cachesize < CACHESIZE) {
- i = (struct item *) malloc(sizeof(struct item));
- cachesize++;
- } else {
- i = cachehead.prev;
- cachehead.prev = i->prev;
- i->prev->next = &cachehead;
- }
- strcpy(i->name, name);
- strcpy(i->type, type);
- i->nhash = hashname(name, type);
- i->id = id;
- i->next = cachehead.next;
- i->prev = &cachehead;
- cachehead.next->prev = i;
- cachehead.next = i;
- return(MR_SUCCESS);
-}
-
-
-/* Flush something that may or may not already be in the cache. */
-
-flush_name(name, type)
-char *name;
-char *type;
-{
- int h;
- register struct item *i;
-
- h = hashname(name, type);
-
- for (i = cachehead.next; i != &cachehead; i = i->next) {
- if (!strcmp(name, i->name) && !strcasecmp(type, i->type)) {
- cachesize--;
- i->next->prev = i->prev;
- i->prev->next = i->next;
- free(i);
- return(MR_SUCCESS);
- }
- }
-}
+++ /dev/null
-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright (C) 1989 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- *
- */
-
-#ifndef lint
-static char *rcsid_qrtn_qc = "$Header$";
-#endif lint
-
-#include <mit-copyright.h>
-#include <moira.h>
-#include "query.h"
-#include "mr_server.h"
-
-extern char *whoami;
-char *malloc();
-
-int inc_pid = 0;
-int inc_running = 0;
-time_t inc_started;
-
-#define MAXARGC 15
-
-/* structures to save before args */
-static char beforeb[MAXARGC][ARGLEN];
-static char *before[MAXARGC];
-##char *barg0, *barg1, *barg2, *barg3, *barg4;
-##char *barg5, *barg6, *barg7, *barg8, *barg9;
-##char *barg10, *barg11, *barg12, *barg13, *barg14;
-static int beforec;
-static char *beforetable;
-
-/* structures to save after args */
-static char afterb[MAXARGC][ARGLEN];
-static char *after[MAXARGC];
-##char *aarg0, *aarg1, *aarg2, *aarg3, *aarg4;
-##char *aarg5, *aarg6, *aarg7, *aarg8, *aarg9;
-##char *aarg10, *aarg11, *aarg12, *aarg13, *aarg14;
-static int afterc;
-
-/* structures to save entire sets of incremental changes */
-struct save_queue *incremental_sq = NULL;
-struct save_queue *incremental_exec = NULL;
-struct iupdate {
- char *table;
- int beforec;
- char **before;
- int afterc;
- char **after;
- char *service;
-};
-
-
-incremental_init()
-{
- int i;
-
- for (i = 0; i < MAXARGC; i++) {
- before[i] = &beforeb[i][0];
- after[i] = &afterb[i][0];
- }
- barg0 = before[0];
- barg1 = before[1];
- barg2 = before[2];
- barg3 = before[3];
- barg4 = before[4];
- barg5 = before[5];
- barg6 = before[6];
- barg7 = before[7];
- barg8 = before[8];
- barg9 = before[9];
- barg10 = before[10];
- barg11 = before[11];
- barg12 = before[12];
- barg13 = before[13];
- barg14 = before[14];
- aarg0 = after[0];
- aarg1 = after[1];
- aarg2 = after[2];
- aarg3 = after[3];
- aarg4 = after[4];
- aarg5 = after[5];
- aarg6 = after[6];
- aarg7 = after[7];
- aarg8 = after[8];
- aarg9 = after[9];
- aarg10 = after[10];
- aarg11 = after[11];
- aarg12 = after[12];
- aarg13 = after[13];
- aarg14 = after[14];
- if (incremental_sq == NULL)
- incremental_sq = sq_create();
- if (incremental_exec == NULL)
- incremental_exec = sq_create();
-}
-
-
-##incremental_before(table, qual, argv)
-##char *table;
-##char *qual;
-char **argv;
-##{
-## int id;
- char buffer[512], *name;
-
- beforetable = table;
-
- if (!strcmp(table, "users")) {
-## retrieve (barg0 = u.login, barg1 = text(u.uid),
-## barg2 = u.shell, barg3 = u.last, barg4 = u.first,
-## barg5 = u.middle, barg6 = text(u.status),
-## barg7 = u.mit_id, barg8 = u.mit_year)
-## where qual
- beforec = 9;
- } else if (!strcmp(table, "machine")) {
-## retrieve (barg0 = m.name, barg1 = m.type) where qual
- beforec = 2;
- } else if (!strcmp(table, "cluster")) {
-## retrieve (barg0 = c.name, barg1 = c.desc, barg2 = c.location)
-## where qual
- beforec = 3;
- } else if (!strcmp(table, "mcmap")) {
- strcpy(barg0, argv[0]);
- strcpy(barg1, argv[1]);
- beforec = 2;
- } else if (!strcmp(table, "svc")) {
- strcpy(barg0, argv[0]);
- strcpy(barg1, argv[1]);
- strcpy(barg2, argv[2]);
- beforec = 3;
- } else if (!strcmp(table, "filesys")) {
-## range of fs is filesys
-## retrieve (barg0 = fs.label, barg1 = fs.type, barg2 = text(fs.mach_id),
-## barg3 = fs.name, barg4 = fs.mount, barg5 = fs.access,
-## barg6 = fs.comments, barg7 = text(fs.owner),
-## barg8 = text(fs.owners), barg9 = text(fs.createflg),
-## barg10 = fs.lockertype)
-## where qual
- beforec = 11;
- } else if (!strcmp(table, "quota")) {
- strcpy(barg0, "?");
- strcpy(barg1, argv[1]);
- strcpy(barg2, "?");
- sprintf(buffer, "%s and filesys.filsys_id = q.filsys_id", qual);
- qual = buffer;
-## range of q is quota
-## retrieve (barg3 = text(q.quota), barg4 = filesys.name) where qual
- beforec = 5;
- } else if (!strcmp(table, "list")) {
-## retrieve (barg0 = l.name, barg1 = text(l.active),
-## barg2 = text(l.public), barg3 = text(l.hidden),
-## barg4 = text(l.maillist), barg5 = text(l.group),
-## barg6 = text(l.gid), barg7 = l.acl_type,
-## barg8 = text(l.acl_id), barg9 = l.desc)
-## where qual
- beforec = 10;
- } else if (!strcmp(table, "members")) {
- id = (int) argv[0];
-## retrieve (barg3 = text(list.group)) where list.list_id = id
- name = malloc(0);
- id_to_name(id, "LIST", &name);
- strcpy(barg0, name);
- strcpy(barg1, argv[1]);
- id = (int) argv[2];
- if (!strcmp(barg1, "USER")) {
- id_to_name(id, barg1, &name);
- } else if (!strcmp(barg1, "LIST")) {
- id_to_name(id, barg1, &name);
- } else if (!strcmp(barg1, "STRING")) {
- id_to_name(id, barg1, &name);
- } else if (!strcmp(barg1, "KERBEROS")) {
- id_to_name(id, "STRING", &name);
- }
- strcpy(barg2, name);
- free(name);
- beforec = 4;
- } /* else
- com_err(whoami, 0, "unknown table in incremental_before"); */
-##}
-
-
-incremental_clear_before()
-{
- beforec = 0;
-}
-
-incremental_clear_after()
-{
- incremental_after("clear", 0);
-}
-
-
-
-##incremental_after(table, qual, argv)
-##char *table;
-##char *qual;
-char **argv;
-##{
- char buffer[2048], *name;
-## int id, i;
- struct iupdate *iu;
- char **copy_argv();
-
- if (!strcmp(table, "users")) {
-## retrieve (aarg0 = u.login, aarg1 = text(u.uid),
-## aarg2 = u.shell, aarg3 = u.last, aarg4 = u.first,
-## aarg5 = u.middle, aarg6 = text(u.status),
-## aarg7 = u.mit_id, aarg8 = u.mit_year)
-## where qual
- afterc = 9;
- } else if (!strcmp(table, "machine")) {
-## retrieve (aarg0 = m.name, aarg1 = m.type) where qual
- afterc = 2;
- } else if (!strcmp(table, "cluster")) {
-## retrieve (aarg0 = c.name, aarg1 = c.desc, aarg2 = c.location)
-## where qual
- afterc = 3;
- } else if (!strcmp(table, "mcmap")) {
- strcpy(aarg0, argv[0]);
- strcpy(aarg1, argv[1]);
- afterc = 2;
- } else if (!strcmp(table, "svc")) {
- strcpy(aarg0, argv[0]);
- strcpy(aarg1, argv[1]);
- strcpy(aarg2, argv[2]);
- afterc = 3;
- } else if (!strcmp(table, "filesys")) {
-## range of fs is filesys
-## retrieve (aarg0 = fs.label, aarg1 = fs.type,
-## aarg2 = text(fs.mach_id),
-## aarg3 = fs.name, aarg4 = fs.mount, aarg5 = fs.access,
-## aarg6 = fs.comments, aarg7 = text(fs.owner),
-## aarg8 = text(fs.owners), aarg9 = text(fs.createflg),
-## aarg10 = fs.lockertype)
-## where qual
- afterc = 11;
- } else if (!strcmp(table, "quota")) {
- strcpy(aarg0, "?");
- strcpy(aarg1, argv[1]);
- strcpy(aarg2, "?");
- sprintf(buffer, "%s and filesys.filsys_id = q.filsys_id", qual);
- qual = buffer;
-## range of q is quota
-## retrieve (aarg3 = text(q.quota), aarg4 = filesys.name) where qual
- afterc = 5;
- } else if (!strcmp(table, "list")) {
-## retrieve (aarg0 = l.name, aarg1 = text(l.active),
-## aarg2 = text(l.public), aarg3 = text(l.hidden),
-## aarg4 = text(l.maillist), aarg5 = text(l.group),
-## aarg6 = text(l.gid), aarg7 = l.acl_type,
-## aarg8 = text(l.acl_id), aarg9 = l.desc)
-## where qual
- afterc = 10;
- } else if (!strcmp(table, "members")) {
- id = (int) argv[0];
-## retrieve (aarg3 = text(list.group)) where list.list_id = id
- name = malloc(0);
- id_to_name(id, "LIST", &name);
- strcpy(aarg0, name);
- strcpy(aarg1, argv[1]);
- id = (int) argv[2];
- if (!strcmp(aarg1, "USER")) {
- id_to_name(id, aarg1, &name);
- } else if (!strcmp(aarg1, "LIST")) {
- id_to_name(id, aarg1, &name);
- } else if (!strcmp(aarg1, "STRING")) {
- id_to_name(id, aarg1, &name);
- } else if (!strcmp(aarg1, "KERBEROS")) {
- id_to_name(id, "STRING", &name);
- }
- strcpy(aarg2, name);
- free(name);
- afterc = 4;
- } else if (!strcmp(table, "clear")) {
- afterc = 0;
- table = beforetable;
- } /* else
- com_err(whoami, 0, "unknown table in incremental_after"); */
-
- iu = (struct iupdate *) malloc(sizeof(struct iupdate));
- iu->table = strsave(table);
- iu->beforec = beforec;
- iu->before = copy_argv(before, beforec);
- iu->afterc = afterc;
- iu->after = copy_argv(after, afterc);
- sq_save_data(incremental_sq, iu);
-
-#ifdef DEBUG
- sprintf(buffer, "INCREMENTAL(%s, [", table);
- for (i = 0; i < beforec; i++) {
- if (i == 0)
- strcat(buffer, strtrim(before[0]));
- else {
- strcat(buffer, ", ");
- strcat(buffer, strtrim(before[i]));
- }
- }
- strcat(buffer, "], [");
- for (i = 0; i < afterc; i++) {
- if (i == 0)
- strcat(buffer, strtrim(after[0]));
- else {
- strcat(buffer, ", ");
- strcat(buffer, strtrim(after[i]));
- }
- }
- strcat(buffer, "])");
- com_err(whoami, 0, buffer);
-#endif DEBUG
-##}
-
-
-/* Called when the current transaction is committed to start any queued
- * incremental updates. This caches the update table the first time it
- * is called.
- */
-
-struct inc_cache {
- struct inc_cache *next;
- char *table;
- char *service;
-};
-
-
-incremental_update()
-{
- static int inited = 0;
- static struct inc_cache *cache;
- struct inc_cache *c;
-## char tab[17], serv[17];
- struct iupdate *iu;
-
- if (!inited) {
- inited++;
-
-## retrieve (tab = incremental.table, serv = incremental.service) {
- c = (struct inc_cache *)malloc(sizeof(struct inc_cache));
- c->next = cache;
- c->table = strsave(strtrim(tab));
- c->service = strsave(strtrim(serv));
- cache = c;
-## }
- }
-
- while (sq_remove_data(incremental_sq, &iu)) {
- for (c = cache; c; c = c->next) {
- if (!strcmp(c->table, iu->table)) {
- iu->service = c->service;
- sq_save_data(incremental_exec, iu);
- }
- }
- }
- if (inc_running == 0)
- next_incremental();
-}
-
-
-next_incremental()
-{
- struct iupdate *iu;
- char *argv[MAXARGC * 2 + 4], cafter[3], cbefore[3], prog[BUFSIZ];
- int i;
-
- if (incremental_exec == NULL)
- incremental_init();
-
- if (sq_empty(incremental_exec) ||
- (inc_running && now - inc_started < INC_TIMEOUT))
- return;
-
- if (inc_running)
- com_err(whoami, 0, "incremental timeout on pid %d", inc_pid);
-
- sq_remove_data(incremental_exec, &iu);
- argv[1] = iu->table;
- sprintf(cbefore, "%d", iu->beforec);
- argv[2] = cbefore;
- sprintf(cafter, "%d", iu->afterc);
- argv[3] = cafter;
- for (i = 0; i < iu->beforec; i++)
- argv[4 + i] = iu->before[i];
- for (i = 0; i < iu->afterc; i++)
- argv[4 + iu->beforec + i] = iu->after[i];
-
- sprintf(prog, "%s/%s.incr", BIN_DIR, iu->service);
-#ifdef DEBUG
- com_err(whoami, 0, "forking %s", prog);
-#endif
- argv[0] = prog;
- argv[4 + iu->beforec + iu->afterc] = 0;
- inc_pid = vfork();
- switch (inc_pid) {
- case 0:
- execv(prog, argv);
- exit(1);
- case -1:
- com_err(whoami, 0, "Failed to start incremental update");
- break;
- default:
- inc_running = 1;
- inc_started = now;
- }
-
- free_argv(iu->before, iu->beforec);
- free_argv(iu->after, iu->afterc);
- free(iu->table);
- free(iu);
-
-}
-
-
-/* Called when the current transaction is aborted to throw away any queued
- * incremental updates
- */
-
-incremental_flush()
-{
- struct iupdate *iu;
-
- while (sq_get_data(incremental_sq, &iu)) {
- free_argv(iu->before, iu->beforec);
- free_argv(iu->after, iu->afterc);
- free(iu->table);
- free(iu);
- }
- sq_destroy(incremental_sq);
- incremental_sq = sq_create();
-}
-
-
-char **copy_argv(argv, argc)
-char **argv;
-int argc;
-{
- char **ret = (char **)malloc(sizeof(char *) * argc);
- while (--argc >= 0)
- ret[argc] = strsave(strtrim(argv[argc]));
- return(ret);
-}
-
-free_argv(argv, argc)
-char **argv;
-int argc;
-{
- while (--argc >= 0)
- free(argv[argc]);
- free(argv);
-}
+++ /dev/null
-/*
- * These are query support routines that are specific to the old version
- * of the protocol. This file may be removed once support for the old
- * protocol has been discontinued.
- *
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- *
- */
-
-#ifndef lint
-static char *rcsid_qsupport_qc = "$Header$";
-#endif lint
-
-#include <mit-copyright.h>
-#include "query.h"
-#include "sms_server.h"
-#include <ctype.h>
-
-
-extern char *whoami;
-
-
-add_locker() { return(SMS_UNKNOWN_PROC); }
-add_user_group() { return(SMS_UNKNOWN_PROC); }
-
-
-/* Specialized Access Routines */
-
-
-/**
- ** access_maillist - access_list + disallow adding user-group to maillists
- **
- ** Inputs:
- ** argv[0] - list_id
- ** cl - client name
- **
- **/
-
-access_maillist(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## int list_id;
-## int exists;
-## char list_name[32];
- int status;
-
- if ((status = access_list(q, argv, cl)) != SMS_SUCCESS)
- return(status);
- if (strcmp(q->name, "add_maillist"))
- return(status);
-
- list_id = *(int *)argv[0];
-## range of l is list
-## repeat retrieve (exists = any(l.#list_id
-## where l.group != 0 and l.#list_id = @list_id))
- if (!exists) return(SMS_SUCCESS);
-## repeat retrieve (exists = any(users.login where users.login = l.name and
-## l.#list_id = @list_id))
- return ((exists) ? SMS_USER_GROUP : SMS_SUCCESS);
-##}
-
-
-\f
-/* Setup Routines */
-
-
-\f
-/* FOLLOWUP ROUTINES */
-
-/* followup_gpob: fixes argv[2] based on the IDs currently there and the
- * type in argv[1]. Then completes the upcall to the user.
- *
- * argv[2] is of the form "123:234" where the first integer is the machine
- * ID if it is a pop box, and the second is the string ID if it is an SMTP
- * box. argv[1] should be "POP", "SMTP", or "NONE". Boxes of type NONE
- * are skipped.
- *
- * followup_old_gpob does the same thing for old style queries. The format
- * is a little different and there is one more argument, but the idea is
- * the same.
- */
-
-followup_old_gpob(q, sq, v, action, actarg, cl)
- register struct query *q;
- register struct save_queue *sq;
- register struct validate *v;
- register int (*action)();
- int actarg;
- client *cl;
-##{
- char **argv, *p, *index();
- char *ptype;
-## char mach[129], box[129];
-## int id, rowcount;
-
- /* for each row */
- while (sq_get_data(sq, &argv)) {
- ptype = argv[1];
- sms_trim_args(2, argv);
-
- if (!strcmp(ptype, "POP")) {
- id = atoi(argv[2]);
-## repeat retrieve (mach=machine.name) where machine.mach_id=@id
- strcpy(box, argv[0]);
- } else if (!strcmp(ptype, "SMTP")) {
- id = atoi(argv[3]);
-## repeat retrieve (box=strings.string) where strings.string_id=@id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- return(SMS_STRING);
- p = index(box, '@');
- if (p) {
- *p++ = 0;
- strcpy(mach, p);
- } else
- strcpy(mach, "");
- } else /* ptype == "NONE" */ {
- goto skip;
- }
-
- free(argv[2]);
- argv[2] = mach;
- free(argv[3]);
- argv[3] = box;
- (*action)(q->vcnt, argv, actarg);
- skip:
- /* free saved data */
- free(argv[0]);
- free(argv[1]);
- free(argv);
- }
-
- sq_destroy(sq);
- return (SMS_SUCCESS);
-##}
-
-\f
-/* Specialized query routines */
-
-/* set_user_pobox - this does all of the real work.
- * argv = user_id, type, machine, box
- */
-int set_user_pobox(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## int user, id, rowcount;
-## char *host;
-## char buffer[256];
-
- host = argv[2];
- user = *(int *)argv[0];
-
- if (!strcmp(argv[1], "POP")) {
-## repeat retrieve (id=machine.mach_id) where machine.name=uppercase(@host)
-## inquire_equel(rowcount = "rowcount")
- if (rowcount == 0)
- return(SMS_MACHINE);
-## replace users (potype="POP", pop_id=id) where users.users_id = user
- } else if (!strcmp(argv[1], "SMTP")) {
- sprintf(buffer, "%s@%s", argv[3], host);
-## range of s is strings
-## repeat retrieve (id = s.string_id) where s.string = @buffer
-## inquire_equel (rowcount = "rowcount")
- if (rowcount == 0) {
-## range of v is values
-## repeat retrieve (id = v.value) where v.name = "strings_id"
- id++;
-## repeat replace v (value = @id) where v.name = "strings_id"
-## append to strings (string_id = id, string = buffer)
- }
-## repeat replace users (potype="SMTP",box_id=@id)
-## where users.users_id = @user
- } else /* argv[1] == "NONE" */ {
-## repeat replace users (potype="NONE") where users.users_id = @user
- }
- set_old_pop_usage(q, argv, 1);
- set_pobox_modtime(q, argv, cl);
- return(SMS_SUCCESS);
-##}
-
-followup_delete_pobox(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-{
- set_old_pop_usage(q, argv, -1);
- set_pobox_modtime(q, argv, cl);
- return(SMS_SUCCESS);
-}
-
-/** set_old_pop_usage - incr/decr usage count for pop server in serverhosts
- ** table
- **
- ** Inputs:
- ** q->name - "add_pobox" or "delete_pobox"
- ** argv[1] - type
- ** argv[2] - mach_id
- **
- ** Description:
- ** - incr/decr value field in serverhosts table for pop/mach_id
- **
- **/
-
-set_old_pop_usage(q, argv, count)
- struct query *q;
- char *argv[];
-##{
-## int mach_id;
-## int n;
-
- if (bcmp(argv[1], "POP", 3)) return(SMS_SUCCESS);
-
- mach_id = *(int *)argv[2];
- n = count;
-
-## range of sh is serverhosts
-## repeat replace sh (value1 = sh.value1 + @n)
-## where sh.service = "pop" and sh.#mach_id = @mach_id
-
- return(SMS_SUCCESS);
-##}
-
-
-/* Finds "acl_type:acl_name" in the argv (index depends on query) and
- * replaces it with the list or user name.
- */
-
-followup_fix_acl(q, sq, v, action, actarg, cl)
- register struct query *q;
- register struct save_queue *sq;
- register struct validate *v;
- register int (*action)();
- int actarg;
- client *cl;
-##{
- char **argv, *p, *index(), *malloc();
-## char *name, *acl;
-## int id, i, rowcount;
- int idx;
-
- if (!strcmp(q->shortname, "gaml"))
- idx = 1;
- else if (!strcmp(q->shortname, "gamd"))
- idx = 1;
- else
- idx = 2;
-
- while (sq_get_data(sq, &argv)) {
- name = argv[idx];
- p = index(name, ':');
- *p++ = 0;
- id = atoi(p);
- if ((acl = malloc(33)) == NULL)
- return(SMS_NO_MEM);
- if (!strcmp(name, "LIST")) {
-## repeat retrieve (acl = list.#name) where list.list_id = @id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- strcpy(acl, "???");
- } else if (!strcmp(name, "USER")) {
-## repeat retrieve (acl = users.login) where users.users_id = @id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- strcpy(acl, "???");
- } else
- strcpy(acl, "???");
- free(argv[idx]);
- argv[idx] = acl;
-
- /* send the data */
- (*action)(q->vcnt, argv, actarg);
-
- /* free saved data */
- for (i = 0; i < q->vcnt; i++)
- free(argv[i]);
- free(argv);
- }
-
- sq_destroy(sq);
- return (SMS_SUCCESS);
-##}
-
-
-/**
- ** get_list_is_group
- ** get_list_is_maillist
- **
- ** Inputs:
- ** argv[0] - list_id
- **
- ** Returns:
- ** {true | false}
- **
- **/
-
-get_list_is_group(q, argv, cl, action, actarg)
- struct query *q;
- char *argv[];
- client *cl;
- int (*action)();
- int actarg;
-##{
-## int exists, list_id, rowcount;
- char *result;
-
- list_id = *(int *)argv[0];
-
-## range of l is list
-## repeat retrieve (exists = l.group) where l.#list_id = @list_id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- return(SMS_NOT_UNIQUE);
-
- result = (exists) ? "true" : "false";
- (*action)(1, &result, actarg);
- return(SMS_SUCCESS);
-##}
-
-get_list_is_maillist(q, argv, cl, action, actarg)
- struct query *q;
- char *argv[];
- client *cl;
- int (*action)();
- int actarg;
-##{
-## int exists, list_id, rowcount;
- char *result;
-
- list_id = *(int *)argv[0];
-
-## range of l is list
-## repeat retrieve (exists = l.maillist) where l.#list_id = @list_id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- return(SMS_NOT_UNIQUE);
-
- result = (exists) ? "true" : "false";
- (*action)(1, &result, actarg);
- return(SMS_SUCCESS);
-##}
-
-
-/* implements the get lists of administrator query. It's fairly
- * straightforward, but too complex for the regular query table.
- * First retrieve any lists with a USER acl which matches the
- * specified user. Then retrieve any lists with an acl which is a
- * list which has the specified user as a member.
- */
-
-get_lists_of_administrator(q, argv, cl, action, actarg)
- struct query *q;
- char *argv[];
- client *cl;
- int (*action)();
- int actarg;
-##{
-## int user;
-## char name[33];
- char *args;
-
-## range of l is list
-## range of m is members
- user = *(int *) argv[0];
- args = name;
-
-## repeat retrieve (name = l.#name)
-## where l.acl_type = "USER" and l.acl_id = @user {
- (*action)(1, &args, actarg);
-## }
-
-## repeat retrieve (name = l.#name)
-## where l.acl_type = "LIST" and l.acl_id = m.#list_id
-## and m.member_type = "USER" and m.member_id = @user {
- (*action)(1, &args, actarg);
-## }
- return(SMS_SUCCESS);
-##}
-
-
-/**
- ** Setup routine for add_group
- **
- ** Inputs: none
- **
- ** Description: allocate next gid and store in values table
- **
- **/
-
-setup_add_group(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## int ngid, exists, rowcount, list_id;
- int status;
-
-## range of l is list
-## range of v is values
- list_id = *(int *)argv[0];
-
-## repeat retrieve (exists = l.group) where l.#list_id = @list_id
- if (exists)
- return(SMS_EXISTS);
-
-## repeat retrieve (ngid = v.value) where v.name = "gid"
- exists = 1;
- while (exists) {
- ngid++;
-## repeat retrieve (exists = any(l.#gid where l.#gid = @ngid))
- }
-
-## repeat replace v (value = @ngid) where v.name = "gid"
-## inquire_equel (rowcount = "rowcount")
- if (rowcount != 1) return SMS_INGRES_ERR;
- else return(SMS_SUCCESS);
-##}
-
-/**
- ** get_groups_of_user - optimized query for retrieval of all groups to
- ** which a user belongs
- **
- **/
-
-get_groups_of_user(q, argv, cl, action, actarg)
- struct query *q;
- char *argv[];
- client *cl;
- int (*action)();
- int actarg;
-##{
-## int users_id;
-## char list_name[33];
-## char gid[11];
-## int rowcount;
- char *targv[2];
-
- users_id = *(int *)argv[0];
- targv[0] = list_name;
- targv[1] = gid;
-
-## range of m is members
-## range of l is list
-
-## repeat retrieve (list_name = l.name, gid = text(l.#gid))
-## where m.member_id = @users_id and m.member_type = "USER" and
-## m.list_id = l.list_id and l.group != 0
-## sort by #list_name
-## {
- (*action)(2, targv, actarg);
-## }
-## inquire_equel (rowcount = "rowcount")
-
- return ((rowcount = 0) ? SMS_NO_MATCH : SMS_SUCCESS);
-##}
-
-get_groups_of_all_users(q, argv, cl, action, actarg)
- struct query *q;
- char *argv[];
- client *cl;
- int (*action)();
- int actarg;
-##{
-## char login[9];
-## char group[33];
-## char gid[11];
- char *targv[3];
-## int errorno;
-
- targv[0] = login;
- targv[1] = group;
- targv[2] = gid;
-
-## range of u is users
-## range of l is list
-## range of m is members
-
-## set lockmode session where readlock = nolock
-
-## repeat retrieve (login = u.#login, group = l.name, gid = text(l.#gid))
-## where m.member_type = "USER" and m.member_id = u.users_id and
-## u.status != 0 and m.list_id = l.list_id and l.group != 0
-## sort by #login, #group
-## {
- (*action)(3, targv, actarg);
-## }
-
-## inquire_equel (errorno = "errorno")
-## set lockmode session where readlock = system
-
- return((errorno) ? SMS_INGRES_ERR : SMS_SUCCESS);
-##}
-
-
-/* expand_list_flags - takes the flag value stuffed into list.active of
- * the list just created, and expands that value into hidden & public,
- * then sets the modtime on the list.
- */
-expand_list_flags(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## int id, flags, active, public, hidden, who;
-## char *entity;
-
- if (!strcmp(q->shortname, "ulis")) {
- id = *(int *)argv[0];
- } else {
-## repeat retrieve (id = values.value) where values.name = "list_id"
- }
-
-## repeat retrieve (flags = l.#active) where l.list_id = @id
- active = flags & 1;
- public = (flags & 2) >> 1;
- hidden = (flags & 4) >> 2;
- entity = cl->entity;
- who = cl->users_id;
-## repeat replace l (#active = @active, #public = @public, #hidden = @hidden,
-## modtime = "now", modby = @who, modwith = @entity)
-## where l.list_id = @id
- return(SMS_SUCCESS);
-##}
-
-
-/**
- ** add_new_quota
- ** delete_current_quota - adjust nfsphys values on xxx_quota queries.
- **
- ** Inputs:
- ** argv[0] - mach_id
- ** argv[1] - device
- ** argv[2] - users_id
- ** argv[3] - quota (add_new_quota only)
- **
- ** Description:
- ** delete_current_quota:
- ** - find nfsquota entry
- ** - decrement nfsphys.allocated by nfsquota.quota
- ** add_new_quota
- ** - increment nfsphys.allocated by quota
- **
- **/
-
-add_new_quota(q, argv, cl)
- struct query *q;
- register char *argv[];
- client *cl;
-##{
-## int mach_id;
-## char *device;
-## int quota;
-
- mach_id = *(int*)argv[0];
- device = argv[1];
- quota = *(int *)argv[3];
-
-## range of np is nfsphys
-## repeat replace np (allocated = np.allocated + @quota)
-## where np.#mach_id = @mach_id and np.#device = @device
-
- return(SMS_SUCCESS);
-##}
-
-delete_current_quota(q, argv, cl)
- struct query *q;
- register char *argv[];
- client *cl;
-##{
-## int mach_id;
-## int users_id;
-## char *device;
-## int quota;
-
- mach_id = *(int *)argv[0];
- device = argv[1];
- users_id = *(int *)argv[2];
-
-## range of np is nfsphys
-## range of nq is nfsquota
-## repeat retrieve (quota = nq.#quota)
-## where nq.#mach_id = @mach_id and nq.#device = @device and
-## nq.#users_id = @users_id
-## repeat replace np (allocated = np.allocated - @quota)
-## where np.#mach_id = @mach_id and np.#device = @device
-
- return(SMS_SUCCESS);
-##}
-
-
-/**
- ** delete_locker - special query routine for deleting a user locker
- **
- ** Inputs:
- ** argv[0] - users_id
- **
- ** Description:
- ** - get login name from users_id
- ** - get filesys entry from login
- ** - use filesys.mach_id and filesys.name to determine machine/device
- ** pair for nfsphys and nfsquota
- ** - delete filesys entry (label=<login>)
- ** - decrement allocated in nfsphys by quota
- ** - delete nfsquota entry
- **
- ** Errors:
- ** - SMS_FILESYS - no filesys exists for user
- **
- **/
-
-delete_locker(q, argv)
- register struct query *q;
- register char *argv[];
-##{
-## int users_id;
-## int mach_id;
-## int quota;
-## int rowcount;
-## char login[9];
-## char lname[64];
-## char ndev[32];
- char *rindex();
- register char *c;
-
- /* copy arguments */
- users_id = *(int *)argv[0];
-
-## range of u is users
-## range of f is filesys
-## range of np is nfsphys
-## range of nq is nfsquota
-## range of tbs is tblstats
-
- /* get login name */
-## repeat retrieve (login = u.#login) where u.#users_id = @users_id
-
- /* get mach_id and locker name from filesys entry; then delete it */
-## repeat retrieve (mach_id = f.#mach_id, lname = f.#name)
-## where f.#label = @login
-## inquire_equel (rowcount = "rowcount")
- if (rowcount == 0) return(SMS_FILESYS);
-## repeat delete f where f.#label = @login
-
- /* get prefix directory */
- c = rindex(lname, '/');
- *c = 0;
-
- /* get nfs device */
-## repeat retrieve (ndev = np.device)
-## where np.#mach_id = @mach_id and np.dir = @lname
-
- /* get quota from nfsquota entry; then delete entry */
-## repeat retrieve (quota = nq.#quota)
-## where nq.#mach_id = @mach_id and nq.#device = @ndev and
-## nq.#users_id = @users_id
-## repeat delete nq where nq.#mach_id = @mach_id and nq.#device = @ndev and
-## nq.#users_id = @users_id
-
- /* decrement nfsphys.allocated */
-## repeat replace np (allocated = np.allocated - @quota)
-## where np.#mach_id = @mach_id and np.#device = @ndev
-
- /* adjust table statistics */
-## repeat replace tbs (deletes = tbs.deletes + 1, modtime = "now")
-## where tbs.table = "filesys"
-## repeat replace tbs (updates = tbs.updates + 1, modtime = "now")
-## where tbs.table = "nfsphys"
-## repeat replace tbs (deletes = tbs.deletes + 1, modtime = "now")
-## where tbs.table = "nfsquota"
-
- return(SMS_SUCCESS);
-##}
+++ /dev/null
-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright (C) 1987, 1988 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- *
- */
-
-#ifndef lint
-static char *rcsid_qrtn_qc = "$Header$";
-#endif lint
-
-#include <mit-copyright.h>
-#include "query.h"
-#include "mr_server.h"
-
-char *Argv[16];
-
-int ingres_errno = 0;
-int mr_errcode = 0;
-## int query_timeout = 30;
-extern char *whoami;
-extern FILE *journal;
-
-#define INGRES_BAD_INT 4111
-#define INGRES_BAD_DATE 4302
-#define INGRES_DEADLOCK 4700
-#define INGRES_TIMEOUT 4702
-#define INGRES_NO_RANGE 2109
-
-/*
- * ingerr: (supposedly) called when Ingres indicates an error.
- * I have not yet been able to get this to work to intercept a
- * database open error.
- */
-
-static int ingerr(num)
- int *num;
-{
- ingres_errno = *num;
-
- switch (*num) {
- case INGRES_BAD_INT:
- mr_errcode = MR_INTEGER;
- break;
- case INGRES_BAD_DATE:
- mr_errcode = MR_DATE;
- break;
- case INGRES_DEADLOCK:
- mr_errcode = MR_DEADLOCK;
- com_err(whoami, 0, "INGRES deadlock detected");
- break;
- case INGRES_TIMEOUT:
- mr_errcode = MR_BUSY;
- com_err(whoami, 0, "timed out getting lock");
- break;
- case INGRES_NO_RANGE:
- mr_errcode = MR_INGRES_SOFTFAIL;
- com_err(whoami, 0, "INGRES missing range statement");
- break;
- default:
- mr_errcode = MR_INGRES_ERR;
- com_err(whoami, MR_INGRES_ERR, " code %d\n", *num);
- critical_alert("MOIRA", "Moira server encountered INGRES ERROR %d", *num);
- return (*num);
- }
- return (0);
-}
-
-int mr_open_database()
-{
- register int i;
- char *malloc();
- static first_open = 1;
-
- if (first_open) {
- first_open = 0;
-
- /* initialize local argv */
- for (i = 0; i < 16; i++)
- Argv[i] = malloc(ARGLEN);
-
- IIseterr(ingerr);
- incremental_init();
- flush_cache();
- }
-
- ingres_errno = 0;
- mr_errcode = 0;
-
- /* open the database */
-## ingres sms
-## set lockmode session where level = table, timeout = query_timeout
-## set lockmode on capacls where readlock = shared
-## set lockmode on alias where readlock = shared
- return ingres_errno;
-}
-
-int mr_close_database()
-{
- flush_cache();
-## exit
-}
-
-mr_check_access(cl, name, argc, argv_ro)
- client *cl;
- char *name;
- int argc;
- char *argv_ro[];
-{
- struct query *q;
- struct query *get_query_by_name();
-
- ingres_errno = 0;
- mr_errcode = 0;
-
- q = get_query_by_name(name, cl->args->mr_version_no);
- if (q == (struct query *)0)
- return(MR_NO_HANDLE);
-
- return(mr_verify_query(cl, q, argc, argv_ro));
-}
-
-mr_process_query(cl, name, argc, argv_ro, action, actarg)
- client *cl;
- char *name;
- int argc;
- char *argv_ro[];
- int (*action)();
- char *actarg;
-{
- register struct query *q;
- register int status;
- register struct validate *v;
- char qual[256];
- char sort[32];
- char *pqual;
- char *psort;
-## char *table, *rvar;
- struct save_queue *sq;
- struct query *get_query_by_name();
- int sq_save_args();
- struct save_queue *sq_create();
- char *build_sort();
-
- ingres_errno = 0;
- mr_errcode = 0;
-
- /* list queries command */
- if (!strcmp(name, "_list_queries")) {
- list_queries(cl->args->mr_version_no, action, actarg);
- return(MR_SUCCESS);
- }
-
- /* help query command */
- if (!strcmp(name, "_help")) {
- if (argc < 1)
- return(MR_ARGS);
- q = get_query_by_name(argv_ro[0], cl->args->mr_version_no);
- if (q == (struct query *)0) return(MR_NO_HANDLE);
- help_query(q, action, actarg);
- return(MR_SUCCESS);
- }
-
- /* get query structure, return error if named query does not exist */
- q = get_query_by_name(name, cl->args->mr_version_no);
- if (q == (struct query *)0) return(MR_NO_HANDLE);
- v = q->validate;
-
- if (q->type != RETRIEVE) {
-## begin transaction
- }
-
- /* setup argument vector, verify access and arguments */
- if ((status = mr_verify_query(cl, q, argc, argv_ro)) != MR_SUCCESS)
- goto out;
-
- /* perform any special query pre-processing */
- if (v && v->pre_rtn) {
- status = (*v->pre_rtn)(q, Argv, cl, 0);
- if (status != MR_SUCCESS)
- goto out;
- }
-
- switch (q->type) {
- case RETRIEVE:
- /* for queries that do not permit wildcarding, check if row
- uniquely exists */
- if (v && v->field) {
- status = validate_row(q, Argv, v);
- if (status != MR_EXISTS) break;
- }
-
- /* build "where" clause if needed */
- if (q->qual) {
- build_qual(q->qual, q->argc, Argv, qual);
- pqual = qual;
- } else {
- pqual = 0;
- }
-
- /* build "sort" clause if needed */
- if (v && v->valobj) {
- psort = build_sort(v, sort);
- } else {
- psort = 0;
- }
-
- /* if there is a followup routine, then we must save the results */
- /* of the first query for use by the followup routine */
- /* if q->rvar = NULL, perform post_rtn only */
- if (q->rvar) {
- if (v && v->post_rtn) {
- sq = sq_create();
- status = do_retrieve(q, pqual, psort, sq_save_args, sq);
- if (status != MR_SUCCESS) {
- sq_destroy(sq);
- break;
- }
- status = (*v->post_rtn)(q, sq, v, action, actarg, cl);
- } else {
- /* normal retrieve */
- status = do_retrieve(q, pqual, psort, action, actarg);
- }
- if (status != MR_SUCCESS) break;
- } else {
- status = (*v->post_rtn)(q, Argv, cl, action, actarg);
- }
-
- break;
-
- case UPDATE:
- /* see if row already exists */
- if (v->field) {
- status = validate_row(q, Argv, v);
- if (status != MR_EXISTS) break;
- }
-
- /* build "where" clause and perform update */
- /* if q->rvar = NULL, perform post_rtn only */
- if (q->rvar) {
- build_qual(q->qual, q->argc, Argv, qual);
- incremental_before(q->rtable, qual, argv_ro);
- status = do_update(q, &Argv[q->argc], qual, action, actarg);
- incremental_after(q->rtable, qual, argv_ro);
- if (status != MR_SUCCESS) break;
- flush_name(argv_ro[0], q->rtable);
- table = q->rtable;
- if (strcmp(q->shortname, "sshi") && strcmp(q->shortname, "ssif")) {
-## repeat replace tblstats (updates = tblstats.updates + 1,
-## modtime = "now")
-## where tblstats.#table = @table
- }
- }
-
- /* execute followup routine (if any) */
- if (v->post_rtn) status = (*v->post_rtn)(q, Argv, cl);
-
- break;
-
- case APPEND:
- /* see if row already exists */
- if (v->field) {
- status = validate_row(q, Argv, v);
- if (status != MR_NO_MATCH) break;
- }
-
- /* increment id number if necessary */
- if (v->object_id) {
- status = set_next_object_id(v->object_id, q->rtable);
- if (status != MR_SUCCESS) break;
- }
-
- /* build "where" clause if needed */
- if (q->qual) {
- build_qual(q->qual, q->argc, Argv, qual);
- pqual = qual;
- } else {
- pqual = 0;
- }
-
- /* perform the append */
- /* if q->rvar = NULL, perform post_rtn only */
- if (q->rvar) {
- incremental_clear_before();
- status = do_append(q, &Argv[q->argc], pqual, action, actarg);
- if (status != MR_SUCCESS) break;
- if (v && v->object_id) {
- sprintf(qual, "%s.%s = values.value and values.name = \"%s\"",
- q->rvar, v->object_id, v->object_id);
- incremental_after(q->rtable, qual, argv_ro);
- } else
- incremental_after(q->rtable, pqual, argv_ro);
-
- table = q->rtable;
-## repeat replace tblstats (appends = tblstats.appends + 1,
-## modtime = "now")
-## where tblstats.#table = @table
- }
-
- /* execute followup routine */
- if (v->post_rtn) status = (*v->post_rtn)(q, Argv, cl);
- break;
-
- case DELETE:
- /* see if row already exists */
- if (v->field) {
- status = validate_row(q, Argv, v);
- if (status != MR_EXISTS) break;
- }
-
- /* build "where" clause and perform delete */
- /* if q->rvar = NULL, perform post_rtn only */
- if (q->rvar) {
- build_qual(q->qual, q->argc, Argv, qual);
- table = q->rtable;
- rvar = q->rvar;
-## range of rvar is table
- incremental_before(q->rtable, qual, argv_ro);
- status = do_delete(q, qual, action, actarg);
- incremental_clear_after();
- if (status != MR_SUCCESS) break;
- flush_name(argv_ro[0], q->rtable);
-## repeat replace tblstats (deletes = tblstats.deletes + 1,
-## modtime = "now")
-## where tblstats.#table = @table
- }
-
- /* execute followup routine */
- if (v->post_rtn) status = (*v->post_rtn)(q, Argv, cl);
- break;
-
- }
-
-out:
- if (status == MR_SUCCESS && ingres_errno != 0) {
- com_err(whoami, MR_INTERNAL, "Server didn't notice INGRES ERROR %d",
- ingres_errno);
- status = mr_errcode;
- }
-
- if (q->type != RETRIEVE) {
- if (status == MR_SUCCESS) {
-## end transaction /* commit to this */
- if (journal) {
- char buf[1024], *bp;
- int i;
- extern time_t now;
-
- fprintf(journal, "%% %s %s %s",
- cl->clname, cl->entity, ctime(&now));
- fprintf(journal, "%s[%d] ", q->name, cl->args->mr_version_no);
- for (i = 0; i < argc; i++) {
- if (i != 0) {
- putc(' ', journal);
- }
- requote(buf, argv_ro[i], sizeof(buf));
- fputs(buf, journal);
- }
- putc('\n', journal);
- fflush(journal);
- }
- incremental_update();
- } else {
- if (ingres_errno != INGRES_DEADLOCK) {
-## abort /* it never happened */
- }
- incremental_flush();
- }
-## set lockmode session where readlock = system
- }
-
- if (status != MR_SUCCESS && log_flags & LOG_RES)
- com_err(whoami, status, " (Query failed)");
- return(status);
-}
-
-build_qual(fmt, argc, argv, qual)
- char *fmt;
- int argc;
- char *argv[];
- char *qual;
-{
- register char *c;
- register int i;
- char *args[4];
- char *index();
-
- c = fmt;
- for (i = 0; i < argc; i++) {
- c = index(c, '%');
- if (c++ == (char *)0) return(MR_ARGS);
- if (*c == 's')
- args[i] = argv[i];
- else if (*c == 'd')
- *(int *)&args[i] = *(int *)argv[i]; /* sigh */
- else
- return(MR_INGRES_ERR);
- }
-
- switch (argc) {
- case 0:
- strcpy(qual, fmt);
- break;
-
- case 1:
- sprintf(qual, fmt, args[0]);
- break;
-
- case 2:
- sprintf(qual, fmt, args[0], args[1]);
- break;
-
- case 3:
- sprintf(qual, fmt, args[0], args[1], args[2]);
- break;
-
- case 4:
- sprintf(qual, fmt, args[0], args[1], args[2], args[3]);
- break;
- }
- return(MR_SUCCESS);
-}
-
-char *
-build_sort(v, sort)
- register struct validate *v;
- char *sort;
-{
- register struct valobj *vo;
- register int n;
- char elem[16];
-
- n = v->objcnt;
- vo = v->valobj;
- *sort = 0;
-
- while (--n >= 0) {
- if (vo->type == V_SORT) {
- sprintf(elem, "RET_VAR%d", vo->index + 1);
- if (*sort) strcat(sort, ", ");
- strcat(sort, elem);
- }
- vo++;
- }
-
- return ((*sort) ? sort : 0);
-}
-
-
-/* Build arguement vector, verify query and arguments */
-
-mr_verify_query(cl, q, argc, argv_ro)
- client *cl;
- struct query *q;
- int argc;
- char *argv_ro[];
-{
- register int argreq;
- register int status;
- register struct validate *v = q->validate;
- register int i;
- register int privileged = 0;
- int len;
-
- /* copy the arguments into a local argv that we can modify */
- if (argc >= QMAXARGS)
- return(MR_ARGS);
- for (i = 0; i < argc; i++) {
- if ((len = strlen(argv_ro[i])) < ARGLEN)
- strcpy(Argv[i], argv_ro[i]);
- else
- return(MR_ARG_TOO_LONG);
- if (Argv[i][len-1] == '\\')
- return(MR_BAD_CHAR);
- }
-
- /* check initial query access */
- status = check_query_access(q, Argv, cl);
- if (status != MR_SUCCESS && status != MR_PERM)
- return(status);
- if (status == MR_SUCCESS)
- privileged++;
-
- /* check argument count */
- argreq = q->argc;
- if (q->type == UPDATE || q->type == APPEND) argreq += q->vcnt;
- if (argc != argreq) return(MR_ARGS);
-
- /* validate arguments */
- if (v && v->valobj) {
- status = validate_fields(q, Argv, v->valobj, v->objcnt);
- if (status != MR_SUCCESS) return(status);
- }
-
- /* perform special query access check */
- if (!privileged && v && v->acs_rtn) {
- status = (*v->acs_rtn)(q, Argv, cl);
- if (status != MR_SUCCESS && status != MR_PERM)
- return(status);
- if (status == MR_SUCCESS)
- privileged++;
- }
-
- return(privileged ? MR_SUCCESS : MR_PERM);
-}
-
-
-/* This routine caches info from the database. Each query acl is stored
- * in the query structure, and whether that acl contains everybody.
- */
-
-check_query_access(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## char *name;
-## int acl_id;
-## int exists;
-## int rowcount;
-## int errorno;
-## static int def_uid;
- int status;
- int client_id;
- char *client_type;
-
- /* initialize default uid */
- if (def_uid == 0) {
-## retrieve (def_uid = users.users_id) where users.login = "default"
- }
-
- /* get query access control list */
- if (q->acl != 0)
- acl_id = q->acl;
- else {
- name = q->shortname;
-## retrieve (acl_id = capacls.list_id) where capacls.tag = name
-## inquire_equel (rowcount = "rowcount", errorno = "errorno")
- if (errorno != 0) return(MR_INGRES_ERR);
- if (rowcount == 0) return(MR_PERM);
- q->acl = acl_id;
-
- /* check for default access */
-## retrieve (exists = any(imembers.#member_id where
-## imembers.list_id = acl_id and
-## imembers.member_type = "USER" and
-## imembers.#member_id = def_uid))
- q->everybody = exists;
- }
-
- if (q->everybody)
- return(MR_SUCCESS);
-
- if (get_client(cl, &client_type, &client_id) != MR_SUCCESS)
- return(MR_PERM);
- if (find_member("LIST", acl_id, client_type, client_id, 0))
- return(MR_SUCCESS);
- else
- return(MR_PERM);
-##}
-
-
-get_client(cl, client_type, client_id)
- client *cl;
- char **client_type;
- int *client_id;
-{
- if (cl->users_id > 0) {
- *client_id = cl->users_id;
- *client_type = "USER";
- return(MR_SUCCESS);
- }
-
- if (cl->client_id < 0) {
- *client_id = -cl->users_id;
- *client_type = "KERBEROS";
- return(MR_SUCCESS);
- }
-
- return(MR_PERM);
-}
-
-##find_member(list_type, list_id, member_type, member_id)
- char *list_type;
-## int list_id;
-## char *member_type;
-## int member_id;
-##{
-## int exists, errorno;
-
- if (!strcmp(strtrim(list_type), strtrim(member_type)) &&
- list_id == member_id)
- return(1);
-
- /* see if client is a direct member of list */
-## repeat retrieve (exists = any(imembers.#member_id where
-## imembers.#list_id = @list_id and
-## imembers.#member_type = @member_type and
-## imembers.#member_id = @member_id))
-## inquire_equel(errorno = "errorno")
- if (errorno == 0)
- return(exists);
- else
- return(0);
-##}
-
-
-do_retrieve(q, pqual, psort, action, actarg)
- register struct query *q;
- char *pqual;
- char *psort;
- int (*action)();
- char *actarg;
-##{
-## char *rvar;
-## char *rtable;
-## char *cqual;
-## char *csort;
-## int rowcount;
-## int errorno;
- static char **vaddrs = (char **)NULL;
-
- if (!vaddrs) {
- register int i;
-
- if ((vaddrs = (char **)malloc(sizeof(char *) * QMAXARGS)) == NULL) {
- com_err(whoami, MR_NO_MEM, "setting up static argv");
- exit(1);
- }
- for (i = 0; i < QMAXARGS; i++) {
- if ((vaddrs[i] = malloc(QMAXARGSIZE)) == NULL) {
- com_err(whoami, MR_NO_MEM, "setting up static argv");
- exit(1);
- }
- }
- }
-
- if (q->rvar) {
- rvar = q->rvar;
- rtable = q->rtable;
-## range of rvar is rtable
- }
-
- if (psort) {
- csort = psort;
- if (pqual) {
- cqual = pqual;
-## retrieve unique (param (q->tlist, vaddrs)) where cqual
-## sort by csort
-## {
- (*action)(q->vcnt, vaddrs, actarg);
-## }
- } else {
-## retrieve unique (param (q->tlist, vaddrs))
-## sort by csort
-## {
- (*action)(q->vcnt, vaddrs, actarg);
-## }
- }
-
- } else {
- if (pqual) {
- cqual = pqual;
-## retrieve unique (param (q->tlist, vaddrs)) where cqual
-## {
- (*action)(q->vcnt, vaddrs, actarg);
-## }
- } else {
-## retrieve unique (param (q->tlist, vaddrs))
-## {
- (*action)(q->vcnt, vaddrs, actarg);
-## }
- }
- }
-
- if (mr_errcode) return(mr_errcode);
-## inquire_equel (rowcount = "rowcount")
- return ((rowcount == 0) ? MR_NO_MATCH : MR_SUCCESS);
-##}
-
-do_update(q, argv, qual, action, actarg)
- register struct query *q;
- char *argv[];
- char *qual;
- int (*action)();
- char *actarg;
-##{
-## char *rvar;
-## char *rtable;
-## char *cqual;
-## int errorno;
-
- rvar = q->rvar;
- rtable = q->rtable;
-## range of rvar is rtable
-
- cqual = qual;
-## replace rvar (param (q->tlist, argv))
-## where cqual
-
- if (mr_errcode) return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-do_append(q, argv, pqual, action, actarg)
- register struct query *q;
- char *argv[];
- char *pqual;
- int (*action)();
- char *actarg;
-##{
-## char *rvar;
-## char *rtable;
-## char *cqual;
-## int errorno;
-
- rvar = q->rvar;
- rtable = q->rtable;
-## range of rvar is rtable
-
- if (pqual) {
- cqual = pqual;
-## append to rtable (param (q->tlist, argv)) where cqual
- } else {
-## append to rtable (param (q->tlist, argv))
- }
-
- if (mr_errcode) return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-do_delete(q, qual, action, actarg)
- register struct query *q;
- char *qual;
- int (*action)();
- char *actarg;
-##{
-## char *rvar;
-## char *rtable;
-## char *cqual;
-## int errorno;
-
- rvar = q->rvar;
- rtable = q->rtable;
-## range of rvar is rtable
-
- cqual = qual;
-## delete rvar where cqual
-
- if (mr_errcode) return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/**
- ** set_next_object_id - set next object id in values table
- **
- ** Inputs: object - object name in values table and in objects
- ** table - name of table objects are found in
- **
- ** - called before an APPEND operation to set the next object id to
- ** be used for the new record to the next free value
- **
- **/
-
-set_next_object_id(object, table)
- char *object;
- char *table;
-##{
-## char *name, *tbl;
-## int rowcount, exists, value;
-
- name = object;
- tbl = table;
-## repeat retrieve (value = values.#value) where values.#name = @name
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- return(MR_NO_ID);
-
-## retrieve (exists = any(tbl.name where tbl.name = value))
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- return(MR_NO_ID);
- while (exists) {
- value++;
- if (value > MAX_ID_VALUE)
- value = MIN_ID_VALUE;
-## retrieve (exists = any(tbl.name where tbl.name = value))
- }
-
- if (LOG_RES)
- com_err(whoami, 0, "setting ID %s to %d", name, value);
-## repeat replace values (#value = @value) where values.#name = @name
- return(MR_SUCCESS);
-##}
-
-
-/* Turn a kerberos name into the user's ID of the account that principal
- * owns. Sets the kerberos ID and user ID.
- */
-
-int set_krb_mapping(name, login, ok, kid, uid)
-char *name;
-char *login;
-int ok;
-int *kid;
-int *uid;
-##{
-## int u_id, k_id, rowcount;
-## char *krbname;
-
- krbname = name;
- *kid = 0;
- *uid = 0;
-
-## repeat retrieve (u_id = krbmap.#users_id, k_id = krbmap.#string_id)
-## where krbmap.string_id = strings.string_id and strings.string = @krbname
-## inquire_equel (rowcount = "rowcount")
- if (ingres_errno) return(mr_errcode);
-
- if (rowcount == 1) {
- *kid = -k_id;
- *uid = u_id;
- return(MR_SUCCESS);
- }
-
- if (name_to_id(name, "STRINGS", &k_id) == MR_SUCCESS)
- *kid = -k_id;
-
- if (!ok) {
- *uid = *kid;
- return(MR_SUCCESS);
- }
-
- if (name_to_id(login, "USERS", uid) != MR_SUCCESS)
- *uid = 0;
-
- if (*kid == 0)
- *kid = *uid;
- if (ingres_errno) return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* For now this just checks the argc's. It should also see that there
- * are no duplicate names.
- */
-
-sanity_check_queries()
-{
- register int i;
- int maxv = 0, maxa = 0;
-#ifdef MULTIPROTOCOLS
- extern int QueryCount1, QueryCount2;
- extern struct query Queries1[], Queries2[];
-#else
- extern int QueryCount2;
- extern struct query Queries2[];
-#endif MULTIPROTOCOLS
-
-#define MAX(x,y) ((x) > (y) ? (x) : (y))
-
-#ifdef MULTIPROTOCOLS
- for (i = 0; i < QueryCount1; i++) {
- maxv = MAX(maxv, Queries1[i].vcnt);
- maxa = MAX(maxa, Queries1[i].argc);
- }
-#endif MULTIPROTOCOLS
- for (i = 0; i < QueryCount2; i++) {
- maxv = MAX(maxv, Queries2[i].vcnt);
- maxa = MAX(maxa, Queries2[i].argc);
- }
- if (MAX(maxv, maxa) > QMAXARGS) {
- com_err(whoami, 0, "A query has more args than QMAXARGS");
- exit(1);
- }
-}
+++ /dev/null
-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- *
- */
-
-#ifndef lint
-static char *rcsid_qsupport_qc = "$Header$";
-#endif lint
-
-#include <mit-copyright.h>
-#include "query.h"
-#include "mr_server.h"
-#include <ctype.h>
-
-
-extern char *whoami, *strsave();
-extern int ingres_errno, mr_errcode;
-
-
-/* Specialized Access Routines */
-
-/* access_user - verify that client name equals specified login name
- *
- * - since field validation routines are called first, a users_id is
- * now in argv[0] instead of the login name.
- */
-
-access_user(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-{
- if (cl->users_id != *(int *)argv[0])
- return(MR_PERM);
- else
- return(MR_SUCCESS);
-}
-
-
-
-/* access_login - verify that client name equals specified login name
- *
- * argv[0...n] contain search info. q->
- */
-
-access_login(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## int rowcount, id;
-## char qual[256];
-
- build_qual(q->qual, q->argc, argv, qual);
-## range of u is users
-## retrieve (id = u.users_id) where qual
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1 || id != cl->users_id)
- return(MR_PERM);
- else
- return(MR_SUCCESS);
-##}
-
-
-
-/* access_list - check access for most list operations
- *
- * Inputs: argv[0] - list_id
- * q - query name
- * argv[2] - member ID (only for queries "amtl" and "dmfl")
- * argv[7] - group IID (only for query "ulis")
- * cl - client name
- *
- * - check that client is a member of the access control list
- * - OR, if the query is add_member_to_list or delete_member_from_list
- * and the list is public, allow access if client = member
- */
-
-access_list(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## int list_id, acl_id, flags, rowcount, gid;
-## char acl_type[9];
- char *client_type;
- int client_id, status;
-
- list_id = *(int *)argv[0];
-## repeat retrieve (acl_id = list.#acl_id, acl_type = list.#acl_type,
-## gid = list.#gid, flags = list.#public)
-## where list.#list_id = @list_id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- return(MR_INTERNAL);
-
- /* parse client structure */
- if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
- return(status);
-
- /* if amtl or dmfl and list is public allow client to add or delete self */
- if (((!strcmp("amtl", q->shortname) && flags) ||
- (!strcmp("dmfl", q->shortname))) &&
- (!strcmp("USER", argv[1]))) {
- if (*(int *)argv[2] == client_id) return(MR_SUCCESS);
- /* if update_list, don't allow them to change the GID */
- } else if (!strcmp("ulis", q->shortname)) {
- if ((!strcmp(argv[7], UNIQUE_GID) && (gid != -1)) ||
- (strcmp(argv[7], UNIQUE_GID) && (gid != atoi(argv[7]))))
- return(MR_PERM);
- }
-
- /* check for client in access control list */
- status = find_member(acl_type, acl_id, client_type, client_id, 0);
- if (!status) return(MR_PERM);
-
- return(MR_SUCCESS);
-##}
-
-
-/* access_visible_list - allow access to list only if it is not hidden,
- * or if the client is on the ACL
- *
- * Inputs: argv[0] - list_id
- * cl - client identifier
- */
-
-access_visible_list(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## int list_id, acl_id, flags, rowcount;
-## char acl_type[9];
- char *client_type;
- int client_id, status;
-
- list_id = *(int *)argv[0];
-## repeat retrieve (flags = list.hidden, acl_id = list.#acl_id,
-## acl_type = list.#acl_type) where list.#list_id = @list_id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- return(MR_INTERNAL);
- if (!flags)
- return(MR_SUCCESS);
-
-
- /* parse client structure */
- if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
- return(status);
-
- /* check for client in access control list */
- status = find_member(acl_type, acl_id, client_type, client_id, 0);
- if (!status)
- return(MR_PERM);
-
- return(MR_SUCCESS);
-##}
-
-
-/* access_vis_list_by_name - allow access to list only if it is not hidden,
- * or if the client is on the ACL
- *
- * Inputs: argv[0] - list name
- * cl - client identifier
- */
-
-access_vis_list_by_name(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## int acl_id, flags, rowcount;
-## char acl_type[9], *listname;
- char *client_type;
- int client_id, status;
-
- listname = argv[0];
-## repeat retrieve (flags = list.hidden, acl_id = list.#acl_id,
-## acl_type = list.#acl_type) where list.#name = @listname
-## inquire_equel(rowcount = "rowcount");
- if (rowcount > 1)
- return(MR_WILDCARD);
- if (rowcount == 0)
- return(MR_NO_MATCH);
- if (!flags)
- return(MR_SUCCESS);
-
- /* parse client structure */
- if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
- return(status);
-
- /* check for client in access control list */
- status = find_member(acl_type, acl_id, client_type, client_id, 0);
- if (!status)
- return(MR_PERM);
-
- return(MR_SUCCESS);
-##}
-
-
-/* access_member - allow user to access member of type "USER" and name matches
- * username, or to access member of type "LIST" and list is one that user is
- * on the acl of, or the list is visible.
- */
-
-access_member(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-{
- if (!strcmp(argv[0], "LIST") || !strcmp(argv[0], "RLIST"))
- return(access_visible_list(q, &argv[1], cl));
-
- if (!strcmp(argv[0], "USER") || !strcmp(argv[0], "RUSER")) {
- if (cl->users_id == *(int *)argv[1])
- return(MR_SUCCESS);
- }
-
- return(MR_PERM);
-}
-
-
-/* access_qgli - special access routine for Qualified_get_lists. Allows
- * access iff argv[0] == "TRUE" and argv[2] == "FALSE".
- */
-
-access_qgli(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-{
- if (!strcmp(argv[0], "TRUE") && !strcmp(argv[2], "FALSE"))
- return(MR_SUCCESS);
- return(MR_PERM);
-}
-
-
-/* access_service - allow access if user is on ACL of service. Don't
- * allow access if a wildcard is used.
- */
-
-access_service(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## int acl_id, rowcount;
-## char *name, acl_type[9];
- int client_id, status;
- char *client_type;
-
- name = argv[0];
-## repeat retrieve (acl_id = servers.#acl_id, acl_type = servers.#acl_type)
-## where servers.#name = uppercase(@name)
-## inquire_equel(rowcount = "rowcount")
- if (rowcount > 1)
- return(MR_PERM);
-
- /* parse client structure */
- if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
- return(status);
-
- /* check for client in access control list */
- status = find_member(acl_type, acl_id, client_type, client_id, 0);
- if (!status) return(MR_PERM);
-
- return(MR_SUCCESS);
-##}
-
-
-
-/* access_filesys - verify that client is owner or on owners list of filesystem
- * named by argv[0]
- */
-
-access_filesys(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## int rowcount, users_id, list_id;
-## char *name;
- int status, client_id;
- char *client_type;
-
- name = argv[0];
-## repeat retrieve (users_id = filesys.owner, list_id = filesys.owners)
-## where filesys.label = @name
-## inquire_equel(rowcount = "rowcount")
-
- if (rowcount != 1)
- return(MR_PERM);
- if (users_id == cl->users_id)
- return(MR_SUCCESS);
- if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
- return(status);
- status = find_member("LIST", list_id, client_type, client_id, 0);
- if (status)
- return(MR_SUCCESS);
- else
- return(MR_PERM);
-##}
-
-
-\f
-/* Setup Routines */
-
-/* Setup routine for add_user
- *
- * Inputs: argv[0] - login
- * argv[1] - uid
- *
- * Description:
- *
- * - if argv[1] == UNIQUE_UID then set argv[1] = next(uid)
- * - if argv[0] == UNIQUE_LOGIN then set argv[0] = "#<uid>"
- */
-
-setup_ausr(q, argv, cl)
- struct query *q;
- register char *argv[];
- client *cl;
-##{
-## int nuid, rowcount;
-## char *mit_id;
-
-#ifdef notdef
- /* this is currently disabled because we need an index on ID's
- * before it can run in finite time.
- */
- mit_id = argv[U_MITID];
-## retrieve (rowcount = any(u.#mit_id where u.#mit_id = mit_id))
- if (ingres_errno) return(mr_errcode);
- if (rowcount) return(MR_EXISTS);
-#endif notdef
-
- if (!strcmp(argv[1], UNIQUE_UID) || atoi(argv[1]) == -1) {
- if (set_next_object_id("uid", "users"))
- return(MR_INGRES_ERR);
-## repeat retrieve (nuid = values.value) where values.name = "uid"
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- return(MR_INTERNAL);
- sprintf(argv[1], "%d", nuid);
- }
-
- if (!strcmp(argv[0], UNIQUE_LOGIN) || atoi(argv[1]) == -1) {
- sprintf(argv[0], "#%s", argv[1]);
- }
-
- return(MR_SUCCESS);
-##}
-
-
-/* setup_dusr - verify that the user is no longer being referenced
- * and may safely be deleted.
- */
-
-int setup_dusr(q, argv)
- struct query *q;
- char **argv;
-##{
-## int flag, id;
-
- id = *(int *)argv[0];
-
- /* For now, only allow users to be deleted if their status is 0 */
-## repeat retrieve (flag = u.status) where u.users_id = @id
- if (flag != 0 && flag != 4)
- return(MR_IN_USE);
-
-## repeat delete quota where quota.entity_id = @id and quota.type = "USER"
-## repeat delete krbmap where krbmap.users_id = @id
-## repeat retrieve (flag = any(imembers.member_id where imembers.member_id=@id
-## and imembers.member_type = "USER"))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(filesys.label where filesys.owner=@id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(list.name where list.acl_id=@id and
-## list.acl_type = "USER"))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(servers.name where servers.acl_id=@id and
-## servers.acl_type = "USER"))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag=any(hostaccess.acl_id where hostaccess.acl_id=@id and
-## hostaccess.acl_type = "USER"))
- if (flag)
- return(MR_IN_USE);
- if (ingres_errno)
- return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_spop: verify that there is already a valid POP machine_id in the
- * pop_id field. Also take care of keeping track of the post office usage.
- */
-int setup_spop(q, argv)
-struct query *q;
-char **argv;
-##{
-## int id, mid, flag;
-## char type[9];
-
- id = *(int *)argv[0];
-## repeat retrieve (type = u.potype, mid = u.pop_id,
-## flag = any(machine.name where machine.mach_id = u.pop_id
-## and u.pop_id != 0 and u.users_id = @id))
-## where u.users_id = @id
- if (!flag)
- return(MR_MACHINE);
- if (strcmp(strtrim(type), "POP"))
- set_pop_usage(mid, 1);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_dpob: Take care of keeping track of the post office usage.
- */
-int setup_dpob(q, argv)
-struct query *q;
-char **argv;
-##{
-## int id, user;
-## char type[9];
-
- user = *(int *)argv[0];
-## repeat retrieve (type = u.potype, id = u.pop_id)
-## where u.users_id = @user
- if (ingres_errno) return(mr_errcode);
-
- if (!strcmp(strtrim(type), "POP"))
- set_pop_usage(id, -1);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_dmac - verify that the machine is no longer being referenced
- * and may safely be deleted.
- */
-
-int setup_dmac(q, argv)
- struct query *q;
- char **argv;
-##{
-## int flag, id;
-
- id = *(int *)argv[0];
-## repeat retrieve (flag = any(users.login where users.potype = "POP"
-## and users.pop_id=@id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(serverhosts.mach_id
-## where serverhosts.mach_id=@id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(nfsphys.mach_id where nfsphys.mach_id=@id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(hostaccess.mach_id where hostaccess.mach_id=@id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(printcap.mach_id where printcap.mach_id=@id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(printcap.quotaserver where printcap.quotaserver=@id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(palladium.mach_id where palladium.mach_id=@id))
- if (flag)
- return(MR_IN_USE);
-
-## repeat delete mcmap where mcmap.mach_id = @id
- if (ingres_errno) return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_dclu - verify that the cluster is no longer being referenced
- * and may safely be deleted.
- */
-
-int setup_dclu(q, argv)
- struct query *q;
- char **argv;
-##{
-## int flag, id;
-
- id = *(int *)argv[0];
-## repeat retrieve (flag = any(mcmap.mach_id where mcmap.clu_id=@id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(svc.clu_id where svc.clu_id=@id))
- if (flag)
- return(MR_IN_USE);
- if (ingres_errno)
- return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_alis - if argv[5] is non-zero and argv[6] is UNIQUE_ID, then allocate
- * a new gid and put it in argv[6]. Otherwise if argv[6] is UNIQUE_ID but
- * argv[5] is not, then remember that UNIQUE_ID is being stored by putting
- * a -1 there. Remember that this is also used for ulis, with the indexes
- * at 6 & 7.
- */
-
-int setup_alis(q, argv)
-struct query *q;
-char **argv;
-##{
-## int ngid;
- char *malloc();
- int idx;
-
- if (!strcmp(q->shortname, "alis"))
- idx = 6;
- else if (!strcmp(q->shortname, "ulis"))
- idx = 7;
-
- if (!strcmp(argv[idx], UNIQUE_GID) || atoi(argv[idx]) == -1) {
- if (atoi(argv[idx - 1])) {
- if (set_next_object_id("gid", "list"))
- return(MR_INGRES_ERR);
-## repeat retrieve (ngid = values.value) where values.name = "gid"
- if (ingres_errno) return(mr_errcode);
- sprintf(argv[idx], "%d", ngid);
- } else {
- strcpy(argv[idx], "-1");
- }
- }
-
- return(MR_SUCCESS);
-##}
-
-
-/* setup_dlist - verify that the list is no longer being referenced
- * and may safely be deleted.
- */
-
-int setup_dlis(q, argv)
- struct query *q;
- char **argv;
-##{
-## int flag, id;
-
- id = *(int *)argv[0];
-## repeat retrieve (flag = any(imembers.member_id where imembers.member_id=@id
-## and imembers.member_type = "LIST"))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(imembers.member_id where imembers.list_id=@id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(filesys.label where filesys.owners=@id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(capacls.tag where capacls.list_id=@id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(list.name where list.acl_id=@id and
-## list.acl_type = "LIST" and list.list_id != @id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(servers.name where servers.acl_id=@id and
-## servers.acl_type = "LIST"))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(quota.entity_id where quota.entity_id=@id and
-## quota.type = "GROUP"))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag=any(hostaccess.acl_id where hostaccess.acl_id=@id and
-## hostaccess.acl_type = "LIST"))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(zephyr.class
-## where zephyr.xmt_type = "LIST" and zephyr.xmt_id = @id or
-## zephyr.sub_type = "LIST" and zephyr.sub_id = @id or
-## zephyr.iws_type = "LIST" and zephyr.iws_id = @id or
-## zephyr.iui_type = "LIST" and zephyr.iui_id = @id))
- if (flag)
- return(MR_IN_USE);
- if (ingres_errno)
- return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_dsin - verify that the service is no longer being referenced
- * and may safely be deleted.
- */
-
-int setup_dsin(q, argv)
- struct query *q;
- char **argv;
-##{
-## int flag;
-## char *name;
-
- name = argv[0];
-## repeat retrieve (flag = any(serverhosts.service
-## where serverhosts.service=uppercase(@name)))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = servers.inprogress) where servers.#name = @name
- if (flag)
- return(MR_IN_USE);
- if (ingres_errno)
- return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_dshi - verify that the service-host is no longer being referenced
- * and may safely be deleted.
- */
-
-int setup_dshi(q, argv)
- struct query *q;
- char **argv;
-##{
-## int flag, id;
-## char *name;
-
- name = argv[0];
- id = *(int *)argv[1];
-## repeat retrieve (flag=serverhosts.inprogress)
-## where serverhosts.service=uppercase(@name) and serverhosts.mach_id=@id
- if (flag)
- return(MR_IN_USE);
- if (ingres_errno)
- return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/**
- ** setup_add_filesys - verify existance of referenced file systems
- **
- ** Inputs: Add
- ** argv[1] - type
- ** argv[2] - mach_id
- ** argv[3] - name
- ** argv[5] - access
- **
- ** Description:
- ** - for type = RVD:
- ** * allow anything
- ** - for type = NFS:
- ** * extract directory prefix from name
- ** * verify mach_id/dir in nfsphys
- ** * verify access in {r, w, R, W}
- **
- ** Side effect: sets variable var_phys_id to the ID of the physical
- ** filesystem (nfsphys_id for NFS, 0 for RVD)
- **
- ** Errors:
- ** MR_NFS - specified directory not exported
- ** MR_FILESYS_ACCESS - invalid filesys access
- **
- **/
-
-##static int var_phys_id;
-
-setup_afil(q, argv)
- struct query *q;
- char *argv[];
-##{
- char *type, *name;
- int mach_id;
-## int ok;
-## char ftype[32], *access;
-
- type = argv[1];
- mach_id = *(int *)argv[2];
- name = argv[3];
- access = argv[5];
- var_phys_id = 0;
-
- sprintf(ftype, "fs_access_%s", type);
-## retrieve (ok = any(alias.trans where alias.name = ftype and
-## alias.type = "TYPE" and alias.trans = access))
- if (ingres_errno) return(mr_errcode);
- if (ok == 0) return(MR_FILESYS_ACCESS);
-
- if (!strcmp(type, "NFS"))
- return (check_nfs(mach_id, name, access));
- else
- return(MR_SUCCESS);
-##}
-
-
-/* Verify the arguments, depending on the FStype. Also, if this is an
- * NFS filesystem, then update any quotas for that filesystem to reflect
- * the new phys_id.
- */
-
-setup_ufil(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
- int mach_id, status;
- char *type, *name;
-## int fid, total, who;
-## char *entity, ftype[32], *access;
-
- type = argv[2];
- mach_id = *(int *)argv[3];
- name = argv[4];
- access = argv[6];
- var_phys_id = 0;
- fid = *(int *)argv[0];
- who = cl->client_id;
- entity = cl->entity;
-
- sprintf(ftype, "fs_access_%s", type);
-## retrieve (total = any(alias.trans where alias.name = ftype and
-## alias.type = "TYPE" and alias.trans = access))
- if (ingres_errno) return(mr_errcode);
- if (total == 0) return(MR_FILESYS_ACCESS);
-
- if (!strcmp(type, "NFS")) {
- status = check_nfs(mach_id, name, access);
-## replace quota (phys_id = var_phys_id) where quota.filsys_id = fid
- if (ingres_errno) return(mr_errcode);
- return(status);
- } else if (!strcmp(type, "AFS")) {
- total = 0;
-## retrieve (total = sum(quota.quota where quota.filsys_id = fid
-## and quota.phys_id != 0))
- if (ingres_errno) return(mr_errcode);
- if (total != 0) {
-## append quota (quota = total, filsys_id = fid,
-## phys_id = 0, entity_id = 0, type = "ANY",
-## modtime = "now", modby = who, modwith = entity)
- if (ingres_errno) return(mr_errcode);
- }
- } else {
-## replace quota (phys_id = 0) where quota.filsys_id = fid
- if (ingres_errno) return(mr_errcode);
- }
- return(MR_SUCCESS);
-##}
-
-
-/* Find the NFS physical partition that the named directory is on.
- * This is done by comparing the dir against the mount point of the
- * partition. To make sure we get the correct match when there is
- * more than one, we sort the query in reverse order by dir name.
- */
-
-##check_nfs(mach_id, name, access)
-## int mach_id;
- char *name;
- char *access;
-##{
-## char dir[81];
- char caccess;
- register int status;
- register char *cp1;
- register char *cp2;
-
- status = MR_NFS;
-## range of np is nfsphys
-## repeat retrieve (var_phys_id = np.#nfsphys_id, dir = trim(np.#dir))
-## where np.#mach_id = @mach_id sort by #dir:d {
- cp1 = name;
- cp2 = dir;
- while (*cp2) {
- if (*cp1++ != *cp2) break;
- cp2++;
- }
- if (*cp2 == 0) {
- status = MR_SUCCESS;
-## endretrieve
- }
-## }
- if (ingres_errno)
- return(mr_errcode);
- return(status);
-##}
-
-
-/* setup_dfil: free any quota records and fsgroup info associated with
- * a filesystem when it is deleted. Also adjust the allocation numbers.
- */
-
-setup_dfil(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## int id;
-
- id = *(int *)argv[0];
-## range of q is quota
-## range of n is nfsphys
-## repeat replace n (allocated=n.allocated-sum(q.quota where q.filsys_id=@id))
-## where n.nfsphys_id = filesys.phys_id and filesys.filsys_id = @id
-
-## repeat delete q where q.filsys_id = @id
-## repeat delete fsgroup where fsgroup.filsys_id = @id
-## repeat delete fsgroup where fsgroup.group_id = @id
- if (ingres_errno) return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_dnfp: check to see that the nfs physical partition does not have
- * any filesystems assigned to it before allowing it to be deleted.
- */
-
-setup_dnfp(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## int id, exists;
-
- id = *(int *)argv[0];
-## repeat retrieve (exists = any(filesys.label where filesys.phys_id = @id))
- if (exists)
- return(MR_IN_USE);
- if (ingres_errno)
- return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_dqot: Remove allocation from nfsphys before deleting quota.
- * argv[0] = filsys_id
- * argv[1] = type if "update_quota" or "delete_quota"
- * argv[2 or 1] = users_id or list_id
- */
-
-setup_dqot(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## int quota, fs, id;
-## char *qtype;
-
- fs = *(int *)argv[0];
- if (!strcmp(q->name, "update_quota") || !strcmp(q->name, "delete_quota")) {
- qtype = argv[1];
- id = *(int *)argv[2];
- } else {
- qtype = "USER";
- id = *(int *)argv[1];
- }
-
-## range of q is #quota
-## repeat retrieve (quota = q.#quota) where q.type = @qtype and
-## q.entity_id = @id and q.filsys_id = @fs
-## repeat replace nfsphys (allocated = nfsphys.allocated - @quota)
-## where nfsphys.nfsphys_id = filesys.#phys_id and filesys.filsys_id = @fs
- if (ingres_errno) return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_sshi: don't exclusive lock the machine table during
- * set_server_host_internal.
- */
-
-setup_sshi(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## set lockmode session where readlock = system
-##}
-
-
-/* setup add_kerberos_user_mapping: add the string to the string
- * table if necessary.
- */
-
-setup_akum(q, argv, cl)
-struct query *q;
-char **argv;
-client *cl;
-##{
-## int id, rowcount;
-## char *name;
-
- name = argv[1];
- if (name_to_id(name, "STRING", &id) != MR_SUCCESS) {
- if (q->type != APPEND) return(MR_STRING);
-## range of v is values
-## retrieve (id = v.value) where v.#name = "strings_id"
- id++;
-## replace v (value = id) where v.#name = "strings_id"
-## append to strings (string_id = id, string = name)
- cache_entry(name, "STRING", id);
- }
- if (ingres_errno) return(mr_errcode);
- *(int *)argv[1] = id;
- return(MR_SUCCESS);
-##}
-
-
-\f
-/* FOLLOWUP ROUTINES */
-
-/* generic set_modtime routine. This takes the table name from the query,
- * and will update the modtime, modby, and modwho fields in the entry in
- * the table whose name field matches argv[0].
- */
-
-set_modtime(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## char *name, *entity, *table;
-## int who;
-
- entity = cl->entity;
- who = cl->client_id;
- table = q->rtable;
- name = argv[0];
-
-## replace table (modtime = "now", modby = who, modwith = entity)
-## where table.#name = name
- return(MR_SUCCESS);
-##}
-
-/* generic set_modtime_by_id routine. This takes the table name from
- * the query, and the id name from the validate record,
- * and will update the modtime, modby, and modwho fields in the entry in
- * the table whose id matches argv[0].
- */
-
-set_modtime_by_id(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## char *entity, *table, *id_name;
-## int who, id;
-
- entity = cl->entity;
- who = cl->client_id;
- table = q->rtable;
- id_name = q->validate->object_id;
-
- id = *(int *)argv[0];
-## replace table (modtime = "now", modby = who, modwith = entity)
-## where table.id_name = id
- return(MR_SUCCESS);
-##}
-
-
-/* Sets the finger modtime on a user record. The users_id will be in argv[0].
- */
-
-set_finger_modtime(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## int users_id, who;
-## char *entity;
-
- entity = cl->entity;
- who = cl->client_id;
- users_id = *(int *)argv[0];
-
-## repeat replace u (fmodtime = "now", fmodby = @who, fmodwith = @entity)
-## where u.#users_id = @users_id
- return(MR_SUCCESS);
-##}
-
-
-/* Sets the pobox modtime on a user record. The users_id will be in argv[0].
- */
-
-set_pobox_modtime(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## int users_id, who;
-## char *entity;
-
- entity = cl->entity;
- who = cl->client_id;
- users_id = *(int *)argv[0];
-
-## repeat replace users (pmodtime = "now", pmodby = @who, pmodwith = @entity)
-## where users.#users_id = @users_id
- return(MR_SUCCESS);
-##}
-
-
-/* Like set_modtime, but uppercases the name first.
- */
-
-set_uppercase_modtime(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## char *name, *entity, *table;
-## int who;
-
- entity = cl->entity;
- who = cl->client_id;
- table = q->rtable;
- name = argv[0];
-
-## replace table (modtime = "now", modby = who, modwith = entity)
-## where table.#name = uppercase(name)
- return(MR_SUCCESS);
-##}
-
-
-/* Sets the modtime on the machine whose mach_id is in argv[0]. This routine
- * is necessary for add_machine_to_cluster becuase the table that query
- * operates on is "mcm", not "machine".
- */
-
-set_mach_modtime_by_id(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## char *entity;
-## int who, id;
-
- entity = cl->entity;
- who = cl->client_id;
-
- id = *(int *)argv[0];
-## repeat replace machine (modtime = "now", modby = @who, modwith = @entity)
-## where machine.mach_id = @id
- return(MR_SUCCESS);
-##}
-
-
-/* Sets the modtime on the cluster whose mach_id is in argv[0]. This routine
- * is necessary for add_cluster_data and delete_cluster_data becuase the
- * table that query operates on is "svc", not "cluster".
- */
-
-set_cluster_modtime_by_id(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## char *entity;
-## int who, id;
-
- entity = cl->entity;
- who = cl->client_id;
-
- id = *(int *)argv[0];
-## repeat replace cluster (modtime = "now", modby = @who, modwith = @entity)
-## where cluster.clu_id = @id
- return(MR_SUCCESS);
-##}
-
-
-/* sets the modtime on the serverhost where the service name is in argv[0]
- * and the mach_id is in argv[1].
- */
-
-set_serverhost_modtime(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## char *entity, *serv;
-## int who, id;
-
- entity = cl->entity;
- who = cl->client_id;
-
- serv = argv[0];
- id = *(int *)argv[1];
-## repeat replace sh (modtime = "now", modby = @who, modwith = @entity)
-## where sh.service = uppercase(@serv) and sh.mach_id = @id
- return(MR_SUCCESS);
-##}
-
-
-/* sets the modtime on the nfsphys where the mach_id is in argv[0] and the
- * directory name is in argv[1].
- */
-
-set_nfsphys_modtime(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## char *entity, *dir;
-## int who, id;
-
- entity = cl->entity;
- who = cl->client_id;
-
- id = *(int *)argv[0];
- dir = argv[1];
-## repeat replace np (modtime = "now", modby = @who, modwith = @entity)
-## where np.#dir = @dir and np.mach_id = @id
- return(MR_SUCCESS);
-##}
-
-
-/* sets the modtime on a filesystem, where argv[0] contains the filesys
- * label.
- */
-
-set_filesys_modtime(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## char *label, *entity;
-## int who;
-
- entity = cl->entity;
- who = cl->client_id;
-
- label = argv[0];
- if (!strcmp(q->shortname, "ufil"))
- label = argv[1];
-
-## repeat replace fs (modtime = "now", modby = @who, modwith = @entity,
-## #phys_id = @var_phys_id) where fs.#label = @label
- return(MR_SUCCESS);
-##}
-
-
-/* sets the modtime on a zephyr class, where argv[0] contains the class
- * name.
- */
-
-set_zephyr_modtime(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## char *class, *entity;
-## int who;
-
- entity = cl->entity;
- who = cl->client_id;
-
- class = argv[0];
-
-## repeat replace z (modtime = "now", modby = @who, modwith = @entity)
-## where z.#class = @class
- return(MR_SUCCESS);
-##}
-
-
-/* fixes the modby field. This will be the second to last thing in the
- * argv, the argv length is determined from the query structure. It is
- * passed as a pointer to an integer. This will either turn it into a
- * username, or # + the users_id.
- */
-followup_fix_modby(q, sq, v, action, actarg, cl)
- struct query *q;
- register struct save_queue *sq;
- struct validate *v;
- register int (*action)();
- register int actarg;
- client *cl;
-{
- register int i, j;
- char **argv, *malloc();
- int id, status;
-
- i = q->vcnt - 2;
- while (sq_get_data(sq, &argv)) {
- id = atoi(argv[i]);
- if (id > 0)
- status = id_to_name(id, "USER", &argv[i]);
- else
- status = id_to_name(-id, "STRING", &argv[i]);
- if (status && status != MR_NO_MATCH)
- return(status);
- (*action)(q->vcnt, argv, actarg);
- for (j = 0; j < q->vcnt; j++)
- free(argv[j]);
- free(argv);
- }
- sq_destroy(sq);
- return(MR_SUCCESS);
-}
-
-
-/**
- ** followup_ausr - add finger and pobox entries, set_user_modtime
- **
- ** Inputs:
- ** argv[0] - login (add_user)
- ** argv[3] - last name
- ** argv[4] - first name
- ** argv[5] - middle name
- **
- **/
-
-followup_ausr(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## int who;
-## char *login, *entity;
-## char fullname[129];
-
- login = argv[0];
- who = cl->client_id;
- entity = cl->entity;
-
- /* build fullname */
- if (strlen(argv[4]) && strlen(argv[5]))
- sprintf(fullname, "%s %s %s", argv[4], argv[5], argv[3]);
- else if (strlen(argv[4]))
- sprintf(fullname, "%s %s", argv[4], argv[3]);
- else
- sprintf(fullname, "%s", argv[3]);
-
- /* create finger entry, pobox & set modtime on user */
-## repeat replace u (modtime = "now", modby=@who, modwith=@entity,
-## #fullname=@fullname, mit_affil = u.mit_year,
-## fmodtime="now", fmodby=@who, fmodwith=@entity,
-## potype="NONE", pmodtime="now", pmodby=@who, pmodwith=@entity)
-## where u.#login = @login
-
- return(MR_SUCCESS);
-##}
-
-
-/* followup_gpob: fixes argv[2] based on the IDs currently there and the
- * type in argv[1]. Then completes the upcall to the user.
- *
- * argv[2] is of the form "123:234" where the first integer is the machine
- * ID if it is a pop box, and the second is the string ID if it is an SMTP
- * box. argv[1] should be "POP", "SMTP", or "NONE". Boxes of type NONE
- * are skipped.
- */
-
-followup_gpob(q, sq, v, action, actarg, cl)
- register struct query *q;
- register struct save_queue *sq;
- register struct validate *v;
- register int (*action)();
- int actarg;
- client *cl;
-{
- char **argv, *index();
- char *ptype, *p;
- int mid, sid, status;
-
- /* for each row */
- while (sq_get_data(sq, &argv)) {
- mr_trim_args(2, argv);
- ptype = argv[1];
- p = index(argv[2], ':');
- *p++ = 0;
- mid = atoi(argv[2]);
- sid = atoi(p);
-
- if (!strcmp(ptype, "POP")) {
- status = id_to_name(mid, "MACHINE", &argv[2]);
- if (status == MR_NO_MATCH)
- return(MR_MACHINE);
- } else if (!strcmp(ptype, "SMTP")) {
- status = id_to_name(sid, "STRING", &argv[2]);
- if (status == MR_NO_MATCH)
- return(MR_STRING);
- } else /* ptype == "NONE" */ {
- goto skip;
- }
- if (status) return(status);
-
- if (!strcmp(q->shortname, "gpob")) {
- sid = atoi(argv[4]);
- if (sid > 0)
- status = id_to_name(sid, "USER", &argv[4]);
- else
- status = id_to_name(-sid, "STRING", &argv[4]);
- }
- if (status && status != MR_NO_MATCH) return(status);
-
- (*action)(q->vcnt, argv, actarg);
- skip:
- /* free saved data */
- free(argv[0]);
- free(argv[1]);
- free(argv[4]);
- free(argv);
- }
-
- sq_destroy(sq);
- return (MR_SUCCESS);
-}
-
-
-/* followup_glin: fix the ace_name in argv[8]. argv[7] will contain the
- * ace_type: "LIST", "USER", or "NONE". Decode the id in argv[8] into the
- * proper name based on the type, and repace that string in the argv.
- * Also fixes the modby field by called followup_fix_modby.
- */
-
-followup_glin(q, sq, v, action, actarg, cl)
- register struct query *q;
- register struct save_queue *sq;
- register struct validate *v;
- register int (*action)();
- int actarg;
- client *cl;
-{
- char **argv, *malloc(), *realloc(), *type;
- int id, i, idx, status;
-
- idx = 8;
- if (!strcmp(q->shortname, "gsin"))
- idx = 12;
-
- while (sq_get_data(sq, &argv)) {
- mr_trim_args(q->vcnt, argv);
-
- id = atoi(argv[i = q->vcnt - 2]);
- if (id > 0)
- status = id_to_name(id, "USER", &argv[i]);
- else
- status = id_to_name(-id, "STRING", &argv[i]);
- if (status && status != MR_NO_MATCH)
- return(status);
-
- id = atoi(argv[idx]);
- type = argv[idx - 1];
-
- if (!strcmp(type, "LIST")) {
- status = id_to_name(id, "LIST", &argv[idx]);
- } else if (!strcmp(type, "USER")) {
- status = id_to_name(id, "USER", &argv[idx]);
- } else if (!strcmp(type, "KERBEROS")) {
- status = id_to_name(id, "STRING", &argv[idx]);
- } else if (!strcmp(type, "NONE")) {
- status = 0;
- free(argv[idx]);
- argv[idx] = strsave("NONE");
- } else {
- status = 0;
- free(argv[idx]);
- argv[idx] = strsave("???");
- }
- if (status && status != MR_NO_MATCH)
- return(status);
-
- if (!strcmp(q->shortname, "glin") && atoi(argv[6]) == -1) {
- argv[6] = realloc(argv[6], strlen(UNIQUE_GID) + 1);
- strcpy(argv[6], UNIQUE_GID);
- }
-
- /* send the data */
- (*action)(q->vcnt, argv, actarg);
-
- /* free saved data */
- for (i = 0; i < q->vcnt; i++)
- free(argv[i]);
- free(argv);
- }
-
- sq_destroy(sq);
- return (MR_SUCCESS);
-}
-
-
-/* followup_gqot: Fix the entity name, directory name & modby fields
- * argv[0] = filsys_id
- * argv[1] = type
- * argv[2] = entity_id
- * argv[3] = ascii(quota)
- */
-
-followup_gqot(q, sq, v, action, actarg, cl)
- struct query *q;
- register struct save_queue *sq;
- struct validate *v;
- register int (*action)();
- register int actarg;
- client *cl;
-##{
- register int j;
- char **argv, *malloc();
-## int id, rowcount;
-## char *name, *label;
- int status, idx;
-
- if (!strcmp(q->name, "get_quota") ||
- !strcmp(q->name, "get_quota_by_filesys"))
- idx = 4;
- else
- idx = 3;
- while (sq_get_data(sq, &argv)) {
- if (idx == 4) {
- switch (argv[1][0]) {
- case 'U':
- status = id_to_name(atoi(argv[2]), "USER", &argv[2]);
- break;
- case 'G':
- case 'L':
- status = id_to_name(atoi(argv[2]), "LIST", &argv[2]);
- break;
- case 'A':
- free(argv[2]);
- argv[2] = strsave("system:anyuser");
- break;
- default:
- id = atoi(argv[2]);
- argv[2] = malloc(8);
- sprintf(argv[2], "%d", id);
- }
- }
- id = atoi(argv[idx]);
- free(argv[idx]);
- argv[idx] = malloc(256);
- name = argv[idx];
- if (id == 0) {
- label = argv[0];
-## repeat retrieve (name = filesys.#name) where filesys.#label = @label
- } else {
-## repeat retrieve (name = nfsphys.dir) where nfsphys.nfsphys_id = @id
- }
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1) {
- sprintf(argv[idx], "#%d", id);
- }
-
- id = atoi(argv[idx+3]);
- if (id > 0)
- status = id_to_name(id, "USER", &argv[idx+3]);
- else
- status = id_to_name(-id, "STRING", &argv[idx+3]);
- if (status && status != MR_NO_MATCH)
- return(status);
- (*action)(q->vcnt, argv, actarg);
- for (j = 0; j < q->vcnt; j++)
- free(argv[j]);
- free(argv);
- }
- sq_destroy(sq);
- return(MR_SUCCESS);
-##}
-
-
-/* followup_aqot: Add allocation to nfsphys after creating quota.
- * argv[0] = filsys_id
- * argv[1] = type if "add_quota" or "update_quota"
- * argv[2 or 1] = id
- * argv[3 or 2] = ascii(quota)
- */
-
-followup_aqot(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## int quota, id, fs, who;
-## char *entity, *qtype;
-
- fs = *(int *)argv[0];
- if (!strcmp(q->name, "add_quota") || !strcmp(q->name, "update_quota")) {
- qtype = argv[1];
- id = *(int *)argv[2];
- quota = atoi(argv[3]);
- } else {
- qtype = "USER";
- id = *(int *)argv[1];
- quota = atoi(argv[2]);
- }
- who = cl->client_id;
- entity = cl->entity;
-
-## repeat replace q (modtime = "now", modby = @who, modwith = @entity)
-## where q.filsys_id = @fs and q.type = @qtype and q.entity_id = @id
-## repeat replace nfsphys (allocated = nfsphys.allocated + @quota)
-## where nfsphys.nfsphys_id = filesys.#phys_id and filesys.filsys_id = @fs
- if (ingres_errno) return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-followup_gpce(q, sq, v, action, actarg, cl)
- struct query *q;
- register struct save_queue *sq;
- struct validate *v;
- register int (*action)();
- register int actarg;
- client *cl;
-{
- register int i, j;
- char **argv, *malloc();
- int id, status;
-
- i = q->vcnt - 2;
- while (sq_get_data(sq, &argv)) {
- id = atoi(argv[PCAP_QSERVER]);
- status = id_to_name(id, "MACHINE", &argv[PCAP_QSERVER]);
- if (status) return (status);
- id = atoi(argv[i]);
- if (id > 0)
- status = id_to_name(id, "USER", &argv[i]);
- else
- status = id_to_name(-id, "STRING", &argv[i]);
- if (status && status != MR_NO_MATCH)
- return(status);
- (*action)(q->vcnt, argv, actarg);
- for (j = 0; j < q->vcnt; j++)
- free(argv[j]);
- free(argv);
- }
- sq_destroy(sq);
- return(MR_SUCCESS);
-}
-
-
-/* followup_gzcl:
- */
-
-followup_gzcl(q, sq, v, action, actarg, cl)
- register struct query *q;
- register struct save_queue *sq;
- register struct validate *v;
- register int (*action)();
- int actarg;
- client *cl;
-{
- int id, i, status;
- char **argv;
-
- while (sq_get_data(sq, &argv)) {
- mr_trim_args(q->vcnt, argv);
-
- id = atoi(argv[i = q->vcnt - 2]);
- if (id > 0)
- status = id_to_name(id, "USER", &argv[i]);
- else
- status = id_to_name(-id, "STRING", &argv[i]);
- if (status && status != MR_NO_MATCH)
- return(status);
-
- for (i = 1; i < 8; i+=2) {
- id = atoi(argv[i+1]);
- if (!strcmp(argv[i], "LIST")) {
- status = id_to_name(id, "LIST", &argv[i+1]);
- } else if (!strcmp(argv[i], "USER")) {
- status = id_to_name(id, "USER", &argv[i+1]);
- } else if (!strcmp(argv[i], "KERBEROS")) {
- status = id_to_name(id, "STRING", &argv[i+1]);
- } else if (!strcmp(argv[i], "NONE")) {
- status = 0;
- free(argv[i+1]);
- argv[i+1] = strsave("NONE");
- } else {
- status = 0;
- free(argv[i+1]);
- argv[i+1] = strsave("???");
- }
- if (status && status != MR_NO_MATCH)
- return(status);
- }
-
- /* send the data */
- (*action)(q->vcnt, argv, actarg);
-
- /* free saved data */
- for (i = 0; i < q->vcnt; i++)
- free(argv[i]);
- free(argv);
- }
- sq_destroy(sq);
- return(MR_SUCCESS);
-}
-
-
-/* followup_gsha:
- */
-
-followup_gsha(q, sq, v, action, actarg, cl)
- register struct query *q;
- register struct save_queue *sq;
- register struct validate *v;
- register int (*action)();
- int actarg;
- client *cl;
-{
- char **argv;
- int i, id, status;
-
- while (sq_get_data(sq, &argv)) {
- mr_trim_args(q->vcnt, argv);
-
- id = atoi(argv[4]);
- if (id > 0)
- status = id_to_name(id, "USER", &argv[4]);
- else
- status = id_to_name(-id, "STRING", &argv[4]);
- if (status && status != MR_NO_MATCH)
- return(status);
-
- id = atoi(argv[2]);
- if (!strcmp(argv[1], "LIST")) {
- status = id_to_name(id, "LIST", &argv[2]);
- } else if (!strcmp(argv[1], "USER")) {
- status = id_to_name(id, "USER", &argv[2]);
- } else if (!strcmp(argv[1], "KERBEROS")) {
- status = id_to_name(id, "STRING", &argv[2]);
- } else if (!strcmp(argv[1], "NONE")) {
- status = 0;
- free(argv[2]);
- argv[2] = strsave("NONE");
- } else {
- status = 0;
- free(argv[2]);
- argv[2] = strsave("???");
- }
- if (status && status != MR_NO_MATCH)
- return(status);
-
- /* send the data */
- (*action)(q->vcnt, argv, actarg);
-
- /* free saved data */
- for (i = 0; i < q->vcnt; i++)
- free(argv[i]);
- free(argv);
- }
- sq_destroy(sq);
- return(MR_SUCCESS);
-}
-
-
-\f
-/* Special query routines */
-
-/* set_pobox - this does all of the real work.
- * argv = user_id, type, box
- * if type is POP, then box should be a machine, and its ID should be put in
- * pop_id. If type is SMTP, then box should be a string and its ID should
- * be put in box_id. If type is NONE, then box doesn't matter.
- */
-
-int set_pobox(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## int user, id, rowcount;
-## char *box, potype[9];
- int status;
-
- box = argv[2];
- user = *(int *)argv[0];
-
-## repeat retrieve (id = users.pop_id, potype = users.#potype)
-## where users.users_id = @user
- if (ingres_errno) return(mr_errcode);
- if (!strcmp(strtrim(potype), "POP"))
- set_pop_usage(id, -1);
-
- if (!strcmp(argv[1], "POP")) {
- status = name_to_id(box, "MACHINE", &id);
- if (status == MR_NO_MATCH)
- return(MR_MACHINE);
- else if (status)
- return(status);
-## repeat replace users (#potype = "POP", pop_id = @id)
-## where users.users_id = @user
- set_pop_usage(id, 1);
- } else if (!strcmp(argv[1], "SMTP")) {
- if (index(box, '/') || index(box, '|'))
- return(MR_BAD_CHAR);
- status = name_to_id(box, "STRING", &id);
- if (status == MR_NO_MATCH) {
-## repeat retrieve (id = values.value) where values.name = "strings_id"
- id++;
-## repeat replace values (value = @id) where values.name = "strings_id"
-## append to strings (string_id = id, string = box)
- } else if (status)
- return(status);
-## repeat replace users (#potype = "SMTP", box_id = @id)
-## where users.users_id = @user
- } else /* argv[1] == "NONE" */ {
-## repeat replace users (#potype = "NONE") where users.users_id = @user
- }
-
- set_pobox_modtime(q, argv, cl);
-## repeat replace tblstats (updates = tblstats.updates + 1, modtime = "now")
-## where tblstats.#table = "users"
- if (ingres_errno) return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* get_list_info: passed a wildcard list name, returns lots of stuff about
- * each list. This is tricky: first build a queue of all requested
- * data. Rest of processing consists of fixing gid, ace_name, and modby.
- */
-
-get_list_info(q, aargv, cl, action, actarg)
- register struct query *q;
- char **aargv;
- client *cl;
- register int (*action)();
- int actarg;
-##{
- char *argv[13], *malloc(), *realloc();
-## char *name, acl_type[9], listname[33], active[5], public[5], hidden[5];
-## char maillist[5], group[5], gid[6], acl_name[256], desc[256], modtime[27];
-## char modby[256], modwith[9];
-## int id, rowcount, acl_id, hid, modby_id;
- int returned, status;
- struct save_queue *sq, *sq_create();
-
- returned = rowcount = 0;
- name = aargv[0];
-
- sq = sq_create();
-## range of l is list
-## repeat retrieve (id = l.list_id) where l.#name = @name {
- sq_save_data(sq, id);
- rowcount++;
-## }
- if (ingres_errno) return(mr_errcode);
- if (rowcount == 0)
- return(MR_NO_MATCH);
-
- argv[0] = listname; argv[1] = active; argv[2] = public; argv[3] = hidden;
- argv[4] = maillist; argv[5] = group; argv[6] = gid; argv[7] = acl_type;
- argv[9] = desc; argv[10] = modtime; argv[12] = modwith;
-
- while (sq_get_data(sq, &id)) {
- if (id == 0)
- continue;
- argv[6] = gid;
-## repeat retrieve (listname = l.#name, active = text(l.#active),
-## public = text(l.#public), hidden = text(l.#hidden),
-## hid = l.#hidden, maillist = text(l.#maillist),
-## group = text(l.#group), gid = text(l.#gid),
-## acl_type = trim(l.#acl_type), acl_id = l.#acl_id,
-## desc = l.#desc, modtime = l.#modtime, modby_id = l.#modby,
-## modwith =l.#modwith)
-## where l.list_id = @id
- if (ingres_errno) return(mr_errcode);
-
- if (atoi(gid) == -1)
- argv[6] = UNIQUE_GID;
-
- argv[8] = malloc(0);
- if (!strcmp(acl_type, "LIST")) {
- status = id_to_name(acl_id, "LIST", &argv[8]);
- } else if (!strcmp(acl_type, "USER")) {
- status = id_to_name(acl_id, "USER", &argv[8]);
- } else if (!strcmp(acl_type, "KERBEROS")) {
- status = id_to_name(acl_id, "STRING", &argv[8]);
- } else if (!strcmp(acl_type, "NONE")) {
- status = 0;
- free(argv[8]);
- argv[8] = strsave("NONE");
- } else {
- status = 0;
- free(argv[8]);
- argv[8] = strsave("???");
- }
- if (status && status != MR_NO_MATCH) return(status);
-
- argv[11] = malloc(0);
- if (modby_id > 0)
- status = id_to_name(modby_id, "USER", &argv[11]);
- else
- status = id_to_name(-modby_id, "STRING", &argv[11]);
- if (status && status != MR_NO_MATCH) return(status);
-
- mr_trim_args(q->vcnt, argv);
- returned++;
- (*action)(q->vcnt, argv, actarg);
- free(argv[8]);
- free(argv[11]);
- }
-
- sq_destroy(sq);
- if (ingres_errno) return(mr_errcode);
- return (MR_SUCCESS);
-##}
-
-
-/* Add_member_to_list: do list flattening as we go! MAXLISTDEPTH is
- * how many different ancestors a member is allowed to have.
- */
-
-#define MAXLISTDEPTH 1024
-
-int add_member_to_list(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## int id, lid, mid, exists, error, who, ref;
-## char *mtype, dtype[9], *entity;
- int ancestors[MAXLISTDEPTH], aref[MAXLISTDEPTH], acount, a;
- int descendants[MAXLISTDEPTH], dref[MAXLISTDEPTH], dcount, d;
- int status;
- char *dtypes[MAXLISTDEPTH];
- char *iargv[3], *buf;
-
-## range of m is imembers
- lid = *(int *)argv[0];
- mtype = argv[1];
- mid = *(int *)argv[2];
- /* if the member is already a direct member of the list, punt */
-## repeat retrieve (exists = any(m.list_id where m.list_id=@lid and
-## m.member_id = @mid and m.member_type = @mtype
-## and m.direct = 1))
- if (exists)
- return(MR_EXISTS);
- if (!strcasecmp(mtype, "STRING")) {
- buf = malloc(0);
- status = id_to_name(mid, "STRING", &buf);
- if (status) return(status);
- if (index(buf, '/') || index(buf, '|')) {
- free(buf);
- return(MR_BAD_CHAR);
- }
- free(buf);
- }
-
- ancestors[0] = lid;
- aref[0] = 1;
- acount = 1;
-## repeat retrieve (id = m.list_id, ref = m.ref_count)
-## where m.member_id = @lid and m.member_type = "LIST" {
- aref[acount] = ref;
- ancestors[acount++] = id;
- if (acount >= MAXLISTDEPTH) {
-## endretrieve
- }
-## }
- if (ingres_errno) return(mr_errcode);
- if (acount >= MAXLISTDEPTH) {
- return(MR_INTERNAL);
- }
- descendants[0] = mid;
- dtypes[0] = mtype;
- dref[0] = 1;
- dcount = 1;
- error = 0;
- if (!strcmp(mtype, "LIST")) {
-## repeat retrieve (id = m.member_id, dtype = m.member_type,
-## ref = m.ref_count)
-## where m.list_id = @mid {
- switch (dtype[0]) {
- case 'L':
- dtypes[dcount] = "LIST";
- break;
- case 'U':
- dtypes[dcount] = "USER";
- break;
- case 'S':
- dtypes[dcount] = "STRING";
- break;
- case 'K':
- dtypes[dcount] = "KERBEROS";
- break;
- default:
- error++;
-## endretrieve
- }
- dref[dcount] = ref;
- descendants[dcount++] = id;
- if (dcount >= MAXLISTDEPTH) {
- error++;
-## endretrieve
- }
-## }
- if (ingres_errno) return(mr_errcode);
- if (error)
- return(MR_INTERNAL);
- }
- for (a = 0; a < acount; a++) {
- lid = ancestors[a];
- for (d = 0; d < dcount; d++) {
- mid = descendants[d];
- mtype = dtypes[d];
- if (mid == lid && !strcmp(mtype, "LIST")) {
- return(MR_LISTLOOP);
- }
-## repeat retrieve (exists = any(m.ref_count where m.list_id = @lid
-## and m.member_id = @mid
-## and m.member_type = @mtype))
- ref = aref[a] * dref[d];
- if (exists) {
- if (a == 0 && d == 0)
-## replace m (ref_count = m.ref_count+ref, direct = 1)
-## where m.list_id = lid and m.member_id = mid and
-## m.member_type = mtype
- else
-## replace m (ref_count = m.ref_count+ref)
-## where m.list_id = lid and m.member_id = mid and
-## m.member_type = mtype
- } else {
- incremental_clear_before();
- if (a == 0 && d == 0)
-## append imembers (list_id=lid, member_id = mid, direct = 1,
-## member_type=mtype, ref_count = 1)
- else
-## append imembers (list_id=lid, member_id = mid,
-## member_type=mtype, ref_count = ref)
- iargv[0] = (char *)lid;
- iargv[1] = mtype;
- iargv[2] = (char *)mid;
- incremental_after("members", 0, iargv);
- }
- }
- }
- lid = *(int *)argv[0];
- entity = cl->entity;
- who = cl->client_id;
-## repeat replace list (modtime = "now", modby = @who, modwith = @entity)
-## where list.#list_id = @lid
- if (ingres_errno) return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* Delete_member_from_list: do list flattening as we go!
- */
-
-int delete_member_from_list(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## int id, lid, mid, cnt, exists, error, who, ref;
-## char *mtype, dtype[9], *entity;
- int ancestors[MAXLISTDEPTH], aref[MAXLISTDEPTH], acount, a;
- int descendants[MAXLISTDEPTH], dref[MAXLISTDEPTH], dcount, d;
- char *dtypes[MAXLISTDEPTH];
- char *iargv[3];
-
-## range of m is imembers
- lid = *(int *)argv[0];
- mtype = argv[1];
- mid = *(int *)argv[2];
- /* if the member is not a direct member of the list, punt */
-## repeat retrieve (exists = any(m.list_id where m.list_id=@lid and
-## m.member_id = @mid and m.member_type = @mtype
-## and m.direct = 1))
- if (ingres_errno) return(mr_errcode);
- if (!exists)
- return(MR_NO_MATCH);
- ancestors[0] = lid;
- aref[0] = 1;
- acount = 1;
-## repeat retrieve (id = m.list_id, ref = m.ref_count)
-## where m.member_id = @lid and m.member_type = "LIST" {
- aref[acount] = ref;
- ancestors[acount++] = id;
- if (acount >= MAXLISTDEPTH)
-## endretrieve
-## }
- if (ingres_errno) return(mr_errcode);
- if (acount >= MAXLISTDEPTH)
- return(MR_INTERNAL);
- descendants[0] = mid;
- dtypes[0] = mtype;
- dref[0] = 1;
- dcount = 1;
- error = 0;
- if (!strcmp(mtype, "LIST")) {
-## repeat retrieve (id = m.member_id, dtype = m.member_type,
-## ref = m.ref_count)
-## where m.list_id = @mid {
- switch (dtype[0]) {
- case 'L':
- dtypes[dcount] = "LIST";
- break;
- case 'U':
- dtypes[dcount] = "USER";
- break;
- case 'S':
- dtypes[dcount] = "STRING";
- break;
- case 'K':
- dtypes[dcount] = "KERBEROS";
- break;
- default:
- error++;
-## endretrieve
- }
- dref[dcount] = ref;
- descendants[dcount++] = id;
- if (dcount >= MAXLISTDEPTH)
-## endretrieve
-## }
- if (ingres_errno) return(mr_errcode);
- if (error)
- return(MR_INTERNAL);
- }
- for (a = 0; a < acount; a++) {
- lid = ancestors[a];
- for (d = 0; d < dcount; d++) {
- mid = descendants[d];
- mtype = dtypes[d];
- if (mid == lid && !strcmp(mtype, "LIST")) {
- return(MR_LISTLOOP);
- }
-## repeat retrieve (cnt = m.ref_count)
-## where m.list_id = @lid and m.member_id = @mid
-## and m.member_type = @mtype
- ref = aref[a] * dref[d];
- if (cnt <= ref) {
- iargv[0] = (char *)lid;
- iargv[1] = mtype;
- iargv[2] = (char *)mid;
- incremental_before("members", 0, iargv);
-## delete m where m.list_id = lid and m.member_id = mid and
-## m.member_type = mtype
- incremental_clear_after();
- } else if (a == 0 && d == 0) {
-## replace m (ref_count = m.ref_count-ref, direct = 0)
-## where m.list_id = lid and m.member_id = mid and
-## m.member_type = mtype
- } else {
-## replace m (ref_count = m.ref_count-ref)
-## where m.list_id = lid and m.member_id = mid and
-## m.member_type = mtype
- }
- }
- }
- lid = *(int *)argv[0];
- entity = cl->entity;
- who = cl->client_id;
-## repeat replace list (modtime = "now", modby = @who, modwith = @entity)
-## where list.#list_id = @lid
- if (ingres_errno) return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* get_ace_use - given a type and a name, return a type and a name.
- * The ace_type is one of "LIST", "USER", "RLIST", or "RUSER" in argv[0],
- * and argv[1] will contain the ID of the entity in question. The R*
- * types mean to recursively look at every containing list, not just
- * when the object in question is a direct member. On return, the
- * usage type will be one of LIST, SERVICE, FILESYS, QUOTA, QUERY, or ZEPHYR.
- */
-
-int get_ace_use(q, argv, cl, action, actarg)
- struct query *q;
- char *argv[];
- client *cl;
- int (*action)();
- int actarg;
-##{
- int found = 0;
-## char *atype;
-## int aid, listid, id;
- struct save_queue *sq, *sq_create();
-
-## range of m is imembers
- atype = argv[0];
- aid = *(int *)argv[1];
- if (!strcmp(atype, "LIST") || !strcmp(atype, "USER") ||
- !strcmp(atype, "KERBEROS")) {
- return(get_ace_internal(atype, aid, action, actarg));
- }
-
- sq = sq_create();
- if (!strcmp(atype, "RLIST")) {
- sq_save_data(sq, aid);
- /* get all the list_id's of containing lists */
-## repeat retrieve (listid = m.list_id)
-## where m.member_type = "LIST" and m.member_id = @id {
- sq_save_unique_data(sq, listid);
-## }
- /* now process each one */
- while (sq_get_data(sq, &id)) {
- if (get_ace_internal("LIST", id, action, actarg) == MR_SUCCESS)
- found++;
- }
- }
-
- if (!strcmp(atype, "RUSER")) {
-## repeat retrieve (listid = m.list_id)
-## where m.member_type = "USER" and m.member_id = @aid {
- sq_save_data(sq, listid);
-## }
- /* now process each one */
- while (sq_get_data(sq, &id)) {
- if (get_ace_internal("LIST", id, action, actarg) == MR_SUCCESS)
- found++;
- }
- if (get_ace_internal("USER", aid, action, actarg) == MR_SUCCESS)
- found++;
- }
-
- if (!strcmp(atype, "RKERBERO")) {
-## repeat retrieve (listid = m.list_id)
-## where m.member_type = "KERBEROS" and m.member_id = @aid {
- sq_save_data(sq, listid);
-## }
- /* now process each one */
- while (sq_get_data(sq, &id)) {
- if (get_ace_internal("LIST", id, action, actarg) == MR_SUCCESS)
- found++;
- }
- if (get_ace_internal("KERBEROS", aid, action, actarg) == MR_SUCCESS)
- found++;
- }
-
- sq_destroy(sq);
- if (ingres_errno) return(mr_errcode);
- if (!found) return(MR_NO_MATCH);
- return(MR_SUCCESS);
-##}
-
-
-/* This looks up a single list or user for ace use. atype must be "USER"
- * or "LIST", and aid is the ID of the corresponding object. This is used
- * by get_ace_use above.
- */
-
-##get_ace_internal(atype, aid, action, actarg)
-## char *atype;
-## int aid;
- int (*action)();
- int actarg;
-##{
- char *rargv[2];
- int found = 0;
-## char name[33];
-
- rargv[1] = name;
- if (!strcmp(atype, "LIST")) {
- rargv[0] = "FILESYS";
-## repeat retrieve (name = filesys.label)
-## where filesys.owners = @aid {
- (*action)(2, rargv, actarg);
- found++;
-## }
-
- rargv[0] = "QUERY";
-## repeat retrieve (name = capacls.capability)
-## where capacls.list_id = @aid {
- (*action)(2, rargv, actarg);
- found++;
-## }
- } else if (!strcmp(atype, "USER")) {
- rargv[0] = "FILESYS";
-## repeat retrieve (name = filesys.label)
-## where filesys.owner = @aid {
- (*action)(2, rargv, actarg);
- found++;
-## }
- }
-
- rargv[0] = "LIST";
-## repeat retrieve (name = list.#name)
-## where list.acl_type = @atype and list.acl_id = @aid {
- (*action)(2, rargv, actarg);
- found++;
-## }
-
- rargv[0] = "SERVICE";
-## repeat retrieve (name = servers.#name)
-## where servers.acl_type = @atype and servers.acl_id = @aid {
- (*action)(2, rargv, actarg);
- found++;
-## }
-
- rargv[0] = "HOSTACCESS";
-## repeat retrieve (name = machine.#name)
-## where machine.mach_id = hostaccess.mach_id and
-## hostaccess.acl_type = @atype and hostaccess.acl_id = @aid {
- (*action)(2, rargv, actarg);
- found++;
-## }
- rargv[0] = "ZEPHYR";
-## repeat retrieve (name = zephyr.class)
-## where zephyr.xmt_type = @atype and zephyr.xmt_id = @aid or
-## zephyr.sub_type = @atype and zephyr.sub_id = @aid or
-## zephyr.iws_type = @atype and zephyr.iws_id = @aid or
-## zephyr.iui_type = @atype and zephyr.iui_id = @aid {
- (*action)(2, rargv, actarg);
- found++;
-## }
-
- if (!found) return(MR_NO_MATCH);
- return(MR_SUCCESS);
-##}
-
-
-/* get_lists_of_member - given a type and a name, return the name and flags
- * of all of the lists of the given member. The member_type is one of
- * "LIST", "USER", "STRING", "RLIST", "RUSER", or "RSTRING" in argv[0],
- * and argv[1] will contain the ID of the entity in question. The R*
- * types mean to recursively look at every containing list, not just
- * when the object in question is a direct member.
- */
-
-int get_lists_of_member(q, argv, cl, action, actarg)
- struct query *q;
- char *argv[];
- client *cl;
- int (*action)();
- int actarg;
-##{
- int found = 0, direct = 1;
- char *rargv[6];
-## char *atype;
-## int aid, listid, id;
-## char name[33], active[5], public[5], hidden[5], maillist[5], group[5];
-
- atype = argv[0];
- aid = *(int *)argv[1];
- if (!strcmp(atype, "RLIST")) {
- atype = "LIST";
- direct = 0;
- }
- if (!strcmp(atype, "RUSER")) {
- atype = "USER";
- direct = 0;
- }
- if (!strcmp(atype, "RSTRING")) {
- atype = "STRING";
- direct = 0;
- }
- if (!strcmp(atype, "RKERBEROS")) {
- atype = "KERBEROS";
- direct = 0;
- }
-
- rargv[0] = name;
- rargv[1] = active;
- rargv[2] = public;
- rargv[3] = hidden;
- rargv[4] = maillist;
- rargv[5] = group;
-## range of m is imembers
- if (direct) {
-## repeat retrieve (name = list.#name, active = text(list.#active),
-## public = text(list.#public), hidden = text(list.#hidden),
-## maillist = text(list.#maillist), group = text(list.#group))
-## where list.list_id = m.list_id and m.direct = 1 and
-## m.member_type = @atype and m.member_id = @aid {
- (*action)(6, rargv, actarg);
- found++;
-## }
- } else {
-## repeat retrieve (name = list.#name, active = text(list.#active),
-## public = text(list.#public), hidden = text(list.#hidden),
-## maillist = text(list.#maillist), group = text(list.#group))
-## where list.list_id = m.list_id and
-## m.member_type = @atype and m.member_id = @aid {
- (*action)(6, rargv, actarg);
- found++;
-## }
- }
-
- if (ingres_errno) return(mr_errcode);
- if (!found) return(MR_NO_MATCH);
- return(MR_SUCCESS);
-##}
-
-
-/* qualified_get_lists: passed "TRUE", "FALSE", or "DONTCARE" for each of
- * the five flags associated with each list. It will return the name of
- * each list that meets the quailifications. It does this by building a
- * where clause based on the arguments, then doing a retrieve.
- */
-
-static char *lflags[5] = { "active", "public", "hidden", "maillist", "group" };
-
-int qualified_get_lists(q, argv, cl, action, actarg)
- struct query *q;
- char *argv[];
- client *cl;
- int (*action)();
- int actarg;
-{
- return(qualified_get(q, argv, action, actarg, "l.list_id != 0",
- "l", "name", lflags));
-}
-
-
-/** get_members_of_list - optimized query for retrieval of list members
- **
- ** Inputs:
- ** argv[0] - list_id
- **
- ** Description:
- ** - retrieve USER members, then LIST members, then STRING members
- **/
-
-get_members_of_list(q, argv, cl, action, actarg)
- struct query *q;
- char *argv[];
- client *cl;
- int (*action)();
- int actarg;
-##{
-## int list_id, member_id;
-## char member_name[129], member_type[9];
- char *targv[2];
- int members;
- struct save_queue *sq;
-
- list_id = *(int *)argv[0];
- members = 0;
- sq = sq_create();
-
-## repeat retrieve (member_type = imembers.#member_type,
-## member_id = imembers.#member_id)
-## where imembers.#list_id = @list_id and imembers.direct = 1 {
- if (members++ > 49)
-## endretrieve
- sq_save_data(sq, (member_type[0] << 24) | (member_id & 0xffffff));
-## }
- if (members <= 49) {
- targv[1] = malloc(0);
- while (sq_remove_data(sq, &member_id)) {
- switch (member_id >> 24) {
- case 'U':
- targv[0] = "USER";
- id_to_name(member_id & 0xffffff, "USER", &targv[1]);
- (*action)(2, targv, actarg);
- break;
- case 'L':
- targv[0] = "LIST";
- id_to_name(member_id & 0xffffff, "LIST", &targv[1]);
- (*action)(2, targv, actarg);
- break;
- case 'S':
- targv[0] = "STRING";
- id_to_name(member_id & 0xffffff, "STRING", &targv[1]);
- (*action)(2, targv, actarg);
- break;
- case 'K':
- targv[0] = "KERBEROS";
- id_to_name(member_id & 0xffffff, "STRING", &targv[1]);
- (*action)(2, targv, actarg);
- break;
- default:
- sq_destroy(sq);
- return(MR_INTERNAL);
- }
- }
- free(targv[1]);
- sq_destroy(sq);
- return(MR_SUCCESS);
- }
- sq_destroy(sq);
-
- targv[1] = member_name;
- targv[0] = "USER";
-## range of m is imembers
-## repeat retrieve (member_name = users.login)
-## where m.#list_id = @list_id and m.#member_type = "USER"
-## and m.#member_id = users.users_id and m.direct = 1
-## sort by #member_name
-## {
- (*action)(2, targv, actarg);
-## }
- if (ingres_errno) return(mr_errcode);
-
- targv[0] = "LIST";
-## repeat retrieve (member_name = list.name)
-## where m.#list_id = @list_id and m.#member_type = "LIST"
-## and m.#member_id = list.#list_id and m.direct = 1
-## sort by #member_name
-## {
- (*action)(2, targv, actarg);
-## }
- if (ingres_errno) return(mr_errcode);
-
- targv[0] = "STRING";
-## repeat retrieve (member_name = strings.string)
-## where m.#list_id = @list_id and m.#member_type = "STRING"
-## and m.#member_id = strings.string_id and m.direct = 1
-## sort by #member_name
-## {
- (*action)(2, targv, actarg);
-## }
- if (ingres_errno) return(mr_errcode);
-
- targv[0] = "KERBEROS";
-## repeat retrieve (member_name = strings.string)
-## where m.#list_id = @list_id and m.#member_type = "KERBEROS"
-## and m.#member_id = strings.string_id and m.direct = 1
-## sort by #member_name
-## {
- (*action)(2, targv, actarg);
-## }
- if (ingres_errno) return(mr_errcode);
-
- return(MR_SUCCESS);
-##}
-
-
-/* count_members_of_list: this is a simple query, but it cannot be done
- * through the dispatch table.
- */
-
-int count_members_of_list(q, argv, cl, action, actarg)
- struct query *q;
- char *argv[];
- client *cl;
- int (*action)();
- int actarg;
-##{
-## int list, ct = 0;
- char *rargv[1], countbuf[5];
-
- list = *(int *)argv[0];
- rargv[0] = countbuf;
-## repeat retrieve (ct = count(imembers.list_id
-## where imembers.list_id = @list and
-## imembers.direct = 1))
- if (ingres_errno) return(mr_errcode);
- sprintf(countbuf, "%d", ct);
- (*action)(1, rargv, actarg);
- return(MR_SUCCESS);
-##}
-
-
-/* qualified_get_server: passed "TRUE", "FALSE", or "DONTCARE" for each of
- * the three flags associated with each service. It will return the name of
- * each service that meets the quailifications. It does this by building a
- * where clause based on the arguments, then doing a retrieve.
- */
-
-static char *sflags[3] = { "enable", "inprogress", "harderror" };
-
-int qualified_get_server(q, argv, cl, action, actarg)
- struct query *q;
- char *argv[];
- client *cl;
- int (*action)();
- int actarg;
-{
- return(qualified_get(q, argv, action, actarg, "s.name != \"\"",
- "s", "name", sflags));
-}
-
-
-/* generic qualified get routine, used by qualified_get_lists,
- * qualified_get_server, and qualified_get_serverhost.
- * Args:
- * start - a simple where clause, must not be empty
- * range - the name of the range variable
- * field - the field to return
- * flags - an array of strings, names of the flag variables
- */
-
-int qualified_get(q, argv, action, actarg, start, range, field, flags)
- struct query *q;
- char *argv[];
- int (*action)();
- int actarg;
- char *start;
- char *range;
- char *field;
- char *flags[];
-##{
-## char name[33], qual[256], *rvar, *rtbl, *rfield;
- char *rargv[1], buf[32];
-## int rowcount, i;
-
- strcpy(qual, start);
- for (i = 0; i < q->argc; i++) {
- if (!strcmp(argv[i], "TRUE")) {
- sprintf(buf, " and %s.%s != 0", range, flags[i]);
- (void) strcat(qual, buf);
- } else if (!strcmp(argv[i], "FALSE")) {
- sprintf(buf, " and %s.%s = 0", range, flags[i]);
- (void) strcat(qual, buf);
- }
- }
-
- rargv[0] = name;
- rvar = range;
- rtbl = q->rtable;
- rfield = field;
-## range of rvar is rtbl
-## retrieve (name = rvar.rfield) where qual {
- (*action)(1, rargv, actarg);
-## }
- if (ingres_errno) return(mr_errcode);
-## inquire_equel(rowcount = "rowcount")
- if (rowcount == 0)
- return(MR_NO_MATCH);
- return(MR_SUCCESS);
-##}
-
-
-/* qualified_get_serverhost: passed "TRUE", "FALSE", or "DONTCARE" for each of
- * the five flags associated with each serverhost. It will return the name of
- * each service and host that meets the quailifications. It does this by
- * building a where clause based on the arguments, then doing a retrieve.
- */
-
-static char *shflags[6] = { "service", "enable", "override", "success",
- "inprogress", "hosterror" };
-
-int qualified_get_serverhost(q, argv, cl, action, actarg)
- struct query *q;
- char *argv[];
- client *cl;
- int (*action)();
- int actarg;
-##{
-## char sname[33], mname[33], qual[256];
- char *rargv[2], buf[32];
-## int rowcount, i;
-
- sprintf(qual, "machine.mach_id = sh.mach_id and sh.service = uppercase(\"%s\")",
- argv[0]);
- for (i = 1; i < q->argc; i++) {
- if (!strcmp(argv[i], "TRUE")) {
- sprintf(buf, " and sh.%s != 0", shflags[i]);
- strcat(qual, buf);
- } else if (!strcmp(argv[i], "FALSE")) {
- sprintf(buf, " and sh.%s = 0", shflags[i]);
- strcat(qual, buf);
- }
- }
-
- rargv[0] = sname;
- rargv[1] = mname;
-## range of sh is serverhosts
-## retrieve (sname = sh.service, mname = machine.name) where qual {
- (*action)(2, rargv, actarg);
-## }
- if (ingres_errno) return(mr_errcode);
-## inquire_equel(rowcount = "rowcount")
- if (rowcount == 0)
- return(MR_NO_MATCH);
- return(MR_SUCCESS);
-##}
-
-
-/* register_user - change user's login name and allocate a pobox, group,
- * filesystem, and quota for them. The user's status must start out as 0,
- * and is left as 2. Arguments are: user's UID, new login name, and user's
- * type for filesystem allocation (MR_FS_STUDENT, MR_FS_FACULTY,
- * MR_FS_STAFF, MR_FS_MISC).
- */
-
-register_user(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## char *login, dir[65], *entity, *directory, machname[33];
-## int who, rowcount, mid, uid, users_id, flag, utype, nid, list_id, quota;
-## int size, alloc, pid, m_id;
- char buffer[256], *aargv[3];
- int maxsize;
-
- entity = cl->entity;
- who = cl->client_id;
-
- uid = atoi(argv[0]);
- login = argv[1];
- utype = atoi(argv[2]);
-
-## range of u is users
-## range of l is list
-## range of sh is serverhosts
-## range of n is nfsphys
-## range of m is machine
-
- /* find user */
-## repeat retrieve (users_id = u.#users_id)
-## where u.#uid = @uid and (u.status = 0 or u.status = 5 or u.status = 6)
-## inquire_equel(rowcount = "rowcount");
- if (rowcount == 0)
- return(MR_NO_MATCH);
- if (rowcount > 1)
- return(MR_NOT_UNIQUE);
-
- /* check new login name */
-## repeat retrieve (flag = any(u.#login where u.#login = @login and
-## u.#users_id != users_id))
- if (ingres_errno) return(mr_errcode);
- if (flag) return(MR_IN_USE);
-## repeat retrieve (flag = any(l.#name where l.#name = @login))
- if (ingres_errno) return(mr_errcode);
- if (flag) return(MR_IN_USE);
-## repeat retrieve (flag = any(filesys.#label where filesys.#label = @login))
- if (ingres_errno) return(mr_errcode);
- if (flag) return(MR_IN_USE);
- com_err(whoami, 0, "new login name OK");
-
- /* choose place for pobox, put in mid */
-## repeat retrieve (mid = sh.mach_id, machname = m.name)
-## where sh.service = "POP" and m.mach_id = sh.mach_id and
-## sh.value2 - sh.value1 = max(sh.value2-sh.value1 where sh.service="POP")
- if (ingres_errno) return(mr_errcode);
-## inquire_equel(rowcount = "rowcount");
- if (rowcount == 0)
- return(MR_NO_POBOX);
-
- /* change login name, set pobox */
- sprintf(buffer, "u.users_id = %d", users_id);
- incremental_before("users", buffer, 0);
-## repeat replace u (#login = @login, status = 2, modtime = "now",
-## modby = @who, modwith = @entity, potype="POP",
-## pop_id = @mid, pmodtime="now", pmodby=@who,
-## pmodwith=@entity)
-## where u.#users_id = @users_id
-## inquire_equel(rowcount = "rowcount");
- if (ingres_errno) return(mr_errcode);
- if (rowcount != 1)
- return(MR_INTERNAL);
- set_pop_usage(mid, 1);
- com_err(whoami, 0, "set login name to %s and pobox to %s", login,
- strtrim(machname));
- incremental_after("users", buffer, 0);
-
- /* create group list */
- if (set_next_object_id("gid", "list"))
- return(MR_NO_ID);
- if (set_next_object_id("list_id", "list"))
- return(MR_NO_ID);
-## repeat retrieve (list_id = values.value) where values.name = "list_id"
- if (ingres_errno) return(mr_errcode);
-## inquire_equel(rowcount = "rowcount");
- if (rowcount != 1)
- return(MR_INTERNAL);
- incremental_clear_before();
-## repeat append list (name = @login, #list_id = @list_id, active = 1,
-## public = 0, hidden = 0, maillist = 0, group = 1,
-## #gid = values.value, desc = "User Group",
-## acl_type = "USER", acl_id = @users_id, modtime = "now",
-## modby = @who, modwith = @entity)
-## where values.name = "gid"
- if (ingres_errno) return(mr_errcode);
-## inquire_equel(rowcount = "rowcount");
- if (rowcount != 1)
- return(MR_INTERNAL);
- sprintf(buffer, "l.list_id = %d", list_id);
- incremental_after("list", buffer, 0);
- aargv[0] = (char *) list_id;
- aargv[1] = "USER";
- aargv[2] = (char *) users_id;
- incremental_clear_before();
-## repeat append imembers (#list_id = @list_id, member_type = "USER",
-## member_id = @users_id, ref_count = 1, direct = 1)
- if (ingres_errno) return(mr_errcode);
-## inquire_equel(rowcount = "rowcount");
- if (rowcount != 1)
- return(MR_INTERNAL);
- incremental_after("members", 0, aargv);
- com_err(whoami, 0, "group list created");
-
- /* decide where to put filesystem */
- maxsize = 0;
- directory = NULL;
-## repeat retrieve (mid = n.mach_id, dir = trim(n.#dir), nid = n.nfsphys_id,
-## flag = n.status, size = n.#size, alloc = n.allocated) {
- if ((flag & utype) && (size != 0) && (size - alloc > maxsize)) {
- maxsize = size - alloc;
- if (directory)
- free(directory);
- directory = strsave(dir);
- pid = nid;
- m_id = mid;
- }
-## }
- if (ingres_errno) return(mr_errcode);
- if (maxsize == 0)
- return(MR_NO_FILESYS);
-
- /* create filesystem */
- if (set_next_object_id("filsys_id", "filesys"))
- return(MR_NO_ID);
- incremental_clear_before();
-## repeat append filesys (filsys_id = values.value, phys_id = @pid,
-## label = @login, type = "NFS", mach_id = @m_id,
-## name = @directory + "/" + @login,
-## mount = "/mit/" + @login,
-## access = "w", comments = "User Locker",
-## owner = @users_id, owners = @list_id, createflg = 1,
-## lockertype = "HOMEDIR", modtime = "now",
-## modby = @who, modwith = @entity)
-## where values.name = "filsys_id"
- if (ingres_errno) return(mr_errcode);
-## inquire_equel(rowcount = "rowcount");
- if (rowcount != 1)
- return(MR_INTERNAL);
- incremental_after("filesys",
- "fs.filsys_id = values.value and values.name = \"filsys_id\"",
- 0);
- com_err(whoami, 0, "filesys created on mach %d in %s/%s", m_id,
- directory, login);
-
- /* set quota */
-## repeat retrieve (quota = values.value) where values.name = "def_quota"
- if (ingres_errno) return(mr_errcode);
-## inquire_equel(rowcount = "rowcount");
- if (rowcount != 1)
- return(MR_NO_QUOTA);
- incremental_clear_before();
-## repeat append #quota (entity_id = @users_id, filsys_id = values.value,
-## type = "USER",
-## #quota = @quota, phys_id = @pid, modtime = "now",
-## modby = @who, modwith = @entity)
-## where values.name = "filsys_id"
- if (ingres_errno) return(mr_errcode);
-## inquire_equel(rowcount = "rowcount");
- if (rowcount != 1)
- return(MR_INTERNAL);
-## repeat replace nfsphys (allocated = nfsphys.allocated + @quota)
-## where nfsphys.nfsphys_id = filesys.#phys_id and
-## filesys.filsys_id = values.value and values.name = "filsys_id"
- if (ingres_errno) return(mr_errcode);
-## inquire_equel(rowcount = "rowcount");
- if (rowcount != 1)
- return(MR_INTERNAL);
- aargv[0] = login;
- aargv[1] = "USER";
- aargv[2] = login;
- sprintf(buffer, "q.entity_id = %d and q.filsys_id = values.value and q.type = \"USER\" and values.name = \"filsys_id\"", users_id);
- incremental_after("quota", buffer, aargv);
- com_err(whoami, 0, "quota of %d assigned", quota);
- if (ingres_errno) return(mr_errcode);
-
- cache_entry(login, "USER", users_id);
-
-## repeat replace tblstats (updates = tblstats.updates + 1, modtime = "now")
-## where tblstats.table = "users"
-## repeat replace tblstats (appends = tblstats.appends + 1, modtime = "now")
-## where tblstats.table = "list" or tblstats.table = "filesys" or
-## tblstats.table = "quota"
- if (ingres_errno) return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-
-/** set_pop_usage - incr/decr usage count for pop server in serverhosts talbe
- **
- ** Inputs:
- ** id of machine
- ** delta (will be +/- 1)
- **
- ** Description:
- ** - incr/decr value field in serverhosts table for pop/mach_id
- **
- **/
-
-static int set_pop_usage(id, count)
-int id;
-int count;
-##{
-## int mach_id = id;
-## int n = count;
-
-## repeat replace serverhosts (value1 = serverhosts.value1 + @n)
-## where serverhosts.service = "POP" and serverhosts.#mach_id = @mach_id
-
- if (ingres_errno) return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-\f
-/* Validation Routines */
-
-validate_row(q, argv, v)
- register struct query *q;
- char *argv[];
- register struct validate *v;
-##{
-## char *rvar;
-## char *table;
-## char *name;
-## char qual[128];
-## int rowcount;
-
- /* build where clause */
- build_qual(v->qual, v->argc, argv, qual);
-
- /* setup ingres variables */
- rvar = q->rvar;
- table = q->rtable;
- name = v->field;
-
- if (log_flags & LOG_VALID)
- /* tell the logfile what we're doing */
- com_err(whoami, 0, "validating row: %s", qual);
-
- /* look for the record */
-## range of rvar is table
-## retrieve (rowcount = count(rvar.name where qual))
- if (ingres_errno) return(mr_errcode);
- if (rowcount == 0) return(MR_NO_MATCH);
- if (rowcount > 1) return(MR_NOT_UNIQUE);
- return(MR_EXISTS);
-##}
-
-validate_fields(q, argv, vo, n)
- struct query *q;
- register char *argv[];
- register struct valobj *vo;
- register int n;
-{
- register int status;
-
- while (--n >= 0) {
- switch (vo->type) {
- case V_NAME:
- if (log_flags & LOG_VALID)
- com_err(whoami, 0, "validating %s in %s: %s",
- vo->namefield, vo->table, argv[vo->index]);
- status = validate_name(argv, vo);
- break;
-
- case V_ID:
- if (log_flags & LOG_VALID)
- com_err(whoami, 0, "validating %s in %s: %s",
- vo->idfield, vo->table, argv[vo->index]);
- status = validate_id(argv, vo);
- break;
-
- case V_DATE:
- if (log_flags & LOG_VALID)
- com_err(whoami, 0, "validating date: %s", argv[vo->index]);
- status = validate_date(argv, vo);
- break;
-
- case V_TYPE:
- if (log_flags & LOG_VALID)
- com_err(whoami, 0, "validating %s type: %s",
- vo->table, argv[vo->index]);
- status = validate_type(argv, vo);
- break;
-
- case V_TYPEDATA:
- if (log_flags & LOG_VALID)
- com_err(whoami, 0, "validating typed data (%s): %s",
- argv[vo->index - 1], argv[vo->index]);
- status = validate_typedata(q, argv, vo);
- break;
-
- case V_RENAME:
- if (log_flags & LOG_VALID)
- com_err(whoami, 0, "validating rename %s in %s",
- argv[vo->index], vo->table);
- status = validate_rename(argv, vo);
- break;
-
- case V_CHAR:
- if (log_flags & LOG_VALID)
- com_err(whoami, 0, "validating chars: %s", argv[vo->index]);
- status = validate_chars(argv[vo->index]);
- break;
-
- case V_SORT:
- status = MR_EXISTS;
- break;
-
- case V_LOCK:
- status = lock_table(vo);
- break;
- }
-
- if (status != MR_EXISTS) return(status);
- vo++;
- }
-
- if (ingres_errno) return(mr_errcode);
- return(MR_SUCCESS);
-}
-
-
-/* validate_chars: verify that there are no illegal characters in
- * the string. Legal characters are printing chars other than
- * ", *, ?, \, [ and ].
- */
-static int illegalchars[] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ^@ - ^O */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ^P - ^_ */
- 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* SPACE - / */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /* 0 - ? */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ - O */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, /* P - _ */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ` - o */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /* p - ^? */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-};
-
-validate_chars(s)
-register char *s;
-{
- while (*s)
- if (illegalchars[*s++])
- return(MR_BAD_CHAR);
- return(MR_EXISTS);
-}
-
-
-validate_id(argv, vo)
- char *argv[];
- register struct valobj *vo;
-##{
-## char *name;
-## char *table;
-## char *namefield;
-## char *idfield;
-## int id, rowcount;
- int status;
- register char *c;
-
-
- name = argv[vo->index];
- table = vo->table;
- namefield = vo->namefield;
- idfield = vo->idfield;
-
- if ((!strcmp(table, "users") && !strcmp(namefield, "login")) ||
- !strcmp(table, "machine") ||
- !strcmp(table, "filesys") ||
- !strcmp(table, "list") ||
- !strcmp(table, "cluster") ||
- !strcmp(table, "string")) {
- if (!strcmp(table, "machine"))
- for (c = name; *c; c++) if (islower(*c)) *c = toupper(*c);
- status = name_to_id(name, table, &id);
- if (status == 0) {
- *(int *)argv[vo->index] = id;
- return(MR_EXISTS);
- } else if (status == MR_NO_MATCH || status == MR_NOT_UNIQUE)
- return(vo->error);
- else
- return(status);
- }
-
- if (!strcmp(namefield, "uid")) {
-## retrieve (id = table.idfield) where table.namefield = int4(name)
- if (ingres_errno) return(mr_errcode);
-## inquire_equel (rowcount = "rowcount")
- } else {
-## retrieve (id = table.idfield) where table.namefield = name
- if (ingres_errno) return(mr_errcode);
-## inquire_equel (rowcount = "rowcount")
- }
- if (rowcount != 1) return(vo->error);
- *(int *)argv[vo->index] = id;
- return(MR_EXISTS);
-##}
-
-validate_name(argv, vo)
- char *argv[];
- register struct valobj *vo;
-##{
-## char *name;
-## char *table;
-## char *namefield;
-## int rowcount;
- register char *c;
-
- name = argv[vo->index];
- table = vo->table;
- namefield = vo->namefield;
- if (!strcmp(table, "servers") && !strcmp(namefield, "name")) {
- for (c = name; *c; c++)
- if (islower(*c))
- *c = toupper(*c);
- }
-## retrieve (rowcount = countu(table.namefield
-## where table.namefield = name))
- if (ingres_errno) return(mr_errcode);
- return ((rowcount == 1) ? MR_EXISTS : vo->error);
-##}
-
-validate_date(argv, vo)
- char *argv[];
- struct valobj *vo;
-##{
-## char *idate;
-## double dd;
-## int errorno;
-
- idate = argv[vo->index];
-
-## retrieve (dd = interval("years", date(idate) - date("today")))
-## inquire_equel (errorno = "errorno")
- if (errorno != 0 || dd > 5.0) return(MR_DATE);
- return(MR_EXISTS);
-##}
-
-
-validate_rename(argv, vo)
-char *argv[];
-struct valobj *vo;
-##{
-## char *name, *table, *namefield, *idfield;
-## int id;
- int status;
- register char *c;
-
- c = name = argv[vo->index];
- while (*c)
- if (illegalchars[*c++])
- return(MR_BAD_CHAR);
- table = vo->table;
- /* minor kludge to upcasify machine names */
- if (!strcmp(table, "machine"))
- for (c = name; *c; c++) if (islower(*c)) *c = toupper(*c);
- namefield = vo->namefield;
- idfield = vo->idfield;
- id = -1;
- if (idfield == 0) {
- if (!strcmp(argv[vo->index], argv[vo->index - 1]))
- return(MR_EXISTS);
-## retrieve (id = any(table.namefield where table.namefield = name))
- if (ingres_errno) return(mr_errcode);
- if (id)
- return(vo->error);
- else
- return(MR_EXISTS);
- }
- status = name_to_id(name, table, &id);
- if (status == MR_NO_MATCH || id == *(int *)argv[vo->index - 1])
- return(MR_EXISTS);
- else
- return(vo->error);
-##}
-
-
-validate_type(argv, vo)
- char *argv[];
- register struct valobj *vo;
-##{
-## char *typename;
-## char *value;
-## int exists;
- register char *c;
-
- typename = vo->table;
- c = value = argv[vo->index];
- while (*c)
- if (illegalchars[*c++])
- return(MR_BAD_CHAR);
-
- /* uppercase type fields */
- for (c = value; *c; c++) if (islower(*c)) *c = toupper(*c);
-
-## repeat retrieve (exists = any(alias.trans where alias.name = @typename and
-## alias.type = "TYPE" and alias.trans = @value))
- if (ingres_errno) return(mr_errcode);
- return (exists ? MR_EXISTS : vo->error);
-##}
-
-/* validate member or type-specific data field */
-
-validate_typedata(q, argv, vo)
- register struct query *q;
- register char *argv[];
- register struct valobj *vo;
-##{
-## char *name;
-## char *field_type;
-## char data_type[129];
-## int id, rowcount;
- int status;
- char *index();
- register char *c;
-
- /* get named object */
- name = argv[vo->index];
-
- /* get field type string (known to be at index-1) */
- field_type = argv[vo->index-1];
-
- /* get corresponding data type associated with field type name */
-## repeat retrieve (data_type = alias.trans)
-## where alias.#name = @field_type and alias.type = "TYPEDATA"
- if (ingres_errno) return(mr_errcode);
-## inquire_equel (rowcount = "rowcount")
- if (rowcount != 1) return(MR_TYPE);
-
- /* now retrieve the record id corresponding to the named object */
- if (index(data_type, ' '))
- *index(data_type, ' ') = 0;
- if (!strcmp(data_type, "user")) {
- /* USER */
- status = name_to_id(name, data_type, &id);
- if (status && (status == MR_NO_MATCH || status == MR_NOT_UNIQUE))
- return(MR_USER);
- if (status) return(status);
- } else if (!strcmp(data_type, "list")) {
- /* LIST */
- status = name_to_id(name, data_type, &id);
- if (status && status == MR_NOT_UNIQUE)
- return(MR_LIST);
- if (status == MR_NO_MATCH) {
- /* if idfield is non-zero, then if argv[0] matches the string
- * that we're trying to resolve, we should get the value of
- * values.[idfield] for the id.
- */
- if (vo->idfield && !strcmp(argv[0], argv[vo->index])) {
- set_next_object_id(q->validate->object_id, q->rtable);
- name = vo->idfield;
-## repeat retrieve (id = values.value) where values.#name = @name
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1) return(MR_LIST);
- } else
- return(MR_LIST);
- } else if (status) return(status);
- } else if (!strcmp(data_type, "machine")) {
- /* MACHINE */
- for (c = name; *c; c++) if (islower(*c)) *c = toupper(*c);
- status = name_to_id(name, data_type, &id);
- if (status && (status == MR_NO_MATCH || status == MR_NOT_UNIQUE))
- return(MR_MACHINE);
- if (status) return(status);
- } else if (!strcmp(data_type, "string")) {
- /* STRING */
- status = name_to_id(name, data_type, &id);
- if (status && status == MR_NOT_UNIQUE)
- return(MR_STRING);
- if (status == MR_NO_MATCH) {
- if (q->type != APPEND && q->type != UPDATE) return(MR_STRING);
-## retrieve (id = values.value) where values.#name = "strings_id"
- id++;
-## replace values (value = id) where values.#name = "strings_id"
-## append to strings (string_id = id, string = name)
- } else if (status) return(status);
- } else if (!strcmp(data_type, "none")) {
- id = 0;
- } else {
- return(MR_TYPE);
- }
-
- /* now set value in argv */
- *(int *)argv[vo->index] = id;
-
- return (MR_EXISTS);
-##}
-
-
-/* Lock the table named by the validation object */
-
-lock_table(vo)
-struct valobj *vo;
-##{
-## char *table, *idfield;
-## int rowcount;
-
- table = vo->table;
- idfield = vo->idfield;
-## replace table (modtime = "now") where table.idfield = 0
- if (ingres_errno) return(mr_errcode);
-## inquire_equel (rowcount = "rowcount")
- if (rowcount != 1)
- return(vo->error);
- else
- return(MR_EXISTS);
-##}
-
-
-/* Check the database at startup time. For now this just resets the
- * inprogress flags that the DCM uses.
- */
-
-sanity_check_database()
-##{
-##}
+++ /dev/null
-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- *
- */
-
-#ifndef lint
-static char *rcsid_qsupport_dc = "$Header$";
-#endif lint
-
-#include <mit-copyright.h>
-#include <unistd.h>
-#include "query.h"
-#include "mr_server.h"
-#include <ctype.h>
-EXEC SQL INCLUDE sqlca;
-EXEC SQL INCLUDE sqlda;
-#include "qrtn.h"
-
-extern char *whoami;
-extern int ingres_errno, mr_errcode;
-
-EXEC SQL BEGIN DECLARE SECTION;
-extern char stmt_buf[];
-EXEC SQL END DECLARE SECTION;
-
-EXEC SQL WHENEVER SQLERROR CALL ingerr;
-
-#ifdef _DEBUG_MALLOC_INC
-#undef index
-#define dbg_index(str1,c) DBindex(__FILE__, __LINE__, str1, c)
-#else
-#define dbg_index index
-#endif
-
-/* Validation Routines */
-
-validate_row(q, argv, v)
- register struct query *q;
- char *argv[];
- register struct validate *v;
-{
- EXEC SQL BEGIN DECLARE SECTION;
- char *name;
- char qual[128];
- int rowcount;
- EXEC SQL END DECLARE SECTION;
-
- /* build where clause */
- build_qual(v->qual, v->argc, argv, qual);
-
- if (log_flags & LOG_VALID)
- /* tell the logfile what we're doing */
- com_err(whoami, 0, "validating row: %s", qual);
-
- /* look for the record */
- sprintf(stmt_buf,"SELECT COUNT (*) FROM %s WHERE %s",q->rtable,qual);
- EXEC SQL PREPARE stmt INTO :SQLDA USING NAMES FROM :stmt_buf;
- if(sqlca.sqlcode)
- return(MR_INTERNAL);
- EXEC SQL DECLARE csr126 CURSOR FOR stmt;
- EXEC SQL OPEN csr126;
- EXEC SQL FETCH csr126 USING DESCRIPTOR :SQLDA;
- EXEC SQL CLOSE csr126;
- rowcount = *(int *)SQLDA->sqlvar[0].sqldata;
-
- if (ingres_errno) return(mr_errcode);
- if (rowcount == 0) return(MR_NO_MATCH);
- if (rowcount > 1) return(MR_NOT_UNIQUE);
- return(MR_EXISTS);
-}
-
-validate_fields(q, argv, vo, n)
- struct query *q;
- register char *argv[];
- register struct valobj *vo;
- register int n;
-{
- register int status;
-
- while (--n >= 0) {
- switch (vo->type) {
- case V_NAME:
- if (log_flags & LOG_VALID)
- com_err(whoami, 0, "validating %s in %s: %s",
- vo->namefield, vo->table, argv[vo->index]);
- status = validate_name(argv, vo);
- break;
-
- case V_ID:
- if (log_flags & LOG_VALID)
- com_err(whoami, 0, "validating %s in %s: %s",
- vo->idfield, vo->table, argv[vo->index]);
- status = validate_id(q, argv, vo);
- break;
-
- case V_DATE:
- if (log_flags & LOG_VALID)
- com_err(whoami, 0, "validating date: %s", argv[vo->index]);
- status = validate_date(argv, vo);
- break;
-
- case V_TYPE:
- if (log_flags & LOG_VALID)
- com_err(whoami, 0, "validating %s type: %s",
- vo->table, argv[vo->index]);
- status = validate_type(argv, vo);
- break;
-
- case V_TYPEDATA:
- if (log_flags & LOG_VALID)
- com_err(whoami, 0, "validating typed data (%s): %s",
- argv[vo->index - 1], argv[vo->index]);
- status = validate_typedata(q, argv, vo);
- break;
-
- case V_RENAME:
- if (log_flags & LOG_VALID)
- com_err(whoami, 0, "validating rename %s in %s",
- argv[vo->index], vo->table);
- status = validate_rename(argv, vo);
- break;
-
- case V_CHAR:
- if (log_flags & LOG_VALID)
- com_err(whoami, 0, "validating chars: %s", argv[vo->index]);
- status = validate_chars(argv[vo->index]);
- break;
-
- case V_SORT:
- status = MR_EXISTS;
- break;
-
- case V_LOCK:
- status = lock_table(vo);
- break;
-
- case V_RLOCK:
- status = readlock_table(vo);
- break;
- case V_WILD:
- status = convert_wildcards(argv[vo->index]);
- break;
-
- case V_UPWILD:
- status = convert_wildcards_uppercase(argv[vo->index]);
- break;
-
- }
-
- if (status != MR_EXISTS){
- com_err(whoami,0,"validation failed type=%ld, code=%ld\n",vo->type, status);
- return(status);
- }
- vo++;
- }
-
- if (ingres_errno) return(mr_errcode);
- return(MR_SUCCESS);
-}
-
-
-/* validate_chars: verify that there are no illegal characters in
- * the string. Legal characters are printing chars other than
- * ", *, ?, \, [ and ].
- */
-static int illegalchars[] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ^@ - ^O */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ^P - ^_ */
- 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* SPACE - / */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /* 0 - ? */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* : - O */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, /* P - _ */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ` - o */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /* p - ^? */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-};
-
-validate_chars(s)
-register char *s;
-{
- while (*s)
- if (illegalchars[*s++])
- return(MR_BAD_CHAR);
- return(MR_EXISTS);
-}
-
-
-validate_id(q, argv, vo)
- struct query *q;
- char *argv[];
- register struct valobj *vo;
-{
- EXEC SQL BEGIN DECLARE SECTION;
- char *name, *tbl, *namefield, *idfield;
- int id, rowcount;
- EXEC SQL END DECLARE SECTION;
- int status;
- register char *c;
-
- name = argv[vo->index];
- tbl = vo->table;
- namefield = vo->namefield;
- idfield = vo->idfield;
-
- if ((!strcmp(tbl, "users") && !strcmp(namefield, "login")) ||
- !strcmp(tbl, "machine") ||
- !strcmp(tbl, "subnet") ||
- !strcmp(tbl, "filesys") ||
- !strcmp(tbl, "list") ||
- !strcmp(tbl, "cluster") ||
- !strcmp(tbl, "strings")) {
- if (!strcmp(tbl, "machine") || !strcmp(tbl, "subnet"))
- for (c = name; *c; c++) if (islower(*c)) *c = toupper(*c);
- status = name_to_id(name, tbl, &id);
- if (status == 0) {
- *(int *)argv[vo->index] = id;
- return(MR_EXISTS);
- } else if (status == MR_NO_MATCH && !strcmp(tbl, "strings") &&
- (q->type == APPEND || q->type == UPDATE)) {
- id=add_string(name);
- cache_entry(name, "STRING", id);
- *(int *)argv[vo->index] = id;
- return(MR_EXISTS);
- } else if (status == MR_NO_MATCH || status == MR_NOT_UNIQUE)
- return(vo->error);
- else
- return(status);
- }
-
- if (!strcmp(namefield, "uid")) {
- sprintf(stmt_buf,"SELECT %s FROM %s WHERE %s = %s",idfield,tbl,namefield,name);
- } else {
- sprintf(stmt_buf,"SELECT %s FROM %s WHERE %s = '%s'",idfield,tbl,namefield,name);
- }
- EXEC SQL PREPARE stmt INTO :SQLDA USING NAMES FROM :stmt_buf;
- if(sqlca.sqlcode)
- return(MR_INTERNAL);
- EXEC SQL DECLARE csr127 CURSOR FOR stmt;
- EXEC SQL OPEN csr127;
- rowcount=0;
- EXEC SQL FETCH csr127 USING DESCRIPTOR :SQLDA;
- if(sqlca.sqlcode == 0) {
- rowcount++;
- EXEC SQL FETCH csr127 USING DESCRIPTOR :SQLDA;
- if(sqlca.sqlcode == 0) rowcount++;
- }
- EXEC SQL CLOSE csr127;
- if (ingres_errno)
- return(mr_errcode);
-
- if (rowcount != 1) return(vo->error);
- bcopy(SQLDA->sqlvar[0].sqldata,argv[vo->index],sizeof(int));
- return(MR_EXISTS);
-}
-
-validate_name(argv, vo)
- char *argv[];
- register struct valobj *vo;
-{
- EXEC SQL BEGIN DECLARE SECTION;
- char *name, *tbl, *namefield;
- int rowcount;
- EXEC SQL END DECLARE SECTION;
- register char *c;
-
- name = argv[vo->index];
- tbl = vo->table;
- namefield = vo->namefield;
- if (!strcmp(tbl, "servers") && !strcmp(namefield, "name")) {
- for (c = name; *c; c++)
- if (islower(*c))
- *c = toupper(*c);
- }
- sprintf(stmt_buf,"SELECT DISTINCT COUNT(*) FROM %s WHERE %s.%s = '%s'",
- tbl,tbl,namefield,name);
- EXEC SQL PREPARE stmt INTO :SQLDA USING NAMES FROM :stmt_buf;
- if(sqlca.sqlcode)
- return(MR_INTERNAL);
- EXEC SQL DECLARE csr128 CURSOR FOR stmt;
- EXEC SQL OPEN csr128;
- EXEC SQL FETCH csr128 USING DESCRIPTOR :SQLDA;
- rowcount = *(int *)SQLDA->sqlvar[0].sqldata;
- EXEC SQL CLOSE csr128;
-
- if (ingres_errno) return(mr_errcode);
- return ((rowcount == 1) ? MR_EXISTS : vo->error);
-}
-
-validate_date(argv, vo)
- char *argv[];
- struct valobj *vo;
-{
- EXEC SQL BEGIN DECLARE SECTION;
- char *idate;
- double dd;
- int errorno;
- EXEC SQL END DECLARE SECTION;
-
- idate = argv[vo->index];
- EXEC SQL SELECT interval('years',date(:idate)-date('today')) INTO :dd;
-
- if (sqlca.sqlcode != 0 || dd > 5.0) return(MR_DATE);
- return(MR_EXISTS);
-}
-
-
-validate_rename(argv, vo)
-char *argv[];
-struct valobj *vo;
-{
- EXEC SQL BEGIN DECLARE SECTION;
- char *name, *tbl, *namefield, *idfield;
- int id;
- EXEC SQL END DECLARE SECTION;
- int status;
- register char *c;
-
- c = name = argv[vo->index];
- while (*c)
- if (illegalchars[*c++])
- return(MR_BAD_CHAR);
- tbl = vo->table;
- /* minor kludge to upcasify machine names */
- if (!strcmp(tbl, "machine"))
- for (c = name; *c; c++) if (islower(*c)) *c = toupper(*c);
- namefield = vo->namefield;
- idfield = vo->idfield;
- id = -1;
- if (idfield == 0) {
- if (!strcmp(argv[vo->index], argv[vo->index - 1]))
- return(MR_EXISTS);
- sprintf(stmt_buf,"SELECT %s FROM %s WHERE %s = LEFT('%s',SIZE(%s))",
- namefield,tbl,namefield,name,namefield);
- EXEC SQL PREPARE stmt INTO :SQLDA USING NAMES FROM :stmt_buf;
- if(sqlca.sqlcode)
- return(MR_INTERNAL);
- EXEC SQL DECLARE csr129 CURSOR FOR stmt;
- EXEC SQL OPEN csr129;
- EXEC SQL FETCH csr129 USING DESCRIPTOR :SQLDA;
- if(sqlca.sqlcode == 0) id=1; else id=0;
- EXEC SQL CLOSE csr129;
-
- if (ingres_errno) return(mr_errcode);
- if (id)
- return(vo->error);
- else
- return(MR_EXISTS);
- }
- status = name_to_id(name, tbl, &id);
- if (status == MR_NO_MATCH || id == *(int *)argv[vo->index - 1])
- return(MR_EXISTS);
- else
- return(vo->error);
-}
-
-
-validate_type(argv, vo)
- char *argv[];
- register struct valobj *vo;
-{
- EXEC SQL BEGIN DECLARE SECTION;
- char *typename;
- char *val;
- int cnt;
- EXEC SQL END DECLARE SECTION;
- register char *c;
-
- typename = vo->table;
- c = val = argv[vo->index];
- while (*c) {
- if (illegalchars[*c++])
- return(MR_BAD_CHAR);
- }
-
- /* uppercase type fields */
- for (c = val; *c; c++) if (islower(*c)) *c = toupper(*c);
-
- EXEC SQL SELECT COUNT(trans) INTO :cnt FROM alias
- WHERE name = :typename AND type='TYPE' AND trans = :val;
- if (ingres_errno) return(mr_errcode);
- return (cnt ? MR_EXISTS : vo->error);
-}
-
-/* validate member or type-specific data field */
-
-validate_typedata(q, argv, vo)
- register struct query *q;
- register char *argv[];
- register struct valobj *vo;
-{
- EXEC SQL BEGIN DECLARE SECTION;
- char *name;
- char *field_type;
- char data_type[129];
- int id;
- EXEC SQL END DECLARE SECTION;
- int status;
- register char *c;
-
- /* get named object */
- name = argv[vo->index];
-
- /* get field type string (known to be at index-1) */
- field_type = argv[vo->index-1];
-
- /* get corresponding data type associated with field type name */
- EXEC SQL SELECT trans INTO :data_type FROM alias
- WHERE name = :field_type AND type='TYPEDATA';
- if (ingres_errno) return(mr_errcode);
- if (sqlca.sqlerrd[2] != 1) return(MR_TYPE);
-
- /* now retrieve the record id corresponding to the named object */
- if (dbg_index(data_type, ' '))
- *dbg_index(data_type, ' ') = 0;
- if (!strcmp(data_type, "user")) {
- /* USER */
- if (dbg_index(name, '@'))
- return(MR_USER);
- status = name_to_id(name, data_type, &id);
- if (status && (status == MR_NO_MATCH || status == MR_NOT_UNIQUE))
- return(MR_USER);
- if (status) return(status);
- } else if (!strcmp(data_type, "list")) {
- /* LIST */
- status = name_to_id(name, data_type, &id);
- if (status && status == MR_NOT_UNIQUE)
- return(MR_LIST);
- if (status == MR_NO_MATCH) {
- /* if idfield is non-zero, then if argv[0] matches the string
- * that we're trying to resolve, we should get the value of
- * numvalues.[idfield] for the id.
- */
- if (vo->idfield && !strcmp(argv[0], argv[vo->index])) {
- set_next_object_id(q->validate->object_id, q->rtable, 0);
- name = vo->idfield;
- EXEC SQL REPEATED SELECT value INTO :id FROM numvalues
- WHERE name = :name;
- if (sqlca.sqlerrd[2] != 1) return(MR_LIST);
- } else
- return(MR_LIST);
- } else if (status) return(status);
- } else if (!strcmp(data_type, "machine")) {
- /* MACHINE */
- for (c = name; *c; c++) if (islower(*c)) *c = toupper(*c);
- status = name_to_id(name, data_type, &id);
- if (status && (status == MR_NO_MATCH || status == MR_NOT_UNIQUE))
- return(MR_MACHINE);
- if (status) return(status);
- } else if (!strcmp(data_type, "string")) {
- /* STRING */
- status = name_to_id(name, data_type, &id);
- if (status && status == MR_NOT_UNIQUE)
- return(MR_STRING);
- if (status == MR_NO_MATCH) {
- if (q->type != APPEND && q->type != UPDATE) return(MR_STRING);
- id=add_string(name);
- cache_entry(name, "STRING", id);
- } else if (status) return(status);
- } else if (!strcmp(data_type, "none")) {
- id = 0;
- } else {
- return(MR_TYPE);
- }
-
- /* now set value in argv */
- *(int *)argv[vo->index] = id;
-
- return (MR_EXISTS);
-}
-
-
-/* Lock the table named by the validation object */
-
-lock_table(vo)
-struct valobj *vo;
-{
- sprintf(stmt_buf,"UPDATE %s SET modtime='now' WHERE %s.%s = 0",
- vo->table,vo->table,vo->idfield);
- EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
- if (sqlca.sqlcode == 100){
- fprintf(stderr,"readlock_table: no matching rows found for %s\n",
- stmt_buf);
- return(MR_INTERNAL);
- }
- if (ingres_errno)
- return(mr_errcode);
- if (sqlca.sqlerrd[2] != 1)
- return(vo->error);
- else
- return(MR_EXISTS);
-}
-
-/*
- * Get a read lock on the table by accessing the magic lock
- * record. Certain tables are constructed so that they contain
- * an id field whose value is zero and a modtime field. We
- * manipulate the modtime field of the id 0 record to effect
- * locking of the table
- */
-
-readlock_table(vo)
- struct valobj *vo;
-{
- EXEC SQL BEGIN DECLARE SECTION;
- int id;
- char buf[256];
- char *tbl, *idfield;
- EXEC SQL END DECLARE SECTION;
-
- tbl=vo->table;
- idfield=vo->idfield;
- sprintf(buf,"SELECT %s FROM %s WHERE %s.%s = 0",
- vo->idfield, vo->table, vo->table, vo->idfield);
- EXEC SQL PREPARE stmt FROM :buf;
- EXEC SQL DESCRIBE stmt INTO SQLDA;
- EXEC SQL DECLARE rcsr CURSOR FOR stmt;
- EXEC SQL OPEN rcsr;
- EXEC SQL FETCH rcsr USING DESCRIPTOR :SQLDA;
- /* Check for no matching rows found - this is
- * flagged as an internal error since the table should
- * have a magic lock record.
- */
- if (sqlca.sqlcode == 100){
- EXEC SQL CLOSE rcsr;
- com_err(whoami,0,"readlock_table: no matching rows found for %s\n",
- buf);
- return(MR_INTERNAL);
- }
- EXEC SQL CLOSE rcsr;
- if (ingres_errno)
- return(mr_errcode);
- if (sqlca.sqlcode)
- return(vo->error);
- return(MR_EXISTS); /* validate_fields expects us to return
- * this value if everything went okay
- */
-}
-
-/* Check the database at startup time. For now this just resets the
- * inprogress flags that the DCM uses.
- */
-
-sanity_check_database()
-{
-}
-
-
-/* Dynamic SQL support routines */
-MR_SQLDA_T *mr_alloc_SQLDA()
-{
- MR_SQLDA_T *it;
- short *null_indicators;
- register int j;
-
- if((it=(MR_SQLDA_T *)malloc(sizeof(MR_SQLDA_T)))==NULL) {
- com_err(whoami, MR_NO_MEM, "setting up SQLDA");
- exit(1);
- }
-
- if((null_indicators=(short *)calloc(QMAXARGS,sizeof(short)))==NULL) {
- com_err(whoami, MR_NO_MEM, "setting up SQLDA null indicators");
- exit(1);
- }
-
- for(j=0; j<QMAXARGS; j++) {
- if((it->sqlvar[j].sqldata=(char *)malloc(sizeof(short)+ARGLEN))==NULL) {
- com_err(whoami, MR_NO_MEM, "setting up SQLDA variables");
- exit(1);
- }
- it->sqlvar[j].sqllen=ARGLEN;
- it->sqlvar[j].sqlind=null_indicators+j;
- null_indicators[j]=0;
- }
- it->sqln=QMAXARGS;
- return it;
-}
-
-
-/* Use this after FETCH USING DESCRIPTOR one or more
- * result columns may contain NULLs. This routine is
- * not currently needed, since db/schema creates all
- * columns with a NOT NULL WITH DEFAULT clause.
- *
- * This is currently dead flesh, since no Moira columns
- * allow null values; all use default values.
- */
-mr_fix_nulls_in_SQLDA(da)
- MR_SQLDA_T *da;
-{
- register IISQLVAR *var;
- register int j;
- int *intp;
-
- for(j=0, var=da->sqlvar; j<da->sqld; j++, var++) {
- switch(var->sqltype) {
- case -IISQ_CHA_TYPE:
- if(*var->sqlind)
- *var->sqldata='\0';
- break;
- case -IISQ_INT_TYPE:
- if(*var->sqlind) {
- intp=(int *)var->sqldata;
- *intp=0;
- }
- break;
- }
- }
-}
-
-/* Convert normal Unix-style wildcards to SQL voodoo */
-convert_wildcards(arg)
- char *arg;
-{
- static char buffer[ARGLEN];
- register char *s, *d;
-
- for(d=buffer,s=arg;*s;s++) {
- switch(*s) {
- case '*': *d++='%'; *d++='%'; break;
- case '?': *d++='_'; break;
- case '_':
- case '[':
- case ']': *d++='*'; *d++ = *s; break;
- case '%': *d++='*'; *d++='%'; *d++='%'; break;
- default: *d++ = *s; break;
- }
- }
- *d='\0';
-
- /* Copy back into argv */
- strcpy(arg,buffer);
-
- return(MR_EXISTS);
-}
-
-/* This version includes uppercase conversion, for things like gmac.
- * This is necessary because "LIKE" doesn't work with "uppercase()".
- * Including it in a wildcard routine saves making two passes over
- * the argument string.
- */
-convert_wildcards_uppercase(arg)
- char *arg;
-{
- static char buffer[ARGLEN];
- register char *s, *d;
-
- for(d=buffer,s=arg;*s;s++) {
- switch(*s) {
- case '*': *d++='%'; *d++='%'; break;
- case '?': *d++='_'; break;
- case '_':
- case '[':
- case ']': *d++='*'; *d++ = *s; break;
- case '%': *d++='*'; *d++='%'; *d++='%'; break;
- default: *d++=toupper(*s); break; /* This is the only diff. */
- }
- }
- *d='\0';
-
- /* Copy back into argv */
- strcpy(arg,buffer);
-
- return(MR_EXISTS);
-}
-
-
-/* Looks like it's time to build an abstraction barrier, Yogi */
-mr_select_any(stmt)
- EXEC SQL BEGIN DECLARE SECTION;
- char *stmt;
- EXEC SQL END DECLARE SECTION;
-{
- int result=0;
-
- EXEC SQL PREPARE stmt FROM :stmt;
- EXEC SQL DESCRIBE stmt INTO :SQLDA;
- if(SQLDA->sqld==0) /* Not a SELECT */
- return(MR_INTERNAL);
- EXEC SQL DECLARE csr CURSOR FOR stmt;
- EXEC SQL OPEN csr;
- EXEC SQL FETCH csr USING DESCRIPTOR :SQLDA;
- if(sqlca.sqlcode==0)
- result=MR_EXISTS;
- else if((sqlca.sqlcode<0) && mr_errcode)
- result=mr_errcode;
- else
- result=0;
- EXEC SQL CLOSE csr;
- return(result);
-}
-
-
-
-/* Adds a string to the string table. Returns the id number.
- *
- */
-int add_string(name)
- EXEC SQL BEGIN DECLARE SECTION;
- char *name;
- EXEC SQL END DECLARE SECTION;
-{
- EXEC SQL BEGIN DECLARE SECTION;
- char buf[256];
- int id;
- EXEC SQL END DECLARE SECTION;
-
- EXEC SQL SELECT value INTO :id FROM numvalues WHERE name = 'strings_id';
- id++;
- EXEC SQL UPDATE numvalues SET value = :id WHERE name = 'strings_id';
-
- /* Use sprintf to get around problem with doubled single quotes */
- sprintf(buf,"INSERT INTO strings (string_id, string) VALUES (%d, '%s')",id,name);
- EXEC SQL EXECUTE IMMEDIATE :buf;
-
- return(id);
-}
-
+++ /dev/null
-/* $Header$
- *
- * Structures and constants used by SQL related code
- */
-
-/* SQL character string constants .. */
-#define SQL_STR 256
-#define SQL_LONG_STR 1024
-#define SQL_MAX_STR_LEN 16383
-
-/* SQL table related constants */
-#define SQL_MAX_COLUMS 128
-
+++ /dev/null
-#
-# $Source$
-# $Header$
-#
-
-#
-# Makefile for 'update' directory.
-#
-# (c) Copyright 1988 by the Massachusetts Institute of Technology.
-# For copying and distribution information, please see the file
-# <mit-copyright.h>.
-
-CC= cc
-INCS= -I../include
-DEFS=
-CFLAGS= -g ${INCS} ${DEFS}
-LINTFLAGS= ${INCS}
-LDFLAGS= -x
-
-# server object files
-SOBJS= update_server.o auth_001.o inst_001.o xfer_002.o exec_002.o \
- hostname.o log.o get_file.o checksum.o
-
-# client object files
-COBJS= client.o ticket.o send_file.o checksum.o hostname.o
-
-SSRCS= update_server.c auth_001.c inst_001.c xfer_002.c exec_002.c \
- hostname.c log.c get_file.c checksum.c
-
-CSRCS= client.c ticket.c send_file.c checksum.c hostname.c
-
-LIBS= -L../lib -lmoira -lgdb -lkrb -ldes -lcom_err
-
-all: moira_update.o update_server
-
-update_server: ${SOBJS}
- cc ${CFLAGS} -o update_server ${SOBJS} ${LIBS}
-
-moira_update.o: ${COBJS}
- ld -r -o moira_update.o ${COBJS}
-
-
-clean:
- -rm -f ${COBJS} ${SOBJS}
- -rm -f update_server moira_update.o
- -rm -f core a.out *~ \#*
-
-install: update_server
- install -c -s update_server ${DESTDIR}/usr/etc/update_server
-
-lint:
- lint ${LINTFLAGS} ${SSRCS}
- lint ${LINTFLAGS} ${CSRCS}
-
-smskey: smskey.c
- ${CC} ${CFLAGS} -o smskey smskey.c -ldes
-
-depend:
- mkdep ${CFLAGS} ${SSRCS} ${CSRCS}
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-
-update_server.o: update_server.c ../include/mit-copyright.h
-update_server.o: /usr/include/stdio.h ../include/gdb.h
-update_server.o: /usr/include/sys/types.h /usr/include/sys/time.h
-update_server.o: /usr/include/sys/time.h /usr/include/errno.h
-update_server.o: /usr/include/strings.h ../include/moira.h ../include/mr_et.h
-update_server.o: /usr/include/sys/file.h /usr/include/sys/ioctl.h
-update_server.o: /usr/include/sys/ttychars.h /usr/include/sys/ttydev.h
-update_server.o: ../include/update.h
-auth_001.o: auth_001.c ../include/mit-copyright.h /usr/include/stdio.h
-auth_001.o: /usr/include/strings.h ../include/gdb.h /usr/include/sys/types.h
-auth_001.o: /usr/include/sys/time.h /usr/include/sys/time.h ../include/krb.h
-auth_001.o: ../include/des.h ../include/krb_et.h /usr/include/netinet/in.h
-auth_001.o: /usr/include/errno.h
-inst_001.o: inst_001.c ../include/mit-copyright.h /usr/include/stdio.h
-inst_001.o: ../include/gdb.h /usr/include/sys/types.h /usr/include/sys/time.h
-inst_001.o: /usr/include/sys/time.h
-xfer_002.o: xfer_002.c ../include/mit-copyright.h /usr/include/stdio.h
-xfer_002.o: ../include/gdb.h /usr/include/sys/types.h /usr/include/sys/time.h
-xfer_002.o: /usr/include/sys/time.h /usr/include/ctype.h
-xfer_002.o: /usr/include/sys/param.h /usr/include/machine/machparam.h
-xfer_002.o: /usr/include/sys/signal.h /usr/include/sys/file.h
-xfer_002.o: /usr/include/strings.h ../include/moira.h ../include/mr_et.h
-exec_002.o: exec_002.c ../include/mit-copyright.h /usr/include/stdio.h
-exec_002.o: /usr/include/sys/wait.h /usr/include/sys/signal.h
-exec_002.o: ../include/gdb.h /usr/include/sys/types.h /usr/include/sys/time.h
-exec_002.o: /usr/include/sys/time.h ../include/moira.h ../include/mr_et.h
-exec_002.o: ../include/update.h
-hostname.o: hostname.c ../include/mit-copyright.h /usr/include/stdio.h
-hostname.o: /usr/include/sys/types.h /usr/include/netinet/in.h
-hostname.o: /usr/include/netdb.h /usr/include/ctype.h /usr/include/strings.h
-log.o: log.c ../include/mit-copyright.h /usr/include/stdio.h
-log.o: ../include/com_err.h /usr/include/varargs.h ../include/update.h
-log.o: ../include/krb.h ../include/des.h
-get_file.o: get_file.c ../include/mit-copyright.h /usr/include/stdio.h
-get_file.o: ../include/gdb.h /usr/include/sys/types.h /usr/include/sys/time.h
-get_file.o: /usr/include/sys/time.h /usr/include/ctype.h
-get_file.o: /usr/include/sys/param.h /usr/include/machine/machparam.h
-get_file.o: /usr/include/sys/signal.h /usr/include/sys/file.h
-get_file.o: ../include/moira.h ../include/mr_et.h ../include/update.h
-checksum.o: checksum.c ../include/mit-copyright.h /usr/include/stdio.h
-checksum.o: /usr/include/sys/file.h
-client.o: client.c ../include/mit-copyright.h /usr/include/stdio.h
-client.o: /usr/include/strings.h ../include/gdb.h /usr/include/sys/types.h
-client.o: /usr/include/sys/time.h /usr/include/sys/time.h
-client.o: /usr/include/sys/param.h /usr/include/machine/machparam.h
-client.o: /usr/include/sys/signal.h /usr/include/sys/wait.h
-client.o: /usr/include/sys/socket.h ../include/update.h /usr/include/errno.h
-client.o: ../include/dcm.h ../include/moira.h ../include/mr_et.h
-client.o: ../include/moira_site.h ../include/krb.h ../include/des.h
-ticket.o: ticket.c ../include/mit-copyright.h /usr/include/stdio.h
-ticket.o: ../include/krb.h ../include/des.h /usr/include/sys/types.h
-ticket.o: /usr/include/sys/stat.h /usr/include/strings.h ../include/update.h
-ticket.o: ../include/com_err.h ../include/krb_et.h
-send_file.o: send_file.c ../include/mit-copyright.h /usr/include/stdio.h
-send_file.o: ../include/com_err.h ../include/gdb.h /usr/include/sys/types.h
-send_file.o: /usr/include/sys/time.h /usr/include/sys/time.h ../include/dcm.h
-send_file.o: ../include/moira.h ../include/mr_et.h /usr/include/sys/file.h
-send_file.o: /usr/include/sys/stat.h ../include/update.h
-checksum.o: checksum.c ../include/mit-copyright.h /usr/include/stdio.h
-checksum.o: /usr/include/sys/file.h
-hostname.o: hostname.c ../include/mit-copyright.h /usr/include/stdio.h
-hostname.o: /usr/include/sys/types.h /usr/include/netinet/in.h
-hostname.o: /usr/include/netdb.h /usr/include/ctype.h /usr/include/strings.h
+++ /dev/null
-/* $Header$
- *
- * Reads a tar file from standard input, and extracts the contents as
- * the user specified by uid as an argument.
- *
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- */
-
-#include <mit-copyright.h>
-
-main(argc,argv)
-int argc;
-char **argv;
-{
- if (getuid() != 0) {
- write(2, "You must be root to run sms_untar\n", 34);
- exit(1);
- }
-
- if (argc != 2) {
- write(2, "Usage: sms_untar uid\n", 21);
- write(2, "sms_untar takes a tar file as standard input.\n", 46);
- exit(2);
- }
-
- setuid(atoi(argv[1]));
- execl("/bin/tar", "tar", "xfp", "-", 0);
- write(2, "sms_untar: unable to exec /bin/tar\n", 35);
- exit(3);
-}
--- /dev/null
+#
+# Makefile for error-table routines
+#
+# Copyright 1987, 1989 MIT Student Information Processing Board
+# For copyright info, see mit-sipb-copyright.h.
+#
+# $Header$
+# $Locker$
+#
+
+CFLAGS= -O -I../../include
+LINTFLAGS= -uhvpb
+LINTFILES= error_message.c et_name.c init_et.c com_err.c
+LIBOBJS= error_message.o et_name.o init_et.o com_err.o
+DEPEND=$(BUILDTOP)/util/makedepend/makedepend
+
+BINDIR=/usr/athena
+INCDIR=/usr/include
+LIBDIR=/usr/athena/lib
+DOCDIR=/usr/doc/athena
+DESTDIR=
+
+FILES= Makefile et_name.c error_message.c compile_et.c \
+ error_table.y et_lex.lex.l init_et.c \
+ com_err.c com_err.h \
+ error_table.h mit-sipb-copyright.h \
+ test.c test1.et test2.et \
+ compiler.h internal.h
+
+CFILES= compile_et.c error_table.c error_message.c et_name.c \
+ init_et.c com_err.c
+
+#
+# what to build...
+#
+all: compile_et libcom_err.a
+
+lint: llib-lcom_err.ln
+
+archive: et.tar
+
+doc: com_err.dvi
+
+#
+# rules
+#
+.SUFFIXES: .h .c .et .ps .x9700 .mss .dvi .texinfo
+
+.et.c:
+ ./compile_et $*.et
+
+.et.h:
+ ./compile_et $*.et
+
+.texinfo.dvi:
+ tex $<
+
+.dvi.ps:
+ rm -f $@.new
+ dvi2ps -r $< > $@.new
+ mv $@.new $@
+
+.c.o:
+ ${CC} -c ${CFLAGS} $*.c
+
+#
+# real entries...
+#
+compile_et: compile_et.o error_table.o
+ ${CC} ${CFLAGS} -o compile_et compile_et.o error_table.o -ll
+
+et.tar: ${FILES}
+ rm -f et.tar
+ tar cfrlv et.tar ${FILES}
+
+tags: TAGS
+
+com_err.ps : com_err.dvi
+com_err.dvi: com_err.texinfo
+
+install: all
+# install -c -s compile_et ${DESTDIR}${BINDIR}/compile_et
+# install -c -m 444 com_err.h ${DESTDIR}${INCDIR}/com_err.h
+# install -c -m 444 mit-sipb-copyright.h \
+# ${DESTDIR}${INCDIR}/mit-sipb-copyright.h
+# install -c libcom_err.a ${DESTDIR}${LIBDIR}/libcom_err.a
+# ranlib ${DESTDIR}${LIBDIR}/libcom_err.a
+# install -c libcom_err_p.a ${DESTDIR}${LIBDIR}/libcom_err_p.a
+# ranlib ${DESTDIR}${LIBDIR}/libcom_err_p.a
+# install -c com_err.texinfo ${DESTDIR}${DOCDIR}/com_err.texinfo
+# install -c com_err.3 ${DESTDIR}/usr/man/man3/com_err.3
+# install -c compile_et.1 ${DESTDIR}/usr/man/man1/compile_et.1
+
+config:
+ -mkdir $(DESTDIR)/util/et
+ for i in $(FILES); do \
+ rm -f ${DESTDIR}/util/et/`basename $$i`; \
+ ln -s $(SRCDIR)/util/et/$$i ${DESTDIR}/util/et/`basename $$i`; done
+ rm -f ${DESTDIR}/util/et/Makefile
+ cp ${SRCDIR}/util/et/Makefile ${DESTDIR}/util/et/Makefile
+ chmod 644 ${DESTDIR}/util/et/Makefile
+
+
+TAGS: et_name.c error_message.c compile_et.c error_table.c \
+ lex.yy.c perror.c init_et.c
+ etags et_name.c error_message.c compile_et.c \
+ error_table.c perror.c init_et.c
+
+libcom_err.a: $(LIBOBJS)
+ ar cruv libcom_err.a $(LIBOBJS)
+ ranlib libcom_err.a
+
+libcom_err_p.a: $(LIBOBJS)
+ (cd profiled; ar uv ../libcom_err_p.a $(LIBOBJS); \
+ ranlib ../libcom_err_p.a)
+
+libcom_err.o: $(LIBOBJS)
+ ld -r -s -o libcom_err.o $(LIBOBJS)
+ chmod -x libcom_err.o
+
+llib-lcom_err.ln: $(LINTFILES)
+ lint -Ccom_err $(LINTFLAGS) $(LINTFILES)
+
+clean:
+ rm -f *~ \#* *.bak \
+ *.otl *.aux *.toc *.PS *.dvi *.x9700 *.ps \
+ *.cp *.fn *.ky *.log *.pg *.tp *.vr \
+ *.o profiled/*.o libcom_err.a libcom_err_p.a \
+ com_err.o compile_et \
+ et.ar TAGS y.tab.c lex.yy.c error_table.c \
+ et_lex.lex.c \
+ test1.h test1.c test2.h test2.c test \
+ eddep makedep
+
+# for testing
+test: test.o test1.o test2.o libcom_err.a
+ cc ${CFLAGS} -o test test.o test1.o test2.o libcom_err.a
+test.o: test1.h test2.h
+test1.o : test1.c
+test1.c : test1.et
+test2.o : test2.c
+test2.c : test2.et
+# 'make depend' code
+depend: ${CFILES} et_lex.lex.c
+ @${DEPEND} ${CFLAGS} ${CFILES}
+
+# DO NOT DELETE THIS LINE -- make depend depends on it.
+
+compile_et.o: /usr/include/stdio.h /usr/include/sys/types.h
+compile_et.o: /usr/include/sys/file.h /usr/include/string.h
+compile_et.o: /usr/include/strings.h /usr/include/sys/param.h
+compile_et.o: /usr/include/machine/machparam.h /usr/include/sys/signal.h
+compile_et.o: ../../include/mit-sipb-copyright.h compiler.h
+error_table.o: /usr/include/stdio.h /usr/include/string.h
+error_table.o: /usr/include/strings.h /usr/include/assert.h
+error_table.o: /usr/include/ctype.h /usr/include/sys/types.h
+error_table.o: /usr/include/sys/time.h /usr/include/sys/time.h internal.h
+error_table.o: ../../include/mit-sipb-copyright.h error_table.h et_lex.lex.c
+error_message.o: /usr/include/stdio.h error_table.h
+error_message.o: ../../include/mit-sipb-copyright.h internal.h
+et_name.o: error_table.h ../../include/mit-sipb-copyright.h internal.h
+init_et.o: /usr/include/stdio.h error_table.h
+init_et.o: ../../include/mit-sipb-copyright.h
+com_err.o: /usr/include/stdio.h ../../include/mit-sipb-copyright.h
+com_err.o: /usr/include/varargs.h error_table.h internal.h com_err.h
--- /dev/null
+.\" Copyright (c) 1988 Massachusetts Institute of Technology,
+.\" Student Information Processing Board. All rights reserved.
+.\"
+.\" $Header$
+.\"
+.TH COM_ERR 3 "22 Nov 1988" SIPB
+.SH NAME
+com_err \- common error display routine
+.SH SYNOPSIS
+.nf
+ #include <com_err.h>
+.PP
+void com_err (whoami, code, format, ...);
+ const char *whoami;
+ long code;
+ const char *format;
+.PP
+proc = set_com_err_hook (proc);
+.fi
+void (*
+.I proc
+) (const char *, long, const char *, va_list);
+.nf
+.PP
+proc = reset_com_err_hook ();
+.PP
+void initialize_XXXX_error_table ();
+.fi
+.SH DESCRIPTION
+.I Com_err
+displays an error message on the standard error stream
+.I stderr
+(see
+.IR stdio (3S))
+composed of the
+.I whoami
+string, which should specify the program name or some subportion of
+a program, followed by an error message generated from the
+.I code
+value (derived from
+.IR compile_et (1)),
+and a string produced using the
+.I format
+string and any following arguments, in the same style as
+.IR fprintf (3).
+
+The behavior of
+.I com_err
+can be modified using
+.I set_com_err_hook;
+this defines a procedure which is called with the arguments passed to
+.I com_err,
+instead of the default internal procedure which sends the formatted
+text to error output. Thus the error messages from a program can all
+easily be diverted to another form of diagnostic logging, such as
+.IR syslog (3).
+.I Reset_com_err_hook
+may be used to restore the behavior of
+.I com_err
+to its default form. Both procedures return the previous ``hook''
+value. These ``hook'' procedures must have the declaration given for
+.I proc
+above in the synopsis.
+
+The
+.I initialize_XXXX_error_table
+routine is generated mechanically by
+.IR compile_et (1)
+from a source file containing names and associated strings. Each
+table has a name of up to four characters, which is used in place of
+the
+.B XXXX
+in the name of the routine. These routines should be called before
+any of the corresponding error codes are used, so that the
+.I com_err
+library will recognize error codes from these tables when they are
+used.
+
+The
+.B com_err.h
+header file should be included in any source file that uses routines
+from the
+.I com_err
+library; executable files must be linked using
+.I ``-lcom_err''
+in order to cause the
+.I com_err
+library to be included.
+
+.\" .IR for manual entries
+.\" .PP for paragraph breaks
+
+.SH "SEE ALSO"
+compile_et (1), syslog (3).
+
+Ken Raeburn, "A Common Error Description Library for UNIX".
--- /dev/null
+/*
+ * Copyright 1987, 1988 by MIT Student Information Processing Board.
+ *
+ * For copyright info, see mit-sipb-copyright.h.
+ */
+
+#include <stdio.h>
+#include "mit-sipb-copyright.h"
+
+/*
+ * Our environment only provides for ANSI's <stdarg.h> when using GNU
+ * C. Grump grump...
+ */
+#if ! __GNUC__
+#define VARARGS 1
+#endif
+
+/* We don't have the v*printf routines... */
+#define vfprintf(stream,fmt,args) _doprnt(fmt,args,stream)
+
+#if __STDC__ && !VARARGS
+# include <stdarg.h>
+#else /* varargs: not STDC or no <stdarg> */
+ /* Non-ANSI, always take <varargs.h> path. */
+# undef VARARGS
+# define VARARGS 1
+# include <varargs.h>
+# undef vfprintf
+# define vfprintf(stream,fmt,args) _doprnt(fmt,args,stream)
+#endif /* varargs */
+
+#include "error_table.h"
+#include "internal.h"
+
+/*
+ * Protect us from header version (externally visible) of com_err, so
+ * we can survive in a <varargs.h> environment. I think.
+ */
+#define com_err com_err_external
+#include "com_err.h"
+#undef com_err
+
+/* BSD. sigh. */
+#undef vfprintf
+#define vfprintf(stream,fmt,args) _doprnt(fmt,args,stream)
+
+#if ! lint
+static const char rcsid[] =
+ "$Header$";
+#endif /* ! lint */
+
+static void
+#ifdef __STDC__
+ default_com_err_proc (const char *whoami, long code, const char *fmt, va_list args)
+#else
+ default_com_err_proc (whoami, code, fmt, args)
+ const char *whoami;
+ long code;
+ const char *fmt;
+ va_list args;
+#endif
+{
+ if (whoami) {
+ fputs(whoami, stderr);
+ fputs(": ", stderr);
+ }
+ if (code) {
+ fputs(error_message(code), stderr);
+ fputs(" ", stderr);
+ }
+ if (fmt) {
+ vfprintf (stderr, fmt, args);
+ }
+ putc('\n', stderr);
+ /* should do this only on a tty in raw mode */
+ putc('\r', stderr);
+ fflush(stderr);
+}
+
+#ifdef __STDC__
+typedef void (*errf) (const char *, long, const char *, va_list);
+#else
+typedef void (*errf) ();
+#endif
+
+errf com_err_hook = default_com_err_proc;
+
+void com_err_va (whoami, code, fmt, args)
+ const char *whoami;
+ long code;
+ const char *fmt;
+ va_list args;
+{
+ (*com_err_hook) (whoami, code, fmt, args);
+}
+
+#if ! VARARGS
+void com_err (const char *whoami,
+ long code,
+ const char *fmt, ...)
+{
+#else
+void com_err (va_alist)
+ va_dcl
+{
+ const char *whoami, *fmt;
+ long code;
+#endif
+ va_list pvar;
+
+ if (!com_err_hook)
+ com_err_hook = default_com_err_proc;
+#if VARARGS
+ va_start (pvar);
+ whoami = va_arg (pvar, const char *);
+ code = va_arg (pvar, long);
+ fmt = va_arg (pvar, const char *);
+#else
+ va_start(pvar, fmt);
+#endif
+ com_err_va (whoami, code, fmt, pvar);
+ va_end(pvar);
+}
+
+errf set_com_err_hook (new_proc)
+ errf new_proc;
+{
+ errf x = com_err_hook;
+ if (new_proc)
+ com_err_hook = new_proc;
+ else
+ com_err_hook = default_com_err_proc;
+ return x;
+}
+
+errf reset_com_err_hook () {
+ errf x = com_err_hook;
+ com_err_hook = default_com_err_proc;
+ return x;
+}
--- /dev/null
+/*
+ * Header file for common error description library.
+ *
+ * Copyright 1988, Student Information Processing Board of the
+ * Massachusetts Institute of Technology.
+ *
+ * For copyright and distribution info, see the documentation supplied
+ * with this package.
+ */
+
+#ifndef __COM_ERR_H
+
+#ifdef __STDC__
+#ifndef __HIGHC__ /* gives us STDC but not stdarg */
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+/* ANSI C -- use prototypes etc */
+void com_err (const char *, long, const char *, ...);
+char const *error_message (long);
+void (*com_err_hook) (const char *, long, const char *, va_list);
+void (*set_com_err_hook (void (*) (const char *, long, const char *, va_list)))
+ (const char *, long, const char *, va_list);
+void (*reset_com_err_hook ()) (const char *, long, const char *, va_list);
+#else
+/* no prototypes */
+void com_err ();
+char *error_message ();
+void (*com_err_hook) ();
+void (*set_com_err_hook ()) ();
+void (*reset_com_err_hook ()) ();
+#endif
+
+#define __COM_ERR_H
+#endif /* ! defined(__COM_ERR_H) */
--- /dev/null
+.\" Copyright (c) 1988 Massachusetts Institute of Technology,
+.\" Student Information Processing Board. All rights reserved.
+.\"
+.\" $Header$
+.\"
+.TH COMPILE_ET 1 "22 Nov 1988" SIPB
+.SH NAME
+compile_et \- error table compiler
+.SH SYNOPSIS
+.B compile_et
+file
+.SH DESCRIPTION
+.B Compile_et
+converts a table listing error-code names and associated messages into
+a C source file suitable for use with the
+.IR com_err (3)
+library.
+
+The source file name must end with a suffix of ``.et''; the file
+consists of a declaration supplying the name (up to four characters
+long) of the error-code table:
+
+.B error_table
+.I name
+
+followed by up to 256 entries of the form:
+
+.B error_code
+.I name,
+"
+.I string
+"
+
+and a final
+
+.B end
+
+to indicate the end of the table.
+
+The name of the table is used to construct the name of a subroutine
+.I initialize_XXXX_error_table
+which must be called in order for the
+.I com_err
+library to recognize the error table.
+
+The various error codes defined are assigned sequentially increasing
+numbers (starting with a large number computed as a hash function of
+the name of the table); thus for compatibility it is suggested that
+new codes be added only to the end of an existing table, and that no
+codes be removed from tables.
+
+The names defined in the table are placed into a C header file with
+preprocessor directives defining them as integer constants of up to
+32 bits in magnitude.
+
+A C source file is also generated which should be compiled and linked
+with the object files which reference these error codes; it contains
+the text of the messages and the initialization subroutine. Both C
+files have names derived from that of the original source file, with
+the ``.et'' suffix replaced by ``.c'' and ``.h''.
+
+A ``#'' in the source file is treated as a comment character, and all
+remaining text to the end of the source line will be ignored.
+
+.SH BUGS
+
+Since
+.B compile_et
+uses a very simple parser based on
+.IR yacc (1),
+its error recovery leaves much to be desired.
+
+.\" .IR for manual entries
+.\" .PP for paragraph breaks
+
+.SH "SEE ALSO"
+com_err (3).
+
+Ken Raeburn, "A Common Error Description Library for UNIX".
--- /dev/null
+/*
+ *
+ * Copyright 1986, 1987, 1988
+ * by MIT Student Information Processing Board.
+ *
+ * For copyright info, see "mit-sipb-copyright.h".
+ *
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/file.h>
+#include <string.h>
+#include <sys/param.h>
+#include "mit-sipb-copyright.h"
+#include "compiler.h"
+
+#ifndef __STDC__
+#define const
+#endif
+
+#ifndef lint
+static const char copyright[] =
+ "Copyright 1987,1988 by MIT Student Information Processing Board";
+
+static const char rcsid_compile_et_c[] =
+ "$Header$";
+#endif
+
+extern char *gensym();
+extern char *current_token;
+extern int table_number, current;
+char buffer[BUFSIZ];
+char *table_name = (char *)NULL;
+FILE *hfile, *cfile;
+
+/* C library */
+extern char *malloc();
+extern int errno;
+
+/* lex stuff */
+extern FILE *yyin;
+extern int yylineno;
+
+char * xmalloc (size) unsigned int size; {
+ char * p = malloc (size);
+ if (!p) {
+ perror (whoami);
+ exit (1);
+ }
+ return p;
+}
+
+static int check_arg (str_list, arg) char const *const *str_list, *arg; {
+ while (*str_list)
+ if (!strcmp(arg, *str_list++))
+ return 1;
+ return 0;
+}
+
+static const char *const debug_args[] = {
+ "d",
+ "debug",
+ 0,
+};
+
+static const char *const lang_args[] = {
+ "lang",
+ "language",
+ 0,
+};
+
+static const char *const language_names[] = {
+ "C",
+ "K&R C",
+ "C++",
+ 0,
+};
+
+static const char * const c_src_prolog[] = {
+ "static const char * const text[] = {\n",
+ 0,
+};
+
+static const char * const krc_src_prolog[] = {
+ "#ifdef __STDC__\n",
+ "#define NOARGS void\n",
+ "#else\n",
+ "#define NOARGS\n",
+ "#define const\n",
+ "#endif\n\n",
+ "static const char * const text[] = {\n",
+ 0,
+};
+
+static const char *const struct_def[] = {
+ "struct error_table {\n",
+ " char const * const * msgs;\n",
+ " long base;\n",
+ " int n_msgs;\n",
+ "};\n",
+ "struct et_list {\n",
+ " struct et_list *next;\n",
+ " const struct error_table * table;\n",
+ "};\n",
+ "extern struct et_list *_et_list;\n",
+ "\n", 0,
+};
+
+static const char warning[] =
+ "/*\n * %s:\n * This file is automatically generated; please do not edit it.\n */\n";
+
+/* pathnames */
+char c_file[MAXPATHLEN]; /* output file */
+char h_file[MAXPATHLEN]; /* output */
+
+static void usage () {
+ fprintf (stderr, "%s: usage: %s ERROR_TABLE\n",
+ whoami, whoami);
+ exit (1);
+}
+
+static void dup_err (type, one, two) char const *type, *one, *two; {
+ fprintf (stderr, "%s: multiple %s specified: `%s' and `%s'\n",
+ whoami, type, one, two);
+ usage ();
+}
+
+int main (argc, argv) int argc; char **argv; {
+ char *p, *ename;
+ int len;
+ char const * const *cpp;
+ int got_language = 0;
+
+ /* argument parsing */
+ debug = 0;
+ filename = 0;
+ whoami = argv[0];
+ p = strrchr (whoami, '/');
+ if (p)
+ whoami = p+1;
+ while (argv++, --argc) {
+ char *arg = *argv;
+ if (arg[0] != '-') {
+ if (filename)
+ dup_err ("filenames", filename, arg);
+ filename = arg;
+ }
+ else {
+ arg++;
+ if (check_arg (debug_args, arg))
+ debug++;
+ else if (check_arg (lang_args, arg)) {
+ got_language++;
+ arg = *++argv, argc--;
+ if (!arg)
+ usage ();
+ if (language)
+ dup_err ("languanges", language_names[(int)language], arg);
+#define check_lang(x,y,v) else if (!strcmp(arg,x)||!strcmp(arg,y)) language = v
+ check_lang ("c", "C", lang_C);
+ check_lang ("ansi_c", "ANSI_C", lang_C);
+ check_lang ("ansi-c", "ANSI-C", lang_C);
+ check_lang ("krc", "KRC", lang_KRC);
+ check_lang ("kr_c", "KR_C", lang_KRC);
+ check_lang ("kr-c", "KR-C", lang_KRC);
+ check_lang ("k&r-c", "K&R-C", lang_KRC);
+ check_lang ("k&r_c", "K&R_C", lang_KRC);
+ check_lang ("c++", "C++", lang_CPP);
+ check_lang ("cplusplus", "CPLUSPLUS", lang_CPP);
+ check_lang ("c-plus-plus", "C-PLUS-PLUS", lang_CPP);
+#undef check_lang
+ else {
+ fprintf (stderr, "%s: unknown language name `%s'\n",
+ whoami, arg);
+ fprintf (stderr, "\tpick one of: C K&R-C\n");
+ exit (1);
+ }
+ }
+ else {
+ fprintf (stderr, "%s: unknown control argument -`%s'\n",
+ whoami, arg);
+ usage ();
+ }
+ }
+ }
+ if (!filename)
+ usage ();
+ if (!got_language)
+ language = lang_KRC;
+ else if (language == lang_CPP) {
+ fprintf (stderr, "%s: Sorry, C++ support is not yet finished.\n",
+ whoami);
+ exit (1);
+ }
+
+ p = xmalloc (strlen (filename) + 5);
+ strcpy (p, filename);
+ filename = p;
+ p = strrchr(filename, '/');
+ if (p == (char *)NULL)
+ p = filename;
+ else
+ p++;
+ ename = p;
+ len = strlen (ename);
+ p += len - 3;
+ if (strcmp (p, ".et"))
+ p += 3;
+ *p++ = '.';
+ /* now p points to where "et" suffix should start */
+ /* generate new filenames */
+ strcpy (p, "c");
+ strcpy (c_file, ename);
+ *p = 'h';
+ strcpy (h_file, ename);
+ strcpy (p, "et");
+
+ yyin = fopen(filename, "r");
+ if (!yyin) {
+ perror(filename);
+ exit(1);
+ }
+
+ hfile = fopen(h_file, "w");
+ if (hfile == (FILE *)NULL) {
+ perror(h_file);
+ exit(1);
+ }
+ fprintf (hfile, warning, h_file);
+
+ cfile = fopen(c_file, "w");
+ if (cfile == (FILE *)NULL) {
+ perror(c_file);
+ exit(1);
+ }
+ fprintf (cfile, warning, c_file);
+
+ /* prologue */
+ if (language == lang_C)
+ cpp = c_src_prolog;
+ else if (language == lang_KRC)
+ cpp = krc_src_prolog;
+ else
+ abort ();
+ while (*cpp)
+ fputs (*cpp++, cfile);
+
+ /* parse it */
+ yyparse();
+ fclose(yyin); /* bye bye input file */
+
+ fputs (" 0\n};\n\n", cfile);
+ for (cpp = struct_def; *cpp; cpp++)
+ fputs (*cpp, cfile);
+ fprintf(cfile,
+ "static const struct error_table et = { text, %ldL, %d };\n\n",
+ table_number, current);
+ fputs("static struct et_list link = { 0, 0 };\n\n",
+ cfile);
+ fprintf(cfile, "void initialize_%s_error_table (%s) {\n",
+ table_name, (language == lang_C) ? "void" : "NOARGS");
+ fputs(" if (!link.table) {\n", cfile);
+ fputs(" link.next = _et_list;\n", cfile);
+ fputs(" link.table = &et;\n", cfile);
+ fputs(" _et_list = &link;\n", cfile);
+ fputs(" }\n", cfile);
+ fputs("}\n", cfile);
+ fclose(cfile);
+
+ fprintf (hfile, "extern void initialize_%s_error_table ();\n",
+ table_name);
+ fprintf (hfile, "#define ERROR_TABLE_BASE_%s (%ldL)\n",
+ table_name, table_number);
+ /* compatibility... */
+ fprintf (hfile, "\n/* for compatibility with older versions... */\n");
+ fprintf (hfile, "#define init_%s_err_tbl initialize_%s_error_table\n",
+ table_name, table_name);
+ fprintf (hfile, "#define %s_err_base ERROR_TABLE_BASE_%s\n", table_name,
+ table_name);
+ fclose(hfile); /* bye bye include file */
+
+ return 0;
+}
+
+int yyerror(s) char *s; {
+ fputs(s, stderr);
+ fprintf(stderr, "\nLine number %d; last token was '%s'\n",
+ yylineno, current_token);
+}
--- /dev/null
+/*
+ * definitions common to the source files of the error table compiler
+ */
+
+#ifndef __STDC__
+/* loser */
+#undef const
+#define const
+#endif
+
+enum lang {
+ lang_C, /* ANSI C (default) */
+ lang_KRC, /* C: ANSI + K&R */
+ lang_CPP /* C++ */
+};
+
+int debug; /* dump debugging info? */
+char *filename; /* error table source */
+enum lang language;
+const char *whoami;
--- /dev/null
+/*
+ * $Header$
+ * $Source$
+ * $Locker$
+ *
+ * Copyright 1987 by the Student Information Processing Board
+ * of the Massachusetts Institute of Technology
+ *
+ * For copyright info, see "mit-sipb-copyright.h".
+ */
+
+#include <stdio.h>
+#include "error_table.h"
+#include "mit-sipb-copyright.h"
+#include "internal.h"
+
+static const char rcsid[] =
+ "$Header$";
+static const char copyright[] =
+ "Copyright 1986, 1987, 1988 by the Student Information Processing Board\nand the department of Information Systems\nof the Massachusetts Institute of Technology";
+
+static char buffer[25];
+
+struct et_list * _et_list = (struct et_list *) NULL;
+
+const char * error_message (code)
+long code;
+{
+ int offset;
+ struct et_list *et;
+ int table_num;
+ int started = 0;
+ char *cp;
+
+ offset = code & ((1<<ERRCODE_RANGE)-1);
+ table_num = code - offset;
+ if (!table_num) {
+ if (offset < sys_nerr)
+ return(sys_errlist[offset]);
+ else
+ goto oops;
+ }
+ for (et = _et_list; et; et = et->next) {
+ if (et->table->base == table_num) {
+ /* This is the right table */
+ if (et->table->n_msgs <= offset)
+ goto oops;
+ return(et->table->msgs[offset]);
+ }
+ }
+oops:
+ strcpy (buffer, "Unknown code ");
+ if (table_num) {
+ strcat (buffer, error_table_name (table_num));
+ strcat (buffer, " ");
+ }
+ for (cp = buffer; *cp; cp++)
+ ;
+ if (offset >= 100) {
+ *cp++ = '0' + offset / 100;
+ offset %= 100;
+ started++;
+ }
+ if (started || offset >= 10) {
+ *cp++ = '0' + offset / 10;
+ offset %= 10;
+ }
+ *cp++ = '0' + offset;
+ *cp = '\0';
+ return(buffer);
+}
--- /dev/null
+/*
+ * Copyright 1988 by the Student Information Processing Board of the
+ * Massachusetts Institute of Technology.
+ *
+ * For copyright info, see mit-sipb-copyright.h.
+ */
+
+#ifndef _ET_H
+/* Are we using ANSI C? */
+#ifndef __STDC__
+#define const
+#endif
+extern int errno;
+struct error_table {
+ char const * const * msgs;
+ long base;
+ int n_msgs;
+};
+struct et_list {
+ struct et_list *next;
+ const struct error_table *table;
+};
+extern struct et_list * _et_list;
+
+#define ERRCODE_RANGE 8 /* # of bits to shift table number */
+#define BITS_PER_CHAR 6 /* # bits to shift per character in name */
+
+extern const char *error_table_name();
+#define _ET_H
+#endif
--- /dev/null
+%{
+#include <stdio.h>
+char *str_concat(), *ds(), *quote(), *malloc(), *realloc();
+char *current_token = (char *)NULL;
+extern char *table_name;
+%}
+%union {
+ char *dynstr;
+}
+
+%token ERROR_TABLE ERROR_CODE_ENTRY END
+%token <dynstr> STRING QUOTED_STRING
+%type <dynstr> ec_name description table_id
+%{
+%}
+%start error_table
+%%
+
+error_table : ERROR_TABLE table_id error_codes END
+ { table_name = ds($2);
+ current_token = table_name;
+ put_ecs(); }
+ ;
+
+table_id : STRING
+ { current_token = $1;
+ set_table_num($1);
+ $$ = $1; }
+ ;
+
+error_codes : error_codes ec_entry
+ | ec_entry
+ ;
+
+ec_entry : ERROR_CODE_ENTRY ec_name ',' description
+ { add_ec($2, $4);
+ free($2);
+ free($4); }
+ | ERROR_CODE_ENTRY ec_name '=' STRING ',' description
+ { add_ec_val($2, $4, $6);
+ free($2);
+ free($4);
+ free($6);
+ }
+ ;
+
+ec_name : STRING
+ { $$ = ds($1);
+ current_token = $$; }
+ ;
+
+description : QUOTED_STRING
+ { $$ = ds($1);
+ current_token = $$; }
+ ;
+
+%%
+/*
+ *
+ * Copyright 1986, 1987 by the MIT Student Information Processing Board
+ *
+ * For copyright info, see mit-sipb-copyright.h.
+ */
+
+#include <string.h>
+#include <assert.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include "internal.h"
+#include "error_table.h"
+#include "mit-sipb-copyright.h"
+
+#ifndef lint
+static char const rcsid_error_table_y[] =
+ "$Header$";
+#endif
+
+char *malloc(), *realloc();
+extern FILE *hfile, *cfile;
+
+static long gensym_n = 0;
+char *
+gensym(x)
+ char const *x;
+{
+ char *symbol;
+ if (!gensym_n) {
+ struct timeval tv;
+ struct timezone tzp;
+ gettimeofday(&tv, &tzp);
+ gensym_n = (tv.tv_sec%10000)*100 + tv.tv_usec/10000;
+ }
+ symbol = malloc(32 * sizeof(char));
+ gensym_n++;
+ sprintf(symbol, "et%ld", gensym_n);
+ return(symbol);
+}
+
+char *
+ds(string)
+ char const *string;
+{
+ char *rv;
+ rv = malloc(strlen(string)+1);
+ strcpy(rv, string);
+ return(rv);
+}
+
+char *
+quote(string)
+ char const *string;
+{
+ char *rv;
+ rv = malloc(strlen(string)+3);
+ strcpy(rv, "\"");
+ strcat(rv, string);
+ strcat(rv, "\"");
+ return(rv);
+}
+
+long table_number;
+int current = 0;
+char **error_codes = (char **)NULL;
+
+add_ec(name, description)
+ char const *name, *description;
+{
+ fprintf(cfile, "\t\"%s\",\n", description);
+ if (error_codes == (char **)NULL) {
+ error_codes = (char **)malloc(sizeof(char *));
+ *error_codes = (char *)NULL;
+ }
+ error_codes = (char **)realloc((char *)error_codes,
+ (current + 2)*sizeof(char *));
+ error_codes[current++] = ds(name);
+ error_codes[current] = (char *)NULL;
+}
+
+add_ec_val(name, val, description)
+ char const *name, *val, *description;
+{
+ const int ncurrent = atoi(val);
+ if (ncurrent < current) {
+ printf("Error code %s (%d) out of order", name,
+ current);
+ return;
+ }
+
+ while (ncurrent > current)
+ fputs("\t(char *)NULL,\n", cfile), current++;
+
+ fprintf(cfile, "\t\"%s\",\n", description);
+ if (error_codes == (char **)NULL) {
+ error_codes = (char **)malloc(sizeof(char *));
+ *error_codes = (char *)NULL;
+ }
+ error_codes = (char **)realloc((char *)error_codes,
+ (current + 2)*sizeof(char *));
+ error_codes[current++] = ds(name);
+ error_codes[current] = (char *)NULL;
+}
+
+put_ecs()
+{
+ int i;
+ for (i = 0; i < current; i++) {
+ if (error_codes[i] != (char *)NULL)
+ fprintf(hfile, "#define %-40s (%ldL)\n",
+ error_codes[i], table_number + i);
+ }
+}
+
+/*
+ * char_to_num -- maps letters and numbers into a small numbering space
+ * uppercase -> 1-26
+ * lowercase -> 27-52
+ * digits -> 53-62
+ * underscore-> 63
+ */
+
+static const char char_set[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
+
+int char_to_num(c)
+ char c;
+{
+ const char *where;
+ int diff;
+
+ where = strchr (char_set, c);
+ if (where) {
+ diff = where - char_set + 1;
+ assert (diff < (1 << ERRCODE_RANGE));
+ return diff;
+ }
+ else if (isprint (c))
+ fprintf (stderr,
+ "Illegal character `%c' in error table name\n",
+ c);
+ else
+ fprintf (stderr,
+ "Illegal character %03o in error table name\n",
+ c);
+ exit (1);
+}
+
+set_table_num(string)
+ char *string;
+{
+ if (char_to_num (string[0]) > char_to_num ('z')) {
+ fprintf (stderr, "%s%s%s%s",
+ "First character of error table name must be ",
+ "a letter; name ``",
+ string, "'' rejected\n");
+ exit (1);
+ }
+ if (strlen(string) > 4) {
+ fprintf(stderr, "Table name %s too long, truncated ",
+ string);
+ string[4] = '\0';
+ fprintf(stderr, "to %s\n", string);
+ }
+ while (*string != '\0') {
+ table_number = (table_number << BITS_PER_CHAR)
+ + char_to_num(*string);
+ string++;
+ }
+ table_number = table_number << ERRCODE_RANGE;
+}
+
+#include "et_lex.lex.c"
--- /dev/null
+PC [^\"]
+AN [A-Z_a-z0-9]
+%%
+
+error_table return ERROR_TABLE;
+et return ERROR_TABLE;
+error_code return ERROR_CODE_ENTRY;
+ec return ERROR_CODE_ENTRY;
+end return END;
+
+[\t\n ] ;
+
+\"{PC}*\" { register char *p; yylval.dynstr = ds(yytext+1);
+ if (p=rindex(yylval.dynstr, '"')) *p='\0';
+ return QUOTED_STRING;
+ }
+
+{AN}* { yylval.dynstr = ds(yytext); return STRING; }
+
+#.*\n ;
+
+. { return (*yytext); }
+%%
+#ifndef lint
+static char rcsid_et_lex_lex_l[] = "$Header$";
+#endif
--- /dev/null
+/*
+ * Copyright 1987 by MIT Student Information Processing Board
+ *
+ * For copyright info, see mit-sipb-copyright.h.
+ */
+
+#include "error_table.h"
+#include "mit-sipb-copyright.h"
+#include "internal.h"
+
+#ifndef lint
+static const char copyright[] =
+ "Copyright 1987,1988 by Student Information Processing Board, Massachusetts Institute of Technology";
+static const char rcsid_et_name_c[] =
+ "$Header$";
+#endif
+
+static const char char_set[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
+
+static char buf[6];
+
+const char * error_table_name(num)
+ int num;
+{
+ int ch;
+ int i;
+ char *p;
+
+ /* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */
+ p = buf;
+ num >>= ERRCODE_RANGE;
+ /* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */
+ num &= 077777777;
+ /* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */
+ for (i = 4; i >= 0; i--) {
+ ch = (num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1);
+ if (ch != 0)
+ *p++ = char_set[ch-1];
+ }
+ *p = '\0';
+ return(buf);
+}
--- /dev/null
+/*
+ * $Header$
+ * $Source$
+ * $Locker$
+ *
+ * Copyright 1986, 1987, 1988 by MIT Information Systems and
+ * the MIT Student Information Processing Board.
+ *
+ * For copyright info, see mit-sipb-copyright.h.
+ */
+
+#include <stdio.h>
+#include "error_table.h"
+#include "mit-sipb-copyright.h"
+
+#ifndef __STDC__
+#define const
+#endif
+
+#ifndef lint
+static const char rcsid_init_et_c[] =
+ "$Header$";
+#endif
+
+extern char *malloc(), *realloc();
+
+struct foobar {
+ struct et_list etl;
+ struct error_table et;
+};
+
+extern struct et_list * _et_list;
+
+int init_error_table(msgs, base, count)
+ const char * const * msgs;
+ int base;
+ int count;
+{
+ struct foobar * new_et;
+
+ if (!base || !count || !msgs)
+ return 0;
+
+ new_et = (struct foobar *) malloc(sizeof(struct foobar));
+ if (!new_et)
+ return errno; /* oops */
+ new_et->etl.table = &new_et->et;
+ new_et->et.msgs = msgs;
+ new_et->et.base = base;
+ new_et->et.n_msgs= count;
+
+ new_et->etl.next = _et_list;
+ _et_list = &new_et->etl;
+ return 0;
+}
--- /dev/null
+/*
+ * internal include file for com_err package
+ */
+#include "mit-sipb-copyright.h"
+#ifndef __STDC__
+#undef const
+#define const
+#endif
+
+extern int errno;
+extern char const * const sys_errlist[];
+extern const int sys_nerr;
+
+#ifdef __STDC__
+void perror (const char *);
+#else
+void perror ();
+#endif
--- /dev/null
+/*
+
+Copyright 1987, 1989 by the Student Information Processing Board
+ of the Massachusetts Institute of Technology
+
+Permission to use, copy, modify, and distribute this software
+and its documentation for any purpose and without fee is
+hereby granted, provided that the above copyright notice
+appear in all copies and that both that copyright notice and
+this permission notice appear in supporting documentation,
+and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
+used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+M.I.T. and the M.I.T. S.I.P.B. make no representations about
+the suitability of this software for any purpose. It is
+provided "as is" without express or implied warranty.
+
+*/
+
--- /dev/null
+#include <stdio.h>
+#include <errno.h>
+#include "com_err.h"
+#include "test1.h"
+#include "test2.h"
+
+extern int sys_nerr, errno;
+
+main()
+{
+ printf("Before initiating error table:\n\n");
+ printf("Table name '%s'\n", error_table_name(KRB_MK_AP_TGTEXP));
+ printf("UNIX name '%s'\n", error_table_name(EPERM));
+ printf("Msg TGT-expired is '%s'\n", error_message(KRB_MK_AP_TGTEXP));
+ printf("Msg EPERM is '%s'\n", error_message(EPERM));
+ printf("Msg FOO_ERR is '%s'\n", error_message(FOO_ERR));
+ printf("Msg {sys_nerr-1} is '%s'\n", error_message(sys_nerr-1));
+ printf("Msg {sys_nerr} is '%s'\n", error_message(sys_nerr));
+
+ printf("With 0: tgt-expired -> %s\n", error_message(KRB_MK_AP_TGTEXP));
+
+ initialize_krb_error_table();
+ printf("KRB error table initialized: base %d (%s), name %s\n",
+ ERROR_TABLE_BASE_krb, error_message(ERROR_TABLE_BASE_krb),
+ error_table_name(ERROR_TABLE_BASE_krb));
+ initialize_krb_error_table();
+ printf("With krb: tgt-expired -> %s\n",
+ error_message(KRB_MK_AP_TGTEXP));
+
+ initialize_quux_error_table();
+ printf("QUUX error table initialized: base %d (%s), name %s\n",
+ ERROR_TABLE_BASE_quux, error_message(ERROR_TABLE_BASE_quux),
+ error_table_name(ERROR_TABLE_BASE_quux));
+
+ printf("Msg for TGT-expired is '%s'\n",
+ error_message(KRB_MK_AP_TGTEXP));
+ printf("Msg {sys_nerr-1} is '%s'\n", error_message(sys_nerr-1));
+ printf("Msg FOO_ERR is '%s'\n", error_message(FOO_ERR));
+ printf("Msg KRB_SKDC_CANT is '%s'\n",
+ error_message(KRB_SKDC_CANT));
+ printf("Msg 1e6 (8B 64) is '%s'\n", error_message(1000000));
+ printf("\n\nCOM_ERR tests:\n");
+ com_err("whoami", FOO_ERR, (char *)NULL);
+ com_err("whoami", FOO_ERR, " -- message goes %s", "here");
+ com_err("whoami", 0, (char *)0);
+ com_err("whoami", 0, "error number %d\n", 0);
+}
--- /dev/null
+ error_table krb
+
+ error_code KRB_MK_AP_TKFIL,
+ "Can't read ticket file"
+
+ ec KRB_MK_AP_NOTKT,
+ "Can't find ticket or TGT"
+
+ ec KRB_MK_AP_TGTEXP,
+ "TGT expired"
+
+ ec KRB_RD_AP_UNDEC,
+ "Can't decode authenticator"
+
+ ec KRB_RD_AP_EXP,
+ "Ticket expired"
+
+ ec KRB_RD_AP_REPEAT,
+ "Repeated request"
+
+ ec KRB_RD_AP_NOT_US,
+ "The ticket isn't for us"
+
+ ec KRB_RD_AP_INCON,
+ "Request is inconsistent"
+
+ ec KRB_RD_AP_TIME,
+ "Delta-T too big"
+
+ ec KRB_RD_AP_BADD,
+ "Incorrect net address"
+
+ ec KRB_RD_AP_VERSION,
+ "Protocol version mismatch"
+
+ ec KRB_RD_AP_MSG_TYPE,
+ "Invalid message type"
+
+ ec KRB_RD_AP_MODIFIED,
+ "Message stream modified"
+
+ ec KRB_RD_AP_ORDER,
+ "Message out of order"
+
+ ec KRB_RD_AP_UNAUTHOR,
+ "Unauthorized request"
+
+ ec KRB_GT_PW_NULL,
+ "Current password is null"
+
+ ec KRB_GT_PW_BADPW,
+ "Incorrect current password"
+
+ ec KRB_GT_PW_PROT,
+ "Protocol error"
+
+ ec KRB_GT_PW_KDCERR,
+ "Error returned by KDC"
+
+ ec KRB_GT_PW_NULLTKT,
+ "Null ticket returned by KDC"
+
+ ec KRB_SKDC_RETRY,
+ "Retry count exceeded"
+
+ ec KRB_SKDC_CANT,
+ "Can't send request"
+
+ end
--- /dev/null
+ error_table quux
+
+ ec FOO_ERR, "foo"
+
+ ec BAR_ERR, "bar"
+
+ ec BAZ_ERR, "meow"
+
+ end
--- /dev/null
+BEGIN {state = 0}
+$1=="#ifsql"&&$2=="INFORMIX" {state = 0; printf("\n"); next}
+$1=="#ifsql" {state = 1; printf("\n"); next}
+$1=="#elsesql" {state = 1-state; printf("\n"); next}
+$1=="#endsql" {state = 0; printf("\n"); next}
+state==1 {printf("\n"); next}
+state==0
--- /dev/null
+BEGIN {state = 0}
+$1=="#ifsql"&&$2=="INGRES" {state = 0; printf("\n"); next}
+$1=="#ifsql" {state = 1; printf("\n"); next}
+$1=="#elsesql" {state = 1-state; printf("\n"); next}
+$1=="#endsql" {state = 0; printf("\n"); next}
+state==1 {printf("\n"); next}
+state==0
--- /dev/null
+BEGIN {state = 0}
+$1=="#ifsql"&&$2=="ORACLE" {state = 0; printf("\n"); next}
+$1=="#ifsql" {state = 1; printf("\n"); next}
+$1=="#elsesql" {state = 1-state; printf("\n"); next}
+$1=="#endsql" {state = 0; printf("\n"); next}
+state==1 {printf("\n"); next}
+state==0
MAKE = make
RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \
tags TAGS make.log
+ LN = cp
NPROC = 1
+ DESTDIR = .
+ SRCDIR = /mit/moiradev/src
+ SOURCES = ${SRCDIR}/util/imake/imake.c ${SRCDIR}/util/imake/ccimake.c \
+ ${SRCDIR}/util/imake/Makefile ${SRCDIR}/util/imake/imakemdep.h
+
+all: imake
imake::
@echo "making imake with BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS)"
depend:
+config: $(SOURCES)
+ -mkdir $(DESTDIR)/util/imake
+ for i in $(SOURCES); do \
+ $(RM) ${DESTDIR}/util/imake/`basename $$i`; \
+ $(LN) $$i ${DESTDIR}/util/imake/`basename $$i`; done
# for manual use
--- /dev/null
+.TH IMAKE 1 "Jan 6, 1987"
+.UC 4
+.SH NAME
+imake \- C preprocessor interface to the make utility
+.SH SYNOPSIS
+.B imake
+[
+.B \-Ddefine
+] [
+.B \-Idirectory
+] [
+.B \-T
+] [
+.B \-f
+.I imakefile
+] [
+.B \-s
+[
+.I makefile
+]] [
+.B \-v
+] [ make options or arguments ]
+.SH DESCRIPTION
+.I Imake
+takes a template and an Imakefile and runs the C preprocessor on it producing a
+temporary makefile in /usr/tmp. It then runs
+.I make
+on this pre-processed makefile.
+See IMPLEMENTATION DETAIL below.
+.PP
+By default,
+.I Imake
+looks first for the file named
+.I Imakefile
+and if that fails, looks for the file named
+.I imakefile,
+both in the current working directory.
+.SH OPTIONS
+.TP 5
+.B \-Ddefine
+Define.
+This argument is passed on to the preprocessor, cpp.
+This can also be accomplished with the environment variable,
+IMAKEINCLUDE.
+.TP 5
+.B \-Idirectory
+Include directory.
+This argument is passed on to the preprocessor, cpp.
+This can also be accomplished with the environment variable,
+IMAKEINCLUDE.
+.TP 5
+.B \-T template
+Template file.
+Specifies the template file to be initially included by cpp,
+instead of the default file
+.I Imake.template.
+.TP 5
+.B \-f imakefile
+File.
+Specifies an alternate imakefile for
+.I imake to use.
+.TP 5
+.B \-s [ filename ]
+Show.
+.I Imake
+will preprocess the imakefile,
+and direct it to the standard output.
+The
+.I make
+program will not be invoked.
+If the filename argument is present
+the output will be directed instead to the named file.
+Typically, this is
+.I \-s Makefile.
+.TP 5
+.B \-v
+Verbose.
+.I Imake
+will display the command line it uses to invoke the C preprocessor before
+actually doing so.
+.SH "ENVIRONMENT VARIABLES"
+Imake consults its environment for three variables:
+.TP 5
+.B IMAKEINCLUDE
+If defined, this should be a valid include argument for the
+C preprocessor. E.g. ``-I/usr/include/local''.
+Actually, any valid
+.I cpp
+argument will work here.
+.TP 5
+.B IMAKECPP
+If defined, this should be a valid path to a preprocessor program.
+E.g. ``/usr/local/cpp''.
+By default,
+.I imake
+will use /lib/cpp.
+.TP 5
+.B IMAKEMAKE
+If defined, this should be a valid path to a make program.
+E.g. ``/usr/local/make''.
+By default,
+.I imake
+will use whatever
+.I make
+program is found using
+.I execvp(3).
+.SH IMPLEMENTATION DETAIL
+.I Imake
+first determins the name of the imakefile from the command line \-f
+flag or from the content of the current directory, depending
+on whether Imakefile or imakefile exist.
+We shall call this \fI<imakefile>\fP.
+It also determines the name of the template
+from the command line \-T flag or the default, Imake.template.
+Call this \fI<template>\fP.
+.PP
+The program then examines the imakefile looking for any lines
+that begin with a '#' character. If it finds one,
+it checks to see if it is a valid C preprocessor directive
+from the set
+.I #include,
+.I #define,
+.I #undef,
+.I #ifdef,
+.I #else,
+.I #endif
+or
+.I #if.
+If it is,
+.I imake
+leaves it unchanged.
+If not,
+it pads the beginning of the line with a null C comment ``/**/''
+so that the line will by untouched by the preprocessor.
+This is usefull for preserving the use of
+.I make
+style ``#'' comments.
+If any lines needed to be changed,
+a temporary file named /tmp/tmp-imake.* will receive the "padded"
+imakefile.
+Call this file, whether it needed to be changed or not,
+\fI<input-imakefile>\fP.
+.PP
+Then the program
+starts up the C preprocessor with the command line
+.RS 5
+.sp 1
+/lib/cpp -I. -I/usr/lib/local/imake.includes -Uunix
+.sp 1
+.RE
+perhaps prepending the argument list with the IMAKEINCLUDE
+environment variable,
+the \fI\-I\fP, and the \fI\-D\fP command line arguments;
+or changing the preprocessor program to the IMAKECPP environment variable.
+Standard input is from the
+.I imake
+program and standard output is directed to a temporary file in
+/usr/tmp/tmp-make.*;
+unless there was an argument to the \-s flag, in which case
+output is directed there.
+Call this file \fI<makefile>\fP.
+The first three lines provided as input to the preprocessor
+will be
+.RS 5
+.sp 1
+#define IMAKE_TEMPLATE "\fI<template>\fP"
+.br
+#define INCLUDE_IMAKEFILE "\fI<input-imakefile>\fP"
+.br
+#include IMAKE_TEMPLATE
+.sp 1
+.RE
+.PP
+Note that this implies that the template must have, at a bare minimum,
+the line
+.RS 5
+.sp 1
+#include INCLUDE_IMAKEFILE
+.sp 1
+.RE
+.PP
+Next,
+.I imake
+reads the entire output of the preprocessor into memory,
+stripping off any double '@' signs encountered in the input.
+This is very useful for writing cpp multi-line macros that
+won't be coalesced into a single line the way
+.I cpp
+normally does.
+In addition, trailing white space on any line is thrown away to keep
+.I make
+from getting upset;
+and most blank lines are thrown
+away.
+For example, the macro
+.ta .8i 1.6i 5i
+.nf
+
+#define program_target(program, objlist) @@\e
+program: objlist @@\e
+ $(CC) -o $@ objlist $(LDFLAGS)
+
+.fi
+when called with
+.I "program_target(foo, foo1.o foo2.o)"
+will expand to
+.nf
+
+foo: foo1.o foo2.o
+ $(CC) -o $@ foo1.o foo2.o $(LDFLAGS)
+
+.fi
+.DT
+.PP
+Finally,
+if the
+.B -s
+option has not been specified,
+.I imake
+calls the program
+.RS 5
+.sp 1
+ make MAKE=\fI<program>\fP MAKEFILE=\fI<imakefile>\fP -f \fI<makefile>\fP makeargs
+.sp 1
+.RE
+where ``makeargs'' is replaced with any arguments found on the command line.
+.SH FILES
+.ta 3i
+/usr/tmp/tmp-imake.\fInnnnnn\fP temporary input file for cpp
+.br
+/usr/tmp/tmp-make.\fInnnnnn\fP temporary input file for make
+.br
+/lib/cpp default C preprocessor
+.br
+/usr/lib/local/imake.includes default directory for include files.
+.DT
+.SH "SEE ALSO"
+make(1)
+.br
+S. I. Feldman
+.I
+Make \- A Program for Maintaining Computer Programs
+.SH "AUTHOR"
+Todd Brunhoff; Tektronix, inc. and Project Athena, MIT.
+.SH "BUGS"
+The C-preprocessor, Cpp,
+on a Sun compresses all tabs in a macro expansion to a single
+space. It also replaces an escaped newline with a space instead of
+deleting it. There is a kludge in the code to try to get around this
+but it depends on the fact that all targets have a ':' somewhere in
+the line and all actions for a target do not have a ':'.
+.PP
+You can use \fImake\fP-style '#' comments in the Imakefile, but
+not in the template or any other included files. If you want
+them, you must preceed them with a C null comment, /**/.
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
signal(SIGINT, catch);
+
+ /* This kludge is here because in AIX cpp doesn't define any
+ * symbols in cpp, they are all defined by cc.
+ */
+#ifdef _AIX
+ AddCppArg("-D_AIX");
+#endif
}
AddMakeArg(arg)
--- /dev/null
+/**/#
+/**/# The Main rules
+/**/#
+
+/*
+ * This is the standard rule for compiling system calls
+ */
+#define library_sysobj_rule() @@\
+.c.o: @@\
+ $(CPP) -E -DPROF $*.c | $(AS) -o $*.o -Mx @@\
+ -$(LD) -X -r -o profiled/$*.o $*.o @@\
+ $(CPP) -E $*.c | $(AS) -o $*.o -Mx @@\
+ -$(LD) -x -r -o a.out $*.o @@\
+ mv a.out $*.o
+
+
+/*
+ * ... and for other objects in libraries
+ */
+#define library_obj_rule() @@\
+.s.o: @@\
+ $(CPP) $(DEFINES) -E -DPROF $*.s \ @@\
+ | $(AS) $(AFLAGS) -68020 -o $*.o -Mx @@\
+ -$(LD) -X -r -o profiled/$*.o $*.o @@\
+ $(CPP) $(DEFINES) -E $*.s | $(AS) $(AFLAGS) -68020 -o $*.o -Mx @@\
+ -$(LD) -x -r -o a.out $*.o @@\
+ mv a.out $*.o @@\
+ @@\
+.c.o: @@\
+ $(CC) -p -c $(CFLAGS) $*.c @@\
+ -$(LD) -X -r -o profiled/$*.o $*.o @@\
+ $(CC) -c $(CFLAGS) $*.c @@\
+ -$(LD) -x -r -o a.out $*.o @@\
+ mv a.out $*.o
+
+
+/*
+ * These two are used by things like csh...
+ */
+#define cxstr_obj_target(target) @@\
+target.o: target @@\
+ ${XSTR} @@\
+ ${CC} -c -R xs.c @@\
+ mv -f xs.o target.o @@\
+ rm -f xs.c
+
+#define cxstr_obj_rule() @@\
+.c.o: @@\
+ ${CC} -E ${CFLAGS} $*.c | ${XSTR} -c - @@\
+ ${CC} -c ${CFLAGS} x.c @@\
+ mv -f x.o $*.o @@\
+ rm -f x.c
+
+
+/*
+ * Special library rules for generating files from the UTek library
+ */
+#define tools_library_obj_rule() @@\
+.s.o: @@\
+ $(CPP) $(DEFINES) -E $*.s | $(AS) $(AFLAGS) -68020 -o $*.o -Mx @@\
+ -$(LD) -x -r -o a.out $*.o @@\
+ mv a.out $*.o @@\
+ @@\
+.c.o: @@\
+ $(CC) -c $(CFLAGS) $*.c @@\
+ -$(LD) -x -r -o a.out $*.o @@\
+ mv a.out $*.o
+
+#define library_target(libname) @@\
+all: lib/**/libname lib/**/libname/**/_p @@\
+lib/**/libname: $(OBJS) @@\
+ ar cruf $@ $(OBJS) @@\
+lib/**/libname/**/_p: $(OBJS) @@\
+ cd profiled; ar cruf ../$@ $(OBJS)
+
+#define tools_library_target(libname) @@\
+all: lib/**/libname @@\
+lib/**/libname: $(OBJS) @@\
+ ar cru $@ $(OBJS) @@\
+
+/*
+ * Note that '/*' plays havoc with cpp. So we use the equivalent '/?*'.
+ */
+#define multiple_library_target(libname,dirlist) @@\
+all: lib/**/libname lib/**/libname/**/_p @@\
+ @@\
+lib/**/libname: dirlist @@\
+ -mkdir tmp @@\
+ for i in dirlist; do \ @@\
+ (cd tmp; ar x ../$$i/lib$${i}); done @@\
+ ar crf $@ `ls tmp/?*.o` @@\
+ rm -rf tmp @@\
+lib/**/libname/**/_p: dirlist @@\
+ -mkdir tmp @@\
+ for i in dirlist; do \ @@\
+ (cd tmp; ar x ../$$i/lib$${i}_p); done @@\
+ ar crf $@ `ls tmp/?*.o` @@\
+ rm -rf tmp @@\
+ @@\
+dirlist: FRC @@\
+ cd $@; $(IMAKE) $(MFLAGS) all @@\
+FRC:
+
+
+/*
+ * This is a basic program target
+ */
+#define program_target(program, objlist) @@\
+program: objlist $(SYSOBJECTS) @@\
+ $(CC) -o $@ objlist $(LDFLAGS) @@\
+ $(XINU) $@
+
+
+/*
+ * This target can be called by all programs that are contained in
+ * a single c source file.
+ */
+#define simple_program_target(program,dest) @@\
+OBJS = program.$O @@\
+SRCS = program.c @@\
+ @@\
+complex_program_target(program,dest)
+
+
+/*
+ * This target is like simple_program_target() except that the dependency
+ * list is long (it must be provided in the Imakefile.
+ */
+#define complex_program_target(program,dest) @@\
+program: $(OBJS) $(SYSOBJECTS) @@\
+ $(CC) -o $@ $(OBJS) $(LDFLAGS) @@\
+ $(XINU) $@ @@\
+ @@\
+install_program(program,dest) @@\
+depend_target()
+
+
+/*
+ * Compile an assembler module that is kept in a .c file (like the
+ * system call library).
+ */
+#define casm_obj_target(basename) @@\
+basename.$O: basename.c @@\
+ ${CC} -E basename.c | ${AS} -o basename.$O
+
+/*
+ * Install a non-executable file.
+ */
+#define install_non_exec(file,dest) @@\
+install:: file @@\
+ install68 -c -m 0664 file $(DEST)/dest
+
+
+/*
+ * Install a shell program. Must be named 'program'.sh.
+ */
+#define install_shell(program,dest) @@\
+install:: program.sh @@\
+ install68 -c program.sh $(DEST)/dest/program
+
+#define install_program(program,dest) @@\
+install:: program @@\
+ install68 -c program $(DEST)/dest
+
+#define install_multiple(list,dest) @@\
+install:: list @@\
+ @for i in list; do \ @@\
+ (set -x; install68 -c $$i $(DEST)/dest); \ @@\
+ done
+
+#define install_library(libname,dest) @@\
+install:: lib/**/libname lib/**/libname/**/_p @@\
+ install68 -c -r -x lib/**/libname \ @@\
+ $(DEST)/dest/lib/**/libname.a @@\
+ install68 -c -r -x lib/**/libname/**/_p \ @@\
+ $(DEST)/dest/lib/**/libname/**/_p.a @@\
+ @@\
+install_vax_library(libname,lib68)
+
+#define install_vax_library(libname,dest) @@\
+install:: lib/**/libname lib/**/libname/**/_p @@\
+ install68 -c -r lib/**/libname \ @@\
+ $(TOOLSDEST)/dest/lib/**/libname.a @@\
+ install68 -c -r lib/**/libname/**/_p \ @@\
+ $(TOOLSDEST)/dest/lib/**/libname/**/_p.a @@\
+
+#define install_tools_library(libname,dest) @@\
+install:: lib/**/libname @@\
+ install68 -c -r lib/**/libname \ @@\
+ $(DEST)/dest/lib/**/libname.a @@\
+
+/*
+ * Do an imake on multiple sub-directories.
+ */
+#define imake_multiple() @@\
+all: @@\
+ @-for dir in `ls -F | egrep /`; do \ @@\
+ (set -x; cd $$dir; $(IMAKE)); \ @@\
+ done @@\
+ @@\
+imake_multiple_install()
+
+
+#define imake_multiple_install() @@\
+install:: @@\
+ @-for dir in `ls -F | egrep /`; do \ @@\
+ (set -x; cd $$dir; $(IMAKE) install); \ @@\
+ done
+
+/*
+ * This makes the depend target given OBJS.
+ */
+#define DependComment '# define Dependencies for $(MACHINE)'
+#define depend_target() @@\
+depend: @@\
+ echo DependComment > $(MACHINE).depend @@\
+ makedepend -s DependComment \ @@\
+ -f $(MACHINE).depend \ @@\
+ $(DEPEND_INCLUDES) \ @@\
+ $(DEPEND_DEFINES) \ @@\
+ $(INCLUDES) \ @@\
+ $(SRCS)
#
# make -f makeconfig SRCDIR=/u2/lockers/moira DESTDIR=myconfig
+SHELL = /bin/sh
DESTDIR = .
SRCDIR = /mit/moiradev/src
--- /dev/null
+The following changes have been made to this directory since R2:
+
+ o support for #eject and #pragma directives has been added.
+ o endmarkers have been added for fix problems with makedepend
+ misinterpreting compiler switches.
+ o support for #include SYMBOL has been added.
+ o the #undef directive has been changed to actually undefine symbols
+ o a bug in error reporting has been fixed.
+ o support for the #elif directive has been added
--- /dev/null
+# Makefile generated by imake - do not edit!
+# $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $
+#
+# The cpp used on this machine replaces all newlines and multiple tabs and
+# spaces in a macro expansion with a single space. Imake tries to compensate
+# for this, but is not always successful.
+#
+
+#
+# This makefile is automatically generated by imake... do not modify
+# or you may lose your changes when imake generates makefiles again.
+# Ignore this message if you are not using imake.
+#
+# $Source$
+#
+
+NEWTOP=.
+BUILDTOP=.
+
+INCLUDE= -I$(BUILDTOP)/include -I$(BUILDTOP)/lib -I/usr/athena/include
+CFLAGS=$(DBG) $(INCLUDE) $(DEFINES) $(GLOBAL_CDEFS)
+LINTFLAGS=$(INCLUDE) $(DEFINES) $(GLOBAL_CDEFS)
+
+# $Source$
+#
+
+CURSES= -L/usr/css/lib -lcurses -ltermcap
+
+OSDEFS= -DPOSIX -DSOLARIS -I/usr/openwin/include
+OSLIBS= -L/usr/ccs/lib -lcurses -ltermcap -lresolv \
+ -lsocket -lnsl -lc /usr/ucblib/libucb.a -lelf -ldl
+CURSES=
+
+GLOBAL_CDEFS= -DHESIOD -DZEPHYR -DGDSS -DATHENA -DDBMS=INGRES -I/usr/athena/include $(OSDEFS)
+
+SRCTOP=/mit/moiradev/src
+
+DESTDIR=
+
+USRDIR= /usr
+ETCDIR= /usr/athena/etc
+PROGDIR=/usr/athena/bin
+LIBDIR= /usr/athena/lib
+LINTLIBDIR = /usr/lib/lint
+INCLDIR= /usr/athena/include
+MANDIR= /usr/athena/man
+
+LZEHPYR=-lzephyr
+
+LIBGDSS= /mit/gdss/`machtype`/libgdss.a
+GDSSINC= -I/mit/gdss/include
+
+LINTLIBFLAG=-C
+
+MR_LIB=$(BUILDTOP)/lib/libmoira.a
+MR_LIBDEP=$(MR_LIB)
+MR_LINTLIB=$(BUILDTOP)/lib/llib-lmoira.ln
+GDB_LIB=$(BUILDTOP)/gdb/libmrgdb.a
+GDB_LIBDEP=$(GDB_LIB)
+GDB_LINTLIB=$(BUILDTOP)/gdb/llib-lmrgdb.ln
+
+COMPILE_ET= compile_et
+
+COM_ERR = -lcom_err
+
+MAKE_COMMANDS= mk_cmds
+
+SS_LIB = -lss
+
+LLIB = -L/usr/athena/lib
+
+CLIBS= $(MR_LIB) $(GDB_LIB) $(LLIB) $(LZEPHYR) $(COM_ERR) -lkrb -ldes -lhesiod
+
+SQL_LIB= /usr/ingres/lib/libingres.a -lm
+
+ARCHIVE= ar cru
+
+RANLIB= /bin/true
+
+INSTALLFILE= install -c -m 444
+
+INSTALLLIB= install -c -m 444
+
+INSTALLPROG= install -c -m 555
+
+INSTALLRAW= install
+
+LD=ld
+
+AS=as
+
+LINT=lint
+
+CC=gcc -traditional
+
+CCRO=$(CC) -R
+
+HCC=$(CC)
+
+CPP=$(CC) -E
+
+DBG=-O
+
+HCFLAGS=$(CFLAGS)
+
+TAGGER=etags
+
+MAKE=make
+RM=rm -f
+MV=mv
+CP=cp
+LN=ln -s
+LPR=lpr -p
+CHMOD=chmod
+AWK=awk
+
+DEPEND=makedepend
+IMAKE=imake -I$(BUILDTOP)/util/imake.includes
+
+# $Source$
+#
+
+# $Source$
+# $Author$
+# $Header$
+#
+# Copyright 1987 by the Massachusetts Institute of Technology.
+#
+# For copying and distribution information,
+# please see the file <mit-copyright.h>.
+#
+# Utility to build makefile header dependancies from C source.
+#
+# If you have source for cpp...
+#
+
+#
+# But if you don't have cpp source...
+#
+SRCS = include.c main.c parse.c pr.c cppsetup.c
+SOURCES = \
+ ${SRCDIR}/util/makedepend/include.c \
+ ${SRCDIR}/util/makedepend/main.c \
+ ${SRCDIR}/util/makedepend/parse.c \
+ ${SRCDIR}/util/makedepend/pr.c \
+ ${SRCDIR}/util/makedepend/cppsetup.c \
+ ${SRCDIR}/util/makedepend/def.h \
+ ${SRCDIR}/util/makedepend/Imakefile \
+ ${SRCDIR}/util/makedepend/Makefile
+OBJS = include.o main.o parse.o pr.o cppsetup.o
+DEFINES = '-DINCLUDEDIR="/usr/include"'
+
+CODE=$(SRCS) Imakefile
+
+all:: makedepend
+
+makedepend: $(OBJS)
+ $(CC) $(CFLAGS) -o $@ $(OBJS) $(OSLIBS)
+
+clean::
+ $(RM) makedepend $(OBJS)
+
+cpy.c: cpy.y yylex.c
+ yacc cpy.y
+ sed -e '/^# *line/d' < y.tab.c > cpy.c
+ $(RM) y.tab.c
+
+cpy.y: $(CPPSRC)/cpy.y
+ $(RM) $@
+ $(LN) $(CPPSRC)/cpy.y .
+
+yylex.c: $(CPPSRC)/yylex.c
+ $(RM) $@
+ sed -e 's/#if pdp11 | vax | mc68000/& | ns16000 | ibm032/' \
+ $(CPPSRC)/yylex.c > yylex.c
+
+cpp.c: $(CPPSRC)/cpp.c cpp.ed
+ $(RM) cpp.c
+ /lib/cpp $(CPPSRC)/cpp.c \
+ | cb \
+ | sed -e '/^$$/d' -e '/^#/d' -e 's/ / /g' > cpp.c
+ sed -e '/^#/d' < cpp.ed | ed - cpp.c
+
+cpp.o: cpp.c
+cpy.o: cpy.c
+
+clean::
+ $(RM) cpp.c cpy.? yylex.c
+
+config: $(SOURCES)
+ -mkdir $(DESTDIR)/util/makedepend
+ for i in $(SOURCES); do \
+ $(RM) ${DESTDIR}/util/makedepend/`basename $$i`; \
+ $(CP) $$i ${DESTDIR}/util/makedepend/`basename $$i`; done
+
+depend:: $(SRCS)
+ @echo "### Now computing dependencies"
+ @$(DEPEND) -s "# DO NOT DELETE" -- $(CFLAGS) -- $(SRCS)
+
+clean::
+ $(RM) *~ \#* *.bak $(TAGSFILE)
+
+tags::
+ $(TAGGER) *.c *.h
+
+Makefile::
+ -$(RM) Makefile.bak; $(MV) Makefile Makefile.bak
+ $(IMAKE) -DNEW_TOP=$(NEWTOP) -s Makefile
+
+print:: ${CODE}
+ ${LPR} ${CODE}
+
+src:: ${CODE}
+
+${CODE}:
+ $(RM) $@
+ -$(LN) ${SRCDIR}/$@ $@
+
+install::
+
+Makefiles::
+
+# DO NOT DELETE THIS LINE
+
--- /dev/null
+#
+# $XConsortium: cpp.ed,v 1.2 88/09/06 17:53:42 jim Exp $
+#
+# $Locker $
+#
+/struct symtab stab/d
+/struct symtab \*defloc;/d
+/struct symtab \*udfloc;/d
+/struct symtab \*incloc;/d
+/struct symtab \*ifloc;/d
+/struct symtab \*elsloc;/d
+/struct symtab \*eifloc;/d
+/struct symtab \*ifdloc;/d
+/struct symtab \*ifnloc;/d
+/struct symtab \*ysysloc;/d
+/struct symtab \*varloc;/d
+/struct symtab \*lneloc;/d
+/struct symtab \*ulnloc;/d
+/struct symtab \*uflloc;/d
+/^sayline(/s/$/ DELETED/p
+.,/^}/d
+/^unfill(/s/$/ DELETED/p
+.-1,/^}/d
+/^doincl(/s/$/ DELETED/p
+.-1,/^}/d
+/^equfrm(/s/$/ DELETED/p
+.,/^}/d
+/^dodef(/s/$/ DELETED/p
+.-1,/^}/d
+/^control(/s/$/ DELETED/p
+.-1,/^}/d
+/^savestring(/s/$/ DELETED/p
+.-1,/^}/d
+/^stsym(/s/$/ DELETED/p
+.-1,/^}/d
+/^ppsym(/s/$/ DELETED/p
+.-1,/^}/d
+/^yyerror(/s/$/ DELETED/p
+.,/^}/d
+/^ppwarn(/s/$/ DELETED/p
+.,/^}/d
+/^lookup(/s/$/ DELETED/p
+.-1,/^}/d
+/^subst(/s/$/ DELETED/p
+.-1,/^}/d
+/^trmdir(/s/$/ DELETED/p
+.-1,/^}/d
+/^copy(/s/$/ DELETED/p
+.-1,/^}/d
+/^pperror(/s/$/ DELETED/p
+.,/^}/d
+/^main(/s/$/ CHANGED to cpp_varsetup(argc,argv)/p
+.c
+cpp_varsetup(argc,argv)
+.
+/^strdex(/s/$/ DELETED/p
+.-1,/^}/d
+/^ for(i=1; i<argc; i++)/s/$/ To the end DELETED/p
+.,$c
+}
+.
+/^dump(/s/$/ DELETED/p
+.,/^}/c
+dump() { log_fatal("dump\n"); }
+.
+/^refill(/s/$/ DELETED/p
+.,/^}/c
+refill() { log_fatal("refill\n"); }
+.
+/^slookup(/s/$/ DELETED/p
+.-1,/^}/c
+static struct symtab *slookup() { log_fatal("slookup\n"); }
+.
+w
+q
--- /dev/null
+/*
+ * $XConsortium: cppsetup.c,v 1.4 88/09/06 17:53:45 jim Exp $
+ */
+#include "def.h"
+
+#ifdef CPP
+/*
+ * This file is strictly for the sake of cpy.y and yylex.c (if
+ * you indeed have the source for cpp).
+ */
+#define IB 1
+#define SB 2
+#define NB 4
+#define CB 8
+#define QB 16
+#define WB 32
+#define SALT '#'
+#if pdp11 | vax | ns16000 | mc68000 | ibm032
+#define COFF 128
+#else
+#define COFF 0
+#endif
+/*
+ * These variables used by cpy.y and yylex.c
+ */
+extern char *outp, *inp, *newp, *pend;
+extern char *ptrtab;
+extern char fastab[];
+extern char slotab[];
+
+/*
+ * cppsetup
+ */
+struct filepointer *currentfile;
+struct inclist *currentinc;
+
+cppsetup(line, filep, inc)
+ register char *line;
+ register struct filepointer *filep;
+ register struct inclist *inc;
+{
+ register char *p, savec;
+ static boolean setupdone = FALSE;
+ boolean value;
+
+ if (!setupdone) {
+ cpp_varsetup();
+ setupdone = TRUE;
+ }
+
+ currentfile = filep;
+ currentinc = inc;
+ inp = newp = line;
+ for (p=newp; *p; p++)
+ ;
+
+ /*
+ * put a newline back on the end, and set up pend, etc.
+ */
+ *p++ = '\n';
+ savec = *p;
+ *p = '\0';
+ pend = p;
+
+ ptrtab = slotab+COFF;
+ *--inp = SALT;
+ outp=inp;
+ value = yyparse();
+ *p = savec;
+ return(value);
+}
+
+struct symtab *lookup(symbol)
+ char *symbol;
+{
+ static struct symtab undefined;
+ struct symtab *sp;
+
+ sp = defined(symbol, currentinc);
+ if (sp == NULL) {
+ sp = &undefined;
+ sp->s_value = NULL;
+ }
+ return (sp);
+}
+
+pperror(tag, x0,x1,x2,x3,x4)
+ int tag,x0,x1,x2,x3,x4;
+{
+ log("\"%s\", line %d: ", currentinc->i_file, currentfile->f_line);
+ log(x0,x1,x2,x3,x4);
+}
+
+
+yyerror(s)
+ register char *s;
+{
+ log_fatal("Fatal error: %s\n", s);
+}
+#endif CPP
--- /dev/null
+/*
+ * $XConsortium: def.h,v 1.6 88/09/22 13:52:33 jim Exp $
+ */
+#include <stdio.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#ifdef USG
+#define u_char unchar
+#endif
+
+#define MAXDEFINES 512
+#define MAXFILES 512
+#define MAXDIRS 10
+#define SYMTABINC 10 /* must be > 1 for define() to work right */
+#define TRUE 1
+#define FALSE 0
+
+/* the following must match the directives table in main.c */
+#define IF 0
+#define IFDEF 1
+#define IFNDEF 2
+#define ELSE 3
+#define ENDIF 4
+#define DEFINE 5
+#define UNDEF 6
+#define INCLUDE 7
+#define LINE 8
+#define PRAGMA 9
+#define ELIF 10
+#define EJECT 11
+#define IFFALSE 12 /* pseudo value --- never matched */
+#define ELIFFALSE 13 /* pseudo value --- never matched */
+#define INCLUDEDOT 14 /* pseudo value --- never matched */
+
+#ifdef DEBUG
+extern int debug;
+#define debug0 ((debug&0x0001)==0) ? debug : log /* show ifn*(def)*,endif */
+#define debug1 ((debug&0x0002)==0) ? debug : log /* trace defined/!defined */
+#define debug2 ((debug&0x0004)==0) ? debug : log /* show #include */
+#define debug3 ((debug&0x0008)==0) ? debug : log /* show #include SYMBOL */
+#define debug4 ((debug&0x0010)==0) ? debug : log /* unused */
+#define debug5 ((debug&0x0020)==0) ? debug : log /* unused */
+#define debug6 ((debug&0x0040)==0) ? debug : log /* unused */
+#else DEBUG
+#define debug0
+#define debug1
+#define debug2
+#define debug3
+#define debug4
+#define debug5
+#define debug6
+#endif DEBUG
+
+typedef u_char boolean;
+
+struct symtab {
+ char *s_name;
+ char *s_value;
+};
+
+struct inclist {
+ char *i_incstring; /* string from #include line */
+ char *i_file; /* path name of the include file */
+ struct inclist **i_list; /* list of files it itself includes */
+ int i_listlen; /* length of i_list */
+ struct symtab *i_defs; /* symbol table for this file */
+ struct symtab *i_lastdef; /* last symbol defined */
+ int i_deflen; /* number of defines */
+ boolean i_defchecked; /* whether defines have been checked */
+ boolean i_notified; /* whether we have revealed includes */
+ boolean i_marked; /* whether it's in the makefile */
+ boolean i_searched; /* whether we have read this */
+ boolean i_included_sym; /* whether #include SYMBOL was found */
+ /* Can't use i_list if TRUE */
+};
+
+struct filepointer {
+ char *f_p;
+ char *f_base;
+ char *f_end;
+ long f_len;
+ long f_line;
+};
+
+char *copy();
+char *malloc();
+char *realloc();
+char *basename();
+char *getline();
+struct symtab *slookup();
+struct symtab *defined();
+struct symtab *fdefined();
+struct filepointer *getfile();
+struct inclist *newinclude();
+struct inclist *inc_path();
--- /dev/null
+/*
+ * $XConsortium: include.c,v 1.6 88/09/22 13:52:38 jim Exp $
+ */
+#include "def.h"
+
+extern struct inclist inclist[ MAXFILES ],
+ *inclistp;
+extern char *includedirs[ ];
+extern char *notdotdot[ ];
+extern boolean show_where_not;
+
+struct inclist *inc_path(file, include, dot)
+ register char *file,
+ *include;
+ boolean dot;
+{
+ static char path[ BUFSIZ ];
+ register char **pp, *p;
+ register struct inclist *ip;
+ struct stat st;
+ boolean found = FALSE;
+
+ /*
+ * Check all previously found include files for a path that
+ * has already been expanded.
+ */
+ for (ip = inclist; ip->i_file; ip++)
+ if ((strcmp(ip->i_incstring, include) == 0) && !ip->i_included_sym)
+ {
+ found = TRUE;
+ break;
+ }
+
+ /*
+ * If the path was surrounded by "", then check the absolute
+ * path provided.
+ */
+ if (!found && dot) {
+ if (stat(include, &st) == 0) {
+ ip = newinclude(include, include);
+ found = TRUE;
+ }
+ else if (show_where_not)
+ log("\tnot in %s\n", include);
+ }
+
+ /*
+ * See if this include file is in the directory of the
+ * file being compiled.
+ */
+ if (!found) {
+ for (p=file+strlen(file); p>file; p--)
+ if (*p == '/')
+ break;
+ if (p == file)
+ strcpy(path, include);
+ else {
+ strncpy(path, file, (p-file) + 1);
+ path[ (p-file) + 1 ] = '\0';
+ strcpy(path + (p-file) + 1, include);
+ }
+ remove_dotdot(path);
+ if (stat(path, &st) == 0) {
+ ip = newinclude(path, include);
+ found = TRUE;
+ }
+ else if (show_where_not)
+ log("\tnot in %s\n", path);
+ }
+
+ /*
+ * Check the include directories specified. (standard include dir
+ * should be at the end.)
+ */
+ if (!found)
+ for (pp = includedirs; *pp; pp++) {
+ sprintf(path, "%s/%s", *pp, include);
+ remove_dotdot(path);
+ if (stat(path, &st) == 0) {
+ ip = newinclude(path, include);
+ found = TRUE;
+ break;
+ }
+ else if (show_where_not)
+ log("\tnot in %s\n", path);
+ }
+
+ if (!found) {
+ /*
+ * If we've announced where it's not include it anyway so
+ * it gets on the dependency list.
+ */
+ if (show_where_not)
+ ip = newinclude(include, include);
+ else
+ ip = NULL;
+ }
+ return(ip);
+}
+
+/*
+ * Ocaisionally, pathnames are created that look like ../x/../y
+ * Any of the 'x/..' sequences within the name can be eliminated.
+ * (but only if 'x' is not a symbolic link!!)
+ */
+remove_dotdot(path)
+ char *path;
+{
+ register char *end, *from, *to, **cp;
+ char *components[ MAXFILES ],
+ newpath[ BUFSIZ ];
+ boolean component_copied;
+
+ /*
+ * slice path up into components.
+ */
+ to = newpath;
+ if (*path == '/')
+ *to++ = '/';
+ *to = '\0';
+ cp = components;
+ for (from=end=path; *end; end++)
+ if (*end == '/') {
+ while (*end == '/')
+ *end++ = '\0';
+ if (*from)
+ *cp++ = from;
+ from = end;
+ }
+ *cp++ = from;
+ *cp = NULL;
+
+ /*
+ * Now copy the path, removing all 'x/..' components.
+ */
+ cp = components;
+ component_copied = FALSE;
+ while(*cp) {
+ if (!isdot(*cp) && !isdotdot(*cp) && isdotdot(*(cp+1))) {
+ if (issymbolic(newpath, *cp))
+ goto dont_remove;
+ cp++;
+ } else {
+ dont_remove:
+ if (component_copied)
+ *to++ = '/';
+ component_copied = TRUE;
+ for (from = *cp; *from; )
+ *to++ = *from++;
+ *to = '\0';
+ }
+ cp++;
+ }
+ *to++ = '\0';
+
+ /*
+ * copy the reconstituted path back to our pointer.
+ */
+ strcpy(path, newpath);
+}
+
+isdot(p)
+ register char *p;
+{
+ if(p && *p++ == '.' && *p++ == '\0')
+ return(TRUE);
+ return(FALSE);
+}
+
+isdotdot(p)
+ register char *p;
+{
+ if(p && *p++ == '.' && *p++ == '.' && *p++ == '\0')
+ return(TRUE);
+ return(FALSE);
+}
+
+issymbolic(dir, component)
+ register char *dir, *component;
+{
+ struct stat st;
+ char buf[ BUFSIZ ], **pp;
+
+ sprintf(buf, "%s%s%s", dir, *dir ? "/" : "", component);
+ for (pp=notdotdot; *pp; pp++)
+ if (strcmp(*pp, buf) == 0)
+ return (TRUE);
+ if (lstat(buf, &st) == 0
+ && (st.st_mode & S_IFMT) == S_IFLNK) {
+ *pp++ = copy(buf);
+ if (pp >= ¬dotdot[ MAXDIRS ])
+ log_fatal("out of .. dirs, increase MAXDIRS\n");
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+/*
+ * Add an include file to the list of those included by 'file'.
+ */
+struct inclist *newinclude(newfile, incstring)
+ register char *newfile, *incstring;
+{
+ register struct inclist *ip;
+
+ /*
+ * First, put this file on the global list of include files.
+ */
+ ip = inclistp++;
+ if (inclistp == inclist + MAXFILES - 1)
+ log_fatal("out of space: increase MAXFILES\n");
+ ip->i_file = copy(newfile);
+ ip->i_included_sym = FALSE;
+ if (incstring == NULL)
+ ip->i_incstring = ip->i_file;
+ else
+ ip->i_incstring = copy(incstring);
+
+ return(ip);
+}
+
+included_by(ip, newfile)
+ register struct inclist *ip, *newfile;
+{
+ register i;
+
+ if (ip == NULL)
+ return;
+ /*
+ * Put this include file (newfile) on the list of files included
+ * by 'file'. If 'file' is NULL, then it is not an include
+ * file itself (i.e. was probably mentioned on the command line).
+ * If it is already on the list, don't stick it on again.
+ */
+ if (ip->i_list == NULL)
+ ip->i_list = (struct inclist **)
+ malloc(sizeof(struct inclist *) * ++ip->i_listlen);
+ else {
+ for (i=0; i<ip->i_listlen; i++)
+ if (ip->i_list[ i ] == newfile) {
+ if (!ip->i_included_sym)
+ {
+ /* only bitch if ip has */
+ /* no #include SYMBOL lines */
+ log("%s includes %s more than once!\n",
+ ip->i_file, newfile->i_file);
+ log("Already have\n");
+ for (i=0; i<ip->i_listlen; i++)
+ log("\t%s\n", ip->i_list[i]->i_file);
+ }
+ return;
+ }
+ ip->i_list = (struct inclist **) realloc(ip->i_list,
+ sizeof(struct inclist *) * ++ip->i_listlen);
+ }
+ ip->i_list[ ip->i_listlen-1 ] = newfile;
+}
+
+inc_clean ()
+{
+ register struct inclist *ip;
+
+ for (ip = inclist; ip < inclistp; ip++) {
+ ip->i_marked = FALSE;
+ }
+}
#endif
#ifdef mips
{"mips", NULL},
+#endif
+#ifdef _AIX
+ {"_AIX", NULL},
#endif
{NULL, NULL}
};
/*VARARGS*/
log_fatal(x0,x1,x2,x3,x4,x5,x6,x7,x8,x9)
+char *x0, *x1, *x2, *x3, *x4, *x5, *x6, *x7, *x8, *x9;
{
log(x0,x1,x2,x3,x4,x5,x6,x7,x8,x9);
exit (1);
/*VARARGS0*/
log(x0,x1,x2,x3,x4,x5,x6,x7,x8,x9)
+char *x0, *x1, *x2, *x3, *x4, *x5, *x6, *x7, *x8, *x9;
{
fprintf(stderr, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9);
}
--- /dev/null
+#!/bin/sh
+#
+# @(#)mdepend.sh 1.3 5/11/88 19:44:36
+#
+# Do the equivalent of the 'makedepend' program, but do it right.
+#
+# Usage:
+#
+# makedepend [cpp-flags] [-w width] [-s magic-string] [-f makefile]
+# [-o object-suffix]
+#
+# Notes:
+#
+# The C compiler used can be overridden with the environment
+# variable "CC".
+#
+# The "-v" switch of the "makedepend" program is not supported.
+#
+#
+# This script should
+# work on both USG and BSD systems. However, when System V.4 comes out,
+# USG users will probably have to change "silent" to "-s" instead of
+# "-" (at least, that's what the documentation implies).
+#
+CC=${CC:-cc}
+
+silent='-'
+
+TMP=${TMPDIR:-/tmp}/mdep$$
+CPPCMD=${TMP}a
+DEPENDLINES=${TMP}b
+TMPMAKEFILE=${TMP}c
+MAGICLINE=${TMP}d
+
+trap "rm -f ${TMP}*; exit 1" 1 2 15
+trap "rm -f ${TMP}*; exit 0" 1 2 13
+
+echo " \c" > $CPPCMD
+if [ `wc -c < $CPPCMD` -eq 1 ]
+then
+ c="\c"
+ n=
+else
+ c=
+ n="-n"
+fi
+
+echo $n "exec $CC -E$c" > $CPPCMD
+chmod +x $CPPCMD
+
+files=
+makefile=
+magic_string='# DO NOT DELETE'
+objsuffix='.o'
+width=78
+while [ $# != 0 ]
+do
+ case "$1" in
+ -D*|-I*)
+ echo $n " '$1'$c" >> $CPPCMD
+ ;;
+ -w)
+ width="$2"
+ shift
+ ;;
+ -s)
+ magic_string="$2"
+ shift
+ ;;
+ -f)
+ makefile="$2"
+ shift
+ ;;
+ -o)
+ objsuffix="$2"
+ shift
+ ;;
+ -*)
+ echo "Unknown option '$1' ignored" 1>&2
+ ;;
+ *)
+ files="$files $1"
+ ;;
+ esac
+ shift
+done
+echo ' $*' >> $CPPCMD
+
+case "$makefile" in
+ '')
+ if [ -r makefile ]
+ then
+ makefile=makefile
+ elif [ -r Makefile ]
+ then
+ makefile=Makefile
+ else
+ echo 'no makefile or Makefile found' 1>&2
+ exit 1
+ fi
+ ;;
+ -)
+ makefile=$TMPMAKEFILE
+ ;;
+esac
+
+echo '' > $DEPENDLINES
+for i in $files
+do
+ $CPPCMD $i \
+ | sed -n "/^#/s;^;$i ;p"
+done \
+ | sed -e 's|/[^/.][^/]*/\.\.||g' -e 's|/\.[^.][^/]*/\.\.||g' \
+ -e 's|"||g' -e 's| \./| |' \
+ | awk '{
+ if ($1 != $4 && $2 != "#ident")
+ {
+ ofile = substr ($1, 1, length ($1) - 2) "'"$objsuffix"'"
+ print ofile, $4
+ }
+ }' \
+ | sort -u \
+ | awk '
+ {
+ newrec = rec " " $2
+ if ($1 != old1)
+ {
+ old1 = $1
+ if (rec != "")
+ print rec
+ rec = $1 ": " $2
+ }
+ else if (length (newrec) > '"$width"')
+ {
+ print rec
+ rec = $1 ": " $2
+ }
+ else
+ rec = newrec
+ }
+ END \
+ {
+ if (rec != "")
+ print rec
+ }' \
+ >> $DEPENDLINES
+
+trap "" 1 2 13 15 # Now we are committed
+case "$makefile" in
+ $TMPMAKEFILE)
+ ;;
+ *)
+ rm -f Makefile.bak
+ cp Makefile Makefile.bak
+ ;;
+esac
+
+#
+# Before we go edit the Makefile, we must make sure that magic_string
+# exists, and that it's not the last line. Otherwise, dear old ed
+# will exit prematurely. What a pain.
+#
+cat >> $makefile <<- END_OF_APPEND
+ $magic_string
+
+END_OF_APPEND
+ed $silent $makefile <<- END_OF_ED_SCRIPT
+ /^$magic_string/w $MAGICLINE
+ /^$magic_string/,\$d
+ \$r $MAGICLINE
+ \$r $DEPENDLINES
+ w
+ q
+END_OF_ED_SCRIPT
+
+case "$makefile" in
+ $TMPMAKEFILE)
+ cat $TMPMAKEFILE
+ ;;
+esac
+
+rm -f ${TMP}*
--- /dev/null
+.TH MAKEDEPEND 1 "26 October 1988" "X Version 11"
+.UC 4
+.SH NAME
+makedepend \- create dependencies in makefiles
+.SH SYNOPSIS
+.B makedepend
+[
+.B \-Dname=def
+] [
+.B \-Dname
+] [
+.B \-Iincludedir
+] [
+.B \-fmakefile
+] [
+.B \-oobjsuffix
+] [
+.B \-sstring
+] [
+.B \-wwidth
+] [
+\-\ \-
+.B otheroptions
+\-\ \-
+]
+sourcefile ...
+.br
+.SH DESCRIPTION
+.B Makedepend
+reads each
+.I sourcefile
+in sequence and parses it like a C-preprocessor,
+processing all
+.I #include,
+.I #define,
+.I #undef,
+.I #ifdef,
+.I #ifndef,
+.I #endif,
+.I #if
+and
+.I #else
+directives so that it can correctly tell which
+.I #include,
+directives would be used in a compilation.
+Any
+.I #include,
+directives can reference files having other
+.I #include
+directives, and parsing will occur in these files as well.
+.PP
+Every file that a
+.I sourcefile
+includes,
+directly or indirectly,
+is what
+.B makedepend
+calls a "dependency".
+These dependencies are then written to a
+.I makefile
+in such a way that
+.B make(1)
+will know which object files must be recompiled when a dependency has changed.
+.PP
+By default,
+.B makedepend
+places its output in the file named
+.I makefile
+if it exists, otherwise
+.I Makefile.
+An alternate makefile may be specified with the
+.I -f
+option.
+It first searches the makefile for
+the line
+.sp
+ # DO NOT DELETE THIS LINE -- make depend depends on it.
+.sp
+or one provided with the
+.I -s
+option,
+as a delimiter for the dependency output.
+If it finds it, it will delete everything
+following this to the end of the makefile
+and put the output after this line.
+If it doesn't find it, the program
+will append the string to the end of the makefile
+and place the output following that.
+For each
+.I sourcefile
+appearing on the command line,
+.B makedepend
+puts lines in the makefile of the form
+.sp
+ sourcefile.o: dfile ...
+.sp
+Where "sourcefile.o" is the name from the command
+line with its suffix replaced with ".o",
+and "dfile" is a dependency discovered in a
+.I #include
+directive while parsing
+.I sourcefile
+or one of the files it included.
+.SH EXAMPLE
+Normally,
+.B makedepend
+will be used in a makefile target so that typing "make depend" will
+bring the dependencies up to date for the makefile.
+For example,
+.nf
+ SRCS = file1.c file2.c ...
+ CFLAGS = -O -DHACK -I../foobar -xyz
+ depend:
+ makedepend -- $(CFLAGS) -- $(SRCS)
+.fi
+.SH OPTIONS
+.B Makedepend
+will ignore any option that it does not understand so that you may use
+the same arguments that you would for
+.B cc(1).
+.TP 5
+.B \-Dname=def or \-Dname
+Define.
+This places a definition for
+.I name
+in
+.B makedepend's
+symbol table.
+Without
+.I =def
+the symbol becomes defined as "1".
+.TP 5
+.B \-Iincludedir
+Include directory.
+This option tells
+.B makedepend
+to prepend
+.I includedir
+to its list of directories to search when it encounters
+a
+.I #include
+directive.
+By default,
+.B makedepend
+only searches /usr/include.
+.TP 5
+.B \-fmakefile
+Filename.
+This allows you to specify an alternate makefile in which
+.B makedepend
+can place its output.
+.TP 5
+.B \-oobjsuffix
+Object file suffix.
+Some systems may have object files whose suffix is something other
+than ".o".
+This option allows you to specify another suffix, such as
+".b" with
+.I -o.b
+or ":obj"
+with
+.I -o:obj
+and so forth.
+.TP 5
+.B \-sstring
+Starting string delimiter.
+This option permits you to specify
+a different string for
+.B makedepend
+to look for in the makefile.
+.TP 5
+.B \-wwidth
+Line width.
+Normally,
+.B makedepend
+will ensure that every output line that it writes will be no wider than
+78 characters for the sake of readability.
+This option enables you to change this width.
+.TP 5
+.B "\-\ \- options \-\ \-"
+If
+.B makedepend
+encounters a double hyphen (\-\ \-) in the argument list,
+then any unrecognized argument following it
+will be silently ignored; a second double hyphen terminates this
+special treatment.
+In this way,
+.B makedepend
+can be made to safely ignore esoteric compiler arguments that might
+normally be found in a CFLAGS
+.B make
+macro (see the
+.B EXAMPLE
+section above).
+All options that
+.B makedepend
+recognizes and appear between the pair of double hyphens
+are processed normally.
+.SH ALGORITHM
+The approach used in this program enables it to run an order of magnitude
+faster than any other "dependency generator" I have ever seen.
+Central to this performance are two assumptions:
+that all files compiled by a single
+makefile will be compiled with roughly the same
+.I -I
+and
+.I -D
+options;
+and that most files in a single directory will include largely the
+same files.
+.PP
+Given these assumptions,
+.B makedepend
+expects to be called once for each makefile, with
+all source files that are maintained by the
+makefile appearing on the command line.
+It parses each source and include
+file exactly once, maintaining an internal symbol table
+for each.
+Thus, the first file on the command line will take an amount of time
+proportional to the amount of time that a normal C preprocessor takes.
+But on subsequent files, if it encounter's an include file
+that it has already parsed, it does not parse it again.
+.PP
+For example,
+imagine you are compiling two files,
+.I file1.c
+and
+.I file2.c,
+they each include the header file
+.I header.h,
+and the file
+.I header.h
+in turn includes the files
+.I def1.h
+and
+.I def2.h.
+When you run the command
+.sp
+ makedepend file1.c file2.c
+.sp
+.B makedepend
+will parse
+.I file1.c
+and consequently,
+.I header.h
+and then
+.I def1.h
+and
+.I def2.h.
+It then decides that the dependencies for this file are
+.sp
+ file1.o: header.h def1.h def2.h
+.sp
+But when the program parses
+.I file2.c
+and discovers that it, too, includes
+.I header.h,
+it does not parse the file,
+but simply adds
+.I header.h,
+.I def1.h
+and
+.I def2.h
+to the list of dependencies for
+.I file2.o.
+.SH "SEE ALSO"
+cc(1), make(1)
+.SH BUGS
+If you do not have the source for cpp, the Berkeley Unix C preprocessor,
+then
+.B makedepend
+will be compiled in such a way that all
+.I #if
+directives will evaluate to "true" regardless of their actual value.
+This may cause the wrong
+.I #include
+directives to be evaluated.
+.B Makedepend
+should simply have its own parser written for
+.I #if
+expressions.
+.PP
+Imagine you are parsing two files,
+say
+.I file1.c
+and
+.I file2.c,
+each includes the file
+.I def.h.
+The list of files that
+.I def.h
+includes might truly be different when
+.I def.h
+is included by
+.I file1.c
+than when it is included by
+.I file2.c.
+But once
+.B makedepend
+arrives at a list of dependencies for a file,
+it is cast in concrete.
+.SH AUTHOR
+Todd Brunhoff, Tektronix, Inc. and MIT Project Athena
--- /dev/null
+/*
+ * $XConsortium: parse.c,v 1.8 88/09/22 13:52:51 jim Exp $
+ */
+#include "def.h"
+#include <sys/signal.h>
+
+extern char *directives[];
+extern struct symtab deflist[];
+
+find_includes(filep, file, file_red, recursion)
+ struct filepointer *filep;
+ struct inclist *file, *file_red;
+ int recursion;
+{
+ register char *line;
+ register int type;
+
+ while (line = getline(filep)) {
+ switch(type = deftype(line, filep, file_red, file, TRUE)) {
+ case IF:
+ doif:
+ type = find_includes(filep, file,
+ file_red, recursion+1);
+ while ((type == ELIF) || (type == ELIFFALSE))
+ type = gobble(filep, file, file_red);
+ if (type == ELSE)
+ gobble(filep, file, file_red);
+ break;
+ case IFFALSE:
+ doiffalse:
+ type = gobble(filep, file, file_red);
+ if (type == ELSE)
+ find_includes(filep, file,
+ file_red, recursion+1);
+ else
+ if (type == ELIF)
+ goto doif;
+ else
+ if (type == ELIFFALSE)
+ goto doiffalse;
+ break;
+ case IFDEF:
+ case IFNDEF:
+ if ((type == IFDEF && defined(line, file_red))
+ || (type == IFNDEF && !defined(line, file_red))) {
+ debug1(type == IFNDEF ?
+ "line %d: %s !def'd in %s via %s%s\n" : "",
+ filep->f_line, line,
+ file->i_file, file_red->i_file, ": doit");
+ type = find_includes(filep, file,
+ file_red, recursion+1);
+ if (type == ELSE)
+ gobble(filep, file, file_red);
+ }
+ else {
+ debug1(type == IFDEF ?
+ "line %d: %s !def'd in %s via %s%s\n" : "",
+ filep->f_line, line,
+ file->i_file, file_red->i_file, ": gobble");
+ type = gobble(filep, file, file_red);
+ if (type == ELSE)
+ find_includes(filep, file,
+ file_red, recursion+1);
+ }
+ break;
+ case ELSE:
+ case ELIFFALSE:
+ case ELIF:
+ if (!recursion)
+ gobble(filep, file, file_red);
+ case ENDIF:
+ if (recursion)
+ return(type);
+ case DEFINE:
+ define(line, file);
+ break;
+ case UNDEF:
+ /*
+ * undefine all occurances of line by killing s_name
+ */
+ if (!*line) {
+ log("%s, line %d: incomplete undef == \"%s\"\n",
+ file_red->i_file, filep->f_line, line);
+ break;
+ }
+ {
+ struct symtab *val;
+ for(val = defined(line, file_red);
+ (val && val->s_name);
+ val = defined(line, file_red))
+
+ *(val->s_name) = '\0';
+ }
+ break;
+ case INCLUDE:
+ add_include(file, file_red, line, FALSE);
+ break;
+ case INCLUDEDOT:
+ add_include(file, file_red, line, TRUE);
+ break;
+ case PRAGMA:
+ case EJECT:
+ break;
+ case -1:
+ log("%s", file_red->i_file);
+ if (file_red != file)
+ log(" (reading %s)", file->i_file);
+ log(", line %d: unknown directive == \"%s\"\n",
+ filep->f_line, line);
+ break;
+ case -2:
+ log("%s", file_red->i_file);
+ if (file_red != file)
+ log(" (reading %s)", file->i_file);
+ log(", line %d: incomplete include == \"%s\"\n",
+ filep->f_line, line);
+ break;
+ }
+ }
+ return(-1);
+}
+
+gobble(filep, file, file_red)
+ register struct filepointer *filep;
+ struct inclist *file, *file_red;
+{
+ register char *line;
+ register int type;
+
+ while (line = getline(filep)) {
+ switch(type = deftype(line, filep, file_red, file, FALSE)) {
+ case IF:
+ case IFFALSE:
+ case IFDEF:
+ case IFNDEF:
+ type = gobble(filep, file, file_red);
+ while ((type == ELIF) || (type == ELIFFALSE))
+ type = gobble(filep, file, file_red);
+ if (type == ELSE)
+ type = gobble(filep, file, file_red);
+ break;
+ case ELSE:
+ case ENDIF:
+ debug0("%s, line %d: #%s\n",
+ file->i_file, filep->f_line,
+ directives[type]);
+ return(type);
+ case DEFINE:
+ case UNDEF:
+ case INCLUDE:
+ case INCLUDEDOT:
+ case PRAGMA:
+ case EJECT:
+ break;
+ case ELIF:
+ case ELIFFALSE:
+ return(type);
+ case -1:
+ log("%s, line %d: unknown directive == \"%s\"\n",
+ file_red->i_file, filep->f_line, line);
+ break;
+ }
+ }
+ return(-1);
+}
+
+/*
+ * Decide what type of # directive this line is.
+ */
+deftype(line, filep, file_red, file, parse_it)
+ register char *line;
+ register struct filepointer *filep;
+ register struct inclist *file_red, *file;
+ int parse_it;
+{
+ register char *p;
+ char *directive, savechar;
+ register int ret;
+
+ /*
+ * Parse the directive...
+ */
+ directive=line+1;
+ while (*directive == ' ' || *directive == '\t')
+ directive++;
+
+ p = directive;
+ while (*p >= 'a' && *p <= 'z')
+ p++;
+ savechar = *p;
+ *p = '\0';
+ ret = match(directive, directives);
+ *p = savechar;
+
+ /* If we don't recognize this compiler directive or we happen to just
+ * be gobbling up text while waiting for an #endif or #elif or #else
+ * in the case of an #elif we must check the zero_value and return an
+ * ELIF or an ELIFFALSE.
+ */
+
+ if (ret == ELIF && !parse_it)
+ {
+ while (*p == ' ' || *p == '\t')
+ p++;
+ /*
+ * parse an expression.
+ */
+ debug0("%s, line %d: #elif %s ",
+ file->i_file, filep->f_line, p);
+ if (zero_value(p, filep, file_red))
+ {
+ debug0("false...\n");
+ return(ELIFFALSE);
+ }
+ else
+ {
+ debug0("true...\n");
+ return(ret);
+ }
+ }
+
+ if (ret < 0 || ! parse_it)
+ return(ret);
+
+ /*
+ * now decide how to parse the directive, and do it.
+ */
+ while (*p == ' ' || *p == '\t')
+ p++;
+ switch (ret) {
+ case IF:
+ /*
+ * parse an expression.
+ */
+ debug0("%s, line %d: #if %s\n",
+ file->i_file, filep->f_line, p);
+ if (zero_value(p, filep, file_red))
+ ret = IFFALSE;
+ break;
+ case IFDEF:
+ case IFNDEF:
+ debug0("%s, line %d: #%s %s\n",
+ file->i_file, filep->f_line, directives[ret], p);
+ case UNDEF:
+ /*
+ * separate the name of a single symbol.
+ */
+ while (isalnum(*p) || *p == '_')
+ *line++ = *p++;
+ *line = '\0';
+ break;
+ case INCLUDE:
+ debug2("%s, line %d: #include %s\n",
+ file->i_file, filep->f_line, p);
+
+ /* Support ANSI macro substitution */
+ {
+ struct symtab *sym = defined(p, file_red);
+ while (sym) {
+ p = sym->s_value;
+ debug3("%s : #includes SYMBOL %s = %s\n",
+ file->i_incstring,
+ sym -> s_name,
+ sym -> s_value);
+ /* mark file as having included a 'soft include' */
+ file->i_included_sym = TRUE;
+ sym = defined(p, file_red);
+ }
+ }
+
+ /*
+ * Separate the name of the include file.
+ */
+ while (*p && *p != '"' && *p != '<')
+ p++;
+ if (! *p)
+ return(-2);
+ if (*p++ == '"') {
+ ret = INCLUDEDOT;
+ while (*p && *p != '"')
+ *line++ = *p++;
+ } else
+ while (*p && *p != '>')
+ *line++ = *p++;
+ *line = '\0';
+ break;
+ case DEFINE:
+ /*
+ * copy the definition back to the beginning of the line.
+ */
+ strcpy (line, p);
+ break;
+ case ELSE:
+ case ENDIF:
+ case ELIF:
+ case PRAGMA:
+ case EJECT:
+ debug0("%s, line %d: #%s\n",
+ file->i_file, filep->f_line, directives[ret]);
+ /*
+ * nothing to do.
+ */
+ break;
+ }
+ return(ret);
+}
+
+struct symtab *defined(symbol, file)
+ register char *symbol;
+ struct inclist *file;
+{
+ register struct symtab *val;
+
+ if (val = slookup(symbol, deflist)) {
+ debug1("%s defined on command line\n", symbol);
+ return(val);
+ }
+ if (val = fdefined(symbol, file))
+ return(val);
+ debug1("%s not defined in %s\n", symbol, file->i_file);
+ return(NULL);
+}
+
+struct symtab *fdefined(symbol, file)
+ register char *symbol;
+ struct inclist *file;
+{
+ register struct inclist **ip;
+ register struct symtab *val;
+ register int i;
+ static int recurse_lvl = 0;
+
+ if (file->i_defchecked)
+ return(NULL);
+ file->i_defchecked = TRUE;
+ if (val = slookup(symbol, file->i_defs))
+ debug1("%s defined in %s\n", symbol, file->i_file);
+ if (val == NULL && file->i_list)
+ for (ip = file->i_list, i=0; i < file->i_listlen; i++, ip++)
+ if (val = fdefined(symbol, *ip)) {
+ debug1("%s defined in %s\n",
+ symbol, (*ip)->i_file);
+ break;
+ }
+ recurse_lvl--;
+ file->i_defchecked = FALSE;
+
+ return(val);
+}
+
+struct symtab *slookup(symbol, stab)
+ register char *symbol;
+ register struct symtab *stab;
+{
+ if (stab)
+ for (; stab->s_name; stab++)
+ if (strcmp(symbol, stab->s_name) == 0)
+ return(stab);
+ return(NULL);
+}
+
+/*
+ * Return true if the #if expression evaluates to 0
+ */
+zero_value(exp, filep, file_red)
+ register char *exp;
+ register struct filepointer *filep;
+ register struct inclist *file_red;
+{
+#ifdef CPP
+ return (cppsetup(exp, filep, file_red) == 0);
+#else CPP
+ return(TRUE);
+#endif CPP
+}
+
+define(def, file)
+ register char *def;
+ register struct inclist *file;
+{
+ register char *p;
+ struct symtab *sp = file->i_lastdef++;
+ register int i;
+
+ /*
+ * If we are out of space, allocate some more.
+ */
+ if (file->i_defs == NULL
+ || file->i_lastdef == file->i_defs + file->i_deflen) {
+ if (file->i_defs)
+ file->i_defs = (struct symtab *) realloc(file->i_defs,
+ sizeof(struct symtab)*(file->i_deflen+SYMTABINC));
+ else
+ file->i_defs = (struct symtab *)
+ malloc(sizeof (struct symtab) * SYMTABINC);
+ i=file->i_deflen;
+ file->i_deflen += SYMTABINC;
+ while (i < file->i_deflen)
+ file->i_defs[ i++ ].s_name = NULL;
+ file->i_lastdef = file->i_defs + file->i_deflen - SYMTABINC;
+ if (sp) /* be sure we use last cell in previous group */
+ file->i_lastdef--;
+ sp = file->i_lastdef++;
+ }
+ else if (file->i_lastdef > file->i_defs + file->i_deflen)
+ log_fatal("define() botch\n");
+
+ /*
+ * copy the symbol being defined.
+ */
+ p = def;
+ while (isalnum(*p) || *p == '_')
+ p++;
+ if (*p)
+ *p++ = '\0';
+ sp->s_name = copy(def);
+
+ /*
+ * And copy its value.
+ */
+ while (*p == ' ' && *p == '\t')
+ p++;
+ sp->s_value = copy(p);
+}
--- /dev/null
+/*
+ * $XConsortium: pr.c,v 1.6 88/09/30 08:55:13 jim Exp $
+ */
+#include "def.h"
+
+extern struct inclist inclist[ MAXFILES ],
+ *inclistp;
+extern char *objfile;
+extern int width;
+extern boolean printed;
+extern boolean verbose;
+extern boolean show_where_not;
+
+add_include(file, file_red, include, dot)
+ struct inclist *file, *file_red;
+ char *include;
+ boolean dot;
+{
+ register struct inclist *newfile;
+ register struct filepointer *content;
+
+ /*
+ * First decide what the pathname of this include file really is.
+ */
+ newfile = inc_path(file->i_file, include, dot);
+ if (newfile == NULL) {
+ if (file != file_red)
+ log("%s (reading %s): ",
+ file_red->i_file, file->i_file);
+ else
+ log("%s: ", file->i_file);
+ log("cannot find include file \"%s\"\n", include);
+ show_where_not = TRUE;
+ newfile = inc_path(file->i_file, include, dot);
+ show_where_not = FALSE;
+ }
+
+ included_by(file, newfile);
+ if (!newfile->i_searched) {
+ newfile->i_searched = TRUE;
+ content = getfile(newfile->i_file);
+ find_includes(content, newfile, file_red, 0);
+ freefile(content);
+ }
+}
+
+recursive_pr_include(head, file, base)
+ register struct inclist *head;
+ register char *file, *base;
+{
+ register int i;
+
+ if (head->i_marked)
+ return;
+ head->i_marked = TRUE;
+ if (head->i_file != file)
+ pr(head, file, base);
+ for (i=0; i<head->i_listlen; i++)
+ recursive_pr_include(head->i_list[ i ], file, base);
+}
+
+pr(ip, file, base)
+ register struct inclist *ip;
+ char *file, *base;
+{
+ static char *lastfile;
+ static int current_len;
+ register int len, i;
+ char buf[ BUFSIZ ];
+
+ printed = TRUE;
+ len = strlen(ip->i_file)+1;
+ if (current_len + len > width || file != lastfile) {
+ lastfile = file;
+ sprintf(buf, "\n%s%s: %s", base, objfile, ip->i_file);
+ len = current_len = strlen(buf);
+ }
+ else {
+ buf[0] = ' ';
+ strcpy(buf+1, ip->i_file);
+ current_len += len;
+ }
+ fwrite(buf, len, 1, stdout);
+
+ /*
+ * If verbose is set, then print out what this file includes.
+ */
+ if (! verbose || ip->i_list == NULL || ip->i_notified)
+ return;
+ ip->i_notified = TRUE;
+ lastfile = NULL;
+ printf("\n# %s includes:", ip->i_file);
+ for (i=0; i<ip->i_listlen; i++)
+ printf("\n#\t%s", ip->i_list[ i ]->i_incstring);
+}
+
+#if defined (mips) && defined (SYSTYPE_SYSV)
+void catch()
+{
+ fflush(stdout);
+ log_fatal("got signal\n");
+}
+#else /* not (mips && SYSTYPE_SYSV) */
+#ifdef ultrix
+void
+#endif
+catch(n)
+{
+ fflush(stdout);
+ log_fatal("got signal %d\n", n);
+}
+#endif /* mips && SYSTYPE_SYSV */
+