]> andersk Git - moira.git/blobdiff - dbck/phase2.pc
make this at least compile. still needs fixes from last deactivation
[moira.git] / dbck / phase2.pc
index 4c92ccc7d5706d75a768a9d714db0b4d3e11439e..8a8ace0354dc8a6773c647f90538c9f65e37f019 100644 (file)
@@ -1,26 +1,92 @@
-/* $Header$
+/* $Id$
  *
- *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * (c) Copyright 1988-1998 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 <stdlib.h>
 #include <moira.h>
 #include "dbck.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
 EXEC SQL INCLUDE sqlca;
 
-static char phase2_qc_rcsid[] = "$Header$";
+RCSID("$Header$");
 
 EXEC SQL WHENEVER SQLERROR DO dbmserr();
 
-int show_mcm_mach(int id)
+int show_mcm_mach(void *id);
+int show_mcm_clu(void *id);
+int show_hostalias(void *id);
+int show_printer_mach(void *id);
+int show_printer_loghost(void *id);
+int show_printer_spool(void *id);
+int show_printer_quota(void *id);
+int show_printer_ac(void *id);
+int show_printer_lpc_acl(void *id);
+void fix_printer_ac(void *id);
+void fix_printer_lpc_acl(void *id);
+void user_check(int id, void *user, void *hint);
+int maybe_fixup_unref_string(int sid, int oid, char *oname, char *table,
+                            char *field, char *idfield);
+int maybe_fixup_modby(int sid, int oid, char *oname, char *table,
+                     char *field, char *idfield);
+int maybe_fixup_unref_string2(char *table, char *field, char *cursor, int sid);
+int maybe_fixup_modby2(char *table, char *field, char *cursor, int id);
+void pobox_check(int id, struct user *u);
+void remove_pobox(int id);
+void fix_smtp_pobox(int id, int sid);
+void mach_check(int id, void *machine, void *hint);
+void subnet_check(int id, void *subnet, void *hint);
+void clear_subnet_owner(struct subnet *s);
+void clear_mach_owner(struct machine *m);
+void cluster_check(int id, void *cluster, void *hint);
+int show_svc(void *id);
+void list_check(int id, void *list, void *hint);
+void fix_list_acl(int id);
+int show_member_list(void *id);
+int show_mem_user(void *id);
+int show_mem_list(void *id);
+int show_mem_str(void *id);
+int show_mem_krb(void *id);
+void del_mem_user(void *id);
+void del_mem_list(void *id);
+void del_mem_str(void *id);
+void del_mem_krb(void *id);
+int show_sh(void *id);
+void del_sh_mach(void *id);
+void fsmatch(int id, void *nfsphys, void *filesys);
+void check_fs(int id, void *filesys, void *hint);
+void check_nfsphys(int id, void *nfsphys, void *hint);
+int show_fsg_missing(void *id);
+int show_fsg_type(void *filesys);
+void fix_fsg_type(void *filesys);
+int show_fsg_nomember(void *id);
+int show_quota_nouser(void *id);
+int show_quota_nolist(void *id);
+void fix_quota_nouser(void *id);
+void fix_quota_nolist(void *id);
+int show_quota_nofs(void *id);
+void fix_quota_nofs(void *id);
+int show_quota_wrongpid(void *id);
+void fix_quota_physid(void *id);
+int show_srv_user(void *id);
+int show_srv_list(void *id);
+void zero_srv_user(void *id);
+void zero_srv_list(void *id);
+int show_krb_usr(void *id);
+int show_krb_str(void *id);
+int show_pdm_mach(void *id);
+
+int show_mcm_mach(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, found = 1;
-  char name[33];
+  int iid = (int)id, found = 1;
+  char name[CLUSTERS_NAME_SIZE];
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DECLARE csr201 CURSOR FOR
@@ -35,17 +101,18 @@ int show_mcm_mach(int id)
 
       strtrim(name);
       found = 0;
-      printf("Cluster %s, non-existant machine %d in cluster map\n", name, id);
+      printf("Cluster %s, non-existant machine %d in cluster map\n",
+            name, iid);
     }
   EXEC SQL CLOSE csr201;
   return found;
 }
 
-int show_mcm_clu(int id)
+int show_mcm_clu(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, found = 1;
-  char name[33];
+  int iid = (int)id, found = 1;
+  char name[MACHINE_NAME_SIZE];
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DECLARE csr202 CURSOR FOR
@@ -61,17 +128,18 @@ int show_mcm_clu(int id)
       strtrim(name);
 
       found = 0;
-      printf("Machine %s, non-existant cluster %d in cluster map\n", name, id);
+      printf("Machine %s, non-existant cluster %d in cluster map\n",
+            name, iid);
     }
   EXEC SQL CLOSE csr202;
   return found;
 }
 
-int show_hostalias(int id)
+int show_hostalias(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, found = 1;
-  char name[33];
+  int iid = (int)id, found = 1;
+  char name[HOSTALIAS_NAME_SIZE];
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DECLARE csr234 CURSOR FOR
@@ -86,21 +154,22 @@ int show_hostalias(int id)
       strtrim(name);
 
       found = 0;
-      printf("Alias %s, non-existant machine %d in hostalias map\n", name, id);
+      printf("Alias %s, non-existant machine %d in hostalias map\n",
+            name, iid);
     }
   EXEC SQL CLOSE csr234;
   return found;
 }
 
-int show_pcap_mach(int id)
+int show_printer_mach(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, found = 1;
-  char name[33];
+  int iid = (int)id, found = 1;
+  char name[PRINTERS_NAME_SIZE];
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DECLARE csr235 CURSOR FOR
-    SELECT name FROM printcap WHERE mach_id = :iid;
+    SELECT name FROM printers WHERE mach_id = :iid;
   EXEC SQL OPEN csr235;
   while (1)
     {
@@ -111,22 +180,22 @@ int show_pcap_mach(int id)
       strtrim(name);
 
       found = 0;
-      printf("Printer %s, non-existant spool machine %d in printcap table\n",
-            name, id);
+      printf("Printer %s, non-existant machine %d in printers table\n",
+            name, iid);
     }
   EXEC SQL CLOSE csr235;
   return found;
 }
 
-int show_pcap_quota(int id)
+int show_printer_loghost(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, found = 1;
-  char name[33];
+  int iid = (int)id, found = 1;
+  char name[PRINTERS_NAME_SIZE];
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DECLARE csr236 CURSOR FOR
-    SELECT name FROM printcap WHERE quotaserver = :iid;
+    SELECT name FROM printers WHERE loghost = :iid;
   EXEC SQL OPEN csr236;
   while (1)
     {
@@ -137,15 +206,151 @@ int show_pcap_quota(int id)
       strtrim(name);
 
       found = 0;
-      printf("Printer %s, non-existant quota server %d in printcap table\n",
-            name, id);
+      printf("Printer %s, non-existant spool machine %d in printers table\n",
+            name, iid);
     }
   EXEC SQL CLOSE csr236;
   return found;
 }
 
-user_check(int id, struct user *u, int hint)
+int show_printer_spool(void *id)
+{
+  EXEC SQL BEGIN DECLARE SECTION;
+  int iid = (int)id, found = 1;
+  char name[PRINTERS_NAME_SIZE];
+  EXEC SQL END DECLARE SECTION;
+
+  EXEC SQL DECLARE csr237 CURSOR FOR
+    SELECT name FROM printers WHERE rm = :iid;
+  EXEC SQL OPEN csr237;
+  while (1)
+    {
+      EXEC SQL FETCH csr237 INTO :name;
+      if (sqlca.sqlcode)
+       break;
+
+      strtrim(name);
+
+      found = 0;
+      printf("Printer %s, non-existant spool machine %d in printers table\n",
+            name, iid);
+    }
+  EXEC SQL CLOSE csr237;
+  return found;
+}
+
+int show_printer_quota(void *id)
+{
+  EXEC SQL BEGIN DECLARE SECTION;
+  int iid = (int)id, found = 1;
+  char name[PRINTERS_NAME_SIZE];
+  EXEC SQL END DECLARE SECTION;
+
+  EXEC SQL DECLARE csr238 CURSOR FOR
+    SELECT name FROM printers WHERE rq = :iid;
+  EXEC SQL OPEN csr238;
+  while (1)
+    {
+      EXEC SQL FETCH csr238 INTO :name;
+      if (sqlca.sqlcode)
+       break;
+
+      strtrim(name);
+
+      found = 0;
+      printf("Printer %s, non-existant quota server %d in printers table\n",
+            name, iid);
+    }
+  EXEC SQL CLOSE csr238;
+  return found;
+}
+
+int show_printer_ac(void *id)
+{
+  EXEC SQL BEGIN DECLARE SECTION;
+  int iid = (int)id, found = 1;
+  char name[PRINTERS_NAME_SIZE];
+  EXEC SQL END DECLARE SECTION;
+
+  EXEC SQL DECLARE csr239 CURSOR FOR
+    SELECT name FROM printers WHERE ac = :iid;
+  EXEC SQL OPEN csr239;
+  while (1)
+    {
+      EXEC SQL FETCH csr239 INTO :name;
+      if (sqlca.sqlcode)
+       break;
+
+      strtrim(name);
+
+      found = 0;
+      printf("Printer %s, non-existant restrict list %d in printers table\n",
+            name, iid);
+    }
+  EXEC SQL CLOSE csr239;
+  return found;
+}
+
+int show_printer_lpc_acl(void *id)
+{
+  EXEC SQL BEGIN DECLARE SECTION;
+  int iid = (int)id, found = 1;
+  char name[PRINTERS_NAME_SIZE];
+  EXEC SQL END DECLARE SECTION;
+
+  EXEC SQL DECLARE csr240 CURSOR FOR
+    SELECT name FROM printers WHERE lpc_acl = :iid;
+  EXEC SQL OPEN csr240;
+  while (1)
+    {
+      EXEC SQL FETCH csr240 INTO :name;
+      if (sqlca.sqlcode)
+       break;
+
+      strtrim(name);
+
+      found = 0;
+      printf("Printer %s, non-existant lpc ACL %d in printers table\n",
+            name, iid);
+    }
+  EXEC SQL CLOSE csr240;
+  return found;
+}
+
+void fix_printer_ac(void *id)
+{
+  EXEC SQL BEGIN DECLARE SECTION;
+  int rowcount, iid = (int)id;
+  EXEC SQL END DECLARE SECTION;
+
+  EXEC SQL UPDATE printers SET ac = 0 WHERE ac = :iid;
+  rowcount = sqlca.sqlerrd[2];
+  if (rowcount > 0)
+    printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
+  else
+    printf("Not fixed\n");
+  modified("printers");
+}
+
+void fix_printer_lpc_acl(void *id)
 {
+  EXEC SQL BEGIN DECLARE SECTION;
+  int rowcount, iid = (int)id;
+  EXEC SQL END DECLARE SECTION;
+
+  EXEC SQL UPDATE printers SET lpc_acl = 0 WHERE lpc_acl = :iid;
+  rowcount = sqlca.sqlerrd[2];
+  if (rowcount > 0)
+    printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
+  else
+    printf("Not fixed\n");
+  modified("printers");
+}
+
+void user_check(int id, void *user, void *hint)
+{
+  struct user *u = user;
+
   u->comment = maybe_fixup_unref_string(u->comment, id, u->login, "users",
                                        "comments", "users_id");
 
@@ -161,7 +366,7 @@ user_check(int id, struct user *u, int hint)
   u->sigwho = maybe_fixup_unref_string(u->sigwho, id, u->login, "users",
                                       "sigwho", "users_id");
 
-  pobox_check(id, u, hint);
+  pobox_check(id, u);
 }
 
 int maybe_fixup_unref_string(int sid, int oid, char *oname, char *table,
@@ -173,7 +378,7 @@ int maybe_fixup_unref_string(int sid, int oid, char *oname, char *table,
   char stmt_buf[500];
   EXEC SQL END DECLARE SECTION;
 
-  if (newid = int_hash_lookup(string_dups, ret))
+  if ((newid = (int)hash_lookup(string_dups, ret)))
     {
       printf("%s entry %s(%d) has a %s with duplicate string %d\n",
             table, oname, oid, field, ret);
@@ -253,7 +458,7 @@ int maybe_fixup_unref_string2(char *table, char *field, char *cursor, int sid)
   char stmt_buf[500];
   EXEC SQL END DECLARE SECTION;
 
-  if ((newid = int_hash_lookup(string_dups, ret)))
+  if ((newid = (int)hash_lookup(string_dups, ret)))
     {
       printf("%s entry has a %s with duplicate string %d\n",
             table, field, ret);
@@ -323,7 +528,7 @@ int maybe_fixup_modby2(char *table, char *field, char *cursor, int id)
   return 1;
 }
 
-pobox_check(int id, struct user *u, int hint)
+void pobox_check(int id, struct user *u)
 {
   switch (u->potype)
     {
@@ -340,7 +545,7 @@ pobox_check(int id, struct user *u, int hint)
        }
       break;
     case 'S':
-      if (int_hash_lookup(string_dups, u->pobox_id))
+      if (hash_lookup(string_dups, u->pobox_id))
        {
          printf("User %s(%s) has P.O.Box with duplicate string %d\n",
                 u->login, u->fullname, u->pobox_id);
@@ -348,8 +553,8 @@ pobox_check(int id, struct user *u, int hint)
            {
              printf("Replacing box_id dup string ID %d with %d\n",
                     u->pobox_id,
-                    int_hash_lookup(string_dups, u->pobox_id));
-             u->pobox_id = int_hash_lookup(string_dups, u->pobox_id);
+                    (int)hash_lookup(string_dups, u->pobox_id));
+             u->pobox_id = (int)hash_lookup(string_dups, u->pobox_id);
              fix_smtp_pobox(u->users_id, u->pobox_id);
              string_check(u->pobox_id);
            }
@@ -371,10 +576,10 @@ pobox_check(int id, struct user *u, int hint)
 }
 
 
-remove_pobox(int id)
+void remove_pobox(int id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int rowcount, iid = id;
+  int rowcount, iid = (int)id;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL UPDATE users SET potype = 'NONE' WHERE users.users_id = :iid;
@@ -386,7 +591,7 @@ remove_pobox(int id)
   modified("users");
 }
 
-fix_smtp_pobox(int id, int sid)
+void fix_smtp_pobox(int id, int sid)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int rowcount, iid = id, isid = sid;
@@ -401,8 +606,10 @@ fix_smtp_pobox(int id, int sid)
   modified("users");
 }
 
-mach_check(int id, struct machine *m, int hint)
+void mach_check(int id, void *machine, void *hint)
 {
+  struct machine *m = machine;
+
   if (!hash_lookup(subnets, m->snet_id))
     {
       printf("Machine %s is on a non-existant subnet %d\n",
@@ -466,8 +673,10 @@ mach_check(int id, struct machine *m, int hint)
                               "modby", "mach_id");
 }
 
-subnet_check(int id, struct subnet *s, int hint)
+void subnet_check(int id, void *subnet, void *hint)
 {
+  struct subnet *s = subnet;
+
   switch (s->owner_type)
     {
     case 'U':
@@ -502,7 +711,7 @@ subnet_check(int id, struct subnet *s, int hint)
                               "modby", "snet_id");
 }
 
-clear_subnet_owner(struct subnet *s)
+void clear_subnet_owner(struct subnet *s)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int rowcount, id = s->snet_id;
@@ -518,7 +727,7 @@ clear_subnet_owner(struct subnet *s)
   modified("subnet");
 }
 
-clear_mach_owner(struct machine *m)
+void clear_mach_owner(struct machine *m)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int rowcount, id = m->mach_id;
@@ -534,17 +743,19 @@ clear_mach_owner(struct machine *m)
   modified("machine");
 }
 
-cluster_check(int id, struct cluster *c, int hint)
+void cluster_check(int id, void *cluster, void *hint)
 {
+  struct cluster *c = cluster;
+
   c->modby = maybe_fixup_modby(c->modby, id, c->name, "clusters",
                               "modby", "clu_id");
 }
 
-int show_svc(int id)
+int show_svc(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, found = 1;
-  char label[17], data[33];
+  int iid = (int)id, found = 1;
+  char label[SVC_SERV_LABEL_SIZE], data[SVC_SERV_CLUSTER_SIZE];
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DECLARE csr203 CURSOR FOR
@@ -561,14 +772,19 @@ int show_svc(int id)
       strtrim(data);
       found = 0;
       printf("Cluster data [%s] %s for non-existant cluster %d\n",
-            label, data, id);
+            label, data, iid);
     }
   EXEC SQL CLOSE csr203;
   return found;
 }
 
-list_check(int id, struct list *l, int hint)
+void list_check(int id, void *list, void *hint)
 {
+  struct list *l = list;
+
+  l->modby = maybe_fixup_modby(l->modby, id, l->name, "list",
+                              "modby", "list_id");
+
   switch (l->acl_type)
     {
     case 'L':
@@ -600,10 +816,10 @@ list_check(int id, struct list *l, int hint)
     }
 }
 
-fix_list_acl(int id)
+void fix_list_acl(int id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int rowcount, iid = id;
+  int rowcount, iid = (int)id;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL UPDATE list SET acl_id = :iid, acl_type = 'LIST'
@@ -616,16 +832,16 @@ fix_list_acl(int id)
   modified("list");
 }
 
-int show_member_list(int id)
+int show_member_list(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int mid, iid = id, found = 1;
-  char mtype[9], *name = "";
+  int mid, iid = (int)id, found = 1;
+  char mtype[IMEMBERS_MEMBER_TYPE_SIZE], *name = NULL;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DECLARE csr204 CURSOR FOR
     SELECT member_type, member_id FROM imembers
-    WHERE list_id = :iid AND direct = 1;
+    WHERE list_id = :iid;
   EXEC SQL OPEN csr204;
   while (1)
     {
@@ -636,127 +852,154 @@ int show_member_list(int id)
       strtrim(mtype);
       found = 0;
       if (mtype[0] == 'L')
-       name = ((struct list *) hash_lookup(lists, mid))->name;
+       {
+         struct list *l = hash_lookup(lists, mid);
+         if (l)
+           name = l->name;
+       }
       else if (mtype[0] == 'U')
-       name = ((struct user *) hash_lookup(users, mid))->login;
+       {
+         struct user *u = hash_lookup(users, mid);
+         if (u)
+           name = u->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);
+       {
+         struct string *s = hash_lookup(strings, mid);
+         if (s)
+           name = s->name;
+       }
+      if (name)
+       printf("Non-existant list %d has member %s %s\n", iid, mtype, name);
+      else
+       {
+         printf("Non-existant list %d has non-existent member %s %d\n",
+                iid, mtype, mid);
+       }
     }
   EXEC SQL CLOSE csr204;
   return found;
 }
 
-int show_mem_user(int id)
+int show_mem_user(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int lid, iid = id, found = 1;
-  char name[33];
+  int lid, iid = (int)id, found = 1;
   EXEC SQL END DECLARE SECTION;
+  struct list *l;
 
   EXEC SQL DECLARE csr205 CURSOR FOR
     SELECT list_id FROM imembers
-    WHERE member_id = :iid AND member_type = 'USER' AND direct = 1;
+    WHERE member_id = :iid AND member_type = 'USER';
   EXEC SQL OPEN csr205;
   while (1)
     {
       EXEC SQL FETCH csr205 INTO :lid;
       if (sqlca.sqlcode)
        break;
+      l = hash_lookup(lists, lid);
+      if (!l)
+       continue;
 
       found = 0;
-      printf("List %s has non-existant user member, id %d\n",
-            ((struct list *)hash_lookup(lists, lid))->name, iid);
+      printf("List %s has non-existant user member, id %d\n", l->name, iid);
     }
   EXEC SQL CLOSE csr205;
   return found;
 }
 
-int show_mem_list(int id)
+int show_mem_list(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int lid, iid = id, found = 1;
-  char name[33];
+  int lid, iid = (int)id, found = 1;
   EXEC SQL END DECLARE SECTION;
+  struct list *l;
 
   EXEC SQL DECLARE csr206 CURSOR FOR
     SELECT list_id FROM imembers
-    WHERE member_id = :iid AND member_type = 'LIST' AND direct = 1;
+    WHERE member_id = :iid AND member_type = 'LIST';
   EXEC SQL OPEN csr206;
   while (1)
     {
       EXEC SQL FETCH csr206 INTO :lid;
       if (sqlca.sqlcode)
        break;
+      l = hash_lookup(lists, lid);
+      if (!l)
+       continue;
 
       found = 0;
-      printf("List %s has non-existant list member, id %d\n",
-            ((struct list *)hash_lookup(lists, lid))->name, iid);
+      printf("List %s has non-existant list member, id %d\n", l->name, iid);
     }
   EXEC SQL CLOSE csr206;
   return found;
 }
 
-int show_mem_str(int id)
+int show_mem_str(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int lid, iid = id, found = 1;
-  char name[33];
+  int lid, iid = (int)id, found = 1;
   EXEC SQL END DECLARE SECTION;
+  struct list *l;
 
   EXEC SQL DECLARE csr207 CURSOR FOR
     SELECT list_id FROM imembers
-    WHERE member_id = :iid AND member_type = 'STRING' AND direct = 1;
+    WHERE member_id = :iid AND member_type = 'STRING';
   EXEC SQL OPEN csr207;
   while (1)
     {
       EXEC SQL FETCH csr207 INTO :lid;
       if (sqlca.sqlcode)
        break;
+      l = hash_lookup(lists, lid);
+      if (!l)
+       continue;
 
       found = 0;
-      printf("List %s has non-existant string member, id %d\n",
-            ((struct list *)hash_lookup(lists, lid))->name, iid);
+      printf("List %s has non-existant string member, id %d\n", l->name, iid);
     }
   EXEC SQL CLOSE csr207;
   return found;
 }
 
 
-int show_mem_krb(int id)
+int show_mem_krb(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int lid, iid = id, found = 1;
-  char name[33];
+  int lid, iid = (int)id, found = 1;
   EXEC SQL END DECLARE SECTION;
+  struct list *l;
 
   EXEC SQL DECLARE csr208 CURSOR FOR
     SELECT list_id FROM imembers
-    WHERE member_id = :iid AND member_type = 'KERBEROS' AND direct = 1;
+    WHERE member_id = :iid AND member_type = 'KERBEROS';
   EXEC SQL OPEN csr208;
   while (1)
     {
       EXEC SQL FETCH csr208 INTO :lid;
       if (sqlca.sqlcode)
        break;
+      l = hash_lookup(lists, lid);
+      if (!l)
+       continue;
 
       found = 0;
       printf("List %s has non-existant kerberos member, id %d\n",
-            ((struct list *)hash_lookup(lists, lid))->name, iid);
+            l->name, iid);
     }
   EXEC SQL CLOSE csr208;
   return found;
 }
 
 
-del_mem_user(int id)
+void del_mem_user(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount;
+  int iid = (int)id, rowcount;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DELETE FROM imembers WHERE member_type = 'USER' AND
-    member_id = :iid AND direct = 1;
+    member_id = :iid;
   rowcount = sqlca.sqlerrd[2];
   if (rowcount > 0)
     printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
@@ -765,14 +1008,14 @@ del_mem_user(int id)
   modified("imembers");
 }
 
-del_mem_list(int id)
+void del_mem_list(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount;
+  int iid = (int)id, rowcount;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DELETE FROM imembers WHERE member_type = 'LIST' AND
-    member_id = :iid AND direct = 1;
+    member_id = :iid;
   rowcount = sqlca.sqlerrd[2];
   if (rowcount > 0)
     printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
@@ -781,14 +1024,14 @@ del_mem_list(int id)
   modified("imembers");
 }
 
-del_mem_str(int id)
+void del_mem_str(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount;
+  int iid = (int)id, rowcount;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DELETE FROM imembers WHERE member_type = 'STRING' AND
-    member_id = :iid AND direct = 1;
+    member_id = :iid;
   rowcount = sqlca.sqlerrd[2];
   if (rowcount > 0)
     printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
@@ -798,14 +1041,14 @@ del_mem_str(int id)
 }
 
 
-del_mem_krb(int id)
+void del_mem_krb(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount;
+  int iid = (int)id, rowcount;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DELETE FROM imembers WHERE member_type = 'KERBEROS' AND
-    member_id = :iid AND direct = 1;
+    member_id = :iid;
   rowcount = sqlca.sqlerrd[2];
   if (rowcount > 0)
     printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
@@ -815,11 +1058,11 @@ del_mem_krb(int id)
 }
 
 
-int show_sh(int id)
+int show_sh(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  char name[33];
-  int iid = id;
+  char name[SERVERHOSTS_SERVICE_SIZE];
+  int iid = (int)id;
   EXEC SQL END DECLARE SECTION;
   int found = 1;
 
@@ -835,16 +1078,16 @@ int show_sh(int id)
 
       found = 0;
       printf("ServerHost entry for service %s non-existant host %d\n",
-            name, id);
+            name, iid);
     }
   EXEC SQL CLOSE csr209;
   return found;
 }
 
-del_sh_mach(int id)
+void del_sh_mach(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount;
+  int iid = (int)id, rowcount;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DELETE FROM serverhosts WHERE mach_id = :iid;
@@ -859,8 +1102,11 @@ del_sh_mach(int id)
 
 static int fnchecklen;
 
-fsmatch(int id, struct nfsphys *n, struct filesys *f)
+void fsmatch(int id, void *nfsphys, void *filesys)
 {
+  struct nfsphys *n = nfsphys;
+  struct filesys *f = filesys;
+
   if (n->mach_id == f->mach_id &&
       !strncmp(f->dir, n->dir, strlen(n->dir)) &&
       strlen(n->dir) > fnchecklen)
@@ -871,12 +1117,13 @@ fsmatch(int id, struct nfsphys *n, struct filesys *f)
 }
 
 
-check_fs(int id, struct filesys *f, int hint)
+void check_fs(int id, void *filesys, void *hint)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int iid = id, id1, id2, id3, rowcount;
   char *dir;
   EXEC SQL END DECLARE SECTION;
+  struct filesys *f = filesys;
   struct nfsphys *n;
   struct machine *m;
 
@@ -919,7 +1166,7 @@ check_fs(int id, struct filesys *f, int hint)
     {
       if (!hash_lookup(nfsphys, f->phys_id))
        {
-         m = (struct machine *)hash_lookup(machines, f->mach_id);
+         m = 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))
            {
@@ -1004,8 +1251,13 @@ check_fs(int id, struct filesys *f, int hint)
     }
 }
 
-check_nfsphys(int id, struct nfsphys *n, int hint)
+void check_nfsphys(int id, void *nfsphys, void *hint)
 {
+  struct nfsphys *n = nfsphys;
+
+  n->modby = maybe_fixup_modby(n->modby, id, n->dir, "nfsphys",
+                              "modby", "nfsphys_id");
+
   if (!hash_lookup(machines, n->mach_id))
     {
       printf("NFSphys %d(%s) on non-existant machine %d\n",
@@ -1015,10 +1267,10 @@ check_nfsphys(int id, struct nfsphys *n, int hint)
     }
 }
 
-int show_fsg_missing(int id)
+int show_fsg_missing(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, id1, found = 1;
+  int iid = (int)id, id1, found = 1;
   EXEC SQL END DECLARE SECTION;
   struct filesys *f;
 
@@ -1033,17 +1285,18 @@ int show_fsg_missing(int id)
        break;
 
       found = 0;
-      if (f = (struct filesys *) hash_lookup(filesys, id1))
-       printf("Missing fsgroup %d has member filesystem %s\n", id, f->name);
+      if ((f = hash_lookup(filesys, id1)))
+       printf("Missing fsgroup %d has member filesystem %s\n", iid, f->name);
       else
-       printf("Missing fsgroup %d has member filesystem %d\n", id, id1);
+       printf("Missing fsgroup %d has member filesystem %d\n", iid, id1);
     }
   EXEC SQL CLOSE csr210;
   return found;
 }
 
-int show_fsg_type(struct filesys *f)
+int show_fsg_type(void *filesys)
 {
+  struct filesys *f = filesys;
   char *t;
 
   switch (f->type)
@@ -1073,8 +1326,9 @@ int show_fsg_type(struct filesys *f)
   return 0;
 }
 
-fix_fsg_type(struct filesys *f)
+void fix_fsg_type(void *filesys)
 {
+  struct filesys *f = filesys;
   EXEC SQL BEGIN DECLARE SECTION;
   int rowcount, id = f->filsys_id;
   EXEC SQL END DECLARE SECTION;
@@ -1088,10 +1342,10 @@ fix_fsg_type(struct filesys *f)
   modified("filesys");
 }
 
-int show_fsg_nomember(int id)
+int show_fsg_nomember(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, id1, found = 1;
+  int iid = (int)id, id1, found = 1;
   EXEC SQL END DECLARE SECTION;
   struct filesys *f;
 
@@ -1106,19 +1360,19 @@ int show_fsg_nomember(int id)
        break;
 
       found = 0;
-      if (f = (struct filesys *) hash_lookup(filesys, id1))
-       printf("FSGroup %s has missing member %d\n", f->name, id);
+      if ((f = hash_lookup(filesys, id1)))
+       printf("FSGroup %s has missing member %d\n", f->name, iid);
       else
-       printf("FSGroup %d has missing member %d\n", id1, id);
+       printf("FSGroup %d has missing member %d\n", id1, iid);
     }
   EXEC SQL CLOSE csr211;
   return found;
 }
 
-int show_quota_nouser(int id)
+int show_quota_nouser(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, id1, found = 1;
+  int iid = (int)id, id1, found = 1;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DECLARE csr212 CURSOR FOR
@@ -1132,16 +1386,16 @@ int show_quota_nouser(int id)
        break;
 
       found = 0;
-      printf("Quota on fs %d for non-existant user %d\n", id1, id);
+      printf("Quota on fs %d for non-existant user %d\n", id1, iid);
     }
   EXEC SQL CLOSE csr212;
   return found;
 }
 
-int show_quota_nolist(int id)
+int show_quota_nolist(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, id1, found = 1;
+  int iid = (int)id, id1, found = 1;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DECLARE csr213 CURSOR FOR
@@ -1155,19 +1409,19 @@ int show_quota_nolist(int id)
        break;
 
       found = 0;
-      printf("Quota on fs %d for non-existant list %d\n", id1, id);
+      printf("Quota on fs %d for non-existant list %d\n", id1, iid);
     }
   EXEC SQL CLOSE csr213;
   return found;
 }
 
-fix_quota_nouser(int id)
+void fix_quota_nouser(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount, id1;
+  int iid = (int)id, rowcount, id1;
   EXEC SQL END DECLARE SECTION;
 
-  id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
+  id1 = ((struct filesys *)hash_lookup(filesys, iid))->phys_id;
   EXEC SQL DELETE FROM quota
     WHERE entity_id = :iid AND type = 'USER';
   rowcount = sqlca.sqlerrd[2];
@@ -1178,13 +1432,13 @@ fix_quota_nouser(int id)
   modified("quota");
 }
 
-fix_quota_nolist(int id)
+void fix_quota_nolist(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount, id1;
+  int iid = (int)id, rowcount, id1;
   EXEC SQL END DECLARE SECTION;
 
-  id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
+  id1 = ((struct filesys *)hash_lookup(filesys, iid))->phys_id;
   EXEC SQL DELETE FROM quota WHERE entity_id = :iid AND type = 'GROUP';
   rowcount = sqlca.sqlerrd[2];
   if (rowcount > 0)
@@ -1194,11 +1448,11 @@ fix_quota_nolist(int id)
   modified("quota");
 }
 
-int show_quota_nofs(int id)
+int show_quota_nofs(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, id1, found = 1;
-  char type[9];
+  int iid = (int)id, id1, found = 1;
+  char type[QUOTA_TYPE_SIZE];
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DECLARE csr214 CURSOR FOR
@@ -1212,27 +1466,26 @@ int show_quota_nofs(int id)
        break;
 
       found = 0;
-      printf("Quota for %s %d on non-existant filesys %d\n", type, id1, id);
+      printf("Quota for %s %d on non-existant filesys %d\n", type, id1, iid);
     }
   EXEC SQL CLOSE csr214;
   return found;
 }
 
-fix_quota_nofs(int id)
+void fix_quota_nofs(void *id)
 {
-  single_delete("quota", "filsys_id", id);
+  single_delete("quota", "filsys_id", (int)id);
 }
 
-int show_quota_wrongpid(int id)
+int show_quota_wrongpid(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, id1, found = 1;
-  char type[9];
+  int iid = (int)id, id1, found = 1;
+  char type[QUOTA_TYPE_SIZE];
   EXEC SQL END DECLARE SECTION;
-  struct user *u;
   struct filesys *f;
 
-  f = (struct filesys *)hash_lookup(filesys, id);
+  f = hash_lookup(filesys, iid);
   EXEC SQL DECLARE csr215 CURSOR FOR
     SELECT entity_id, type FROM quota
     WHERE filsys_id = :iid;
@@ -1245,19 +1498,19 @@ int show_quota_wrongpid(int id)
 
       found = 0;
       printf("Quota for %s %d on filesys %s has wrong phys_id %d\n",
-            type, id1, f->name, id);
+            type, id1, f->name, iid);
     }
   EXEC SQL CLOSE csr215;
   return found;
 }
 
-fix_quota_physid(int id)
+void fix_quota_physid(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount, id1;
+  int iid = (int)id, rowcount, id1;
   EXEC SQL END DECLARE SECTION;
 
-  id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
+  id1 = ((struct filesys *)hash_lookup(filesys, iid))->phys_id;
   EXEC SQL UPDATE quota SET phys_id = :id1
     WHERE filsys_id = :iid AND phys_id != :id1;
   rowcount = sqlca.sqlerrd[2];
@@ -1268,11 +1521,11 @@ fix_quota_physid(int id)
   modified("quota");
 }
 
-int show_srv_user(int id)
+int show_srv_user(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  char name[33];
-  int iid = id;
+  char name[SERVERS_NAME_SIZE];
+  int iid = (int)id;
   EXEC SQL END DECLARE SECTION;
   int found = 1;
 
@@ -1287,18 +1540,18 @@ int show_srv_user(int id)
        break;
 
       strtrim(name);
-      printf("Service %s has acl non-existant user %d\n", name, id);
+      printf("Service %s has acl non-existant user %d\n", name, iid);
       found = 0;
     }
   EXEC SQL CLOSE csr216;
   return found;
 }
 
-int show_srv_list(int id)
+int show_srv_list(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  char name[33];
-  int iid = id;
+  char name[SERVERS_NAME_SIZE];
+  int iid = (int)id;
   EXEC SQL END DECLARE SECTION;
   int found = 1;
 
@@ -1313,17 +1566,17 @@ int show_srv_list(int id)
        break;
 
       strtrim(name);
-      printf("Service %s has acl non-existant list %d\n", name, id);
+      printf("Service %s has acl non-existant list %d\n", name, iid);
       found = 0;
     }
   EXEC SQL CLOSE csr217;
   return found;
 }
 
-zero_srv_user(int id)
+void zero_srv_user(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount;
+  int iid = (int)id, rowcount;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL UPDATE servers SET acl_id = 0 WHERE acl_id = :iid AND
@@ -1336,10 +1589,10 @@ zero_srv_user(int id)
   modified("servers");
 }
 
-zero_srv_list(int id)
+void zero_srv_list(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount;
+  int iid = (int)id, rowcount;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL UPDATE servers SET acl_id = 0 WHERE acl_id = :iid AND
@@ -1352,10 +1605,10 @@ zero_srv_list(int id)
   modified("servers");
 }
 
-int show_krb_usr(int id)
+int show_krb_usr(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, found = 1, id1;
+  int iid = (int)id, found = 1, id1;
   EXEC SQL END DECLARE SECTION;
   struct string *s;
   char *ss;
@@ -1370,22 +1623,22 @@ int show_krb_usr(int id)
       if (sqlca.sqlcode)
        break;
 
-      if ((s = ((struct string *)hash_lookup(strings, id1))))
+      if ((s = 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);
+            iid, ss);
     }
   EXEC SQL CLOSE csr218;
   return found;
 }
 
-int show_krb_str(int id)
+int show_krb_str(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, found = 1, id1;
+  int iid = (int)id, found = 1, id1;
   EXEC SQL END DECLARE SECTION;
   struct user *u;
   char *s;
@@ -1400,52 +1653,20 @@ int show_krb_str(int id)
       if (sqlca.sqlcode)
        break;
 
-      if ((u = ((struct user *)hash_lookup(users, id1))))
+      if ((u = 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);
+            s, id1, iid);
     }
   EXEC SQL CLOSE csr219;
   return found;
 }
 
-int show_pdm_mach(int id)
+void phase2(void)
 {
-  EXEC SQL BEGIN DECLARE SECTION;
-  char name[33];
-  int iid = id;
-  EXEC SQL END DECLARE SECTION;
-  int found = 1;
-
-  EXEC SQL DECLARE csr220 CURSOR FOR
-    SELECT name FROM palladium
-    WHERE mach_id = :iid;
-  EXEC SQL OPEN csr220;
-  while (1)
-    {
-      EXEC SQL FETCH csr220 INTO :name;
-      if (sqlca.sqlcode)
-       break;
-
-      strtrim(name);
-      printf("Palladium server/supervisor %s is on non-existant machine %d\n",
-            name, id);
-      found = 0;
-    }
-  EXEC SQL CLOSE csr220;
-  return found;
-}
-
-
-phase2(void)
-{
-  EXEC SQL BEGIN DECLARE SECTION;
-  int id1, id2, id3, id4, id5;
-  char type[9], name[33];
-  EXEC SQL END DECLARE SECTION;
   struct save_queue *sq, *sq1, *sq2, *sq3, *sq4, *sq5;
   struct filesys *f;
   struct list *l;
@@ -1474,14 +1695,18 @@ phase2(void)
   EXEC SQL OPEN csr221;
   while (1)
     {
-      EXEC SQL FETCH csr221 INTO :id1, :id2;
+      EXEC SQL BEGIN DECLARE SECTION;
+      int mach_id, clu_id;
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr221 INTO :mach_id, :clu_id;
       if (sqlca.sqlcode)
        break;
 
-      if (!(m = (struct machine *)hash_lookup(machines, id1)))
-       sq_save_unique_data(sq1, id1);
-      else if (!hash_lookup(clusters, id2))
-       sq_save_unique_data(sq2, id2);
+      if (!(m = hash_lookup(machines, mach_id)))
+       sq_save_unique_data(sq1, (void *)mach_id);
+      else if (!hash_lookup(clusters, clu_id))
+       sq_save_unique_data(sq2, (void *)clu_id);
       if (m)
        m->clucount++;
     }
@@ -1496,12 +1721,16 @@ phase2(void)
   EXEC SQL OPEN csr222;
   while (1)
     {
-      EXEC SQL FETCH csr222 INTO :id1;
+      EXEC SQL BEGIN DECLARE SECTION;
+      int clu_id;
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr222 INTO :clu_id;
       if (sqlca.sqlcode)
        break;
 
-      if (!hash_lookup(clusters, id1))
-       sq_save_unique_data(sq1, id1);
+      if (!hash_lookup(clusters, clu_id))
+       sq_save_unique_data(sq1, (void *)clu_id);
     }
   EXEC SQL CLOSE csr222;
   generic_delete(sq1, show_svc, "svc", "clu_id", 1);
@@ -1522,20 +1751,26 @@ phase2(void)
   EXEC SQL OPEN csr223;
   while (1)
     {
-      EXEC SQL FETCH csr223 INTO :id1, :type, :id2, :id3, :id4;
+      EXEC SQL BEGIN DECLARE SECTION;
+      int list_id, id, ref_count, direct;
+      char type[IMEMBERS_MEMBER_TYPE_SIZE];
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr223 INTO :list_id, :type, :id,
+       :ref_count, :direct;
       if (sqlca.sqlcode)
        break;
 
-      if (!(l = (struct list *) hash_lookup(lists, id1)))
-       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' && !maybe_fixup_unref_string2("imembers", "member_id", "csr223", id2))
-       sq_save_unique_data(sq4, id2);
-      else if (type[0] == 'K' && !maybe_fixup_unref_string2("imembers", "member_id", "csr223", id2))
-       sq_save_unique_data(sq5, id2);
+      if (!(l = hash_lookup(lists, list_id)))
+       sq_save_unique_data(sq1, (void *)list_id);
+      else if (type[0] == 'U' && !hash_lookup(users, id))
+       sq_save_unique_data(sq2, (void *)id);
+      else if (type[0] == 'L' && !hash_lookup(lists, id))
+       sq_save_unique_data(sq3, (void *)id);
+      else if (type[0] == 'S' && !maybe_fixup_unref_string2("imembers", "member_id", "csr223", id))
+       sq_save_unique_data(sq4, (void *)id);
+      else if (type[0] == 'K' && !maybe_fixup_unref_string2("imembers", "member_id", "csr223", id))
+       sq_save_unique_data(sq5, (void *)id);
       else
        l->members++;
     }
@@ -1555,16 +1790,21 @@ phase2(void)
   EXEC SQL OPEN csr224;
   while (1)
     {
-      EXEC SQL FETCH csr224 INTO :name, :type, :id1, :id2;
+      EXEC SQL BEGIN DECLARE SECTION;
+      int acl_id, modby;
+      char name[SERVERS_NAME_SIZE], acl_type[SERVERS_ACL_TYPE_SIZE];
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr224 INTO :name, :acl_type, :acl_id, :modby;
       if (sqlca.sqlcode)
        break;
 
-      maybe_fixup_modby2("servers", "modby", "csr224", id2);
-      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);
+      maybe_fixup_modby2("servers", "modby", "csr224", modby);
+      strtrim(acl_type);
+      if (!strcmp(acl_type, "USER") && !hash_lookup(users, acl_id))
+       sq_save_data(sq1, (void *)acl_id);
+      else if (!strcmp(acl_type, "LIST") && !hash_lookup(lists, acl_id))
+       sq_save_data(sq2, (void *)acl_id);
     }
   EXEC SQL CLOSE csr224;
   generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
@@ -1578,13 +1818,17 @@ phase2(void)
   EXEC SQL OPEN csr225;
   while (1)
     {
-      EXEC SQL FETCH csr225 INTO :id1, :id2;
+      EXEC SQL BEGIN DECLARE SECTION;
+      int mach_id, modby;
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr225 INTO :mach_id, :modby;
       if (sqlca.sqlcode)
        break;
 
-      maybe_fixup_modby2("serverhosts", "modby", "csr225", id2);
-      if (!hash_lookup(machines, id1))
-       sq_save_data(sq, id1);
+      maybe_fixup_modby2("serverhosts", "modby", "csr225", modby);
+      if (!hash_lookup(machines, mach_id))
+       sq_save_data(sq, (void *)mach_id);
     }
   EXEC SQL CLOSE csr225;
   generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
@@ -1604,14 +1848,18 @@ phase2(void)
   EXEC SQL OPEN csr226;
   while (1)
     {
-      EXEC SQL FETCH csr226 INTO :id1, :id2;
+      EXEC SQL BEGIN DECLARE SECTION;
+      int group_id, filsys_id;
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr226 INTO :group_id, :filsys_id;
       if (sqlca.sqlcode)
        break;
 
-      if (!(f = (struct filesys *) hash_lookup(filesys, id1)))
-       sq_save_data(sq1, id1);
-      if (!hash_lookup(filesys, id2))
-       sq_save_data(sq3, id2);
+      if (!(f = hash_lookup(filesys, group_id)))
+       sq_save_data(sq1, (void *)group_id);
+      if (!hash_lookup(filesys, filsys_id))
+       sq_save_data(sq3, (void *)filsys_id);
     }
   EXEC SQL CLOSE csr226;
   generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0);
@@ -1628,22 +1876,27 @@ phase2(void)
   EXEC SQL OPEN csr227;
   while (1)
     {
-      EXEC SQL FETCH csr227 INTO :id1, :type, :id2, :id3, :id4, :id5;
+      EXEC SQL BEGIN DECLARE SECTION;
+      int entity_id, filsys_id, phys_id, quota, modby;
+      char type[QUOTA_TYPE_SIZE];
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr227 INTO :entity_id, :type, :filsys_id,
+       :phys_id, :quota, :modby;
       if (sqlca.sqlcode)
        break;
 
-      maybe_fixup_modby2("quota", "modby", "csr227", id5);
-      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)))
-       sq_save_data(sq3, id2);
+      maybe_fixup_modby2("quota", "modby", "csr227", modby);
+      if (type[0] == 'U' && entity_id != 0 && !hash_lookup(users, entity_id))
+       sq_save_data(sq1, (void *)entity_id);
+      else if (type[0] == 'G' && !hash_lookup(lists, entity_id))
+       sq_save_data(sq4, (void *)entity_id);
+      else if (!(f = hash_lookup(filesys, filsys_id)))
+       sq_save_data(sq2, (void *)filsys_id);
+      else if (phys_id != f->phys_id || !(n = hash_lookup(nfsphys, phys_id)))
+       sq_save_data(sq3, (void *)phys_id);
       else
-       n->count += id4;
+       n->count += quota;
     }
   EXEC SQL CLOSE csr227;
   generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1);
@@ -1660,49 +1913,35 @@ phase2(void)
   EXEC SQL OPEN csr228;
   while (1)
     {
-      EXEC SQL FETCH csr228 INTO :id1, :type, :id2, :id3;
+      EXEC SQL BEGIN DECLARE SECTION;
+      int mach_id, acl_id, modby;
+      char acl_type[HOSTACCESS_ACL_TYPE_SIZE];
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr228 INTO :mach_id, :acl_type, :acl_id, :modby;
       if (sqlca.sqlcode)
        break;
 
-      maybe_fixup_modby2("hostaccess", "modby", "csr228", id3);
-      strtrim(type);
-      if (!hash_lookup(machines, id1))
+      maybe_fixup_modby2("hostaccess", "modby", "csr228", modby);
+      strtrim(acl_type);
+      if (!hash_lookup(machines, mach_id))
        {
-         printf("Hostaccess for non-existant host %d\n", id1);
+         printf("Hostaccess for non-existant host %d\n", mach_id);
          printf("Not fixing this error\n");
        }
-      if (!strcmp(type, "USER") && !hash_lookup(users, id2))
+      if (!strcmp(acl_type, "USER") && !hash_lookup(users, acl_id))
        {
-         printf("Hostaccess for %d is non-existant user %d\n", id1, id2);
+         printf("Hostaccess for %d is non-existant user %d\n", mach_id, acl_id);
          printf("Not fixing this error\n");
        }
-      else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2))
+      else if (!strcmp(acl_type, "LIST") && !hash_lookup(lists, acl_id))
        {
-         printf("Hostaccess for %d is non-existant list %d\n", id1, id2);
+         printf("Hostaccess for %d is non-existant list %d\n", mach_id, acl_id);
          printf("Not fixing this error\n");
        }
     }
   EXEC SQL CLOSE csr228;
 
-  dprintf("Checking palladium...\n");
-  sq1 = sq_create();
-  EXEC SQL DECLARE csr229 CURSOR FOR
-    SELECT mach_id, modby FROM palladium
-    FOR UPDATE OF modby;
-  EXEC SQL OPEN csr229;
-  while (1)
-    {
-      EXEC SQL FETCH csr229 INTO :id1, :id2;
-      if (sqlca.sqlcode)
-       break;
-
-      maybe_fixup_modby2("palladium", "modby", "csr229", id2);
-      if (!hash_lookup(machines, id1))
-       sq_save_unique_data(sq1, id1);
-    }
-  EXEC SQL CLOSE csr229;
-  generic_delete(sq1, show_pdm_mach, "palladium", "mach_id", 1);
-
   dprintf("Checking krbmap...\n");
   sq1 = sq_create();
   sq2 = sq_create();
@@ -1712,14 +1951,18 @@ phase2(void)
   EXEC SQL OPEN csr230;
   while (1)
     {
-      EXEC SQL FETCH csr230 INTO :id1, :id2;
+      EXEC SQL BEGIN DECLARE SECTION;
+      int users_id, string_id;
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr230 INTO :users_id, :string_id;
       if (sqlca.sqlcode)
        break;
 
-      if (!hash_lookup(users, id1))
-       sq_save_unique_data(sq1, id1);
-      else if (!maybe_fixup_unref_string2("krbmap", "string_id", "csr230", id2))
-       sq_save_unique_data(sq2, id2);
+      if (!hash_lookup(users, users_id))
+       sq_save_unique_data(sq1, (void *)users_id);
+      else if (!maybe_fixup_unref_string2("krbmap", "string_id", "csr230", string_id))
+       sq_save_unique_data(sq2, (void *)string_id);
     }
   EXEC SQL CLOSE csr230;
   generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1);
@@ -1731,13 +1974,18 @@ phase2(void)
   EXEC SQL OPEN csr231;
   while (1)
     {
-      EXEC SQL FETCH csr231 INTO :id1, :name;
+      EXEC SQL BEGIN DECLARE SECTION;
+      int list_id;
+      char tag[CAPACLS_TAG_SIZE];
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr231 INTO :list_id, :tag;
       if (sqlca.sqlcode)
        break;
 
-      if (!hash_lookup(lists, id1))
+      if (!hash_lookup(lists, list_id))
        {
-         printf("Capacl for %s is non-existant list %d\n", name, id1);
+         printf("Capacl for %s is non-existant list %d\n", tag, list_id);
          printf("Not fixing this error\n");
        }
     }
@@ -1750,35 +1998,64 @@ phase2(void)
   EXEC SQL OPEN csr232;
   while (1)
     {
-      EXEC SQL FETCH csr232 INTO :id1;
+      EXEC SQL BEGIN DECLARE SECTION;
+      int mach_id;
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr232 INTO :mach_id;
       if (sqlca.sqlcode)
        break;
 
-      if (!hash_lookup(machines, id1))
-       sq_save_unique_data(sq1, id1);
+      if (!hash_lookup(machines, mach_id))
+       sq_save_unique_data(sq1, (void *)mach_id);
     }
   EXEC SQL CLOSE csr232;
   generic_delete(sq1, show_hostalias, "hostalias", "mach_id", 1);
 
-  dprintf("Checking printcaps\n");
+  dprintf("Checking printers\n");
   sq1 = sq_create();
   sq2 = sq_create();
+  sq3 = sq_create();
+  sq4 = sq_create();
+  sq5 = sq_create();
   EXEC SQL DECLARE csr233 CURSOR FOR
-    SELECT mach_id, quotaserver, modby FROM printcap;
+    SELECT mach_id, loghost, rm, rq, ac, lpc_acl, modby FROM printers;
   EXEC SQL OPEN csr233;
   while (1)
     {
-      EXEC SQL FETCH csr233 INTO :id1, :id2, :id3;
+      EXEC SQL BEGIN DECLARE SECTION;
+      int mach_id, loghost, rm, rq, ac, lpc_acl, modby;
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr233 INTO :mach_id, :loghost, :rm, :rq,
+       :lpc_acl, :modby;
       if (sqlca.sqlcode)
        break;
 
-      maybe_fixup_modby2("printcap", "modby", "csr233", id3);
-      if (!hash_lookup(machines, id1))
-       sq_save_unique_data(sq1, id1);
-      else if (!hash_lookup(machines, id2))
-       sq_save_unique_data(sq2, id2);
+      maybe_fixup_modby2("printers", "modby", "csr233", modby);
+      if (!hash_lookup(machines, mach_id))
+       sq_save_unique_data(sq1, (void *)mach_id);
+      else if (!hash_lookup(machines, rm))
+       sq_save_unique_data(sq2, (void *)rm);
+      else if (!hash_lookup(machines, rq))
+       sq_save_unique_data(sq3, (void *)rq);
+      else {
+       if (!hash_lookup(lists, ac))
+         sq_save_unique_data(sq4, (void *)ac);
+       if (!hash_lookup(lists, lpc_acl))
+         sq_save_unique_data(sq5, (void *)lpc_acl);
+       if (!hash_lookup(machines, loghost))
+         {
+           show_printer_loghost((void *)loghost);
+           cant_fix();
+         }
+      }
     }
   EXEC SQL CLOSE csr233;
-  generic_delete(sq1, show_pcap_mach, "printcap", "mach_id", 1);
-  generic_delete(sq2, show_pcap_quota, "printcap", "quotaserver", 1);
+  generic_delete(sq1, show_printer_mach, "printers", "mach_id", 1);
+  generic_delete(sq2, show_printer_spool, "printers", "rm", 1);
+  generic_delete(sq3, show_printer_quota, "printers", "rq", 1);
+  generic_fix(sq4, show_printer_ac, "Clear", fix_printer_ac, 1);
+  generic_fix(sq5, show_printer_lpc_acl, "Clear", fix_printer_lpc_acl, 1);
 }
This page took 0.108388 seconds and 4 git commands to generate.