]> andersk Git - moira.git/commitdiff
Initial revision
authormar <mar>
Mon, 4 Jan 1993 15:57:35 +0000 (15:57 +0000)
committermar <mar>
Mon, 4 Jan 1993 15:57:35 +0000 (15:57 +0000)
regtape/Imakefile [new file with mode: 0644]
regtape/empconv.qc [new file with mode: 0644]
regtape/resign.qc [new file with mode: 0644]
regtape/stuconv.qc [new file with mode: 0644]
regtape/uidfix.qc [new file with mode: 0644]
regtape/verify.dc

diff --git a/regtape/Imakefile b/regtape/Imakefile
new file mode 100644 (file)
index 0000000..6853741
--- /dev/null
@@ -0,0 +1,20 @@
+# $Header$
+
+# Copyright 1992 by the Massachusetts Institute of Technology.
+#
+# For copying and distribution information,
+# please see the file <mit-copyright.h>.
+#
+# Imakefile for moira regtape programs.
+
+SRCS= students.c employee.c sign.c rafnu.c
+CODE= students.dc employee.dc sign.dc rafnu.c
+sqlrule()
+
+program(students, students.o rafnu.o,,$(CLIBS) $(SQL_LIB), $(PROGDIR))
+program(employee, employee.o rafnu.o,,$(CLIBS) $(SQL_LIB), $(PROGDIR))
+program(sign, sign.o rafnu.o,,$(CLIBS) $(SQL_LIB), $(PROGDIR))
+
+sqlfile(students)
+sqlfile(employee)
+sqlfile(sign)
diff --git a/regtape/empconv.qc b/regtape/empconv.qc
new file mode 100644 (file)
index 0000000..0fb3211
--- /dev/null
@@ -0,0 +1,262 @@
+/* $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
+##}
+
diff --git a/regtape/resign.qc b/regtape/resign.qc
new file mode 100644 (file)
index 0000000..116b45f
--- /dev/null
@@ -0,0 +1,122 @@
+/* $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);
+##}
diff --git a/regtape/stuconv.qc b/regtape/stuconv.qc
new file mode 100644 (file)
index 0000000..8341b20
--- /dev/null
@@ -0,0 +1,319 @@
+/* $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);
+##}
+
+
diff --git a/regtape/uidfix.qc b/regtape/uidfix.qc
new file mode 100644 (file)
index 0000000..bbd9922
--- /dev/null
@@ -0,0 +1,102 @@
+/* $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);
+##}
index 9561e5581465942874e604e4c2a6d85158236c70..6a505eeff05643674e93b2f39414c262911ce091 100644 (file)
@@ -12,7 +12,6 @@
 #include <des.h>
 #include <krb.h>
 #include <gdss.h>
-EXEC SQL INCLUDE sqlca;
 
 
 char *program;
@@ -20,23 +19,21 @@ char *program;
 main(argc, argv)
 int argc;
 char **argv;
-{
-    char buf[BUFSIZ], *usercheck[100], sigbuf[256];
-    SigInfo si;
-    int status, i, wait, check, debug;
-    EXEC SQL BEGIN DECLARE SECTION;
-    char login[10], mid[32], rawsig[256], who[257];
-    int id, timestamp;
-    EXEC SQL END DECLARE SECTION;
+##{
+     char buf[BUFSIZ], *usercheck[100], sigbuf[256];
+     SigInfo si;
+     int status, i, wait, check, debug;
+##   char login[10], mid[32], rawsig[256], who[257];
+##   int id, timestamp;
 
-    initialize_sms_error_table();
-    initialize_krb_error_table();
-    initialize_gdss_error_table();
+     initialize_sms_error_table();
+     initialize_krb_error_table();
+     initialize_gdss_error_table();
 
-    program = "sign";
-    check = debug = 0;
+     program = "sign";
+     check = debug = 0;
 
-    for (i = 1; i < argc; i++) {
+     for (i = 1; i < argc; i++) {
        if (!strcmp(argv[i], "-w"))
          wait++;
        else if (!strcmp(argv[i], "-d"))
@@ -48,17 +45,14 @@ char **argv;
        else usercheck[check++] = argv[i];
     }
 
-    EXEC SQL CONNECT moira;
+##   ingres sms
+##   range of u is users
+##   range of s is strings
 
-    if (check == 0) {
-       EXEC SQL DECLARE c CURSOR FOR
-         SELECT login, clearid, signature, string, sigdate
-         FROM users, strings
-         WHERE signature != '' and sigwho = string_id;
-       EXEC SQL OPEN c;
-       while (1) {
-           EXEC SQL FETCH c INTO :login, :mid, :rawsig, :who, :timestamp;
-           if (sqlca.sqlcode != 0) break;
+     if (check == 0) {
+##     retrieve (login = u.#login, mid = u.mit_id, rawsig = u.signature,
+##               who = s.string, timestamp = u.sigdate)
+##           where u.signature != "" and u.sigwho = s.string_id {
            sprintf(buf, "%s:%s", strtrim(login), strtrim(mid));
            si.timestamp = timestamp;
            si.SigInfoVersion = 0;
@@ -66,8 +60,7 @@ char **argv;
            si.rawsig = (unsigned char *) &rawsig[0];
            status = GDSS_Recompose(&si, sigbuf);
            if (status) {
-               com_err(program, gdss2et(status), "recomposing for user %s",
-                       login);
+               com_err(program, gdss2et(status), "recomposing for user %s", login);
                continue;
            }
            si.rawsig = NULL;
@@ -80,18 +73,14 @@ char **argv;
                fflush(stdout);
                gets(buf);
            }
-       }
+##     }
     } else {
        for (i = check - 1; i >= 0; i--) {
            strcpy(login, usercheck[i]);
-           EXEC SQL DECLARE s CURSOR FOR
-             SELECT clearid, signature, string, sigdate
-             FROM users, strings
-             WHERE signature != '' and sigwho = string_id and login = :login;
-           EXEC SQL OPEN s;
-           while (1) {
-               EXEC SQL FETCH s INTO :mid, :rawsig, :who, :timestamp;
-               if (sqlca.sqlcode != 0) break;
+##         retrieve (mid = u.mit_id, rawsig = u.signature,
+##                   who = s.string, timestamp = u.sigdate)
+##               where u.signature != "" and u.sigwho = s.string_id 
+##                     and u.#login = login {
                sprintf(buf, "%s:%s", strtrim(login), strtrim(mid));
                if (debug) {
                    printf("Verifying \"%s\"\n", buf);
@@ -120,12 +109,13 @@ char **argv;
                    fflush(stdout);
                    gets(buf);
                }
-           }
+##         }
        }
     }
 
+##   exit
      exit(0);
-}
+##}
 
 
 hex_dump(p)
This page took 0.085577 seconds and 5 git commands to generate.