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_mcntmap_mach(void *id);
25 int show_mcntmap_cnt(void *id);
26 int show_hostalias(void *id);
27 int show_printer_mach(void *id);
28 int show_printer_server(void *id);
29 int show_printer_loghost(void *id);
30 int show_printer_spool(void *id);
31 int show_printer_quota(void *id);
32 int show_printer_ac(void *id);
33 int show_printer_lpc_acl(void *id);
34 void fix_printer_ac(void *id);
35 void fix_printer_lpc_acl(void *id);
36 void user_check(int id, void *user, void *hint);
37 void clear_user_sponsor(struct user *u);
38 int maybe_fixup_unref_string(int sid, int oid, char *oname, char *table,
39 char *field, char *idfield);
40 int maybe_fixup_modby(int sid, int oid, char *oname, char *table,
41 char *field, char *idfield);
42 int maybe_fixup_unref_string2(char *table, char *field, char *rowid, int sid);
43 int maybe_fixup_modby2(char *table, char *field, char *rowid, int id);
44 void pobox_check(int id, struct user *u);
45 void remove_pobox(int id);
46 void fix_smtp_pobox(int id, int sid);
47 void mach_check(int id, void *machine, void *hint);
48 void subnet_check(int id, void *subnet, void *hint);
49 void clear_subnet_owner(struct subnet *s);
50 void clear_mach_owner(struct machine *m);
51 void cluster_check(int id, void *cluster, void *hint);
52 int show_svc(void *id);
53 void list_check(int id, void *list, void *hint);
54 void fix_list_acl(int id);
55 void fix_list_memacl(int id);
56 int show_member_list(void *id);
57 int show_mem_user(void *id);
58 int show_mem_list(void *id);
59 int show_mem_str(void *id);
60 int show_mem_krb(void *id);
61 int show_mem_mach(void *id);
62 void del_mem_user(void *id);
63 void del_mem_list(void *id);
64 void del_mem_str(void *id);
65 void del_mem_krb(void *id);
66 void del_mem_mach(void *id);
67 int show_sh(void *id);
68 void del_sh_mach(void *id);
69 void fsmatch(int id, void *nfsphys, void *filesys);
70 void check_fs(int id, void *filesys, void *hint);
71 void check_nfsphys(int id, void *nfsphys, void *hint);
72 void check_ps(int id, void *printserver, void *hint);
73 void check_container(int id, void *container, void *hint);
74 void fix_container_acl(int id);
75 void fix_container_memacl(int id);
76 int show_fsg_missing(void *id);
77 int show_fsg_type(void *filesys);
78 void fix_fsg_type(void *filesys);
79 int show_fsg_nomember(void *id);
80 int show_quota_nouser(void *id);
81 int show_quota_nolist(void *id);
82 void fix_quota_nouser(void *id);
83 void fix_quota_nolist(void *id);
84 int show_quota_nofs(void *id);
85 void fix_quota_nofs(void *id);
86 int show_quota_wrongpid(void *id);
87 void fix_quota_physid(void *id);
88 int show_srv_user(void *id);
89 int show_srv_list(void *id);
90 void zero_srv_user(void *id);
91 void zero_srv_list(void *id);
92 int show_krb_usr(void *id);
93 int show_krb_str(void *id);
94 int show_pdm_mach(void *id);
96 int show_mcm_mach(void *id)
98 EXEC SQL BEGIN DECLARE SECTION;
99 int iid = (int)id, found = 1;
100 char name[CLUSTERS_NAME_SIZE];
101 EXEC SQL END DECLARE SECTION;
103 EXEC SQL DECLARE csr201 CURSOR FOR
104 SELECT clusters.name FROM clusters, mcmap
105 WHERE clusters.clu_id = mcmap.clu_id AND mcmap.mach_id = :iid;
106 EXEC SQL OPEN csr201;
109 EXEC SQL FETCH csr201 INTO :name;
115 printf("Cluster %s, non-existant machine %d in cluster map\n",
118 EXEC SQL CLOSE csr201;
122 int show_mcm_clu(void *id)
124 EXEC SQL BEGIN DECLARE SECTION;
125 int iid = (int)id, found = 1;
126 char name[MACHINE_NAME_SIZE];
127 EXEC SQL END DECLARE SECTION;
129 EXEC SQL DECLARE csr202 CURSOR FOR
130 SELECT machine.name FROM machine, mcmap
131 WHERE machine.mach_id = mcmap.mach_id AND mcmap.clu_id = :iid;
132 EXEC SQL OPEN csr202;
135 EXEC SQL FETCH csr202 INTO :name;
142 printf("Machine %s, non-existant cluster %d in cluster map\n",
145 EXEC SQL CLOSE csr202;
149 int show_mcntmap_mach(void *id)
151 EXEC SQL BEGIN DECLARE SECTION;
152 int iid = (int)id, found = 1;
153 char name[CONTAINERS_NAME_SIZE];
154 EXEC SQL END DECLARE SECTION;
156 EXEC SQL DECLARE csr_show_mcnt_mach CURSOR FOR
157 SELECT cnt.name FROM container cnt, mcntmap mc
158 WHERE cnt.cnt_id = mc.cnt_id AND mc.mach_id = :iid;
159 EXEC SQL OPEN csr_show_mcnt_mach;
162 EXEC SQL FETCH csr_show_mcnt_mach INTO :name;
168 printf("Container %s, non-existant machine %d in container map\n",
171 EXEC SQL CLOSE csr_show_mcnt_mach;
175 int show_mcntmap_cnt(void *id)
177 EXEC SQL BEGIN DECLARE SECTION;
178 int iid = (int)id, found = 1;
179 char name[MACHINE_NAME_SIZE];
180 EXEC SQL END DECLARE SECTION;
182 EXEC SQL DECLARE csr_show_mcnt_cnt CURSOR FOR
183 SELECT m.name FROM machine m, mcntmap mc
184 WHERE m.mach_id = mc.mach_id AND mc.cnt_id = :iid;
185 EXEC SQL OPEN csr_show_mcnt_cnt;
188 EXEC SQL FETCH csr_show_mcnt_cnt INTO :name;
195 printf("Machine %s, non-existant container %d in container map\n",
198 EXEC SQL CLOSE csr_show_mcnt_cnt;
202 int show_hostalias(void *id)
204 EXEC SQL BEGIN DECLARE SECTION;
205 int iid = (int)id, found = 1;
206 char name[HOSTALIAS_NAME_SIZE];
207 EXEC SQL END DECLARE SECTION;
209 EXEC SQL DECLARE csr234 CURSOR FOR
210 SELECT name FROM hostalias WHERE mach_id = :iid;
211 EXEC SQL OPEN csr234;
214 EXEC SQL FETCH csr234 INTO :name;
221 printf("Alias %s, non-existant machine %d in hostalias map\n",
224 EXEC SQL CLOSE csr234;
228 int show_printer_mach(void *id)
230 EXEC SQL BEGIN DECLARE SECTION;
231 int iid = (int)id, found = 1;
232 char name[PRINTERS_NAME_SIZE];
233 EXEC SQL END DECLARE SECTION;
235 EXEC SQL DECLARE csr235 CURSOR FOR
236 SELECT name FROM printers WHERE mach_id = :iid;
237 EXEC SQL OPEN csr235;
240 EXEC SQL FETCH csr235 INTO :name;
247 printf("Printer %s, non-existant machine %d in printers table\n",
250 EXEC SQL CLOSE csr235;
254 int show_printer_server(void *id)
256 EXEC SQL BEGIN DECLARE SECTION;
257 int iid = (int)id, found = 1;
258 char name[PRINTERS_NAME_SIZE];
259 EXEC SQL END DECLARE SECTION;
261 EXEC SQL DECLARE csr_sps CURSOR FOR
262 SELECT name FROM printers WHERE mach_id = :iid;
263 EXEC SQL OPEN csr_sps;
266 EXEC SQL FETCH csr_sps INTO :name;
273 printf("Printer %s, non-existant printserver %d in printers table\n",
276 EXEC SQL CLOSE csr_sps;
280 int show_printer_loghost(void *id)
282 EXEC SQL BEGIN DECLARE SECTION;
283 int iid = (int)id, found = 1;
284 char name[PRINTERS_NAME_SIZE];
285 EXEC SQL END DECLARE SECTION;
287 EXEC SQL DECLARE csr236 CURSOR FOR
288 SELECT name FROM printers WHERE loghost = :iid;
289 EXEC SQL OPEN csr236;
292 EXEC SQL FETCH csr236 INTO :name;
299 printf("Printer %s, non-existant spool machine %d in printers table\n",
302 EXEC SQL CLOSE csr236;
306 int show_printer_spool(void *id)
308 EXEC SQL BEGIN DECLARE SECTION;
309 int iid = (int)id, found = 1;
310 char name[PRINTERS_NAME_SIZE];
311 EXEC SQL END DECLARE SECTION;
313 EXEC SQL DECLARE csr237 CURSOR FOR
314 SELECT name FROM printers WHERE rm = :iid;
315 EXEC SQL OPEN csr237;
318 EXEC SQL FETCH csr237 INTO :name;
325 printf("Printer %s, non-existant spool machine %d in printers table\n",
328 EXEC SQL CLOSE csr237;
332 int show_printer_quota(void *id)
334 EXEC SQL BEGIN DECLARE SECTION;
335 int iid = (int)id, found = 1;
336 char name[PRINTERS_NAME_SIZE];
337 EXEC SQL END DECLARE SECTION;
339 EXEC SQL DECLARE csr238 CURSOR FOR
340 SELECT name FROM printers WHERE rq = :iid;
341 EXEC SQL OPEN csr238;
344 EXEC SQL FETCH csr238 INTO :name;
351 printf("Printer %s, non-existant quota server %d in printers table\n",
354 EXEC SQL CLOSE csr238;
358 int show_printer_ac(void *id)
360 EXEC SQL BEGIN DECLARE SECTION;
361 int iid = (int)id, found = 1;
362 char name[PRINTERS_NAME_SIZE];
363 EXEC SQL END DECLARE SECTION;
365 EXEC SQL DECLARE csr239 CURSOR FOR
366 SELECT name FROM printers WHERE ac = :iid;
367 EXEC SQL OPEN csr239;
370 EXEC SQL FETCH csr239 INTO :name;
377 printf("Printer %s, non-existant restrict list %d in printers table\n",
380 EXEC SQL CLOSE csr239;
384 int show_printer_lpc_acl(void *id)
386 EXEC SQL BEGIN DECLARE SECTION;
387 int iid = (int)id, found = 1;
388 char name[PRINTERS_NAME_SIZE];
389 EXEC SQL END DECLARE SECTION;
391 EXEC SQL DECLARE csr240 CURSOR FOR
392 SELECT name FROM printers WHERE lpc_acl = :iid;
393 EXEC SQL OPEN csr240;
396 EXEC SQL FETCH csr240 INTO :name;
403 printf("Printer %s, non-existant lpc ACL %d in printers table\n",
406 EXEC SQL CLOSE csr240;
410 void fix_printer_ac(void *id)
412 EXEC SQL BEGIN DECLARE SECTION;
413 int rowcount, iid = (int)id;
414 EXEC SQL END DECLARE SECTION;
416 EXEC SQL UPDATE printers SET ac = 0 WHERE ac = :iid;
417 rowcount = sqlca.sqlerrd[2];
419 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
421 printf("Not fixed\n");
422 modified("printers");
425 void fix_printer_lpc_acl(void *id)
427 EXEC SQL BEGIN DECLARE SECTION;
428 int rowcount, iid = (int)id;
429 EXEC SQL END DECLARE SECTION;
431 EXEC SQL UPDATE printers SET lpc_acl = 0 WHERE lpc_acl = :iid;
432 rowcount = sqlca.sqlerrd[2];
434 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
436 printf("Not fixed\n");
437 modified("printers");
440 void user_check(int id, void *user, void *hint)
442 struct user *u = user;
444 u->comment = maybe_fixup_unref_string(u->comment, id, u->login, "users",
445 "comments", "users_id");
447 u->modby = maybe_fixup_modby(u->modby, id, u->login, "users",
448 "modby", "users_id");
450 u->fmodby = maybe_fixup_modby(u->fmodby, id, u->login, "users",
451 "fmodby", "users_id");
453 u->pmodby = maybe_fixup_modby(u->pmodby, id, u->login, "users",
454 "pmodby", "users_id");
456 u->sigwho = maybe_fixup_unref_string(u->sigwho, id, u->login, "users",
457 "sigwho", "users_id");
459 switch (u->sponsor_type)
462 if (!hash_lookup(users, u->sponsor_id))
464 printf("User %s has non-existant USER sponsor %d\n",
465 u->login, u->sponsor_id);
466 if (single_fix("Set to no sponsor", 1))
467 clear_user_sponsor(u);
471 if (!hash_lookup(lists, u->sponsor_id))
473 printf("User %s has non-existant LIST sponsor %d\n",
474 u->login, u->sponsor_id);
475 if (single_fix("Set to no sponsor", 1))
476 clear_user_sponsor(u);
482 u->sponsor_id = maybe_fixup_unref_string(u->sponsor_id, id, u->login,
483 "users", "sponsor_id",
485 if (u->sponsor_id == 0)
486 clear_user_sponsor(u);
492 int maybe_fixup_unref_string(int sid, int oid, char *oname, char *table,
493 char *field, char *idfield)
495 int ret = (sid < 0) ? -sid : sid, doit = 0, newid;
496 EXEC SQL BEGIN DECLARE SECTION;
499 EXEC SQL END DECLARE SECTION;
501 if ((newid = (int)hash_lookup(string_dups, ret)))
503 printf("%s entry %s(%d) has a %s with duplicate string %d\n",
504 table, oname, oid, field, ret);
505 if (single_fix("Replace duplicate", 0))
512 else if (!string_check(ret))
514 printf("%s entry %s(%d) has a %s with non-existant string %d\n",
515 table, oname, oid, field, ret);
516 if (single_fix("Delete", 1))
525 sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE %s = %d",
526 table, field, (sid < 0) ? -ret : ret, idfield, oid);
527 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
528 rowcount = sqlca.sqlerrd[2];
532 printf("Not fixed, rowcount = %d\n", rowcount);
536 return (sid < 0) ? -ret : ret;
539 int maybe_fixup_modby(int sid, int oid, char *oname, char *table,
540 char *field, char *idfield)
542 EXEC SQL BEGIN DECLARE SECTION;
545 EXEC SQL END DECLARE SECTION;
548 return maybe_fixup_unref_string(sid, oid, oname, table, field, idfield);
551 if (!hash_lookup(users, sid))
553 printf("%s entry %s(%d) has a %s with non-existant user %d\n",
554 table, oname, oid, field, sid);
555 if (single_fix("Delete", 1))
557 sprintf(stmt_buf, "UPDATE %s SET %s = 0 WHERE %s = %d",
558 table, field, idfield, oid);
559 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
560 rowcount = sqlca.sqlerrd[2];
564 printf("Not fixed, rowcount = %d\n", rowcount);
573 int maybe_fixup_unref_string2(char *table, char *field, char *rowid, int sid)
575 int ret = (sid < 0) ? -sid : sid, doit = 0, newid;
576 EXEC SQL BEGIN DECLARE SECTION;
579 EXEC SQL END DECLARE SECTION;
581 if ((newid = (int)hash_lookup(string_dups, ret)))
583 printf("%s entry has a %s with duplicate string %d\n",
585 if (single_fix("Replace duplicate", 0))
592 else if (!string_check(ret))
594 printf("%s entry has a %s with non-existant string %d\n",
596 if (single_fix("Clear", 1))
605 sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE rowid = '%s'",
606 table, field, (sid < 0) ? -ret : ret, rowid);
607 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
608 rowcount = sqlca.sqlerrd[2];
612 printf("Not fixed, rowcount = %d\n", rowcount);
615 return (sid < 0) ? -ret : ret;
618 int maybe_fixup_modby2(char *table, char *field, char *rowid, int id)
620 EXEC SQL BEGIN DECLARE SECTION;
623 EXEC SQL END DECLARE SECTION;
626 return maybe_fixup_unref_string2(table, field, rowid, id);
629 if (!hash_lookup(users, id))
631 printf("%s entry has a %s with non-existant user %d\n",
633 if (single_fix("Clear", 1))
635 sprintf(stmt_buf, "UPDATE %s SET %s = 0 WHERE rowid = '%s'",
636 table, field, rowid);
637 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
638 rowcount = sqlca.sqlerrd[2];
642 printf("Not fixed, rowcount = %d\n", rowcount);
651 void pobox_check(int id, struct user *u)
658 if (!hash_lookup(machines, u->pobox_id))
660 printf("User %s(%s) has P.O.Box on non-existant machine %d\n",
661 u->login, u->fullname, u->pobox_id);
662 if (single_fix("Delete", 0))
664 remove_pobox(u->users_id);
671 if (hash_lookup(string_dups, u->pobox_id))
673 printf("User %s(%s) has P.O.Box with duplicate string %d\n",
674 u->login, u->fullname, u->pobox_id);
675 if (single_fix("Update", 0))
677 printf("Replacing box_id dup string ID %d with %d\n",
679 (int)hash_lookup(string_dups, u->pobox_id));
680 u->pobox_id = (int)hash_lookup(string_dups, u->pobox_id);
681 fix_smtp_pobox(u->users_id, u->pobox_id);
682 string_check(u->pobox_id);
685 else if (!string_check(u->pobox_id))
687 printf("User %s(%s) has P.O.Box with non-existant string %d\n",
688 u->login, u->fullname, u->pobox_id);
689 if (single_fix("Delete", 0))
691 remove_pobox(u->users_id);
698 fs = hash_lookup(filesys, u->pobox_id);
701 printf("User %s(%s) has P.O.Box on non-existant filesystem %d\n",
702 u->login, u->fullname, u->pobox_id);
703 if (single_fix("Delete", 0))
705 remove_pobox(u->users_id);
709 else if (fs->type != 'I')
711 printf("User %s(%s) has IMAP P.O.Box on non-IMAP filesystem %s\n",
712 u->login, u->fullname, fs->name);
713 if (single_fix("Delete", 0))
715 remove_pobox(u->users_id);
727 void remove_pobox(int id)
729 EXEC SQL BEGIN DECLARE SECTION;
730 int rowcount, iid = (int)id;
731 EXEC SQL END DECLARE SECTION;
733 EXEC SQL UPDATE users SET potype = 'NONE' WHERE users.users_id = :iid;
734 rowcount = sqlca.sqlerrd[2];
736 printf("%d entr%s removed\n", rowcount, rowcount == 1 ? "y" : "ies");
738 printf("Not removed\n");
742 void fix_smtp_pobox(int id, int sid)
744 EXEC SQL BEGIN DECLARE SECTION;
745 int rowcount, iid = id, isid = sid;
746 EXEC SQL END DECLARE SECTION;
748 EXEC SQL UPDATE users SET box_id = :isid WHERE users.users_id = :iid;
749 rowcount = sqlca.sqlerrd[2];
751 printf("%d entr%s updated\n", rowcount, rowcount == 1 ? "y" : "ies");
753 printf("Not updated\n");
757 void mach_check(int id, void *machine, void *hint)
759 struct machine *m = machine;
761 if (!hash_lookup(subnets, m->snet_id))
763 printf("Machine %s is on a non-existant subnet %d\n",
764 m->name, m->snet_id);
765 if (single_fix("Move to null-subnet", 1))
767 EXEC SQL BEGIN DECLARE SECTION;
768 int rowcount, iid = id;
769 EXEC SQL END DECLARE SECTION;
771 EXEC SQL UPDATE machine SET snet_id = 0 WHERE mach_id = :iid;
772 rowcount = sqlca.sqlerrd[2];
774 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
776 printf("Not fixed\n");
781 switch (m->owner_type)
784 if (!hash_lookup(users, m->owner_id))
786 printf("Machine %s has non-existant USER owner %d\n",
787 m->name, m->owner_id);
788 if (single_fix("Set to no owner", 1))
793 if (!hash_lookup(lists, m->owner_id))
795 printf("Machine %s has non-existant LIST owner %d\n",
796 m->name, m->owner_id);
797 if (single_fix("Set to no owner", 1))
804 m->owner_id = maybe_fixup_unref_string(m->owner_id, id, m->name,
805 "machine", "owner_id",
807 if (m->owner_id == 0)
812 m->acomment = maybe_fixup_unref_string(m->acomment, id, m->name,
813 "machine", "acomment", "mach_id");
815 m->ocomment = maybe_fixup_unref_string(m->ocomment, id, m->name,
816 "machine", "ocomment", "mach_id");
818 m->creator = maybe_fixup_modby(m->creator, id, m->name, "machine",
819 "creator", "mach_id");
820 m->modby = maybe_fixup_modby(m->modby, id, m->name, "machine",
824 void subnet_check(int id, void *subnet, void *hint)
826 struct subnet *s = subnet;
828 switch (s->owner_type)
831 if (!hash_lookup(users, s->owner_id))
833 printf("Subnet %s has non-existant USER owner %d\n",
834 s->name, s->owner_id);
835 if (single_fix("Set to no owner", 1))
836 clear_subnet_owner(s);
840 if (!hash_lookup(lists, s->owner_id))
842 printf("Machine %s has non-existant LIST owner %d\n",
843 s->name, s->owner_id);
844 if (single_fix("Set to no owner", 1))
845 clear_subnet_owner(s);
851 s->owner_id = maybe_fixup_unref_string(s->owner_id, id, s->name,
852 "machine", "owner_id",
854 if (s->owner_id == 0)
855 clear_subnet_owner(s);
858 s->modby = maybe_fixup_modby(s->modby, id, s->name, "subnet",
862 void clear_user_sponsor(struct user *u)
864 EXEC SQL BEGIN DECLARE SECTION;
865 int rowcount, id = u->users_id;
866 EXEC SQL END DECLARE SECTION;
868 EXEC SQL UPDATE users SET sponsor_type = 'NONE', sponsor_id = 0
869 WHERE users_id = :id;
870 rowcount = sqlca.sqlerrd[2];
872 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
874 printf("Not fixed\n");
878 void clear_subnet_owner(struct subnet *s)
880 EXEC SQL BEGIN DECLARE SECTION;
881 int rowcount, id = s->snet_id;
882 EXEC SQL END DECLARE SECTION;
884 EXEC SQL UPDATE subnet SET owner_type = 'NONE', owner_id = 0
886 rowcount = sqlca.sqlerrd[2];
888 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
890 printf("Not fixed\n");
894 void clear_mach_owner(struct machine *m)
896 EXEC SQL BEGIN DECLARE SECTION;
897 int rowcount, id = m->mach_id;
898 EXEC SQL END DECLARE SECTION;
900 EXEC SQL UPDATE machine SET owner_type = 'NONE', owner_id = 0
902 rowcount = sqlca.sqlerrd[2];
904 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
906 printf("Not fixed\n");
910 void cluster_check(int id, void *cluster, void *hint)
912 struct cluster *c = cluster;
914 c->modby = maybe_fixup_modby(c->modby, id, c->name, "clusters",
918 int show_svc(void *id)
920 EXEC SQL BEGIN DECLARE SECTION;
921 int iid = (int)id, found = 1;
922 char label[SVC_SERV_LABEL_SIZE], data[SVC_SERV_CLUSTER_SIZE];
923 EXEC SQL END DECLARE SECTION;
925 EXEC SQL DECLARE csr203 CURSOR FOR
926 SELECT serv_label, serv_cluster FROM svc
928 EXEC SQL OPEN csr203;
931 EXEC SQL FETCH csr203 INTO :label, :data;
938 printf("Cluster data [%s] %s for non-existant cluster %d\n",
941 EXEC SQL CLOSE csr203;
945 void list_check(int id, void *list, void *hint)
947 struct list *l = list;
949 l->modby = maybe_fixup_modby(l->modby, id, l->name, "list",
955 if (!hash_lookup(lists, l->acl_id))
957 printf("List %s has bad LIST acl %d\n", l->name, l->acl_id);
958 if (single_fix("Patch", 1))
959 fix_list_acl(l->list_id);
963 if (!hash_lookup(users, l->acl_id))
965 printf("List %s has bad USER acl %d\n", l->name, l->acl_id);
966 if (single_fix("Patch", 1))
967 fix_list_acl(l->list_id);
971 l->acl_id = maybe_fixup_unref_string(l->acl_id, id, l->name,
972 "list", "acl_id", "list_id");
975 printf("List %s has bad KERBEROS acl %d\n", l->name, l->acl_id);
976 if (single_fix("Patch", 1))
977 fix_list_acl(l->list_id);
982 switch (l->memacl_type)
985 if (!hash_lookup(lists, l->memacl_id))
987 printf("List %s has bad LIST memacl %d\n", l->name, l->memacl_id);
988 if (single_fix("Patch", 1))
989 fix_list_memacl(l->list_id);
993 if (!hash_lookup(users, l->memacl_id))
995 printf("List %s has bad USER acl %d\n", l->name, l->memacl_id);
996 if (single_fix("Patch", 1))
997 fix_list_memacl(l->list_id);
1001 l->memacl_id = maybe_fixup_unref_string(l->memacl_id, id, l->name,
1002 "list", "memacl_id", "list_id");
1005 printf("List %s has bad KERBEROS acl %d\n", l->name,
1007 if (single_fix("Patch", 1))
1008 fix_list_memacl(l->list_id);
1014 void fix_list_acl(int id)
1016 EXEC SQL BEGIN DECLARE SECTION;
1017 int rowcount, iid = (int)id;
1018 EXEC SQL END DECLARE SECTION;
1020 EXEC SQL UPDATE list SET acl_id = :iid, acl_type = 'LIST'
1021 WHERE list_id = :iid;
1022 rowcount = sqlca.sqlerrd[2];
1024 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1026 printf("Not fixed\n");
1030 void fix_list_memacl(int id)
1032 EXEC SQL BEGIN DECLARE SECTION;
1033 int rowcount, iid = (int)id;
1034 EXEC SQL END DECLARE SECTION;
1036 EXEC SQL UPDATE list SET memacl_id = 0, memacl_type = 'NONE'
1037 WHERE list_id = :iid;
1038 rowcount = sqlca.sqlerrd[2];
1040 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1042 printf("Not fixed\n");
1046 int show_member_list(void *id)
1048 EXEC SQL BEGIN DECLARE SECTION;
1049 int mid, iid = (int)id, found = 1;
1050 char mtype[IMEMBERS_MEMBER_TYPE_SIZE], *name = NULL;
1051 EXEC SQL END DECLARE SECTION;
1053 EXEC SQL DECLARE csr204 CURSOR FOR
1054 SELECT member_type, member_id FROM imembers
1055 WHERE list_id = :iid;
1056 EXEC SQL OPEN csr204;
1059 EXEC SQL FETCH csr204 INTO :mtype, :mid;
1065 if (mtype[0] == 'L')
1067 struct list *l = hash_lookup(lists, mid);
1071 else if (mtype[0] == 'U')
1073 struct user *u = hash_lookup(users, mid);
1077 else if (mtype[0] == 'S' || mtype[0] == 'K')
1079 struct string *s = hash_lookup(strings, mid);
1084 printf("Non-existant list %d has member %s %s\n", iid, mtype, name);
1087 printf("Non-existant list %d has non-existent member %s %d\n",
1091 EXEC SQL CLOSE csr204;
1095 int show_mem_user(void *id)
1097 EXEC SQL BEGIN DECLARE SECTION;
1098 int lid, iid = (int)id, found = 1;
1099 EXEC SQL END DECLARE SECTION;
1102 EXEC SQL DECLARE csr205 CURSOR FOR
1103 SELECT list_id FROM imembers
1104 WHERE member_id = :iid AND member_type = 'USER';
1105 EXEC SQL OPEN csr205;
1108 EXEC SQL FETCH csr205 INTO :lid;
1111 l = hash_lookup(lists, lid);
1116 printf("List %s has non-existant user member, id %d\n", l->name, iid);
1118 EXEC SQL CLOSE csr205;
1122 int show_mem_list(void *id)
1124 EXEC SQL BEGIN DECLARE SECTION;
1125 int lid, iid = (int)id, found = 1;
1126 EXEC SQL END DECLARE SECTION;
1129 EXEC SQL DECLARE csr206 CURSOR FOR
1130 SELECT list_id FROM imembers
1131 WHERE member_id = :iid AND member_type = 'LIST';
1132 EXEC SQL OPEN csr206;
1135 EXEC SQL FETCH csr206 INTO :lid;
1138 l = hash_lookup(lists, lid);
1143 printf("List %s has non-existant list member, id %d\n", l->name, iid);
1145 EXEC SQL CLOSE csr206;
1149 int show_mem_str(void *id)
1151 EXEC SQL BEGIN DECLARE SECTION;
1152 int lid, iid = (int)id, found = 1;
1153 EXEC SQL END DECLARE SECTION;
1156 EXEC SQL DECLARE csr207 CURSOR FOR
1157 SELECT list_id FROM imembers
1158 WHERE member_id = :iid AND member_type = 'STRING';
1159 EXEC SQL OPEN csr207;
1162 EXEC SQL FETCH csr207 INTO :lid;
1165 l = hash_lookup(lists, lid);
1170 printf("List %s has non-existant string member, id %d\n", l->name, iid);
1172 EXEC SQL CLOSE csr207;
1177 int show_mem_krb(void *id)
1179 EXEC SQL BEGIN DECLARE SECTION;
1180 int lid, iid = (int)id, found = 1;
1181 EXEC SQL END DECLARE SECTION;
1184 EXEC SQL DECLARE csr208 CURSOR FOR
1185 SELECT list_id FROM imembers
1186 WHERE member_id = :iid AND member_type = 'KERBEROS';
1187 EXEC SQL OPEN csr208;
1190 EXEC SQL FETCH csr208 INTO :lid;
1193 l = hash_lookup(lists, lid);
1198 printf("List %s has non-existant kerberos member, id %d\n",
1201 EXEC SQL CLOSE csr208;
1205 int show_mem_mach(void *id)
1207 EXEC SQL BEGIN DECLARE SECTION;
1208 int lid, iid = (int)id, found = 1;
1209 EXEC SQL END DECLARE SECTION;
1212 EXEC SQL DECLARE csr208a CURSOR FOR
1213 SELECT list_id FROM imembers
1214 WHERE member_id = :iid AND member_type = 'MACHINE';
1215 EXEC SQL OPEN csr208a;
1218 EXEC SQL FETCH csr208a INTO :lid;
1221 l = hash_lookup(lists, lid);
1226 printf("List %s has nonexistant machine member, id %d\n",
1229 EXEC SQL CLOSE csr208a;
1233 void del_mem_user(void *id)
1235 EXEC SQL BEGIN DECLARE SECTION;
1236 int iid = (int)id, rowcount;
1237 EXEC SQL END DECLARE SECTION;
1239 EXEC SQL DELETE FROM imembers WHERE member_type = 'USER' AND
1241 rowcount = sqlca.sqlerrd[2];
1243 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1245 printf("Not deleted\n");
1246 modified("imembers");
1249 void del_mem_list(void *id)
1251 EXEC SQL BEGIN DECLARE SECTION;
1252 int iid = (int)id, rowcount;
1253 EXEC SQL END DECLARE SECTION;
1255 EXEC SQL DELETE FROM imembers WHERE member_type = 'LIST' AND
1257 rowcount = sqlca.sqlerrd[2];
1259 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1261 printf("Not deleted\n");
1262 modified("imembers");
1265 void del_mem_str(void *id)
1267 EXEC SQL BEGIN DECLARE SECTION;
1268 int iid = (int)id, rowcount;
1269 EXEC SQL END DECLARE SECTION;
1271 EXEC SQL DELETE FROM imembers WHERE member_type = 'STRING' AND
1273 rowcount = sqlca.sqlerrd[2];
1275 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1277 printf("Not deleted\n");
1278 modified("imembers");
1282 void del_mem_krb(void *id)
1284 EXEC SQL BEGIN DECLARE SECTION;
1285 int iid = (int)id, rowcount;
1286 EXEC SQL END DECLARE SECTION;
1288 EXEC SQL DELETE FROM imembers WHERE member_type = 'KERBEROS' AND
1290 rowcount = sqlca.sqlerrd[2];
1292 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1294 printf("Not deleted\n");
1295 modified("imembers");
1298 void del_mem_mach(void *id)
1300 EXEC SQL BEGIN DECLARE SECTION;
1301 int iid = (int)id, rowcount;
1302 EXEC SQL END DECLARE SECTION;
1304 EXEC SQL DELETE FROM imembers WHERE member_type = 'MACHINE' AND
1306 rowcount = sqlca.sqlerrd[2];
1308 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1310 printf("Not deleted\n");
1311 modified("imembers");
1314 int show_sh(void *id)
1316 EXEC SQL BEGIN DECLARE SECTION;
1317 char name[SERVERHOSTS_SERVICE_SIZE];
1319 EXEC SQL END DECLARE SECTION;
1322 EXEC SQL DECLARE csr209 CURSOR FOR
1323 SELECT service FROM serverhosts
1324 WHERE mach_id = :iid;
1325 EXEC SQL OPEN csr209;
1328 EXEC SQL FETCH csr209 INTO :name;
1333 printf("ServerHost entry for service %s non-existant host %d\n",
1336 EXEC SQL CLOSE csr209;
1340 void del_sh_mach(void *id)
1342 EXEC SQL BEGIN DECLARE SECTION;
1343 int iid = (int)id, rowcount;
1344 EXEC SQL END DECLARE SECTION;
1346 EXEC SQL DELETE FROM serverhosts WHERE mach_id = :iid;
1347 rowcount = sqlca.sqlerrd[2];
1349 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1351 printf("Not deleted\n");
1352 modified("serverhosts");
1356 static int fnchecklen;
1358 void fsmatch(int id, void *nfsphys, void *filesys)
1360 struct nfsphys *n = nfsphys;
1361 struct filesys *f = filesys;
1363 if (n->mach_id == f->mach_id &&
1364 !strncmp(f->dir, n->dir, strlen(n->dir)) &&
1365 strlen(n->dir) > fnchecklen)
1368 fnchecklen = strlen(n->dir);
1373 void check_fs(int id, void *filesys, void *hint)
1375 EXEC SQL BEGIN DECLARE SECTION;
1376 int iid = id, id1, id2, id3, rowcount;
1378 EXEC SQL END DECLARE SECTION;
1379 struct filesys *f = filesys;
1383 if (!hash_lookup(machines, f->mach_id))
1385 printf("Filesys %s with bad machine %d\n", f->name, f->mach_id);
1386 if (single_fix("Fix", 0))
1388 EXEC SQL UPDATE filesys SET mach_id = 0 WHERE filsys_id = :iid;
1389 rowcount = sqlca.sqlerrd[2];
1391 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1393 printf("Not fixed\n");
1394 modified("filesys");
1399 if (!hash_lookup(users, f->owner))
1401 printf("Filesys %s with bad owning user %d\n", f->name, f->owner);
1402 if (single_fix("Fix", 1))
1404 zero_fix("filesys", "owner", "filsys_id", f->filsys_id);
1408 if (!hash_lookup(lists, f->owners))
1410 printf("Filesys %s with bad owning group %d\n", f->name, f->owners);
1411 if (single_fix("Fix", 1))
1413 zero_fix("filesys", "owners", "filsys_id", f->filsys_id);
1418 if (f->type == 'N' || f->type == 'I')
1420 if (!hash_lookup(nfsphys, f->phys_id))
1422 m = hash_lookup(machines, f->mach_id);
1423 printf("Filesys %s with bad phys_id %d\n", f->name, f->phys_id);
1424 if (single_fix("Fix", 1))
1427 hash_step(nfsphys, fsmatch, f);
1428 if (fnchecklen != 0)
1433 EXEC SQL UPDATE filesys SET phys_id = :id1
1434 WHERE filsys_id = :id2;
1435 rowcount = sqlca.sqlerrd[2];
1437 printf("%d entr%s fixed\n", rowcount,
1438 rowcount == 1 ? "y" : "ies");
1440 printf("Not fixed\n");
1441 modified("filesys");
1445 printf("No NFSphys exsits for %s:%s\n", m->name, f->dir);
1446 if (single_fix("Create", 0))
1452 if (set_next_object_id("nfsphys_id", "nfsphys") !=
1455 printf("Unable to assign unique ID\n");
1458 EXEC SQL SELECT COUNT(*) INTO :rowcount FROM numvalues
1459 WHERE name = 'nfsphys_id';
1462 printf("Unable to retrieve unique ID\n");
1465 EXEC SQL INSERT INTO nfsphys
1466 (nfsphys_id, mach_id, device, dir, status, allocated,
1467 size, modtime, modby, modwith) VALUES
1468 (:id1, :id3, '\?\?\?', :dir, 0, 0, 0, SYSDATE, 0,
1470 rowcount = sqlca.sqlerrd[2];
1473 printf("%d entr%s created\n", rowcount,
1474 rowcount == 1 ? "y" : "ies");
1477 printf("Not created\n");
1478 modified("nfsphys");
1479 n = malloc(sizeof(struct nfsphys));
1481 out_of_mem("storing new nfsphys");
1482 strcpy(n->dir, dir);
1484 n->nfsphys_id = id1;
1487 if (hash_store(nfsphys, id1, n) == -1)
1488 out_of_mem("storing nfsphys in hash table");
1489 EXEC SQL UPDATE filesys SET phys_id = :id1
1490 WHERE filsys_id = :id2;
1491 rowcount = sqlca.sqlerrd[2];
1494 printf("%d filesys entr%s fixed\n", rowcount,
1495 rowcount == 1 ? "y" : "ies");
1498 printf("Not fixed\n");
1499 modified("filesys");
1507 void check_nfsphys(int id, void *nfsphys, void *hint)
1509 struct nfsphys *n = nfsphys;
1511 n->modby = maybe_fixup_modby(n->modby, id, n->dir, "nfsphys",
1512 "modby", "nfsphys_id");
1514 if (!hash_lookup(machines, n->mach_id))
1516 printf("NFSphys %d(%s) on non-existant machine %d\n",
1517 id, n->dir, n->mach_id);
1518 if (single_fix("Delete", 0))
1519 single_delete("nfsphys", "nfsphys_id", id);
1523 static void clear_ps_owner(struct printserver *ps)
1525 EXEC SQL BEGIN DECLARE SECTION;
1526 int rowcount, id = ps->mach_id;
1527 EXEC SQL END DECLARE SECTION;
1529 EXEC SQL UPDATE printserver SET owner_type = 'NONE', owner_id = 0
1530 WHERE mach_id = :id;
1531 rowcount = sqlca.sqlerrd[2];
1533 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1535 printf("Not fixed\n");
1536 modified("printservers");
1539 static void clear_ps_lpc(struct printserver *ps)
1541 EXEC SQL BEGIN DECLARE SECTION;
1542 int rowcount, id = ps->mach_id;
1543 EXEC SQL END DECLARE SECTION;
1545 EXEC SQL UPDATE printserver SET lpc_acl = 0
1546 WHERE mach_id = :id;
1547 rowcount = sqlca.sqlerrd[2];
1549 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1551 printf("Not fixed\n");
1552 modified("printservers");
1555 void check_ps(int id, void *printserver, void *hint)
1557 struct printserver *ps = printserver;
1561 m = hash_lookup(machines, id);
1564 printf("Printserver on non-existant machine %d\n", id);
1565 if (single_fix("Delete", 0))
1567 single_delete("printservers", "mach_id", id);
1576 ps->modby = maybe_fixup_modby(ps->modby, id, name, "printservers",
1577 "modby", "mach_id");
1578 ps->printer_types = maybe_fixup_unref_string(ps->printer_types, id, name,
1579 "printservers", "printer_types",
1582 switch (ps->owner_type)
1585 if (!hash_lookup(users, ps->owner_id))
1587 printf("Printserver %s has non-existant USER owner %d\n",
1588 name, ps->owner_id);
1589 if (single_fix("Set to no owner", 1))
1594 if (!hash_lookup(lists, ps->owner_id))
1596 printf("Printserver %s has non-existant LIST owner %d\n",
1597 name, ps->owner_id);
1598 if (single_fix("Set to no owner", 1))
1604 ps->owner_id = maybe_fixup_unref_string(ps->owner_id, id, name,
1605 "printserver", "owner_id",
1607 if (ps->owner_id == 0)
1611 if (!hash_lookup(lists, ps->lpc_acl))
1613 printf("Printserver %s has non-existent lpc_acl %d\n",
1615 if (single_fix("Set to no lpc_acl", 1))
1620 static void clear_container_list(struct container *cnt)
1622 EXEC SQL BEGIN DECLARE SECTION;
1623 int rowcount, id = cnt->cnt_id;
1624 EXEC SQL END DECLARE SECTION;
1626 EXEC SQL UPDATE containers SET list_id = 0
1628 rowcount = sqlca.sqlerrd[2];
1630 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1632 printf("Not fixed\n");
1633 modified("containers");
1636 void fix_container_acl(int id)
1638 EXEC SQL BEGIN DECLARE SECTION;
1639 int rowcount, iid = (int)id;
1640 EXEC SQL END DECLARE SECTION;
1642 EXEC SQL UPDATE containers SET acl_id = 0, acl_type = 'NONE'
1643 WHERE cnt_id = :iid;
1644 rowcount = sqlca.sqlerrd[2];
1646 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1648 printf("Not fixed\n");
1649 modified("containers");
1652 void fix_container_memacl(int id)
1654 EXEC SQL BEGIN DECLARE SECTION;
1655 int rowcount, iid = (int)id;
1656 EXEC SQL END DECLARE SECTION;
1658 EXEC SQL UPDATE containers SET memacl_id = 0, memacl_type = 'NONE'
1659 WHERE cnt_id = :iid;
1660 rowcount = sqlca.sqlerrd[2];
1662 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1664 printf("Not fixed\n");
1665 modified("containers");
1668 void check_container(int id, void *container, void *hint)
1670 struct container *cnt = container;
1672 if (!hash_lookup(lists, cnt->list_id))
1674 printf("Container %s has non-existent associated list_id %d\n",
1675 cnt->name, cnt->list_id);
1676 if (single_fix("Set to no associated list", 1))
1677 clear_container_list(cnt);
1680 switch (cnt->acl_type)
1683 if (!hash_lookup(lists, cnt->acl_id))
1685 printf("Container %s has bad LIST acl %d\n", cnt->name, cnt->acl_id);
1686 if (single_fix("Patch", 1))
1687 fix_container_acl(cnt->cnt_id);
1691 if (!hash_lookup(users, cnt->acl_id))
1693 printf("Container %s has bad USER acl %d\n", cnt->name, cnt->acl_id);
1694 if (single_fix("Patch", 1))
1695 fix_container_acl(cnt->cnt_id);
1699 cnt->acl_id = maybe_fixup_unref_string(cnt->acl_id, id, cnt->name,
1700 "container", "acl_id", "cnt_id");
1703 printf("Container %s has bad KERBEROS acl %d\n", cnt->name,
1705 if (single_fix("Patch", 1))
1706 fix_container_acl(cnt->cnt_id);
1711 switch (cnt->memacl_type)
1714 if (!hash_lookup(lists, cnt->memacl_id))
1716 printf("Container %s has bad LIST memacl %d\n", cnt->name,
1718 if (single_fix("Patch", 1))
1719 fix_container_memacl(cnt->cnt_id);
1723 if (!hash_lookup(users, cnt->memacl_id))
1725 printf("Container %s has bad USER memacl %d\n", cnt->name,
1727 if (single_fix("Patch", 1))
1728 fix_container_memacl(cnt->cnt_id);
1732 cnt->memacl_id = maybe_fixup_unref_string(cnt->memacl_id, id, cnt->name,
1733 "container", "memacl_id",
1735 if (!cnt->memacl_id)
1737 printf("Container %s has bad KERBEROS memacl %d\n", cnt->name,
1739 if (single_fix("Patch", 1))
1740 fix_container_memacl(cnt->cnt_id);
1745 cnt->modby = maybe_fixup_modby(cnt->modby, id, cnt->name, "containers",
1749 int show_fsg_missing(void *id)
1751 EXEC SQL BEGIN DECLARE SECTION;
1752 int iid = (int)id, id1, found = 1;
1753 EXEC SQL END DECLARE SECTION;
1756 EXEC SQL DECLARE csr210 CURSOR FOR
1757 SELECT filsys_id FROM fsgroup
1758 WHERE group_id = :iid;
1759 EXEC SQL OPEN csr210;
1762 EXEC SQL FETCH csr210 INTO :id1;
1767 if ((f = hash_lookup(filesys, id1)))
1768 printf("Missing fsgroup %d has member filesystem %s\n", iid, f->name);
1770 printf("Missing fsgroup %d has member filesystem %d\n", iid, id1);
1772 EXEC SQL CLOSE csr210;
1776 int show_fsg_type(void *filesys)
1778 struct filesys *f = filesys;
1804 printf("FSGroup %s has type %s instead of FSGROUP\n", f->name, t);
1808 void fix_fsg_type(void *filesys)
1810 struct filesys *f = filesys;
1811 EXEC SQL BEGIN DECLARE SECTION;
1812 int rowcount, id = f->filsys_id;
1813 EXEC SQL END DECLARE SECTION;
1815 EXEC SQL UPDATE filesys SET type = 'FSGROUP' WHERE filsys_id = :id;
1816 rowcount = sqlca.sqlerrd[2];
1818 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1820 printf("Not fixed\n");
1821 modified("filesys");
1824 int show_fsg_nomember(void *id)
1826 EXEC SQL BEGIN DECLARE SECTION;
1827 int iid = (int)id, id1, found = 1;
1828 EXEC SQL END DECLARE SECTION;
1831 EXEC SQL DECLARE csr211 CURSOR FOR
1832 SELECT group_id FROM fsgroup
1833 WHERE filsys_id = :iid;
1834 EXEC SQL OPEN csr211;
1837 EXEC SQL FETCH csr211 INTO :id1;
1842 if ((f = hash_lookup(filesys, id1)))
1843 printf("FSGroup %s has missing member %d\n", f->name, iid);
1845 printf("FSGroup %d has missing member %d\n", id1, iid);
1847 EXEC SQL CLOSE csr211;
1851 int show_quota_nouser(void *id)
1853 EXEC SQL BEGIN DECLARE SECTION;
1854 int iid = (int)id, id1, found = 1;
1855 EXEC SQL END DECLARE SECTION;
1857 EXEC SQL DECLARE csr212 CURSOR FOR
1858 SELECT filsys_id FROM quota
1859 WHERE entity_id = :iid AND type = 'USER';
1860 EXEC SQL OPEN csr212;
1863 EXEC SQL FETCH csr212 INTO :id1;
1868 printf("Quota on fs %d for non-existant user %d\n", id1, iid);
1870 EXEC SQL CLOSE csr212;
1874 int show_quota_nolist(void *id)
1876 EXEC SQL BEGIN DECLARE SECTION;
1877 int iid = (int)id, id1, found = 1;
1878 EXEC SQL END DECLARE SECTION;
1880 EXEC SQL DECLARE csr213 CURSOR FOR
1881 SELECT filsys_id FROM quota
1882 WHERE entity_id = :iid AND type = 'GROUP';
1883 EXEC SQL OPEN csr213;
1886 EXEC SQL FETCH csr213 INTO :id1;
1891 printf("Quota on fs %d for non-existant list %d\n", id1, iid);
1893 EXEC SQL CLOSE csr213;
1897 void fix_quota_nouser(void *id)
1899 EXEC SQL BEGIN DECLARE SECTION;
1900 int iid = (int)id, rowcount;
1901 EXEC SQL END DECLARE SECTION;
1903 EXEC SQL DELETE FROM quota
1904 WHERE entity_id = :iid AND type = 'USER';
1905 rowcount = sqlca.sqlerrd[2];
1907 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1909 printf("Not deleted\n");
1913 void fix_quota_nolist(void *id)
1915 EXEC SQL BEGIN DECLARE SECTION;
1916 int iid = (int)id, rowcount;
1917 EXEC SQL END DECLARE SECTION;
1919 EXEC SQL DELETE FROM quota WHERE entity_id = :iid AND type = 'GROUP';
1920 rowcount = sqlca.sqlerrd[2];
1922 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1924 printf("Not deleted\n");
1928 int show_quota_nofs(void *id)
1930 EXEC SQL BEGIN DECLARE SECTION;
1931 int iid = (int)id, id1, found = 1;
1932 char type[QUOTA_TYPE_SIZE];
1933 EXEC SQL END DECLARE SECTION;
1935 EXEC SQL DECLARE csr214 CURSOR FOR
1936 SELECT entity_id, type FROM quota
1937 WHERE filsys_id = :iid;
1938 EXEC SQL OPEN csr214;
1941 EXEC SQL FETCH csr214 INTO :id1, :type;
1946 printf("Quota for %s %d on non-existant filesys %d\n", type, id1, iid);
1948 EXEC SQL CLOSE csr214;
1952 void fix_quota_nofs(void *id)
1954 single_delete("quota", "filsys_id", (int)id);
1957 int show_quota_wrongpid(void *id)
1959 EXEC SQL BEGIN DECLARE SECTION;
1960 int iid = (int)id, id1, found = 1;
1961 char type[QUOTA_TYPE_SIZE];
1962 EXEC SQL END DECLARE SECTION;
1965 f = hash_lookup(filesys, iid);
1966 EXEC SQL DECLARE csr215 CURSOR FOR
1967 SELECT entity_id, type FROM quota
1968 WHERE filsys_id = :iid;
1969 EXEC SQL OPEN csr215;
1972 EXEC SQL FETCH csr215 INTO :id1, :type;
1977 printf("Quota for %s %d on filesys %s has wrong phys_id %d\n",
1978 type, id1, f->name, iid);
1980 EXEC SQL CLOSE csr215;
1984 void fix_quota_physid(void *id)
1986 EXEC SQL BEGIN DECLARE SECTION;
1987 int iid = (int)id, rowcount, id1;
1988 EXEC SQL END DECLARE SECTION;
1990 id1 = ((struct filesys *)hash_lookup(filesys, iid))->phys_id;
1991 EXEC SQL UPDATE quota SET phys_id = :id1
1992 WHERE filsys_id = :iid AND phys_id != :id1;
1993 rowcount = sqlca.sqlerrd[2];
1995 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1997 printf("Not fixed\n");
2001 int show_srv_user(void *id)
2003 EXEC SQL BEGIN DECLARE SECTION;
2004 char name[SERVERS_NAME_SIZE];
2006 EXEC SQL END DECLARE SECTION;
2009 EXEC SQL DECLARE csr216 CURSOR FOR
2010 SELECT name FROM servers
2011 WHERE acl_type = 'USER' and acl_id = :iid;
2012 EXEC SQL OPEN csr216;
2015 EXEC SQL FETCH csr216 INTO :name;
2020 printf("Service %s has acl non-existant user %d\n", name, iid);
2023 EXEC SQL CLOSE csr216;
2027 int show_srv_list(void *id)
2029 EXEC SQL BEGIN DECLARE SECTION;
2030 char name[SERVERS_NAME_SIZE];
2032 EXEC SQL END DECLARE SECTION;
2035 EXEC SQL DECLARE csr217 CURSOR FOR
2036 SELECT name FROM servers
2037 WHERE acl_type = 'LIST' AND acl_id = :iid;
2038 EXEC SQL OPEN csr217;
2041 EXEC SQL FETCH csr217 INTO :name;
2046 printf("Service %s has acl non-existant list %d\n", name, iid);
2049 EXEC SQL CLOSE csr217;
2053 void zero_srv_user(void *id)
2055 EXEC SQL BEGIN DECLARE SECTION;
2056 int iid = (int)id, rowcount;
2057 EXEC SQL END DECLARE SECTION;
2059 EXEC SQL UPDATE servers SET acl_id = 0 WHERE acl_id = :iid AND
2061 rowcount = sqlca.sqlerrd[2];
2063 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
2065 printf("Not fixed\n");
2066 modified("servers");
2069 void zero_srv_list(void *id)
2071 EXEC SQL BEGIN DECLARE SECTION;
2072 int iid = (int)id, rowcount;
2073 EXEC SQL END DECLARE SECTION;
2075 EXEC SQL UPDATE servers SET acl_id = 0 WHERE acl_id = :iid AND
2077 rowcount = sqlca.sqlerrd[2];
2079 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
2081 printf("Not fixed\n");
2082 modified("servers");
2085 int show_krb_usr(void *id)
2087 EXEC SQL BEGIN DECLARE SECTION;
2088 int iid = (int)id, found = 1, id1;
2089 EXEC SQL END DECLARE SECTION;
2093 EXEC SQL DECLARE csr218 CURSOR FOR
2094 SELECT string_id FROM krbmap
2095 WHERE users_id = :iid;
2096 EXEC SQL OPEN csr218;
2099 EXEC SQL FETCH csr218 INTO :id1;
2103 if ((s = hash_lookup(strings, id1)))
2108 printf("Kerberos map for non-existant user %d to principal %s\n",
2111 EXEC SQL CLOSE csr218;
2115 int show_krb_str(void *id)
2117 EXEC SQL BEGIN DECLARE SECTION;
2118 int iid = (int)id, found = 1, id1;
2119 EXEC SQL END DECLARE SECTION;
2123 EXEC SQL DECLARE csr219 CURSOR FOR
2124 SELECT users_id FROM krbmap
2125 WHERE string_id = :iid;
2126 EXEC SQL OPEN csr219;
2129 EXEC SQL FETCH csr219 INTO :id1;
2133 if ((u = hash_lookup(users, id1)))
2138 printf("Kerberos map for user %s (%d) to non-existant string %d\n",
2141 EXEC SQL CLOSE csr219;
2147 struct save_queue *sq, *sq1, *sq2, *sq3, *sq4, *sq5, *sq6;
2154 printf("Phase 2 - Checking references\n");
2156 dprintf("Checking users...\n");
2157 hash_step(users, user_check, NULL);
2159 dprintf("Checking machines...\n");
2160 hash_step(machines, mach_check, NULL);
2162 dprintf("Checking subnets...\n");
2163 hash_step(subnets, subnet_check, NULL);
2165 dprintf("Checking clusters...\n");
2166 hash_step(clusters, cluster_check, NULL);
2168 dprintf("Checking mcmap...\n");
2171 EXEC SQL DECLARE csr221 CURSOR FOR
2172 SELECT mach_id, clu_id FROM mcmap;
2173 EXEC SQL OPEN csr221;
2176 EXEC SQL BEGIN DECLARE SECTION;
2177 int mach_id, clu_id;
2178 EXEC SQL END DECLARE SECTION;
2180 EXEC SQL FETCH csr221 INTO :mach_id, :clu_id;
2184 if (!(m = hash_lookup(machines, mach_id)))
2185 sq_save_unique_data(sq1, (void *)mach_id);
2186 else if (!hash_lookup(clusters, clu_id))
2187 sq_save_unique_data(sq2, (void *)clu_id);
2191 EXEC SQL CLOSE csr221;
2192 generic_delete(sq1, show_mcm_mach, "mcmap", "mach_id", 1);
2193 generic_delete(sq2, show_mcm_clu, "mcmap", "clu_id", 1);
2195 dprintf("Checking service clusters...\n");
2197 EXEC SQL DECLARE csr222 CURSOR FOR
2198 SELECT clu_id FROM svc;
2199 EXEC SQL OPEN csr222;
2202 EXEC SQL BEGIN DECLARE SECTION;
2204 EXEC SQL END DECLARE SECTION;
2206 EXEC SQL FETCH csr222 INTO :clu_id;
2210 if (!hash_lookup(clusters, clu_id))
2211 sq_save_unique_data(sq1, (void *)clu_id);
2213 EXEC SQL CLOSE csr222;
2214 generic_delete(sq1, show_svc, "svc", "clu_id", 1);
2216 dprintf("Checking lists...\n");
2217 hash_step(lists, list_check, NULL);
2219 dprintf("Checking members...\n");
2227 EXEC SQL DECLARE csr223 CURSOR FOR
2228 SELECT list_id, member_type, member_id, tag, ref_count, direct, rowid
2229 FROM imembers FOR UPDATE OF member_id;
2230 EXEC SQL OPEN csr223;
2233 EXEC SQL BEGIN DECLARE SECTION;
2234 int list_id, id, tag, ref_count, direct;
2235 char type[IMEMBERS_MEMBER_TYPE_SIZE];
2236 EXEC SQL END DECLARE SECTION;
2238 EXEC SQL FETCH csr223 INTO :list_id, :type, :id, :tag,
2239 :ref_count, :direct, :rowid;
2244 if (!(l = hash_lookup(lists, list_id)))
2245 sq_save_unique_data(sq1, (void *)list_id);
2246 else if (type[0] == 'U' && !hash_lookup(users, id))
2247 sq_save_unique_data(sq2, (void *)id);
2248 else if (type[0] == 'L' && !hash_lookup(lists, id))
2249 sq_save_unique_data(sq3, (void *)id);
2250 else if (type[0] == 'S' && !maybe_fixup_unref_string2("imembers", "member_id", rowid, id))
2251 sq_save_unique_data(sq4, (void *)id);
2252 else if (type[0] == 'K' && !maybe_fixup_unref_string2("imembers", "member_id", rowid, id))
2253 sq_save_unique_data(sq5, (void *)id);
2254 else if (type[0] == 'M' && !hash_lookup(machines, id))
2255 sq_save_unique_data(sq6, (void *)id);
2258 maybe_fixup_unref_string2("imembers", "tag", rowid, tag);
2260 EXEC SQL CLOSE csr223;
2261 generic_delete(sq1, show_member_list, "imembers", "list_id", 1);
2262 generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1);
2263 generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1);
2264 generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1);
2265 generic_fix(sq5, show_mem_krb, "Delete", del_mem_krb, 1);
2266 generic_fix(sq6, show_mem_mach, "Delete", del_mem_mach, 1);
2268 dprintf("Checking servers...\n");
2271 EXEC SQL DECLARE csr224 CURSOR FOR
2272 SELECT name, acl_type, acl_id, modby, rowid FROM servers
2273 FOR UPDATE of modby;
2274 EXEC SQL OPEN csr224;
2277 EXEC SQL BEGIN DECLARE SECTION;
2279 char name[SERVERS_NAME_SIZE], acl_type[SERVERS_ACL_TYPE_SIZE];
2280 EXEC SQL END DECLARE SECTION;
2282 EXEC SQL FETCH csr224 INTO :name, :acl_type, :acl_id, :modby, :rowid;
2286 maybe_fixup_modby2("servers", "modby", strtrim(rowid), modby);
2288 if (!strcmp(acl_type, "USER") && !hash_lookup(users, acl_id))
2289 sq_save_data(sq1, (void *)acl_id);
2290 else if (!strcmp(acl_type, "LIST") && !hash_lookup(lists, acl_id))
2291 sq_save_data(sq2, (void *)acl_id);
2293 EXEC SQL CLOSE csr224;
2294 generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
2295 generic_fix(sq2, show_srv_list, "Fix", zero_srv_list, 1);
2297 dprintf("Checking serverhosts...\n");
2299 EXEC SQL DECLARE csr225 CURSOR FOR
2300 SELECT mach_id, modby, rowid FROM serverhosts
2301 FOR UPDATE OF modby;
2302 EXEC SQL OPEN csr225;
2305 EXEC SQL BEGIN DECLARE SECTION;
2307 EXEC SQL END DECLARE SECTION;
2309 EXEC SQL FETCH csr225 INTO :mach_id, :modby, :rowid;
2313 maybe_fixup_modby2("serverhosts", "modby", strtrim(rowid), modby);
2314 if (!hash_lookup(machines, mach_id))
2315 sq_save_data(sq, (void *)mach_id);
2317 EXEC SQL CLOSE csr225;
2318 generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
2320 dprintf("Checking nfsphys...\n");
2321 hash_step(nfsphys, check_nfsphys, NULL);
2323 dprintf("Checking filesys...\n");
2324 hash_step(filesys, check_fs, NULL);
2326 dprintf("Checking filesystem groups...\n");
2330 EXEC SQL DECLARE csr226 CURSOR FOR
2331 SELECT group_id, filsys_id FROM fsgroup;
2332 EXEC SQL OPEN csr226;
2335 EXEC SQL BEGIN DECLARE SECTION;
2336 int group_id, filsys_id;
2337 EXEC SQL END DECLARE SECTION;
2339 EXEC SQL FETCH csr226 INTO :group_id, :filsys_id;
2343 if (!(f = hash_lookup(filesys, group_id)))
2344 sq_save_data(sq1, (void *)group_id);
2345 if (!hash_lookup(filesys, filsys_id))
2346 sq_save_data(sq3, (void *)filsys_id);
2348 EXEC SQL CLOSE csr226;
2349 generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0);
2350 generic_delete(sq3, show_fsg_nomember, "fsgroup", "filsys_id", 1);
2352 dprintf("Checking quotas...\n");
2357 EXEC SQL DECLARE csr227 CURSOR FOR
2358 SELECT entity_id, type, filsys_id, phys_id, quota, modby, rowid
2359 FROM quota FOR UPDATE OF modby;
2360 EXEC SQL OPEN csr227;
2363 EXEC SQL BEGIN DECLARE SECTION;
2364 int entity_id, filsys_id, phys_id, quota, modby;
2365 char type[QUOTA_TYPE_SIZE];
2366 EXEC SQL END DECLARE SECTION;
2368 EXEC SQL FETCH csr227 INTO :entity_id, :type, :filsys_id,
2369 :phys_id, :quota, :modby, :rowid;
2373 maybe_fixup_modby2("quota", "modby", strtrim(rowid), modby);
2374 if (type[0] == 'U' && entity_id != 0 && !hash_lookup(users, entity_id))
2375 sq_save_data(sq1, (void *)entity_id);
2376 else if (type[0] == 'G' && !hash_lookup(lists, entity_id))
2377 sq_save_data(sq4, (void *)entity_id);
2378 else if (!(f = hash_lookup(filesys, filsys_id)))
2379 sq_save_data(sq2, (void *)filsys_id);
2380 else if (phys_id != f->phys_id || !(n = hash_lookup(nfsphys, phys_id)))
2381 sq_save_data(sq3, (void *)phys_id);
2385 EXEC SQL CLOSE csr227;
2386 generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1);
2387 generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0);
2388 generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1);
2389 generic_fix(sq4, show_quota_nolist, "Delete", fix_quota_nolist, 1);
2391 dprintf("Checking zephyr...\n");
2392 EXEC SQL DECLARE csr_zc CURSOR FOR
2393 SELECT class, xmt_type, xmt_id, sub_type, sub_id, iws_type, iws_id,
2394 iui_type, iui_id, modby FROM zephyr;
2395 EXEC SQL OPEN csr_zc;
2398 EXEC SQL BEGIN DECLARE SECTION;
2399 int xmt_id, sub_id, iws_id, iui_id, modby;
2400 char class[ZEPHYR_CLASS_SIZE];
2401 char xmt_type[ZEPHYR_XMT_TYPE_SIZE];
2402 char sub_type[ZEPHYR_SUB_TYPE_SIZE];
2403 char iws_type[ZEPHYR_IWS_TYPE_SIZE];
2404 char iui_type[ZEPHYR_IUI_TYPE_SIZE];
2405 EXEC SQL END DECLARE SECTION;
2407 EXEC SQL FETCH csr_zc INTO :class, :xmt_type, :xmt_id, :sub_type,
2408 :sub_id, :iws_type, :iws_id, :iui_type, :iui_id, :modby;
2413 maybe_fixup_modby2("zephyr", "modby", strtrim(rowid), modby);
2416 if (!strcmp(xmt_type, "USER") && !hash_lookup(users, xmt_id))
2418 printf("xmt acl for %s is non-existant user %d\n", class, xmt_id);
2419 printf("Not fixing this error\n");
2421 else if (!strcmp(xmt_type, "LIST") && !hash_lookup(lists, xmt_id))
2423 printf("xmt acl for %s is non-existant list %d\n", class, xmt_id);
2424 printf("Not fixing this error\n");
2426 else if (!strcmp(xmt_type, "STRING") || !strcmp(xmt_type, "KERBEROS"))
2427 maybe_fixup_unref_string2("zephyr", "xmt_id", strtrim(rowid), xmt_id);
2430 if (!strcmp(sub_type, "USER") && !hash_lookup(users, sub_id))
2432 printf("sub acl for %s is non-existant user %d\n", class, sub_id);
2433 printf("Not fixing this error\n");
2435 else if (!strcmp(sub_type, "LIST") && !hash_lookup(lists, sub_id))
2437 printf("sub acl for %s is non-existant list %d\n", class, sub_id);
2438 printf("Not fixing this error\n");
2440 else if (!strcmp(sub_type, "STRING") || !strcmp(sub_type, "KERBEROS"))
2441 maybe_fixup_unref_string2("zephyr", "sub_id", strtrim(rowid), sub_id);
2444 if (!strcmp(iws_type, "USER") && !hash_lookup(users, iws_id))
2446 printf("iws acl for %s is non-existant user %d\n", class, iws_id);
2447 printf("Not fixing this error\n");
2449 else if (!strcmp(iws_type, "LIST") && !hash_lookup(lists, iws_id))
2451 printf("iws acl for %s is non-existant list %d\n", class, iws_id);
2452 printf("Not fixing this error\n");
2454 else if (!strcmp(iws_type, "STRING") || !strcmp(iws_type, "KERBEROS"))
2455 maybe_fixup_unref_string2("zephyr", "iws_id", strtrim(rowid), iws_id);
2458 if (!strcmp(iui_type, "USER") && !hash_lookup(users, iui_id))
2460 printf("iui acl for %s is non-existant user %d\n", class, iui_id);
2461 printf("Not fixing this error\n");
2463 else if (!strcmp(iui_type, "LIST") && !hash_lookup(lists, iui_id))
2465 printf("iui acl for %s is non-existant list %d\n", class, iui_id);
2466 printf("Not fixing this error\n");
2468 else if (!strcmp(iui_type, "STRING") || !strcmp(iui_type, "KERBEROS"))
2469 maybe_fixup_unref_string2("zephyr", "iui_id", strtrim(rowid), iui_id);
2472 dprintf("Checking hostaccess...\n");
2473 EXEC SQL DECLARE csr228 CURSOR FOR
2474 SELECT mach_id, acl_type, acl_id, modby, rowid FROM hostaccess
2475 FOR UPDATE OF modby;
2476 EXEC SQL OPEN csr228;
2479 EXEC SQL BEGIN DECLARE SECTION;
2480 int mach_id, acl_id, modby;
2481 char acl_type[HOSTACCESS_ACL_TYPE_SIZE];
2482 EXEC SQL END DECLARE SECTION;
2484 EXEC SQL FETCH csr228 INTO :mach_id, :acl_type, :acl_id, :modby, :rowid;
2488 maybe_fixup_modby2("hostaccess", "modby", strtrim(rowid), modby);
2490 if (!hash_lookup(machines, mach_id))
2492 printf("Hostaccess for non-existant host %d\n", mach_id);
2493 printf("Not fixing this error\n");
2495 if (!strcmp(acl_type, "USER") && !hash_lookup(users, acl_id))
2497 printf("Hostaccess for %d is non-existant user %d\n", mach_id, acl_id);
2498 printf("Not fixing this error\n");
2500 else if (!strcmp(acl_type, "LIST") && !hash_lookup(lists, acl_id))
2502 printf("Hostaccess for %d is non-existant list %d\n", mach_id, acl_id);
2503 printf("Not fixing this error\n");
2506 EXEC SQL CLOSE csr228;
2508 dprintf("Checking krbmap...\n");
2511 EXEC SQL DECLARE csr230 CURSOR FOR
2512 SELECT users_id, string_id, rowid FROM krbmap
2513 FOR UPDATE OF string_id;
2514 EXEC SQL OPEN csr230;
2517 EXEC SQL BEGIN DECLARE SECTION;
2518 int users_id, string_id;
2519 EXEC SQL END DECLARE SECTION;
2521 EXEC SQL FETCH csr230 INTO :users_id, :string_id, :rowid;
2525 if (!hash_lookup(users, users_id))
2526 sq_save_unique_data(sq1, (void *)users_id);
2527 else if (!maybe_fixup_unref_string2("krbmap", "string_id", strtrim(rowid), string_id))
2528 sq_save_unique_data(sq2, (void *)string_id);
2530 EXEC SQL CLOSE csr230;
2531 generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1);
2532 generic_delete(sq2, show_krb_str, "krbmap", "string_id", 1);
2534 dprintf("Checking capacls...\n");
2535 EXEC SQL DECLARE csr231 CURSOR FOR
2536 SELECT list_id, tag FROM capacls;
2537 EXEC SQL OPEN csr231;
2540 EXEC SQL BEGIN DECLARE SECTION;
2542 char tag[CAPACLS_TAG_SIZE];
2543 EXEC SQL END DECLARE SECTION;
2545 EXEC SQL FETCH csr231 INTO :list_id, :tag;
2549 if (!hash_lookup(lists, list_id))
2551 printf("Capacl for %s is non-existant list %d\n", tag, list_id);
2552 printf("Not fixing this error\n");
2555 EXEC SQL CLOSE csr231;
2557 dprintf("Checking hostaliases...\n");
2559 EXEC SQL DECLARE csr232 CURSOR FOR
2560 SELECT mach_id FROM hostalias;
2561 EXEC SQL OPEN csr232;
2564 EXEC SQL BEGIN DECLARE SECTION;
2566 EXEC SQL END DECLARE SECTION;
2568 EXEC SQL FETCH csr232 INTO :mach_id;
2572 if (!hash_lookup(machines, mach_id))
2573 sq_save_unique_data(sq1, (void *)mach_id);
2575 EXEC SQL CLOSE csr232;
2576 generic_delete(sq1, show_hostalias, "hostalias", "mach_id", 1);
2578 dprintf("Checking printers...\n");
2585 EXEC SQL DECLARE csr233 CURSOR FOR
2586 SELECT mach_id, loghost, rm, rq, ac, lpc_acl, modby, rowid FROM printers;
2587 EXEC SQL OPEN csr233;
2590 EXEC SQL BEGIN DECLARE SECTION;
2591 int mach_id, loghost, rm, rq, ac, lpc_acl, modby;
2592 EXEC SQL END DECLARE SECTION;
2594 EXEC SQL FETCH csr233 INTO :mach_id, :loghost, :rm, :rq, :ac,
2595 :lpc_acl, :modby, :rowid;
2599 maybe_fixup_modby2("printers", "modby", strtrim(rowid), modby);
2600 if (!hash_lookup(machines, mach_id))
2601 sq_save_unique_data(sq1, (void *)mach_id);
2602 else if (!hash_lookup(machines, rm))
2603 sq_save_unique_data(sq2, (void *)rm);
2604 else if (!hash_lookup(printservers, rm))
2605 sq_save_unique_data(sq6, (void *)mach_id);
2606 else if (!hash_lookup(machines, rq))
2607 sq_save_unique_data(sq3, (void *)rq);
2609 if (!hash_lookup(lists, ac))
2610 sq_save_unique_data(sq4, (void *)ac);
2611 if (!hash_lookup(lists, lpc_acl))
2612 sq_save_unique_data(sq5, (void *)lpc_acl);
2613 if (!hash_lookup(machines, loghost))
2615 show_printer_loghost((void *)loghost);
2620 EXEC SQL CLOSE csr233;
2621 generic_delete(sq1, show_printer_mach, "printers", "mach_id", 1);
2622 generic_delete(sq6, show_printer_server, "printers", "mach_id", 1);
2623 generic_delete(sq2, show_printer_spool, "printers", "rm", 1);
2624 generic_delete(sq3, show_printer_quota, "printers", "rq", 1);
2625 generic_fix(sq4, show_printer_ac, "Clear", fix_printer_ac, 1);
2626 generic_fix(sq5, show_printer_lpc_acl, "Clear", fix_printer_lpc_acl, 1);
2628 dprintf("Checking printservers...\n");
2629 hash_step(printservers, check_ps, NULL);
2631 dprintf("Checking containers...\n");
2632 hash_step(containers, check_container, NULL);
2634 dprintf("Checking mcntmap...\n");
2637 EXEC SQL DECLARE csr_mcntmap CURSOR FOR
2638 SELECT mach_id, cnt_id FROM mcntmap;
2639 EXEC SQL OPEN csr_mcntmap;
2642 EXEC SQL BEGIN DECLARE SECTION;
2643 int mach_id, cnt_id;
2644 EXEC SQL END DECLARE SECTION;
2646 EXEC SQL FETCH csr_mcntmap INTO :mach_id, :cnt_id;
2650 if (!(m = hash_lookup(machines, mach_id)))
2651 sq_save_unique_data(sq1, (void *)mach_id);
2652 else if (!hash_lookup(containers, cnt_id))
2653 sq_save_unique_data(sq2, (void *)cnt_id);
2655 EXEC SQL CLOSE csr_mcntmap;
2656 generic_delete(sq1, show_mcntmap_mach, "mcntmap", "mach_id", 1);
2657 generic_delete(sq2, show_mcntmap_cnt, "mcntmap", "cnt_id", 1);