3 * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
4 * For copying and distribution information, please see the file
8 #include <mit-copyright.h>
16 EXEC SQL INCLUDE sqlca;
20 EXEC SQL WHENEVER SQLERROR DO dbmserr();
22 int show_mcm_mach(void *id);
23 int show_mcm_clu(void *id);
24 int show_hostalias(void *id);
25 int show_printer_mach(void *id);
26 int show_printer_server(void *id);
27 int show_printer_loghost(void *id);
28 int show_printer_spool(void *id);
29 int show_printer_quota(void *id);
30 int show_printer_ac(void *id);
31 int show_printer_lpc_acl(void *id);
32 void fix_printer_ac(void *id);
33 void fix_printer_lpc_acl(void *id);
34 void user_check(int id, void *user, void *hint);
35 int maybe_fixup_unref_string(int sid, int oid, char *oname, char *table,
36 char *field, char *idfield);
37 int maybe_fixup_modby(int sid, int oid, char *oname, char *table,
38 char *field, char *idfield);
39 int maybe_fixup_unref_string2(char *table, char *field, char *rowid, int sid);
40 int maybe_fixup_modby2(char *table, char *field, char *rowid, int id);
41 void pobox_check(int id, struct user *u);
42 void remove_pobox(int id);
43 void fix_smtp_pobox(int id, int sid);
44 void mach_check(int id, void *machine, void *hint);
45 void subnet_check(int id, void *subnet, void *hint);
46 void clear_subnet_owner(struct subnet *s);
47 void clear_mach_owner(struct machine *m);
48 void cluster_check(int id, void *cluster, void *hint);
49 int show_svc(void *id);
50 void list_check(int id, void *list, void *hint);
51 void fix_list_acl(int id);
52 void fix_list_memacl(int id);
53 int show_member_list(void *id);
54 int show_mem_user(void *id);
55 int show_mem_list(void *id);
56 int show_mem_str(void *id);
57 int show_mem_krb(void *id);
58 int show_mem_mach(void *id);
59 void del_mem_user(void *id);
60 void del_mem_list(void *id);
61 void del_mem_str(void *id);
62 void del_mem_krb(void *id);
63 void del_mem_mach(void *id);
64 int show_sh(void *id);
65 void del_sh_mach(void *id);
66 void fsmatch(int id, void *nfsphys, void *filesys);
67 void check_fs(int id, void *filesys, void *hint);
68 void check_nfsphys(int id, void *nfsphys, void *hint);
69 void check_ps(int id, void *printserver, void *hint);
70 int show_fsg_missing(void *id);
71 int show_fsg_type(void *filesys);
72 void fix_fsg_type(void *filesys);
73 int show_fsg_nomember(void *id);
74 int show_quota_nouser(void *id);
75 int show_quota_nolist(void *id);
76 void fix_quota_nouser(void *id);
77 void fix_quota_nolist(void *id);
78 int show_quota_nofs(void *id);
79 void fix_quota_nofs(void *id);
80 int show_quota_wrongpid(void *id);
81 void fix_quota_physid(void *id);
82 int show_srv_user(void *id);
83 int show_srv_list(void *id);
84 void zero_srv_user(void *id);
85 void zero_srv_list(void *id);
86 int show_krb_usr(void *id);
87 int show_krb_str(void *id);
88 int show_pdm_mach(void *id);
90 int show_mcm_mach(void *id)
92 EXEC SQL BEGIN DECLARE SECTION;
93 int iid = (int)id, found = 1;
94 char name[CLUSTERS_NAME_SIZE];
95 EXEC SQL END DECLARE SECTION;
97 EXEC SQL DECLARE csr201 CURSOR FOR
98 SELECT clusters.name FROM clusters, mcmap
99 WHERE clusters.clu_id = mcmap.clu_id AND mcmap.mach_id = :iid;
100 EXEC SQL OPEN csr201;
103 EXEC SQL FETCH csr201 INTO :name;
109 printf("Cluster %s, non-existant machine %d in cluster map\n",
112 EXEC SQL CLOSE csr201;
116 int show_mcm_clu(void *id)
118 EXEC SQL BEGIN DECLARE SECTION;
119 int iid = (int)id, found = 1;
120 char name[MACHINE_NAME_SIZE];
121 EXEC SQL END DECLARE SECTION;
123 EXEC SQL DECLARE csr202 CURSOR FOR
124 SELECT machine.name FROM machine, mcmap
125 WHERE machine.mach_id = mcmap.mach_id AND mcmap.clu_id = :iid;
126 EXEC SQL OPEN csr202;
129 EXEC SQL FETCH csr202 INTO :name;
136 printf("Machine %s, non-existant cluster %d in cluster map\n",
139 EXEC SQL CLOSE csr202;
143 int show_hostalias(void *id)
145 EXEC SQL BEGIN DECLARE SECTION;
146 int iid = (int)id, found = 1;
147 char name[HOSTALIAS_NAME_SIZE];
148 EXEC SQL END DECLARE SECTION;
150 EXEC SQL DECLARE csr234 CURSOR FOR
151 SELECT name FROM hostalias WHERE mach_id = :iid;
152 EXEC SQL OPEN csr234;
155 EXEC SQL FETCH csr234 INTO :name;
162 printf("Alias %s, non-existant machine %d in hostalias map\n",
165 EXEC SQL CLOSE csr234;
169 int show_printer_mach(void *id)
171 EXEC SQL BEGIN DECLARE SECTION;
172 int iid = (int)id, found = 1;
173 char name[PRINTERS_NAME_SIZE];
174 EXEC SQL END DECLARE SECTION;
176 EXEC SQL DECLARE csr235 CURSOR FOR
177 SELECT name FROM printers WHERE mach_id = :iid;
178 EXEC SQL OPEN csr235;
181 EXEC SQL FETCH csr235 INTO :name;
188 printf("Printer %s, non-existant machine %d in printers table\n",
191 EXEC SQL CLOSE csr235;
195 int show_printer_server(void *id)
197 EXEC SQL BEGIN DECLARE SECTION;
198 int iid = (int)id, found = 1;
199 char name[PRINTERS_NAME_SIZE];
200 EXEC SQL END DECLARE SECTION;
202 EXEC SQL DECLARE csr_sps CURSOR FOR
203 SELECT name FROM printers WHERE mach_id = :iid;
204 EXEC SQL OPEN csr_sps;
207 EXEC SQL FETCH csr_sps INTO :name;
214 printf("Printer %s, non-existant printserver %d in printers table\n",
217 EXEC SQL CLOSE csr_sps;
221 int show_printer_loghost(void *id)
223 EXEC SQL BEGIN DECLARE SECTION;
224 int iid = (int)id, found = 1;
225 char name[PRINTERS_NAME_SIZE];
226 EXEC SQL END DECLARE SECTION;
228 EXEC SQL DECLARE csr236 CURSOR FOR
229 SELECT name FROM printers WHERE loghost = :iid;
230 EXEC SQL OPEN csr236;
233 EXEC SQL FETCH csr236 INTO :name;
240 printf("Printer %s, non-existant spool machine %d in printers table\n",
243 EXEC SQL CLOSE csr236;
247 int show_printer_spool(void *id)
249 EXEC SQL BEGIN DECLARE SECTION;
250 int iid = (int)id, found = 1;
251 char name[PRINTERS_NAME_SIZE];
252 EXEC SQL END DECLARE SECTION;
254 EXEC SQL DECLARE csr237 CURSOR FOR
255 SELECT name FROM printers WHERE rm = :iid;
256 EXEC SQL OPEN csr237;
259 EXEC SQL FETCH csr237 INTO :name;
266 printf("Printer %s, non-existant spool machine %d in printers table\n",
269 EXEC SQL CLOSE csr237;
273 int show_printer_quota(void *id)
275 EXEC SQL BEGIN DECLARE SECTION;
276 int iid = (int)id, found = 1;
277 char name[PRINTERS_NAME_SIZE];
278 EXEC SQL END DECLARE SECTION;
280 EXEC SQL DECLARE csr238 CURSOR FOR
281 SELECT name FROM printers WHERE rq = :iid;
282 EXEC SQL OPEN csr238;
285 EXEC SQL FETCH csr238 INTO :name;
292 printf("Printer %s, non-existant quota server %d in printers table\n",
295 EXEC SQL CLOSE csr238;
299 int show_printer_ac(void *id)
301 EXEC SQL BEGIN DECLARE SECTION;
302 int iid = (int)id, found = 1;
303 char name[PRINTERS_NAME_SIZE];
304 EXEC SQL END DECLARE SECTION;
306 EXEC SQL DECLARE csr239 CURSOR FOR
307 SELECT name FROM printers WHERE ac = :iid;
308 EXEC SQL OPEN csr239;
311 EXEC SQL FETCH csr239 INTO :name;
318 printf("Printer %s, non-existant restrict list %d in printers table\n",
321 EXEC SQL CLOSE csr239;
325 int show_printer_lpc_acl(void *id)
327 EXEC SQL BEGIN DECLARE SECTION;
328 int iid = (int)id, found = 1;
329 char name[PRINTERS_NAME_SIZE];
330 EXEC SQL END DECLARE SECTION;
332 EXEC SQL DECLARE csr240 CURSOR FOR
333 SELECT name FROM printers WHERE lpc_acl = :iid;
334 EXEC SQL OPEN csr240;
337 EXEC SQL FETCH csr240 INTO :name;
344 printf("Printer %s, non-existant lpc ACL %d in printers table\n",
347 EXEC SQL CLOSE csr240;
351 void fix_printer_ac(void *id)
353 EXEC SQL BEGIN DECLARE SECTION;
354 int rowcount, iid = (int)id;
355 EXEC SQL END DECLARE SECTION;
357 EXEC SQL UPDATE printers SET ac = 0 WHERE ac = :iid;
358 rowcount = sqlca.sqlerrd[2];
360 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
362 printf("Not fixed\n");
363 modified("printers");
366 void fix_printer_lpc_acl(void *id)
368 EXEC SQL BEGIN DECLARE SECTION;
369 int rowcount, iid = (int)id;
370 EXEC SQL END DECLARE SECTION;
372 EXEC SQL UPDATE printers SET lpc_acl = 0 WHERE lpc_acl = :iid;
373 rowcount = sqlca.sqlerrd[2];
375 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
377 printf("Not fixed\n");
378 modified("printers");
381 void user_check(int id, void *user, void *hint)
383 struct user *u = user;
385 u->comment = maybe_fixup_unref_string(u->comment, id, u->login, "users",
386 "comments", "users_id");
388 u->modby = maybe_fixup_modby(u->modby, id, u->login, "users",
389 "modby", "users_id");
391 u->fmodby = maybe_fixup_modby(u->fmodby, id, u->login, "users",
392 "fmodby", "users_id");
394 u->pmodby = maybe_fixup_modby(u->pmodby, id, u->login, "users",
395 "pmodby", "users_id");
397 u->sigwho = maybe_fixup_unref_string(u->sigwho, id, u->login, "users",
398 "sigwho", "users_id");
403 int maybe_fixup_unref_string(int sid, int oid, char *oname, char *table,
404 char *field, char *idfield)
406 int ret = (sid < 0) ? -sid : sid, doit = 0, newid;
407 EXEC SQL BEGIN DECLARE SECTION;
410 EXEC SQL END DECLARE SECTION;
412 if ((newid = (int)hash_lookup(string_dups, ret)))
414 printf("%s entry %s(%d) has a %s with duplicate string %d\n",
415 table, oname, oid, field, ret);
416 if (single_fix("Replace duplicate", 0))
423 else if (!string_check(ret))
425 printf("%s entry %s(%d) has a %s with non-existant string %d\n",
426 table, oname, oid, field, ret);
427 if (single_fix("Delete", 1))
436 sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE %s = %d",
437 table, field, (sid < 0) ? -ret : ret, idfield, oid);
438 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
439 rowcount = sqlca.sqlerrd[2];
443 printf("Not fixed, rowcount = %d\n", rowcount);
447 return (sid < 0) ? -ret : ret;
450 int maybe_fixup_modby(int sid, int oid, char *oname, char *table,
451 char *field, char *idfield)
453 EXEC SQL BEGIN DECLARE SECTION;
456 EXEC SQL END DECLARE SECTION;
459 return maybe_fixup_unref_string(sid, oid, oname, table, field, idfield);
462 if (!hash_lookup(users, sid))
464 printf("%s entry %s(%d) has a %s with non-existant user %d\n",
465 table, oname, oid, field, sid);
466 if (single_fix("Delete", 1))
468 sprintf(stmt_buf, "UPDATE %s SET %s = 0 WHERE %s = %d",
469 table, field, idfield, oid);
470 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
471 rowcount = sqlca.sqlerrd[2];
475 printf("Not fixed, rowcount = %d\n", rowcount);
484 int maybe_fixup_unref_string2(char *table, char *field, char *rowid, int sid)
486 int ret = (sid < 0) ? -sid : sid, doit = 0, newid;
487 EXEC SQL BEGIN DECLARE SECTION;
490 EXEC SQL END DECLARE SECTION;
492 if ((newid = (int)hash_lookup(string_dups, ret)))
494 printf("%s entry has a %s with duplicate string %d\n",
496 if (single_fix("Replace duplicate", 0))
503 else if (!string_check(ret))
505 printf("%s entry has a %s with non-existant string %d\n",
507 if (single_fix("Clear", 1))
516 sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE rowid = '%s'",
517 table, field, (sid < 0) ? -ret : ret, rowid);
518 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
519 rowcount = sqlca.sqlerrd[2];
523 printf("Not fixed, rowcount = %d\n", rowcount);
526 return (sid < 0) ? -ret : ret;
529 int maybe_fixup_modby2(char *table, char *field, char *rowid, int id)
531 EXEC SQL BEGIN DECLARE SECTION;
534 EXEC SQL END DECLARE SECTION;
537 return maybe_fixup_unref_string2(table, field, rowid, id);
540 if (!hash_lookup(users, id))
542 printf("%s entry has a %s with non-existant user %d\n",
544 if (single_fix("Clear", 1))
546 sprintf(stmt_buf, "UPDATE %s SET %s = 0 WHERE rowid = '%s'",
547 table, field, rowid);
548 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
549 rowcount = sqlca.sqlerrd[2];
553 printf("Not fixed, rowcount = %d\n", rowcount);
562 void pobox_check(int id, struct user *u)
569 if (!hash_lookup(machines, u->pobox_id))
571 printf("User %s(%s) has P.O.Box on non-existant machine %d\n",
572 u->login, u->fullname, u->pobox_id);
573 if (single_fix("Delete", 0))
575 remove_pobox(u->users_id);
582 if (hash_lookup(string_dups, u->pobox_id))
584 printf("User %s(%s) has P.O.Box with duplicate string %d\n",
585 u->login, u->fullname, u->pobox_id);
586 if (single_fix("Update", 0))
588 printf("Replacing box_id dup string ID %d with %d\n",
590 (int)hash_lookup(string_dups, u->pobox_id));
591 u->pobox_id = (int)hash_lookup(string_dups, u->pobox_id);
592 fix_smtp_pobox(u->users_id, u->pobox_id);
593 string_check(u->pobox_id);
596 else if (!string_check(u->pobox_id))
598 printf("User %s(%s) has P.O.Box with non-existant string %d\n",
599 u->login, u->fullname, u->pobox_id);
600 if (single_fix("Delete", 0))
602 remove_pobox(u->users_id);
609 fs = hash_lookup(filesys, u->pobox_id);
612 printf("User %s(%s) has P.O.Box on non-existant filesystem %d\n",
613 u->login, u->fullname, u->pobox_id);
614 if (single_fix("Delete", 0))
616 remove_pobox(u->users_id);
620 else if (fs->type != 'I')
622 printf("User %s(%s) has IMAP P.O.Box on non-IMAP filesystem %s\n",
623 u->login, u->fullname, fs->name);
624 if (single_fix("Delete", 0))
626 remove_pobox(u->users_id);
638 void remove_pobox(int id)
640 EXEC SQL BEGIN DECLARE SECTION;
641 int rowcount, iid = (int)id;
642 EXEC SQL END DECLARE SECTION;
644 EXEC SQL UPDATE users SET potype = 'NONE' WHERE users.users_id = :iid;
645 rowcount = sqlca.sqlerrd[2];
647 printf("%d entr%s removed\n", rowcount, rowcount == 1 ? "y" : "ies");
649 printf("Not removed\n");
653 void fix_smtp_pobox(int id, int sid)
655 EXEC SQL BEGIN DECLARE SECTION;
656 int rowcount, iid = id, isid = sid;
657 EXEC SQL END DECLARE SECTION;
659 EXEC SQL UPDATE users SET box_id = :isid WHERE users.users_id = :iid;
660 rowcount = sqlca.sqlerrd[2];
662 printf("%d entr%s updated\n", rowcount, rowcount == 1 ? "y" : "ies");
664 printf("Not updated\n");
668 void mach_check(int id, void *machine, void *hint)
670 struct machine *m = machine;
672 if (!hash_lookup(subnets, m->snet_id))
674 printf("Machine %s is on a non-existant subnet %d\n",
675 m->name, m->snet_id);
676 if (single_fix("Move to null-subnet", 1))
678 EXEC SQL BEGIN DECLARE SECTION;
679 int rowcount, iid = id;
680 EXEC SQL END DECLARE SECTION;
682 EXEC SQL UPDATE machine SET snet_id = 0 WHERE mach_id = :iid;
683 rowcount = sqlca.sqlerrd[2];
685 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
687 printf("Not fixed\n");
692 switch (m->owner_type)
695 if (!hash_lookup(users, m->owner_id))
697 printf("Machine %s has non-existant USER owner %d\n",
698 m->name, m->owner_id);
699 if (single_fix("Set to no owner", 1))
704 if (!hash_lookup(lists, m->owner_id))
706 printf("Machine %s has non-existant LIST owner %d\n",
707 m->name, m->owner_id);
708 if (single_fix("Set to no owner", 1))
715 m->owner_id = maybe_fixup_unref_string(m->owner_id, id, m->name,
716 "machine", "owner_id",
718 if (m->owner_id == 0)
723 m->acomment = maybe_fixup_unref_string(m->acomment, id, m->name,
724 "machine", "acomment", "mach_id");
726 m->ocomment = maybe_fixup_unref_string(m->ocomment, id, m->name,
727 "machine", "ocomment", "mach_id");
729 m->creator = maybe_fixup_modby(m->creator, id, m->name, "machine",
730 "creator", "mach_id");
731 m->modby = maybe_fixup_modby(m->modby, id, m->name, "machine",
735 void subnet_check(int id, void *subnet, void *hint)
737 struct subnet *s = subnet;
739 switch (s->owner_type)
742 if (!hash_lookup(users, s->owner_id))
744 printf("Subnet %s has non-existant USER owner %d\n",
745 s->name, s->owner_id);
746 if (single_fix("Set to no owner", 1))
747 clear_subnet_owner(s);
751 if (!hash_lookup(lists, s->owner_id))
753 printf("Machine %s has non-existant LIST owner %d\n",
754 s->name, s->owner_id);
755 if (single_fix("Set to no owner", 1))
756 clear_subnet_owner(s);
762 s->owner_id = maybe_fixup_unref_string(s->owner_id, id, s->name,
763 "machine", "owner_id",
765 if (s->owner_id == 0)
766 clear_subnet_owner(s);
769 s->modby = maybe_fixup_modby(s->modby, id, s->name, "subnet",
773 void clear_subnet_owner(struct subnet *s)
775 EXEC SQL BEGIN DECLARE SECTION;
776 int rowcount, id = s->snet_id;
777 EXEC SQL END DECLARE SECTION;
779 EXEC SQL UPDATE subnet SET owner_type = 'NONE', owner_id = 0
781 rowcount = sqlca.sqlerrd[2];
783 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
785 printf("Not fixed\n");
789 void clear_mach_owner(struct machine *m)
791 EXEC SQL BEGIN DECLARE SECTION;
792 int rowcount, id = m->mach_id;
793 EXEC SQL END DECLARE SECTION;
795 EXEC SQL UPDATE machine SET owner_type = 'NONE', owner_id = 0
797 rowcount = sqlca.sqlerrd[2];
799 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
801 printf("Not fixed\n");
805 void cluster_check(int id, void *cluster, void *hint)
807 struct cluster *c = cluster;
809 c->modby = maybe_fixup_modby(c->modby, id, c->name, "clusters",
813 int show_svc(void *id)
815 EXEC SQL BEGIN DECLARE SECTION;
816 int iid = (int)id, found = 1;
817 char label[SVC_SERV_LABEL_SIZE], data[SVC_SERV_CLUSTER_SIZE];
818 EXEC SQL END DECLARE SECTION;
820 EXEC SQL DECLARE csr203 CURSOR FOR
821 SELECT serv_label, serv_cluster FROM svc
823 EXEC SQL OPEN csr203;
826 EXEC SQL FETCH csr203 INTO :label, :data;
833 printf("Cluster data [%s] %s for non-existant cluster %d\n",
836 EXEC SQL CLOSE csr203;
840 void list_check(int id, void *list, void *hint)
842 struct list *l = list;
844 l->modby = maybe_fixup_modby(l->modby, id, l->name, "list",
850 if (!hash_lookup(lists, l->acl_id))
852 printf("List %s has bad LIST acl %d\n", l->name, l->acl_id);
853 if (single_fix("Patch", 1))
854 fix_list_acl(l->list_id);
858 if (!hash_lookup(users, l->acl_id))
860 printf("List %s has bad USER acl %d\n", l->name, l->acl_id);
861 if (single_fix("Patch", 1))
862 fix_list_acl(l->list_id);
866 l->acl_id = maybe_fixup_unref_string(l->acl_id, id, l->name,
867 "list", "acl_id", "list_id");
870 printf("List %s has bad KERBEROS acl %d\n", l->name, l->acl_id);
871 if (single_fix("Patch", 1))
872 fix_list_acl(l->list_id);
877 switch (l->memacl_type)
880 if (!hash_lookup(lists, l->memacl_id))
882 printf("List %s has bad LIST memacl %d\n", l->name, l->memacl_id);
883 if (single_fix("Patch", 1))
884 fix_list_memacl(l->list_id);
888 if (!hash_lookup(users, l->memacl_id))
890 printf("List %s has bad USER acl %d\n", l->name, l->memacl_id);
891 if (single_fix("Patch", 1))
892 fix_list_memacl(l->list_id);
896 l->memacl_id = maybe_fixup_unref_string(l->memacl_id, id, l->name,
897 "list", "memacl_id", "list_id");
900 printf("List %s has bad KERBEROS acl %d\n", l->name,
902 if (single_fix("Patch", 1))
903 fix_list_memacl(l->list_id);
909 void fix_list_acl(int id)
911 EXEC SQL BEGIN DECLARE SECTION;
912 int rowcount, iid = (int)id;
913 EXEC SQL END DECLARE SECTION;
915 EXEC SQL UPDATE list SET acl_id = :iid, acl_type = 'LIST'
916 WHERE list_id = :iid;
917 rowcount = sqlca.sqlerrd[2];
919 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
921 printf("Not fixed\n");
925 void fix_list_memacl(int id)
927 EXEC SQL BEGIN DECLARE SECTION;
928 int rowcount, iid = (int)id;
929 EXEC SQL END DECLARE SECTION;
931 EXEC SQL UPDATE list SET memacl_id = 0, memacl_type = 'NONE'
932 WHERE list_id = :iid;
933 rowcount = sqlca.sqlerrd[2];
935 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
937 printf("Not fixed\n");
941 int show_member_list(void *id)
943 EXEC SQL BEGIN DECLARE SECTION;
944 int mid, iid = (int)id, found = 1;
945 char mtype[IMEMBERS_MEMBER_TYPE_SIZE], *name = NULL;
946 EXEC SQL END DECLARE SECTION;
948 EXEC SQL DECLARE csr204 CURSOR FOR
949 SELECT member_type, member_id FROM imembers
950 WHERE list_id = :iid;
951 EXEC SQL OPEN csr204;
954 EXEC SQL FETCH csr204 INTO :mtype, :mid;
962 struct list *l = hash_lookup(lists, mid);
966 else if (mtype[0] == 'U')
968 struct user *u = hash_lookup(users, mid);
972 else if (mtype[0] == 'S' || mtype[0] == 'K')
974 struct string *s = hash_lookup(strings, mid);
979 printf("Non-existant list %d has member %s %s\n", iid, mtype, name);
982 printf("Non-existant list %d has non-existent member %s %d\n",
986 EXEC SQL CLOSE csr204;
990 int show_mem_user(void *id)
992 EXEC SQL BEGIN DECLARE SECTION;
993 int lid, iid = (int)id, found = 1;
994 EXEC SQL END DECLARE SECTION;
997 EXEC SQL DECLARE csr205 CURSOR FOR
998 SELECT list_id FROM imembers
999 WHERE member_id = :iid AND member_type = 'USER';
1000 EXEC SQL OPEN csr205;
1003 EXEC SQL FETCH csr205 INTO :lid;
1006 l = hash_lookup(lists, lid);
1011 printf("List %s has non-existant user member, id %d\n", l->name, iid);
1013 EXEC SQL CLOSE csr205;
1017 int show_mem_list(void *id)
1019 EXEC SQL BEGIN DECLARE SECTION;
1020 int lid, iid = (int)id, found = 1;
1021 EXEC SQL END DECLARE SECTION;
1024 EXEC SQL DECLARE csr206 CURSOR FOR
1025 SELECT list_id FROM imembers
1026 WHERE member_id = :iid AND member_type = 'LIST';
1027 EXEC SQL OPEN csr206;
1030 EXEC SQL FETCH csr206 INTO :lid;
1033 l = hash_lookup(lists, lid);
1038 printf("List %s has non-existant list member, id %d\n", l->name, iid);
1040 EXEC SQL CLOSE csr206;
1044 int show_mem_str(void *id)
1046 EXEC SQL BEGIN DECLARE SECTION;
1047 int lid, iid = (int)id, found = 1;
1048 EXEC SQL END DECLARE SECTION;
1051 EXEC SQL DECLARE csr207 CURSOR FOR
1052 SELECT list_id FROM imembers
1053 WHERE member_id = :iid AND member_type = 'STRING';
1054 EXEC SQL OPEN csr207;
1057 EXEC SQL FETCH csr207 INTO :lid;
1060 l = hash_lookup(lists, lid);
1065 printf("List %s has non-existant string member, id %d\n", l->name, iid);
1067 EXEC SQL CLOSE csr207;
1072 int show_mem_krb(void *id)
1074 EXEC SQL BEGIN DECLARE SECTION;
1075 int lid, iid = (int)id, found = 1;
1076 EXEC SQL END DECLARE SECTION;
1079 EXEC SQL DECLARE csr208 CURSOR FOR
1080 SELECT list_id FROM imembers
1081 WHERE member_id = :iid AND member_type = 'KERBEROS';
1082 EXEC SQL OPEN csr208;
1085 EXEC SQL FETCH csr208 INTO :lid;
1088 l = hash_lookup(lists, lid);
1093 printf("List %s has non-existant kerberos member, id %d\n",
1096 EXEC SQL CLOSE csr208;
1100 int show_mem_mach(void *id)
1102 EXEC SQL BEGIN DECLARE SECTION;
1103 int lid, iid = (int)id, found = 1;
1104 EXEC SQL END DECLARE SECTION;
1107 EXEC SQL DECLARE csr208a CURSOR FOR
1108 SELECT list_id FROM imembers
1109 WHERE member_id = :iid AND member_type = 'MACHINE';
1110 EXEC SQL OPEN csr208a;
1113 EXEC SQL FETCH csr208a INTO :lid;
1116 l = hash_lookup(lists, lid);
1121 printf("List %s has nonexistant machine member, id %d\n",
1124 EXEC SQL CLOSE csr208a;
1128 void del_mem_user(void *id)
1130 EXEC SQL BEGIN DECLARE SECTION;
1131 int iid = (int)id, rowcount;
1132 EXEC SQL END DECLARE SECTION;
1134 EXEC SQL DELETE FROM imembers WHERE member_type = 'USER' AND
1136 rowcount = sqlca.sqlerrd[2];
1138 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1140 printf("Not deleted\n");
1141 modified("imembers");
1144 void del_mem_list(void *id)
1146 EXEC SQL BEGIN DECLARE SECTION;
1147 int iid = (int)id, rowcount;
1148 EXEC SQL END DECLARE SECTION;
1150 EXEC SQL DELETE FROM imembers WHERE member_type = 'LIST' AND
1152 rowcount = sqlca.sqlerrd[2];
1154 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1156 printf("Not deleted\n");
1157 modified("imembers");
1160 void del_mem_str(void *id)
1162 EXEC SQL BEGIN DECLARE SECTION;
1163 int iid = (int)id, rowcount;
1164 EXEC SQL END DECLARE SECTION;
1166 EXEC SQL DELETE FROM imembers WHERE member_type = 'STRING' AND
1168 rowcount = sqlca.sqlerrd[2];
1170 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1172 printf("Not deleted\n");
1173 modified("imembers");
1177 void del_mem_krb(void *id)
1179 EXEC SQL BEGIN DECLARE SECTION;
1180 int iid = (int)id, rowcount;
1181 EXEC SQL END DECLARE SECTION;
1183 EXEC SQL DELETE FROM imembers WHERE member_type = 'KERBEROS' AND
1185 rowcount = sqlca.sqlerrd[2];
1187 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1189 printf("Not deleted\n");
1190 modified("imembers");
1193 void del_mem_mach(void *id)
1195 EXEC SQL BEGIN DECLARE SECTION;
1196 int iid = (int)id, rowcount;
1197 EXEC SQL END DECLARE SECTION;
1199 EXEC SQL DELETE FROM imembers WHERE member_type = 'MACHINE' AND
1201 rowcount = sqlca.sqlerrd[2];
1203 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1205 printf("Not deleted\n");
1206 modified("imembers");
1209 int show_sh(void *id)
1211 EXEC SQL BEGIN DECLARE SECTION;
1212 char name[SERVERHOSTS_SERVICE_SIZE];
1214 EXEC SQL END DECLARE SECTION;
1217 EXEC SQL DECLARE csr209 CURSOR FOR
1218 SELECT service FROM serverhosts
1219 WHERE mach_id = :iid;
1220 EXEC SQL OPEN csr209;
1223 EXEC SQL FETCH csr209 INTO :name;
1228 printf("ServerHost entry for service %s non-existant host %d\n",
1231 EXEC SQL CLOSE csr209;
1235 void del_sh_mach(void *id)
1237 EXEC SQL BEGIN DECLARE SECTION;
1238 int iid = (int)id, rowcount;
1239 EXEC SQL END DECLARE SECTION;
1241 EXEC SQL DELETE FROM serverhosts WHERE mach_id = :iid;
1242 rowcount = sqlca.sqlerrd[2];
1244 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1246 printf("Not deleted\n");
1247 modified("serverhosts");
1251 static int fnchecklen;
1253 void fsmatch(int id, void *nfsphys, void *filesys)
1255 struct nfsphys *n = nfsphys;
1256 struct filesys *f = filesys;
1258 if (n->mach_id == f->mach_id &&
1259 !strncmp(f->dir, n->dir, strlen(n->dir)) &&
1260 strlen(n->dir) > fnchecklen)
1263 fnchecklen = strlen(n->dir);
1268 void check_fs(int id, void *filesys, void *hint)
1270 EXEC SQL BEGIN DECLARE SECTION;
1271 int iid = id, id1, id2, id3, rowcount;
1273 EXEC SQL END DECLARE SECTION;
1274 struct filesys *f = filesys;
1278 if (!hash_lookup(machines, f->mach_id))
1280 printf("Filesys %s with bad machine %d\n", f->name, f->mach_id);
1281 if (single_fix("Fix", 0))
1283 EXEC SQL UPDATE filesys SET mach_id = 0 WHERE filsys_id = :iid;
1284 rowcount = sqlca.sqlerrd[2];
1286 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1288 printf("Not fixed\n");
1289 modified("filesys");
1294 if (!hash_lookup(users, f->owner))
1296 printf("Filesys %s with bad owning user %d\n", f->name, f->owner);
1297 if (single_fix("Fix", 1))
1299 zero_fix("filesys", "owner", "filsys_id", f->filsys_id);
1303 if (!hash_lookup(lists, f->owners))
1305 printf("Filesys %s with bad owning group %d\n", f->name, f->owners);
1306 if (single_fix("Fix", 1))
1308 zero_fix("filesys", "owners", "filsys_id", f->filsys_id);
1313 if (f->type == 'N' || f->type == 'I')
1315 if (!hash_lookup(nfsphys, f->phys_id))
1317 m = hash_lookup(machines, f->mach_id);
1318 printf("Filesys %s with bad phys_id %d\n", f->name, f->phys_id);
1319 if (single_fix("Fix", 1))
1322 hash_step(nfsphys, fsmatch, f);
1323 if (fnchecklen != 0)
1328 EXEC SQL UPDATE filesys SET phys_id = :id1
1329 WHERE filsys_id = :id2;
1330 rowcount = sqlca.sqlerrd[2];
1332 printf("%d entr%s fixed\n", rowcount,
1333 rowcount == 1 ? "y" : "ies");
1335 printf("Not fixed\n");
1336 modified("filesys");
1340 printf("No NFSphys exsits for %s:%s\n", m->name, f->dir);
1341 if (single_fix("Create", 0))
1347 if (set_next_object_id("nfsphys_id", "nfsphys") !=
1350 printf("Unable to assign unique ID\n");
1353 EXEC SQL SELECT COUNT(*) INTO :rowcount FROM numvalues
1354 WHERE name = 'nfsphys_id';
1357 printf("Unable to retrieve unique ID\n");
1360 EXEC SQL INSERT INTO nfsphys
1361 (nfsphys_id, mach_id, device, dir, status, allocated,
1362 size, modtime, modby, modwith) VALUES
1363 (:id1, :id3, '\?\?\?', :dir, 0, 0, 0, SYSDATE, 0,
1365 rowcount = sqlca.sqlerrd[2];
1368 printf("%d entr%s created\n", rowcount,
1369 rowcount == 1 ? "y" : "ies");
1372 printf("Not created\n");
1373 modified("nfsphys");
1374 n = malloc(sizeof(struct nfsphys));
1376 out_of_mem("storing new nfsphys");
1377 strcpy(n->dir, dir);
1379 n->nfsphys_id = id1;
1382 if (hash_store(nfsphys, id1, n) == -1)
1383 out_of_mem("storing nfsphys in hash table");
1384 EXEC SQL UPDATE filesys SET phys_id = :id1
1385 WHERE filsys_id = :id2;
1386 rowcount = sqlca.sqlerrd[2];
1389 printf("%d filesys entr%s fixed\n", rowcount,
1390 rowcount == 1 ? "y" : "ies");
1393 printf("Not fixed\n");
1394 modified("filesys");
1402 void check_nfsphys(int id, void *nfsphys, void *hint)
1404 struct nfsphys *n = nfsphys;
1406 n->modby = maybe_fixup_modby(n->modby, id, n->dir, "nfsphys",
1407 "modby", "nfsphys_id");
1409 if (!hash_lookup(machines, n->mach_id))
1411 printf("NFSphys %d(%s) on non-existant machine %d\n",
1412 id, n->dir, n->mach_id);
1413 if (single_fix("Delete", 0))
1414 single_delete("nfsphys", "nfsphys_id", id);
1418 static void clear_ps_owner(struct printserver *ps)
1420 EXEC SQL BEGIN DECLARE SECTION;
1421 int rowcount, id = ps->mach_id;
1422 EXEC SQL END DECLARE SECTION;
1424 EXEC SQL UPDATE printserver SET owner_type = 'NONE', owner_id = 0
1425 WHERE mach_id = :id;
1426 rowcount = sqlca.sqlerrd[2];
1428 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1430 printf("Not fixed\n");
1431 modified("printservers");
1434 static void clear_ps_lpc(struct printserver *ps)
1436 EXEC SQL BEGIN DECLARE SECTION;
1437 int rowcount, id = ps->mach_id;
1438 EXEC SQL END DECLARE SECTION;
1440 EXEC SQL UPDATE printserver SET lpc_acl = 0
1441 WHERE mach_id = :id;
1442 rowcount = sqlca.sqlerrd[2];
1444 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1446 printf("Not fixed\n");
1447 modified("printservers");
1450 void check_ps(int id, void *printserver, void *hint)
1452 struct printserver *ps = printserver;
1456 m = hash_lookup(machines, id);
1459 printf("Printserver on non-existant machine %d\n", id);
1460 if (single_fix("Delete", 0))
1462 single_delete("printservers", "mach_id", id);
1471 ps->modby = maybe_fixup_modby(ps->modby, id, name, "printservers",
1472 "modby", "mach_id");
1473 ps->printer_types = maybe_fixup_unref_string(ps->printer_types, id, name,
1474 "printservers", "printer_types",
1477 switch (ps->owner_type)
1480 if (!hash_lookup(users, ps->owner_id))
1482 printf("Printserver %s has non-existant USER owner %d\n",
1483 name, ps->owner_id);
1484 if (single_fix("Set to no owner", 1))
1489 if (!hash_lookup(lists, ps->owner_id))
1491 printf("Printserver %s has non-existant LIST owner %d\n",
1492 name, ps->owner_id);
1493 if (single_fix("Set to no owner", 1))
1499 ps->owner_id = maybe_fixup_unref_string(ps->owner_id, id, name,
1500 "printserver", "owner_id",
1502 if (ps->owner_id == 0)
1506 if (!hash_lookup(lists, ps->lpc_acl))
1508 printf("Printserver %s has non-existent lpc_acl %d\n",
1510 if (single_fix("Set to no lpc_acl", 1))
1515 int show_fsg_missing(void *id)
1517 EXEC SQL BEGIN DECLARE SECTION;
1518 int iid = (int)id, id1, found = 1;
1519 EXEC SQL END DECLARE SECTION;
1522 EXEC SQL DECLARE csr210 CURSOR FOR
1523 SELECT filsys_id FROM fsgroup
1524 WHERE group_id = :iid;
1525 EXEC SQL OPEN csr210;
1528 EXEC SQL FETCH csr210 INTO :id1;
1533 if ((f = hash_lookup(filesys, id1)))
1534 printf("Missing fsgroup %d has member filesystem %s\n", iid, f->name);
1536 printf("Missing fsgroup %d has member filesystem %d\n", iid, id1);
1538 EXEC SQL CLOSE csr210;
1542 int show_fsg_type(void *filesys)
1544 struct filesys *f = filesys;
1570 printf("FSGroup %s has type %s instead of FSGROUP\n", f->name, t);
1574 void fix_fsg_type(void *filesys)
1576 struct filesys *f = filesys;
1577 EXEC SQL BEGIN DECLARE SECTION;
1578 int rowcount, id = f->filsys_id;
1579 EXEC SQL END DECLARE SECTION;
1581 EXEC SQL UPDATE filesys SET type = 'FSGROUP' WHERE filsys_id = :id;
1582 rowcount = sqlca.sqlerrd[2];
1584 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1586 printf("Not fixed\n");
1587 modified("filesys");
1590 int show_fsg_nomember(void *id)
1592 EXEC SQL BEGIN DECLARE SECTION;
1593 int iid = (int)id, id1, found = 1;
1594 EXEC SQL END DECLARE SECTION;
1597 EXEC SQL DECLARE csr211 CURSOR FOR
1598 SELECT group_id FROM fsgroup
1599 WHERE filsys_id = :iid;
1600 EXEC SQL OPEN csr211;
1603 EXEC SQL FETCH csr211 INTO :id1;
1608 if ((f = hash_lookup(filesys, id1)))
1609 printf("FSGroup %s has missing member %d\n", f->name, iid);
1611 printf("FSGroup %d has missing member %d\n", id1, iid);
1613 EXEC SQL CLOSE csr211;
1617 int show_quota_nouser(void *id)
1619 EXEC SQL BEGIN DECLARE SECTION;
1620 int iid = (int)id, id1, found = 1;
1621 EXEC SQL END DECLARE SECTION;
1623 EXEC SQL DECLARE csr212 CURSOR FOR
1624 SELECT filsys_id FROM quota
1625 WHERE entity_id = :iid AND type = 'USER';
1626 EXEC SQL OPEN csr212;
1629 EXEC SQL FETCH csr212 INTO :id1;
1634 printf("Quota on fs %d for non-existant user %d\n", id1, iid);
1636 EXEC SQL CLOSE csr212;
1640 int show_quota_nolist(void *id)
1642 EXEC SQL BEGIN DECLARE SECTION;
1643 int iid = (int)id, id1, found = 1;
1644 EXEC SQL END DECLARE SECTION;
1646 EXEC SQL DECLARE csr213 CURSOR FOR
1647 SELECT filsys_id FROM quota
1648 WHERE entity_id = :iid AND type = 'GROUP';
1649 EXEC SQL OPEN csr213;
1652 EXEC SQL FETCH csr213 INTO :id1;
1657 printf("Quota on fs %d for non-existant list %d\n", id1, iid);
1659 EXEC SQL CLOSE csr213;
1663 void fix_quota_nouser(void *id)
1665 EXEC SQL BEGIN DECLARE SECTION;
1666 int iid = (int)id, rowcount;
1667 EXEC SQL END DECLARE SECTION;
1669 EXEC SQL DELETE FROM quota
1670 WHERE entity_id = :iid AND type = 'USER';
1671 rowcount = sqlca.sqlerrd[2];
1673 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1675 printf("Not deleted\n");
1679 void fix_quota_nolist(void *id)
1681 EXEC SQL BEGIN DECLARE SECTION;
1682 int iid = (int)id, rowcount;
1683 EXEC SQL END DECLARE SECTION;
1685 EXEC SQL DELETE FROM quota WHERE entity_id = :iid AND type = 'GROUP';
1686 rowcount = sqlca.sqlerrd[2];
1688 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1690 printf("Not deleted\n");
1694 int show_quota_nofs(void *id)
1696 EXEC SQL BEGIN DECLARE SECTION;
1697 int iid = (int)id, id1, found = 1;
1698 char type[QUOTA_TYPE_SIZE];
1699 EXEC SQL END DECLARE SECTION;
1701 EXEC SQL DECLARE csr214 CURSOR FOR
1702 SELECT entity_id, type FROM quota
1703 WHERE filsys_id = :iid;
1704 EXEC SQL OPEN csr214;
1707 EXEC SQL FETCH csr214 INTO :id1, :type;
1712 printf("Quota for %s %d on non-existant filesys %d\n", type, id1, iid);
1714 EXEC SQL CLOSE csr214;
1718 void fix_quota_nofs(void *id)
1720 single_delete("quota", "filsys_id", (int)id);
1723 int show_quota_wrongpid(void *id)
1725 EXEC SQL BEGIN DECLARE SECTION;
1726 int iid = (int)id, id1, found = 1;
1727 char type[QUOTA_TYPE_SIZE];
1728 EXEC SQL END DECLARE SECTION;
1731 f = hash_lookup(filesys, iid);
1732 EXEC SQL DECLARE csr215 CURSOR FOR
1733 SELECT entity_id, type FROM quota
1734 WHERE filsys_id = :iid;
1735 EXEC SQL OPEN csr215;
1738 EXEC SQL FETCH csr215 INTO :id1, :type;
1743 printf("Quota for %s %d on filesys %s has wrong phys_id %d\n",
1744 type, id1, f->name, iid);
1746 EXEC SQL CLOSE csr215;
1750 void fix_quota_physid(void *id)
1752 EXEC SQL BEGIN DECLARE SECTION;
1753 int iid = (int)id, rowcount, id1;
1754 EXEC SQL END DECLARE SECTION;
1756 id1 = ((struct filesys *)hash_lookup(filesys, iid))->phys_id;
1757 EXEC SQL UPDATE quota SET phys_id = :id1
1758 WHERE filsys_id = :iid AND phys_id != :id1;
1759 rowcount = sqlca.sqlerrd[2];
1761 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1763 printf("Not fixed\n");
1767 int show_srv_user(void *id)
1769 EXEC SQL BEGIN DECLARE SECTION;
1770 char name[SERVERS_NAME_SIZE];
1772 EXEC SQL END DECLARE SECTION;
1775 EXEC SQL DECLARE csr216 CURSOR FOR
1776 SELECT name FROM servers
1777 WHERE acl_type = 'USER' and acl_id = :iid;
1778 EXEC SQL OPEN csr216;
1781 EXEC SQL FETCH csr216 INTO :name;
1786 printf("Service %s has acl non-existant user %d\n", name, iid);
1789 EXEC SQL CLOSE csr216;
1793 int show_srv_list(void *id)
1795 EXEC SQL BEGIN DECLARE SECTION;
1796 char name[SERVERS_NAME_SIZE];
1798 EXEC SQL END DECLARE SECTION;
1801 EXEC SQL DECLARE csr217 CURSOR FOR
1802 SELECT name FROM servers
1803 WHERE acl_type = 'LIST' AND acl_id = :iid;
1804 EXEC SQL OPEN csr217;
1807 EXEC SQL FETCH csr217 INTO :name;
1812 printf("Service %s has acl non-existant list %d\n", name, iid);
1815 EXEC SQL CLOSE csr217;
1819 void zero_srv_user(void *id)
1821 EXEC SQL BEGIN DECLARE SECTION;
1822 int iid = (int)id, rowcount;
1823 EXEC SQL END DECLARE SECTION;
1825 EXEC SQL UPDATE servers SET acl_id = 0 WHERE acl_id = :iid AND
1827 rowcount = sqlca.sqlerrd[2];
1829 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1831 printf("Not fixed\n");
1832 modified("servers");
1835 void zero_srv_list(void *id)
1837 EXEC SQL BEGIN DECLARE SECTION;
1838 int iid = (int)id, rowcount;
1839 EXEC SQL END DECLARE SECTION;
1841 EXEC SQL UPDATE servers SET acl_id = 0 WHERE acl_id = :iid AND
1843 rowcount = sqlca.sqlerrd[2];
1845 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1847 printf("Not fixed\n");
1848 modified("servers");
1851 int show_krb_usr(void *id)
1853 EXEC SQL BEGIN DECLARE SECTION;
1854 int iid = (int)id, found = 1, id1;
1855 EXEC SQL END DECLARE SECTION;
1859 EXEC SQL DECLARE csr218 CURSOR FOR
1860 SELECT string_id FROM krbmap
1861 WHERE users_id = :iid;
1862 EXEC SQL OPEN csr218;
1865 EXEC SQL FETCH csr218 INTO :id1;
1869 if ((s = hash_lookup(strings, id1)))
1874 printf("Kerberos map for non-existant user %d to principal %s\n",
1877 EXEC SQL CLOSE csr218;
1881 int show_krb_str(void *id)
1883 EXEC SQL BEGIN DECLARE SECTION;
1884 int iid = (int)id, found = 1, id1;
1885 EXEC SQL END DECLARE SECTION;
1889 EXEC SQL DECLARE csr219 CURSOR FOR
1890 SELECT users_id FROM krbmap
1891 WHERE string_id = :iid;
1892 EXEC SQL OPEN csr219;
1895 EXEC SQL FETCH csr219 INTO :id1;
1899 if ((u = hash_lookup(users, id1)))
1904 printf("Kerberos map for user %s (%d) to non-existant string %d\n",
1907 EXEC SQL CLOSE csr219;
1913 struct save_queue *sq, *sq1, *sq2, *sq3, *sq4, *sq5, *sq6;
1920 printf("Phase 2 - Checking references\n");
1922 dprintf("Checking users...\n");
1923 hash_step(users, user_check, NULL);
1925 dprintf("Checking machines...\n");
1926 hash_step(machines, mach_check, NULL);
1928 dprintf("Checking subnets...\n");
1929 hash_step(subnets, subnet_check, NULL);
1931 dprintf("Checking clusters...\n");
1932 hash_step(clusters, cluster_check, NULL);
1934 dprintf("Checking mcmap...\n");
1937 EXEC SQL DECLARE csr221 CURSOR FOR
1938 SELECT mach_id, clu_id FROM mcmap;
1939 EXEC SQL OPEN csr221;
1942 EXEC SQL BEGIN DECLARE SECTION;
1943 int mach_id, clu_id;
1944 EXEC SQL END DECLARE SECTION;
1946 EXEC SQL FETCH csr221 INTO :mach_id, :clu_id;
1950 if (!(m = hash_lookup(machines, mach_id)))
1951 sq_save_unique_data(sq1, (void *)mach_id);
1952 else if (!hash_lookup(clusters, clu_id))
1953 sq_save_unique_data(sq2, (void *)clu_id);
1957 EXEC SQL CLOSE csr221;
1958 generic_delete(sq1, show_mcm_mach, "mcmap", "mach_id", 1);
1959 generic_delete(sq2, show_mcm_clu, "mcmap", "clu_id", 1);
1961 dprintf("Checking service clusters...\n");
1963 EXEC SQL DECLARE csr222 CURSOR FOR
1964 SELECT clu_id FROM svc;
1965 EXEC SQL OPEN csr222;
1968 EXEC SQL BEGIN DECLARE SECTION;
1970 EXEC SQL END DECLARE SECTION;
1972 EXEC SQL FETCH csr222 INTO :clu_id;
1976 if (!hash_lookup(clusters, clu_id))
1977 sq_save_unique_data(sq1, (void *)clu_id);
1979 EXEC SQL CLOSE csr222;
1980 generic_delete(sq1, show_svc, "svc", "clu_id", 1);
1982 dprintf("Checking lists...\n");
1983 hash_step(lists, list_check, NULL);
1985 dprintf("Checking members...\n");
1993 EXEC SQL DECLARE csr223 CURSOR FOR
1994 SELECT list_id, member_type, member_id, tag, ref_count, direct, rowid
1995 FROM imembers FOR UPDATE OF member_id;
1996 EXEC SQL OPEN csr223;
1999 EXEC SQL BEGIN DECLARE SECTION;
2000 int list_id, id, tag, ref_count, direct;
2001 char type[IMEMBERS_MEMBER_TYPE_SIZE];
2002 EXEC SQL END DECLARE SECTION;
2004 EXEC SQL FETCH csr223 INTO :list_id, :type, :id, :tag,
2005 :ref_count, :direct, :rowid;
2010 if (!(l = hash_lookup(lists, list_id)))
2011 sq_save_unique_data(sq1, (void *)list_id);
2012 else if (type[0] == 'U' && !hash_lookup(users, id))
2013 sq_save_unique_data(sq2, (void *)id);
2014 else if (type[0] == 'L' && !hash_lookup(lists, id))
2015 sq_save_unique_data(sq3, (void *)id);
2016 else if (type[0] == 'S' && !maybe_fixup_unref_string2("imembers", "member_id", rowid, id))
2017 sq_save_unique_data(sq4, (void *)id);
2018 else if (type[0] == 'K' && !maybe_fixup_unref_string2("imembers", "member_id", rowid, id))
2019 sq_save_unique_data(sq5, (void *)id);
2020 else if (type[0] == 'M' && !maybe_fixup_unref_string2("imembers", "member_id", rowid, id))
2021 sq_save_unique_data(sq6, (void *)id);
2024 maybe_fixup_unref_string2("imembers", "tag", rowid, tag);
2026 EXEC SQL CLOSE csr223;
2027 generic_delete(sq1, show_member_list, "imembers", "list_id", 1);
2028 generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1);
2029 generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1);
2030 generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1);
2031 generic_fix(sq5, show_mem_krb, "Delete", del_mem_krb, 1);
2032 generic_fix(sq6, show_mem_mach, "Delete", del_mem_mach, 1);
2034 dprintf("Checking servers...\n");
2037 EXEC SQL DECLARE csr224 CURSOR FOR
2038 SELECT name, acl_type, acl_id, modby, rowid FROM servers
2039 FOR UPDATE of modby;
2040 EXEC SQL OPEN csr224;
2043 EXEC SQL BEGIN DECLARE SECTION;
2045 char name[SERVERS_NAME_SIZE], acl_type[SERVERS_ACL_TYPE_SIZE];
2046 EXEC SQL END DECLARE SECTION;
2048 EXEC SQL FETCH csr224 INTO :name, :acl_type, :acl_id, :modby, :rowid;
2052 maybe_fixup_modby2("servers", "modby", strtrim(rowid), modby);
2054 if (!strcmp(acl_type, "USER") && !hash_lookup(users, acl_id))
2055 sq_save_data(sq1, (void *)acl_id);
2056 else if (!strcmp(acl_type, "LIST") && !hash_lookup(lists, acl_id))
2057 sq_save_data(sq2, (void *)acl_id);
2059 EXEC SQL CLOSE csr224;
2060 generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
2061 generic_fix(sq2, show_srv_list, "Fix", zero_srv_list, 1);
2063 dprintf("Checking serverhosts...\n");
2065 EXEC SQL DECLARE csr225 CURSOR FOR
2066 SELECT mach_id, modby, rowid FROM serverhosts
2067 FOR UPDATE OF modby;
2068 EXEC SQL OPEN csr225;
2071 EXEC SQL BEGIN DECLARE SECTION;
2073 EXEC SQL END DECLARE SECTION;
2075 EXEC SQL FETCH csr225 INTO :mach_id, :modby, :rowid;
2079 maybe_fixup_modby2("serverhosts", "modby", strtrim(rowid), modby);
2080 if (!hash_lookup(machines, mach_id))
2081 sq_save_data(sq, (void *)mach_id);
2083 EXEC SQL CLOSE csr225;
2084 generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
2086 dprintf("Checking nfsphys...\n");
2087 hash_step(nfsphys, check_nfsphys, NULL);
2089 dprintf("Checking filesys...\n");
2090 hash_step(filesys, check_fs, NULL);
2092 dprintf("Checking filesystem groups...\n");
2096 EXEC SQL DECLARE csr226 CURSOR FOR
2097 SELECT group_id, filsys_id FROM fsgroup;
2098 EXEC SQL OPEN csr226;
2101 EXEC SQL BEGIN DECLARE SECTION;
2102 int group_id, filsys_id;
2103 EXEC SQL END DECLARE SECTION;
2105 EXEC SQL FETCH csr226 INTO :group_id, :filsys_id;
2109 if (!(f = hash_lookup(filesys, group_id)))
2110 sq_save_data(sq1, (void *)group_id);
2111 if (!hash_lookup(filesys, filsys_id))
2112 sq_save_data(sq3, (void *)filsys_id);
2114 EXEC SQL CLOSE csr226;
2115 generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0);
2116 generic_delete(sq3, show_fsg_nomember, "fsgroup", "filsys_id", 1);
2118 dprintf("Checking quotas...\n");
2123 EXEC SQL DECLARE csr227 CURSOR FOR
2124 SELECT entity_id, type, filsys_id, phys_id, quota, modby, rowid
2125 FROM quota FOR UPDATE OF modby;
2126 EXEC SQL OPEN csr227;
2129 EXEC SQL BEGIN DECLARE SECTION;
2130 int entity_id, filsys_id, phys_id, quota, modby;
2131 char type[QUOTA_TYPE_SIZE];
2132 EXEC SQL END DECLARE SECTION;
2134 EXEC SQL FETCH csr227 INTO :entity_id, :type, :filsys_id,
2135 :phys_id, :quota, :modby, :rowid;
2139 maybe_fixup_modby2("quota", "modby", strtrim(rowid), modby);
2140 if (type[0] == 'U' && entity_id != 0 && !hash_lookup(users, entity_id))
2141 sq_save_data(sq1, (void *)entity_id);
2142 else if (type[0] == 'G' && !hash_lookup(lists, entity_id))
2143 sq_save_data(sq4, (void *)entity_id);
2144 else if (!(f = hash_lookup(filesys, filsys_id)))
2145 sq_save_data(sq2, (void *)filsys_id);
2146 else if (phys_id != f->phys_id || !(n = hash_lookup(nfsphys, phys_id)))
2147 sq_save_data(sq3, (void *)phys_id);
2151 EXEC SQL CLOSE csr227;
2152 generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1);
2153 generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0);
2154 generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1);
2155 generic_fix(sq4, show_quota_nolist, "Delete", fix_quota_nolist, 1);
2157 dprintf("Checking zephyr...\n");
2158 EXEC SQL DECLARE csr_zc CURSOR FOR
2159 SELECT class, xmt_type, xmt_id, sub_type, sub_id, iws_type, iws_id,
2160 iui_type, iui_id, modby FROM zephyr;
2161 EXEC SQL OPEN csr_zc;
2164 EXEC SQL BEGIN DECLARE SECTION;
2165 int xmt_id, sub_id, iws_id, iui_id, modby;
2166 char class[ZEPHYR_CLASS_SIZE];
2167 char xmt_type[ZEPHYR_XMT_TYPE_SIZE];
2168 char sub_type[ZEPHYR_SUB_TYPE_SIZE];
2169 char iws_type[ZEPHYR_IWS_TYPE_SIZE];
2170 char iui_type[ZEPHYR_IUI_TYPE_SIZE];
2171 EXEC SQL END DECLARE SECTION;
2173 EXEC SQL FETCH csr_zc INTO :class, :xmt_type, :xmt_id, :sub_type,
2174 :sub_id, :iws_type, :iws_id, :iui_type, :iui_id, :modby;
2179 maybe_fixup_modby2("zephyr", "modby", strtrim(rowid), modby);
2182 if (!strcmp(xmt_type, "USER") && !hash_lookup(users, xmt_id))
2184 printf("xmt acl for %s is non-existant user %d\n", class, xmt_id);
2185 printf("Not fixing this error\n");
2187 else if (!strcmp(xmt_type, "LIST") && !hash_lookup(lists, xmt_id))
2189 printf("xmt acl for %s is non-existant list %d\n", class, xmt_id);
2190 printf("Not fixing this error\n");
2192 else if (!strcmp(xmt_type, "STRING") || !strcmp(xmt_type, "KERBEROS"))
2193 maybe_fixup_unref_string2("zephyr", "xmt_id", strtrim(rowid), xmt_id);
2196 if (!strcmp(sub_type, "USER") && !hash_lookup(users, sub_id))
2198 printf("sub acl for %s is non-existant user %d\n", class, sub_id);
2199 printf("Not fixing this error\n");
2201 else if (!strcmp(sub_type, "LIST") && !hash_lookup(lists, sub_id))
2203 printf("sub acl for %s is non-existant list %d\n", class, sub_id);
2204 printf("Not fixing this error\n");
2206 else if (!strcmp(sub_type, "STRING") || !strcmp(sub_type, "KERBEROS"))
2207 maybe_fixup_unref_string2("zephyr", "sub_id", strtrim(rowid), sub_id);
2210 if (!strcmp(iws_type, "USER") && !hash_lookup(users, iws_id))
2212 printf("iws acl for %s is non-existant user %d\n", class, iws_id);
2213 printf("Not fixing this error\n");
2215 else if (!strcmp(iws_type, "LIST") && !hash_lookup(lists, iws_id))
2217 printf("iws acl for %s is non-existant list %d\n", class, iws_id);
2218 printf("Not fixing this error\n");
2220 else if (!strcmp(iws_type, "STRING") || !strcmp(iws_type, "KERBEROS"))
2221 maybe_fixup_unref_string2("zephyr", "iws_id", strtrim(rowid), iws_id);
2224 if (!strcmp(iui_type, "USER") && !hash_lookup(users, iui_id))
2226 printf("iui acl for %s is non-existant user %d\n", class, iui_id);
2227 printf("Not fixing this error\n");
2229 else if (!strcmp(iui_type, "LIST") && !hash_lookup(lists, iui_id))
2231 printf("iui acl for %s is non-existant list %d\n", class, iui_id);
2232 printf("Not fixing this error\n");
2234 else if (!strcmp(iui_type, "STRING") || !strcmp(iui_type, "KERBEROS"))
2235 maybe_fixup_unref_string2("zephyr", "iui_id", strtrim(rowid), iui_id);
2238 dprintf("Checking hostaccess...\n");
2239 EXEC SQL DECLARE csr228 CURSOR FOR
2240 SELECT mach_id, acl_type, acl_id, modby, rowid FROM hostaccess
2241 FOR UPDATE OF modby;
2242 EXEC SQL OPEN csr228;
2245 EXEC SQL BEGIN DECLARE SECTION;
2246 int mach_id, acl_id, modby;
2247 char acl_type[HOSTACCESS_ACL_TYPE_SIZE];
2248 EXEC SQL END DECLARE SECTION;
2250 EXEC SQL FETCH csr228 INTO :mach_id, :acl_type, :acl_id, :modby, :rowid;
2254 maybe_fixup_modby2("hostaccess", "modby", strtrim(rowid), modby);
2256 if (!hash_lookup(machines, mach_id))
2258 printf("Hostaccess for non-existant host %d\n", mach_id);
2259 printf("Not fixing this error\n");
2261 if (!strcmp(acl_type, "USER") && !hash_lookup(users, acl_id))
2263 printf("Hostaccess for %d is non-existant user %d\n", mach_id, acl_id);
2264 printf("Not fixing this error\n");
2266 else if (!strcmp(acl_type, "LIST") && !hash_lookup(lists, acl_id))
2268 printf("Hostaccess for %d is non-existant list %d\n", mach_id, acl_id);
2269 printf("Not fixing this error\n");
2272 EXEC SQL CLOSE csr228;
2274 dprintf("Checking krbmap...\n");
2277 EXEC SQL DECLARE csr230 CURSOR FOR
2278 SELECT users_id, string_id, rowid FROM krbmap
2279 FOR UPDATE OF string_id;
2280 EXEC SQL OPEN csr230;
2283 EXEC SQL BEGIN DECLARE SECTION;
2284 int users_id, string_id;
2285 EXEC SQL END DECLARE SECTION;
2287 EXEC SQL FETCH csr230 INTO :users_id, :string_id, :rowid;
2291 if (!hash_lookup(users, users_id))
2292 sq_save_unique_data(sq1, (void *)users_id);
2293 else if (!maybe_fixup_unref_string2("krbmap", "string_id", strtrim(rowid), string_id))
2294 sq_save_unique_data(sq2, (void *)string_id);
2296 EXEC SQL CLOSE csr230;
2297 generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1);
2298 generic_delete(sq2, show_krb_str, "krbmap", "string_id", 1);
2300 dprintf("Checking capacls...\n");
2301 EXEC SQL DECLARE csr231 CURSOR FOR
2302 SELECT list_id, tag FROM capacls;
2303 EXEC SQL OPEN csr231;
2306 EXEC SQL BEGIN DECLARE SECTION;
2308 char tag[CAPACLS_TAG_SIZE];
2309 EXEC SQL END DECLARE SECTION;
2311 EXEC SQL FETCH csr231 INTO :list_id, :tag;
2315 if (!hash_lookup(lists, list_id))
2317 printf("Capacl for %s is non-existant list %d\n", tag, list_id);
2318 printf("Not fixing this error\n");
2321 EXEC SQL CLOSE csr231;
2323 dprintf("Checking hostaliases\n");
2325 EXEC SQL DECLARE csr232 CURSOR FOR
2326 SELECT mach_id FROM hostalias;
2327 EXEC SQL OPEN csr232;
2330 EXEC SQL BEGIN DECLARE SECTION;
2332 EXEC SQL END DECLARE SECTION;
2334 EXEC SQL FETCH csr232 INTO :mach_id;
2338 if (!hash_lookup(machines, mach_id))
2339 sq_save_unique_data(sq1, (void *)mach_id);
2341 EXEC SQL CLOSE csr232;
2342 generic_delete(sq1, show_hostalias, "hostalias", "mach_id", 1);
2344 dprintf("Checking printers\n");
2351 EXEC SQL DECLARE csr233 CURSOR FOR
2352 SELECT mach_id, loghost, rm, rq, ac, lpc_acl, modby, rowid FROM printers;
2353 EXEC SQL OPEN csr233;
2356 EXEC SQL BEGIN DECLARE SECTION;
2357 int mach_id, loghost, rm, rq, ac, lpc_acl, modby;
2358 EXEC SQL END DECLARE SECTION;
2360 EXEC SQL FETCH csr233 INTO :mach_id, :loghost, :rm, :rq, :ac,
2361 :lpc_acl, :modby, :rowid;
2365 maybe_fixup_modby2("printers", "modby", strtrim(rowid), modby);
2366 if (!hash_lookup(machines, mach_id))
2367 sq_save_unique_data(sq1, (void *)mach_id);
2368 else if (!hash_lookup(machines, rm))
2369 sq_save_unique_data(sq2, (void *)rm);
2370 else if (!hash_lookup(printservers, rm))
2371 sq_save_unique_data(sq6, (void *)mach_id);
2372 else if (!hash_lookup(machines, rq))
2373 sq_save_unique_data(sq3, (void *)rq);
2375 if (!hash_lookup(lists, ac))
2376 sq_save_unique_data(sq4, (void *)ac);
2377 if (!hash_lookup(lists, lpc_acl))
2378 sq_save_unique_data(sq5, (void *)lpc_acl);
2379 if (!hash_lookup(machines, loghost))
2381 show_printer_loghost((void *)loghost);
2386 EXEC SQL CLOSE csr233;
2387 generic_delete(sq1, show_printer_mach, "printers", "mach_id", 1);
2388 generic_delete(sq6, show_printer_server, "printers", "mach_id", 1);
2389 generic_delete(sq2, show_printer_spool, "printers", "rm", 1);
2390 generic_delete(sq3, show_printer_quota, "printers", "rq", 1);
2391 generic_fix(sq4, show_printer_ac, "Clear", fix_printer_ac, 1);
2392 generic_fix(sq5, show_printer_lpc_acl, "Clear", fix_printer_lpc_acl, 1);
2394 dprintf("Checking printservers\n");
2395 hash_step(printservers, check_ps, NULL);