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(machines, u->pobox_id))
673 printf("User %s(%s) has P.O.Box on non-existant machine %d\n",
674 u->login, u->fullname, u->pobox_id);
675 if (single_fix("Delete", 0))
677 remove_pobox(u->users_id);
684 if (hash_lookup(string_dups, u->pobox_id))
686 printf("User %s(%s) has P.O.Box with duplicate string %d\n",
687 u->login, u->fullname, u->pobox_id);
688 if (single_fix("Update", 0))
690 printf("Replacing box_id dup string ID %d with %d\n",
692 (int)hash_lookup(string_dups, u->pobox_id));
693 u->pobox_id = (int)hash_lookup(string_dups, u->pobox_id);
694 fix_smtp_pobox(u->users_id, u->pobox_id);
695 string_check(u->pobox_id);
698 else if (!string_check(u->pobox_id))
700 printf("User %s(%s) has P.O.Box with non-existant string %d\n",
701 u->login, u->fullname, u->pobox_id);
702 if (single_fix("Delete", 0))
704 remove_pobox(u->users_id);
711 fs = hash_lookup(filesys, u->pobox_id);
714 printf("User %s(%s) has P.O.Box on non-existant filesystem %d\n",
715 u->login, u->fullname, u->pobox_id);
716 if (single_fix("Delete", 0))
718 remove_pobox(u->users_id);
722 else if (fs->type != 'I')
724 printf("User %s(%s) has IMAP P.O.Box on non-IMAP filesystem %s\n",
725 u->login, u->fullname, fs->name);
726 if (single_fix("Delete", 0))
728 remove_pobox(u->users_id);
740 void remove_pobox(int id)
742 EXEC SQL BEGIN DECLARE SECTION;
743 int rowcount, iid = (int)id;
744 EXEC SQL END DECLARE SECTION;
746 EXEC SQL UPDATE users SET potype = 'NONE' WHERE users.users_id = :iid;
747 rowcount = sqlca.sqlerrd[2];
749 printf("%d entr%s removed\n", rowcount, rowcount == 1 ? "y" : "ies");
751 printf("Not removed\n");
755 void fix_smtp_pobox(int id, int sid)
757 EXEC SQL BEGIN DECLARE SECTION;
758 int rowcount, iid = id, isid = sid;
759 EXEC SQL END DECLARE SECTION;
761 EXEC SQL UPDATE users SET box_id = :isid WHERE users.users_id = :iid;
762 rowcount = sqlca.sqlerrd[2];
764 printf("%d entr%s updated\n", rowcount, rowcount == 1 ? "y" : "ies");
766 printf("Not updated\n");
770 void mach_check(int id, void *machine, void *hint)
772 struct machine *m = machine;
774 if (!hash_lookup(subnets, m->snet_id))
776 printf("Machine %s is on a non-existant subnet %d\n",
777 m->name, m->snet_id);
778 if (single_fix("Move to null-subnet", 1))
780 EXEC SQL BEGIN DECLARE SECTION;
781 int rowcount, iid = id;
782 EXEC SQL END DECLARE SECTION;
784 EXEC SQL UPDATE machine SET snet_id = 0 WHERE mach_id = :iid;
785 rowcount = sqlca.sqlerrd[2];
787 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
789 printf("Not fixed\n");
794 switch (m->owner_type)
797 if (!hash_lookup(users, m->owner_id))
799 printf("Machine %s has non-existant USER owner %d\n",
800 m->name, m->owner_id);
801 if (single_fix("Set to no owner", 1))
806 if (!hash_lookup(lists, m->owner_id))
808 printf("Machine %s has non-existant LIST owner %d\n",
809 m->name, m->owner_id);
810 if (single_fix("Set to no owner", 1))
817 m->owner_id = maybe_fixup_unref_string(m->owner_id, id, m->name,
818 "machine", "owner_id",
820 if (m->owner_id == 0)
825 m->acomment = maybe_fixup_unref_string(m->acomment, id, m->name,
826 "machine", "acomment", "mach_id");
828 m->ocomment = maybe_fixup_unref_string(m->ocomment, id, m->name,
829 "machine", "ocomment", "mach_id");
831 m->creator = maybe_fixup_modby(m->creator, id, m->name, "machine",
832 "creator", "mach_id");
833 m->modby = maybe_fixup_modby(m->modby, id, m->name, "machine",
837 void subnet_check(int id, void *subnet, void *hint)
839 struct subnet *s = subnet;
841 switch (s->owner_type)
844 if (!hash_lookup(users, s->owner_id))
846 printf("Subnet %s has non-existant USER owner %d\n",
847 s->name, s->owner_id);
848 if (single_fix("Set to no owner", 1))
849 clear_subnet_owner(s);
853 if (!hash_lookup(lists, s->owner_id))
855 printf("Machine %s has non-existant LIST owner %d\n",
856 s->name, s->owner_id);
857 if (single_fix("Set to no owner", 1))
858 clear_subnet_owner(s);
864 s->owner_id = maybe_fixup_unref_string(s->owner_id, id, s->name,
865 "machine", "owner_id",
867 if (s->owner_id == 0)
868 clear_subnet_owner(s);
871 s->modby = maybe_fixup_modby(s->modby, id, s->name, "subnet",
875 void clear_user_sponsor(struct user *u)
877 EXEC SQL BEGIN DECLARE SECTION;
878 int rowcount, id = u->users_id;
879 EXEC SQL END DECLARE SECTION;
881 EXEC SQL UPDATE users SET sponsor_type = 'NONE', sponsor_id = 0
882 WHERE users_id = :id;
883 rowcount = sqlca.sqlerrd[2];
885 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
887 printf("Not fixed\n");
891 void clear_subnet_owner(struct subnet *s)
893 EXEC SQL BEGIN DECLARE SECTION;
894 int rowcount, id = s->snet_id;
895 EXEC SQL END DECLARE SECTION;
897 EXEC SQL UPDATE subnet SET owner_type = 'NONE', owner_id = 0
899 rowcount = sqlca.sqlerrd[2];
901 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
903 printf("Not fixed\n");
907 void clear_mach_owner(struct machine *m)
909 EXEC SQL BEGIN DECLARE SECTION;
910 int rowcount, id = m->mach_id;
911 EXEC SQL END DECLARE SECTION;
913 EXEC SQL UPDATE machine SET owner_type = 'NONE', owner_id = 0
915 rowcount = sqlca.sqlerrd[2];
917 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
919 printf("Not fixed\n");
923 void cluster_check(int id, void *cluster, void *hint)
925 struct cluster *c = cluster;
927 c->modby = maybe_fixup_modby(c->modby, id, c->name, "clusters",
931 int show_svc(void *id)
933 EXEC SQL BEGIN DECLARE SECTION;
934 int iid = (int)id, found = 1;
935 char label[SVC_SERV_LABEL_SIZE], data[SVC_SERV_CLUSTER_SIZE];
936 EXEC SQL END DECLARE SECTION;
938 EXEC SQL DECLARE csr203 CURSOR FOR
939 SELECT serv_label, serv_cluster FROM svc
941 EXEC SQL OPEN csr203;
944 EXEC SQL FETCH csr203 INTO :label, :data;
951 printf("Cluster data [%s] %s for non-existant cluster %d\n",
954 EXEC SQL CLOSE csr203;
958 void list_check(int id, void *list, void *hint)
960 struct list *l = list;
962 l->modby = maybe_fixup_modby(l->modby, id, l->name, "list",
968 if (!hash_lookup(lists, l->acl_id))
970 printf("List %s has bad LIST acl %d\n", l->name, l->acl_id);
971 if (single_fix("Patch", 1))
972 fix_list_acl(l->list_id);
976 if (!hash_lookup(users, l->acl_id))
978 printf("List %s has bad USER acl %d\n", l->name, l->acl_id);
979 if (single_fix("Patch", 1))
980 fix_list_acl(l->list_id);
984 l->acl_id = maybe_fixup_unref_string(l->acl_id, id, l->name,
985 "list", "acl_id", "list_id");
988 printf("List %s has bad KERBEROS acl %d\n", l->name, l->acl_id);
989 if (single_fix("Patch", 1))
990 fix_list_acl(l->list_id);
995 switch (l->memacl_type)
998 if (!hash_lookup(lists, l->memacl_id))
1000 printf("List %s has bad LIST memacl %d\n", l->name, l->memacl_id);
1001 if (single_fix("Patch", 1))
1002 fix_list_memacl(l->list_id);
1006 if (!hash_lookup(users, l->memacl_id))
1008 printf("List %s has bad USER acl %d\n", l->name, l->memacl_id);
1009 if (single_fix("Patch", 1))
1010 fix_list_memacl(l->list_id);
1014 l->memacl_id = maybe_fixup_unref_string(l->memacl_id, id, l->name,
1015 "list", "memacl_id", "list_id");
1018 printf("List %s has bad KERBEROS acl %d\n", l->name,
1020 if (single_fix("Patch", 1))
1021 fix_list_memacl(l->list_id);
1027 void fix_list_acl(int id)
1029 EXEC SQL BEGIN DECLARE SECTION;
1030 int rowcount, iid = (int)id;
1031 EXEC SQL END DECLARE SECTION;
1033 EXEC SQL UPDATE list SET acl_id = :iid, acl_type = 'LIST'
1034 WHERE list_id = :iid;
1035 rowcount = sqlca.sqlerrd[2];
1037 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1039 printf("Not fixed\n");
1043 void fix_list_memacl(int id)
1045 EXEC SQL BEGIN DECLARE SECTION;
1046 int rowcount, iid = (int)id;
1047 EXEC SQL END DECLARE SECTION;
1049 EXEC SQL UPDATE list SET memacl_id = 0, memacl_type = 'NONE'
1050 WHERE list_id = :iid;
1051 rowcount = sqlca.sqlerrd[2];
1053 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1055 printf("Not fixed\n");
1059 int show_member_list(void *id)
1061 EXEC SQL BEGIN DECLARE SECTION;
1062 int mid, iid = (int)id, found = 1;
1063 char mtype[IMEMBERS_MEMBER_TYPE_SIZE], *name = NULL;
1064 EXEC SQL END DECLARE SECTION;
1066 EXEC SQL DECLARE csr204 CURSOR FOR
1067 SELECT member_type, member_id FROM imembers
1068 WHERE list_id = :iid;
1069 EXEC SQL OPEN csr204;
1072 EXEC SQL FETCH csr204 INTO :mtype, :mid;
1078 if (mtype[0] == 'L')
1080 struct list *l = hash_lookup(lists, mid);
1084 else if (mtype[0] == 'U')
1086 struct user *u = hash_lookup(users, mid);
1090 else if (mtype[0] == 'S' || mtype[0] == 'K')
1092 struct string *s = hash_lookup(strings, mid);
1097 printf("Non-existant list %d has member %s %s\n", iid, mtype, name);
1100 printf("Non-existant list %d has non-existent member %s %d\n",
1104 EXEC SQL CLOSE csr204;
1108 int show_mem_user(void *id)
1110 EXEC SQL BEGIN DECLARE SECTION;
1111 int lid, iid = (int)id, found = 1;
1112 EXEC SQL END DECLARE SECTION;
1115 EXEC SQL DECLARE csr205 CURSOR FOR
1116 SELECT list_id FROM imembers
1117 WHERE member_id = :iid AND member_type = 'USER';
1118 EXEC SQL OPEN csr205;
1121 EXEC SQL FETCH csr205 INTO :lid;
1124 l = hash_lookup(lists, lid);
1129 printf("List %s has non-existant user member, id %d\n", l->name, iid);
1131 EXEC SQL CLOSE csr205;
1135 int show_mem_list(void *id)
1137 EXEC SQL BEGIN DECLARE SECTION;
1138 int lid, iid = (int)id, found = 1;
1139 EXEC SQL END DECLARE SECTION;
1142 EXEC SQL DECLARE csr206 CURSOR FOR
1143 SELECT list_id FROM imembers
1144 WHERE member_id = :iid AND member_type = 'LIST';
1145 EXEC SQL OPEN csr206;
1148 EXEC SQL FETCH csr206 INTO :lid;
1151 l = hash_lookup(lists, lid);
1156 printf("List %s has non-existant list member, id %d\n", l->name, iid);
1158 EXEC SQL CLOSE csr206;
1162 int show_mem_str(void *id)
1164 EXEC SQL BEGIN DECLARE SECTION;
1165 int lid, iid = (int)id, found = 1;
1166 EXEC SQL END DECLARE SECTION;
1169 EXEC SQL DECLARE csr207 CURSOR FOR
1170 SELECT list_id FROM imembers
1171 WHERE member_id = :iid AND member_type = 'STRING';
1172 EXEC SQL OPEN csr207;
1175 EXEC SQL FETCH csr207 INTO :lid;
1178 l = hash_lookup(lists, lid);
1183 printf("List %s has non-existant string member, id %d\n", l->name, iid);
1185 EXEC SQL CLOSE csr207;
1190 int show_mem_krb(void *id)
1192 EXEC SQL BEGIN DECLARE SECTION;
1193 int lid, iid = (int)id, found = 1;
1194 EXEC SQL END DECLARE SECTION;
1197 EXEC SQL DECLARE csr208 CURSOR FOR
1198 SELECT list_id FROM imembers
1199 WHERE member_id = :iid AND member_type = 'KERBEROS';
1200 EXEC SQL OPEN csr208;
1203 EXEC SQL FETCH csr208 INTO :lid;
1206 l = hash_lookup(lists, lid);
1211 printf("List %s has non-existant kerberos member, id %d\n",
1214 EXEC SQL CLOSE csr208;
1218 int show_mem_mach(void *id)
1220 EXEC SQL BEGIN DECLARE SECTION;
1221 int lid, iid = (int)id, found = 1;
1222 EXEC SQL END DECLARE SECTION;
1225 EXEC SQL DECLARE csr208a CURSOR FOR
1226 SELECT list_id FROM imembers
1227 WHERE member_id = :iid AND member_type = 'MACHINE';
1228 EXEC SQL OPEN csr208a;
1231 EXEC SQL FETCH csr208a INTO :lid;
1234 l = hash_lookup(lists, lid);
1239 printf("List %s has nonexistant machine member, id %d\n",
1242 EXEC SQL CLOSE csr208a;
1246 void del_mem_user(void *id)
1248 EXEC SQL BEGIN DECLARE SECTION;
1249 int iid = (int)id, rowcount;
1250 EXEC SQL END DECLARE SECTION;
1252 EXEC SQL DELETE FROM imembers WHERE member_type = 'USER' AND
1254 rowcount = sqlca.sqlerrd[2];
1256 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1258 printf("Not deleted\n");
1259 modified("imembers");
1262 void del_mem_list(void *id)
1264 EXEC SQL BEGIN DECLARE SECTION;
1265 int iid = (int)id, rowcount;
1266 EXEC SQL END DECLARE SECTION;
1268 EXEC SQL DELETE FROM imembers WHERE member_type = 'LIST' AND
1270 rowcount = sqlca.sqlerrd[2];
1272 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1274 printf("Not deleted\n");
1275 modified("imembers");
1278 void del_mem_str(void *id)
1280 EXEC SQL BEGIN DECLARE SECTION;
1281 int iid = (int)id, rowcount;
1282 EXEC SQL END DECLARE SECTION;
1284 EXEC SQL DELETE FROM imembers WHERE member_type = 'STRING' AND
1286 rowcount = sqlca.sqlerrd[2];
1288 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1290 printf("Not deleted\n");
1291 modified("imembers");
1295 void del_mem_krb(void *id)
1297 EXEC SQL BEGIN DECLARE SECTION;
1298 int iid = (int)id, rowcount;
1299 EXEC SQL END DECLARE SECTION;
1301 EXEC SQL DELETE FROM imembers WHERE member_type = 'KERBEROS' AND
1303 rowcount = sqlca.sqlerrd[2];
1305 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1307 printf("Not deleted\n");
1308 modified("imembers");
1311 void del_mem_mach(void *id)
1313 EXEC SQL BEGIN DECLARE SECTION;
1314 int iid = (int)id, rowcount;
1315 EXEC SQL END DECLARE SECTION;
1317 EXEC SQL DELETE FROM imembers WHERE member_type = 'MACHINE' AND
1319 rowcount = sqlca.sqlerrd[2];
1321 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1323 printf("Not deleted\n");
1324 modified("imembers");
1327 int show_sh(void *id)
1329 EXEC SQL BEGIN DECLARE SECTION;
1330 char name[SERVERHOSTS_SERVICE_SIZE];
1332 EXEC SQL END DECLARE SECTION;
1335 EXEC SQL DECLARE csr209 CURSOR FOR
1336 SELECT service FROM serverhosts
1337 WHERE mach_id = :iid;
1338 EXEC SQL OPEN csr209;
1341 EXEC SQL FETCH csr209 INTO :name;
1346 printf("ServerHost entry for service %s non-existant host %d\n",
1349 EXEC SQL CLOSE csr209;
1353 void del_sh_mach(void *id)
1355 EXEC SQL BEGIN DECLARE SECTION;
1356 int iid = (int)id, rowcount;
1357 EXEC SQL END DECLARE SECTION;
1359 EXEC SQL DELETE FROM serverhosts WHERE mach_id = :iid;
1360 rowcount = sqlca.sqlerrd[2];
1362 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1364 printf("Not deleted\n");
1365 modified("serverhosts");
1369 static int fnchecklen;
1371 void fsmatch(int id, void *nfsphys, void *filesys)
1373 struct nfsphys *n = nfsphys;
1374 struct filesys *f = filesys;
1376 if (n->mach_id == f->mach_id &&
1377 !strncmp(f->dir, n->dir, strlen(n->dir)) &&
1378 strlen(n->dir) > fnchecklen)
1381 fnchecklen = strlen(n->dir);
1386 void check_fs(int id, void *filesys, void *hint)
1388 EXEC SQL BEGIN DECLARE SECTION;
1389 int iid = id, id1, id2, id3, rowcount;
1391 EXEC SQL END DECLARE SECTION;
1392 struct filesys *f = filesys;
1396 if (!hash_lookup(machines, f->mach_id))
1398 printf("Filesys %s with bad machine %d\n", f->name, f->mach_id);
1399 if (single_fix("Fix", 0))
1401 EXEC SQL UPDATE filesys SET mach_id = 0 WHERE filsys_id = :iid;
1402 rowcount = sqlca.sqlerrd[2];
1404 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1406 printf("Not fixed\n");
1407 modified("filesys");
1412 if (!hash_lookup(users, f->owner))
1414 printf("Filesys %s with bad owning user %d\n", f->name, f->owner);
1415 if (single_fix("Fix", 1))
1417 zero_fix("filesys", "owner", "filsys_id", f->filsys_id);
1421 if (!hash_lookup(lists, f->owners))
1423 printf("Filesys %s with bad owning group %d\n", f->name, f->owners);
1424 if (single_fix("Fix", 1))
1426 zero_fix("filesys", "owners", "filsys_id", f->filsys_id);
1431 if (f->type == 'N' || f->type == 'I')
1433 if (!hash_lookup(nfsphys, f->phys_id))
1435 m = hash_lookup(machines, f->mach_id);
1436 printf("Filesys %s with bad phys_id %d\n", f->name, f->phys_id);
1437 if (single_fix("Fix", 1))
1440 hash_step(nfsphys, fsmatch, f);
1441 if (fnchecklen != 0)
1446 EXEC SQL UPDATE filesys SET phys_id = :id1
1447 WHERE filsys_id = :id2;
1448 rowcount = sqlca.sqlerrd[2];
1450 printf("%d entr%s fixed\n", rowcount,
1451 rowcount == 1 ? "y" : "ies");
1453 printf("Not fixed\n");
1454 modified("filesys");
1458 printf("No NFSphys exsits for %s:%s\n", m->name, f->dir);
1459 if (single_fix("Create", 0))
1465 if (set_next_object_id("nfsphys_id", "nfsphys") !=
1468 printf("Unable to assign unique ID\n");
1471 EXEC SQL SELECT COUNT(*) INTO :rowcount FROM numvalues
1472 WHERE name = 'nfsphys_id';
1475 printf("Unable to retrieve unique ID\n");
1478 EXEC SQL INSERT INTO nfsphys
1479 (nfsphys_id, mach_id, device, dir, status, allocated,
1480 size, modtime, modby, modwith) VALUES
1481 (:id1, :id3, '\?\?\?', :dir, 0, 0, 0, SYSDATE, 0,
1483 rowcount = sqlca.sqlerrd[2];
1486 printf("%d entr%s created\n", rowcount,
1487 rowcount == 1 ? "y" : "ies");
1490 printf("Not created\n");
1491 modified("nfsphys");
1492 n = malloc(sizeof(struct nfsphys));
1494 out_of_mem("storing new nfsphys");
1495 strcpy(n->dir, dir);
1497 n->nfsphys_id = id1;
1500 if (hash_store(nfsphys, id1, n) == -1)
1501 out_of_mem("storing nfsphys in hash table");
1502 EXEC SQL UPDATE filesys SET phys_id = :id1
1503 WHERE filsys_id = :id2;
1504 rowcount = sqlca.sqlerrd[2];
1507 printf("%d filesys entr%s fixed\n", rowcount,
1508 rowcount == 1 ? "y" : "ies");
1511 printf("Not fixed\n");
1512 modified("filesys");
1520 void check_nfsphys(int id, void *nfsphys, void *hint)
1522 struct nfsphys *n = nfsphys;
1524 n->modby = maybe_fixup_modby(n->modby, id, n->dir, "nfsphys",
1525 "modby", "nfsphys_id");
1527 if (!hash_lookup(machines, n->mach_id))
1529 printf("NFSphys %d(%s) on non-existant machine %d\n",
1530 id, n->dir, n->mach_id);
1531 if (single_fix("Delete", 0))
1532 single_delete("nfsphys", "nfsphys_id", id);
1536 static void clear_ps_owner(struct printserver *ps)
1538 EXEC SQL BEGIN DECLARE SECTION;
1539 int rowcount, id = ps->mach_id;
1540 EXEC SQL END DECLARE SECTION;
1542 EXEC SQL UPDATE printserver SET owner_type = 'NONE', owner_id = 0
1543 WHERE mach_id = :id;
1544 rowcount = sqlca.sqlerrd[2];
1546 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1548 printf("Not fixed\n");
1549 modified("printservers");
1552 static void clear_ps_lpc(struct printserver *ps)
1554 EXEC SQL BEGIN DECLARE SECTION;
1555 int rowcount, id = ps->mach_id;
1556 EXEC SQL END DECLARE SECTION;
1558 EXEC SQL UPDATE printserver SET lpc_acl = 0
1559 WHERE mach_id = :id;
1560 rowcount = sqlca.sqlerrd[2];
1562 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1564 printf("Not fixed\n");
1565 modified("printservers");
1568 void check_ps(int id, void *printserver, void *hint)
1570 struct printserver *ps = printserver;
1574 m = hash_lookup(machines, id);
1577 printf("Printserver on non-existant machine %d\n", id);
1578 if (single_fix("Delete", 0))
1580 single_delete("printservers", "mach_id", id);
1589 ps->modby = maybe_fixup_modby(ps->modby, id, name, "printservers",
1590 "modby", "mach_id");
1591 ps->printer_types = maybe_fixup_unref_string(ps->printer_types, id, name,
1592 "printservers", "printer_types",
1595 switch (ps->owner_type)
1598 if (!hash_lookup(users, ps->owner_id))
1600 printf("Printserver %s has non-existant USER owner %d\n",
1601 name, ps->owner_id);
1602 if (single_fix("Set to no owner", 1))
1607 if (!hash_lookup(lists, ps->owner_id))
1609 printf("Printserver %s has non-existant LIST owner %d\n",
1610 name, ps->owner_id);
1611 if (single_fix("Set to no owner", 1))
1617 ps->owner_id = maybe_fixup_unref_string(ps->owner_id, id, name,
1618 "printserver", "owner_id",
1620 if (ps->owner_id == 0)
1624 if (!hash_lookup(lists, ps->lpc_acl))
1626 printf("Printserver %s has non-existent lpc_acl %d\n",
1628 if (single_fix("Set to no lpc_acl", 1))
1633 static void clear_container_list(struct container *cnt)
1635 EXEC SQL BEGIN DECLARE SECTION;
1636 int rowcount, id = cnt->cnt_id;
1637 EXEC SQL END DECLARE SECTION;
1639 EXEC SQL UPDATE containers SET list_id = 0
1641 rowcount = sqlca.sqlerrd[2];
1643 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1645 printf("Not fixed\n");
1646 modified("containers");
1649 void fix_container_acl(int id)
1651 EXEC SQL BEGIN DECLARE SECTION;
1652 int rowcount, iid = (int)id;
1653 EXEC SQL END DECLARE SECTION;
1655 EXEC SQL UPDATE containers SET acl_id = 0, acl_type = 'NONE'
1656 WHERE cnt_id = :iid;
1657 rowcount = sqlca.sqlerrd[2];
1659 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1661 printf("Not fixed\n");
1662 modified("containers");
1665 void fix_container_memacl(int id)
1667 EXEC SQL BEGIN DECLARE SECTION;
1668 int rowcount, iid = (int)id;
1669 EXEC SQL END DECLARE SECTION;
1671 EXEC SQL UPDATE containers SET memacl_id = 0, memacl_type = 'NONE'
1672 WHERE cnt_id = :iid;
1673 rowcount = sqlca.sqlerrd[2];
1675 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1677 printf("Not fixed\n");
1678 modified("containers");
1681 void check_container(int id, void *container, void *hint)
1683 struct container *cnt = container;
1685 if (!hash_lookup(lists, cnt->list_id))
1687 printf("Container %s has non-existent associated list_id %d\n",
1688 cnt->name, cnt->list_id);
1689 if (single_fix("Set to no associated list", 1))
1690 clear_container_list(cnt);
1693 switch (cnt->acl_type)
1696 if (!hash_lookup(lists, cnt->acl_id))
1698 printf("Container %s has bad LIST acl %d\n", cnt->name, cnt->acl_id);
1699 if (single_fix("Patch", 1))
1700 fix_container_acl(cnt->cnt_id);
1704 if (!hash_lookup(users, cnt->acl_id))
1706 printf("Container %s has bad USER acl %d\n", cnt->name, cnt->acl_id);
1707 if (single_fix("Patch", 1))
1708 fix_container_acl(cnt->cnt_id);
1712 cnt->acl_id = maybe_fixup_unref_string(cnt->acl_id, id, cnt->name,
1713 "container", "acl_id", "cnt_id");
1716 printf("Container %s has bad KERBEROS acl %d\n", cnt->name,
1718 if (single_fix("Patch", 1))
1719 fix_container_acl(cnt->cnt_id);
1724 switch (cnt->memacl_type)
1727 if (!hash_lookup(lists, cnt->memacl_id))
1729 printf("Container %s has bad LIST memacl %d\n", cnt->name,
1731 if (single_fix("Patch", 1))
1732 fix_container_memacl(cnt->cnt_id);
1736 if (!hash_lookup(users, cnt->memacl_id))
1738 printf("Container %s has bad USER memacl %d\n", cnt->name,
1740 if (single_fix("Patch", 1))
1741 fix_container_memacl(cnt->cnt_id);
1745 cnt->memacl_id = maybe_fixup_unref_string(cnt->memacl_id, id, cnt->name,
1746 "container", "memacl_id",
1748 if (!cnt->memacl_id)
1750 printf("Container %s has bad KERBEROS memacl %d\n", cnt->name,
1752 if (single_fix("Patch", 1))
1753 fix_container_memacl(cnt->cnt_id);
1758 cnt->modby = maybe_fixup_modby(cnt->modby, id, cnt->name, "containers",
1762 int show_fsg_missing(void *id)
1764 EXEC SQL BEGIN DECLARE SECTION;
1765 int iid = (int)id, id1, found = 1;
1766 EXEC SQL END DECLARE SECTION;
1769 EXEC SQL DECLARE csr210 CURSOR FOR
1770 SELECT filsys_id FROM fsgroup
1771 WHERE group_id = :iid;
1772 EXEC SQL OPEN csr210;
1775 EXEC SQL FETCH csr210 INTO :id1;
1780 if ((f = hash_lookup(filesys, id1)))
1781 printf("Missing fsgroup %d has member filesystem %s\n", iid, f->name);
1783 printf("Missing fsgroup %d has member filesystem %d\n", iid, id1);
1785 EXEC SQL CLOSE csr210;
1789 int show_fsg_type(void *filesys)
1791 struct filesys *f = filesys;
1817 printf("FSGroup %s has type %s instead of FSGROUP\n", f->name, t);
1821 void fix_fsg_type(void *filesys)
1823 struct filesys *f = filesys;
1824 EXEC SQL BEGIN DECLARE SECTION;
1825 int rowcount, id = f->filsys_id;
1826 EXEC SQL END DECLARE SECTION;
1828 EXEC SQL UPDATE filesys SET type = 'FSGROUP' WHERE filsys_id = :id;
1829 rowcount = sqlca.sqlerrd[2];
1831 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1833 printf("Not fixed\n");
1834 modified("filesys");
1837 int show_fsg_nomember(void *id)
1839 EXEC SQL BEGIN DECLARE SECTION;
1840 int iid = (int)id, id1, found = 1;
1841 EXEC SQL END DECLARE SECTION;
1844 EXEC SQL DECLARE csr211 CURSOR FOR
1845 SELECT group_id FROM fsgroup
1846 WHERE filsys_id = :iid;
1847 EXEC SQL OPEN csr211;
1850 EXEC SQL FETCH csr211 INTO :id1;
1855 if ((f = hash_lookup(filesys, id1)))
1856 printf("FSGroup %s has missing member %d\n", f->name, iid);
1858 printf("FSGroup %d has missing member %d\n", id1, iid);
1860 EXEC SQL CLOSE csr211;
1864 int show_quota_nouser(void *id)
1866 EXEC SQL BEGIN DECLARE SECTION;
1867 int iid = (int)id, id1, found = 1;
1868 EXEC SQL END DECLARE SECTION;
1870 EXEC SQL DECLARE csr212 CURSOR FOR
1871 SELECT filsys_id FROM quota
1872 WHERE entity_id = :iid AND type = 'USER';
1873 EXEC SQL OPEN csr212;
1876 EXEC SQL FETCH csr212 INTO :id1;
1881 printf("Quota on fs %d for non-existant user %d\n", id1, iid);
1883 EXEC SQL CLOSE csr212;
1887 int show_quota_nolist(void *id)
1889 EXEC SQL BEGIN DECLARE SECTION;
1890 int iid = (int)id, id1, found = 1;
1891 EXEC SQL END DECLARE SECTION;
1893 EXEC SQL DECLARE csr213 CURSOR FOR
1894 SELECT filsys_id FROM quota
1895 WHERE entity_id = :iid AND type = 'GROUP';
1896 EXEC SQL OPEN csr213;
1899 EXEC SQL FETCH csr213 INTO :id1;
1904 printf("Quota on fs %d for non-existant list %d\n", id1, iid);
1906 EXEC SQL CLOSE csr213;
1910 void fix_quota_nouser(void *id)
1912 EXEC SQL BEGIN DECLARE SECTION;
1913 int iid = (int)id, rowcount;
1914 EXEC SQL END DECLARE SECTION;
1916 EXEC SQL DELETE FROM quota
1917 WHERE entity_id = :iid AND type = 'USER';
1918 rowcount = sqlca.sqlerrd[2];
1920 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1922 printf("Not deleted\n");
1926 void fix_quota_nolist(void *id)
1928 EXEC SQL BEGIN DECLARE SECTION;
1929 int iid = (int)id, rowcount;
1930 EXEC SQL END DECLARE SECTION;
1932 EXEC SQL DELETE FROM quota WHERE entity_id = :iid AND type = 'GROUP';
1933 rowcount = sqlca.sqlerrd[2];
1935 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1937 printf("Not deleted\n");
1941 int show_quota_nofs(void *id)
1943 EXEC SQL BEGIN DECLARE SECTION;
1944 int iid = (int)id, id1, found = 1;
1945 char type[QUOTA_TYPE_SIZE];
1946 EXEC SQL END DECLARE SECTION;
1948 EXEC SQL DECLARE csr214 CURSOR FOR
1949 SELECT entity_id, type FROM quota
1950 WHERE filsys_id = :iid;
1951 EXEC SQL OPEN csr214;
1954 EXEC SQL FETCH csr214 INTO :id1, :type;
1959 printf("Quota for %s %d on non-existant filesys %d\n", type, id1, iid);
1961 EXEC SQL CLOSE csr214;
1965 void fix_quota_nofs(void *id)
1967 single_delete("quota", "filsys_id", (int)id);
1970 int show_quota_wrongpid(void *id)
1972 EXEC SQL BEGIN DECLARE SECTION;
1973 int iid = (int)id, id1, found = 1;
1974 char type[QUOTA_TYPE_SIZE];
1975 EXEC SQL END DECLARE SECTION;
1978 f = hash_lookup(filesys, iid);
1979 EXEC SQL DECLARE csr215 CURSOR FOR
1980 SELECT entity_id, type FROM quota
1981 WHERE filsys_id = :iid;
1982 EXEC SQL OPEN csr215;
1985 EXEC SQL FETCH csr215 INTO :id1, :type;
1990 printf("Quota for %s %d on filesys %s has wrong phys_id %d\n",
1991 type, id1, f->name, iid);
1993 EXEC SQL CLOSE csr215;
1997 void fix_quota_physid(void *id)
1999 EXEC SQL BEGIN DECLARE SECTION;
2000 int iid = (int)id, rowcount, id1;
2001 EXEC SQL END DECLARE SECTION;
2003 id1 = ((struct filesys *)hash_lookup(filesys, iid))->phys_id;
2004 EXEC SQL UPDATE quota SET phys_id = :id1
2005 WHERE filsys_id = :iid AND phys_id != :id1;
2006 rowcount = sqlca.sqlerrd[2];
2008 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
2010 printf("Not fixed\n");
2014 int show_srv_user(void *id)
2016 EXEC SQL BEGIN DECLARE SECTION;
2017 char name[SERVERS_NAME_SIZE];
2019 EXEC SQL END DECLARE SECTION;
2022 EXEC SQL DECLARE csr216 CURSOR FOR
2023 SELECT name FROM servers
2024 WHERE acl_type = 'USER' and acl_id = :iid;
2025 EXEC SQL OPEN csr216;
2028 EXEC SQL FETCH csr216 INTO :name;
2033 printf("Service %s has acl non-existant user %d\n", name, iid);
2036 EXEC SQL CLOSE csr216;
2040 int show_srv_list(void *id)
2042 EXEC SQL BEGIN DECLARE SECTION;
2043 char name[SERVERS_NAME_SIZE];
2045 EXEC SQL END DECLARE SECTION;
2048 EXEC SQL DECLARE csr217 CURSOR FOR
2049 SELECT name FROM servers
2050 WHERE acl_type = 'LIST' AND acl_id = :iid;
2051 EXEC SQL OPEN csr217;
2054 EXEC SQL FETCH csr217 INTO :name;
2059 printf("Service %s has acl non-existant list %d\n", name, iid);
2062 EXEC SQL CLOSE csr217;
2066 void zero_srv_user(void *id)
2068 EXEC SQL BEGIN DECLARE SECTION;
2069 int iid = (int)id, rowcount;
2070 EXEC SQL END DECLARE SECTION;
2072 EXEC SQL UPDATE servers SET acl_id = 0 WHERE acl_id = :iid AND
2074 rowcount = sqlca.sqlerrd[2];
2076 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
2078 printf("Not fixed\n");
2079 modified("servers");
2082 void zero_srv_list(void *id)
2084 EXEC SQL BEGIN DECLARE SECTION;
2085 int iid = (int)id, rowcount;
2086 EXEC SQL END DECLARE SECTION;
2088 EXEC SQL UPDATE servers SET acl_id = 0 WHERE acl_id = :iid AND
2090 rowcount = sqlca.sqlerrd[2];
2092 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
2094 printf("Not fixed\n");
2095 modified("servers");
2098 int show_krb_usr(void *id)
2100 EXEC SQL BEGIN DECLARE SECTION;
2101 int iid = (int)id, found = 1, id1;
2102 EXEC SQL END DECLARE SECTION;
2106 EXEC SQL DECLARE csr218 CURSOR FOR
2107 SELECT string_id FROM krbmap
2108 WHERE users_id = :iid;
2109 EXEC SQL OPEN csr218;
2112 EXEC SQL FETCH csr218 INTO :id1;
2116 if ((s = hash_lookup(strings, id1)))
2121 printf("Kerberos map for non-existant user %d to principal %s\n",
2124 EXEC SQL CLOSE csr218;
2128 int show_krb_str(void *id)
2130 EXEC SQL BEGIN DECLARE SECTION;
2131 int iid = (int)id, found = 1, id1;
2132 EXEC SQL END DECLARE SECTION;
2136 EXEC SQL DECLARE csr219 CURSOR FOR
2137 SELECT users_id FROM krbmap
2138 WHERE string_id = :iid;
2139 EXEC SQL OPEN csr219;
2142 EXEC SQL FETCH csr219 INTO :id1;
2146 if ((u = hash_lookup(users, id1)))
2151 printf("Kerberos map for user %s (%d) to non-existant string %d\n",
2154 EXEC SQL CLOSE csr219;
2160 struct save_queue *sq, *sq1, *sq2, *sq3, *sq4, *sq5, *sq6;
2167 printf("Phase 2 - Checking references\n");
2169 dprintf("Checking users...\n");
2170 hash_step(users, user_check, NULL);
2172 dprintf("Checking machines...\n");
2173 hash_step(machines, mach_check, NULL);
2175 dprintf("Checking subnets...\n");
2176 hash_step(subnets, subnet_check, NULL);
2178 dprintf("Checking clusters...\n");
2179 hash_step(clusters, cluster_check, NULL);
2181 dprintf("Checking mcmap...\n");
2184 EXEC SQL DECLARE csr221 CURSOR FOR
2185 SELECT mach_id, clu_id FROM mcmap;
2186 EXEC SQL OPEN csr221;
2189 EXEC SQL BEGIN DECLARE SECTION;
2190 int mach_id, clu_id;
2191 EXEC SQL END DECLARE SECTION;
2193 EXEC SQL FETCH csr221 INTO :mach_id, :clu_id;
2197 if (!(m = hash_lookup(machines, mach_id)))
2198 sq_save_unique_data(sq1, (void *)mach_id);
2199 else if (!hash_lookup(clusters, clu_id))
2200 sq_save_unique_data(sq2, (void *)clu_id);
2204 EXEC SQL CLOSE csr221;
2205 generic_delete(sq1, show_mcm_mach, "mcmap", "mach_id", 1);
2206 generic_delete(sq2, show_mcm_clu, "mcmap", "clu_id", 1);
2208 dprintf("Checking service clusters...\n");
2210 EXEC SQL DECLARE csr222 CURSOR FOR
2211 SELECT clu_id FROM svc;
2212 EXEC SQL OPEN csr222;
2215 EXEC SQL BEGIN DECLARE SECTION;
2217 EXEC SQL END DECLARE SECTION;
2219 EXEC SQL FETCH csr222 INTO :clu_id;
2223 if (!hash_lookup(clusters, clu_id))
2224 sq_save_unique_data(sq1, (void *)clu_id);
2226 EXEC SQL CLOSE csr222;
2227 generic_delete(sq1, show_svc, "svc", "clu_id", 1);
2229 dprintf("Checking lists...\n");
2230 hash_step(lists, list_check, NULL);
2232 dprintf("Checking members...\n");
2240 EXEC SQL DECLARE csr223 CURSOR FOR
2241 SELECT list_id, member_type, member_id, tag, ref_count, direct, rowid
2242 FROM imembers FOR UPDATE OF member_id;
2243 EXEC SQL OPEN csr223;
2246 EXEC SQL BEGIN DECLARE SECTION;
2247 int list_id, id, tag, ref_count, direct;
2248 char type[IMEMBERS_MEMBER_TYPE_SIZE];
2249 EXEC SQL END DECLARE SECTION;
2251 EXEC SQL FETCH csr223 INTO :list_id, :type, :id, :tag,
2252 :ref_count, :direct, :rowid;
2257 if (!(l = hash_lookup(lists, list_id)))
2258 sq_save_unique_data(sq1, (void *)list_id);
2259 else if (type[0] == 'U' && !hash_lookup(users, id))
2260 sq_save_unique_data(sq2, (void *)id);
2261 else if (type[0] == 'L' && !hash_lookup(lists, id))
2262 sq_save_unique_data(sq3, (void *)id);
2263 else if (type[0] == 'S' && !maybe_fixup_unref_string2("imembers", "member_id", rowid, id))
2264 sq_save_unique_data(sq4, (void *)id);
2265 else if (type[0] == 'K' && !maybe_fixup_unref_string2("imembers", "member_id", rowid, id))
2266 sq_save_unique_data(sq5, (void *)id);
2267 else if (type[0] == 'M' && !hash_lookup(machines, id))
2268 sq_save_unique_data(sq6, (void *)id);
2271 maybe_fixup_unref_string2("imembers", "tag", rowid, tag);
2273 EXEC SQL CLOSE csr223;
2274 generic_delete(sq1, show_member_list, "imembers", "list_id", 1);
2275 generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1);
2276 generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1);
2277 generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1);
2278 generic_fix(sq5, show_mem_krb, "Delete", del_mem_krb, 1);
2279 generic_fix(sq6, show_mem_mach, "Delete", del_mem_mach, 1);
2281 dprintf("Checking servers...\n");
2284 EXEC SQL DECLARE csr224 CURSOR FOR
2285 SELECT name, acl_type, acl_id, modby, rowid FROM servers
2286 FOR UPDATE of modby;
2287 EXEC SQL OPEN csr224;
2290 EXEC SQL BEGIN DECLARE SECTION;
2292 char name[SERVERS_NAME_SIZE], acl_type[SERVERS_ACL_TYPE_SIZE];
2293 EXEC SQL END DECLARE SECTION;
2295 EXEC SQL FETCH csr224 INTO :name, :acl_type, :acl_id, :modby, :rowid;
2299 maybe_fixup_modby2("servers", "modby", strtrim(rowid), modby);
2301 if (!strcmp(acl_type, "USER") && !hash_lookup(users, acl_id))
2302 sq_save_data(sq1, (void *)acl_id);
2303 else if (!strcmp(acl_type, "LIST") && !hash_lookup(lists, acl_id))
2304 sq_save_data(sq2, (void *)acl_id);
2306 EXEC SQL CLOSE csr224;
2307 generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
2308 generic_fix(sq2, show_srv_list, "Fix", zero_srv_list, 1);
2310 dprintf("Checking serverhosts...\n");
2312 EXEC SQL DECLARE csr225 CURSOR FOR
2313 SELECT mach_id, modby, rowid FROM serverhosts
2314 FOR UPDATE OF modby;
2315 EXEC SQL OPEN csr225;
2318 EXEC SQL BEGIN DECLARE SECTION;
2320 EXEC SQL END DECLARE SECTION;
2322 EXEC SQL FETCH csr225 INTO :mach_id, :modby, :rowid;
2326 maybe_fixup_modby2("serverhosts", "modby", strtrim(rowid), modby);
2327 if (!hash_lookup(machines, mach_id))
2328 sq_save_data(sq, (void *)mach_id);
2330 EXEC SQL CLOSE csr225;
2331 generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
2333 dprintf("Checking nfsphys...\n");
2334 hash_step(nfsphys, check_nfsphys, NULL);
2336 dprintf("Checking filesys...\n");
2337 hash_step(filesys, check_fs, NULL);
2339 dprintf("Checking filesystem groups...\n");
2343 EXEC SQL DECLARE csr226 CURSOR FOR
2344 SELECT group_id, filsys_id FROM fsgroup;
2345 EXEC SQL OPEN csr226;
2348 EXEC SQL BEGIN DECLARE SECTION;
2349 int group_id, filsys_id;
2350 EXEC SQL END DECLARE SECTION;
2352 EXEC SQL FETCH csr226 INTO :group_id, :filsys_id;
2356 if (!(f = hash_lookup(filesys, group_id)))
2357 sq_save_data(sq1, (void *)group_id);
2358 if (!hash_lookup(filesys, filsys_id))
2359 sq_save_data(sq3, (void *)filsys_id);
2361 EXEC SQL CLOSE csr226;
2362 generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0);
2363 generic_delete(sq3, show_fsg_nomember, "fsgroup", "filsys_id", 1);
2365 dprintf("Checking quotas...\n");
2370 EXEC SQL DECLARE csr227 CURSOR FOR
2371 SELECT entity_id, type, filsys_id, phys_id, quota, modby, rowid
2372 FROM quota FOR UPDATE OF modby;
2373 EXEC SQL OPEN csr227;
2376 EXEC SQL BEGIN DECLARE SECTION;
2377 int entity_id, filsys_id, phys_id, quota, modby;
2378 char type[QUOTA_TYPE_SIZE];
2379 EXEC SQL END DECLARE SECTION;
2381 EXEC SQL FETCH csr227 INTO :entity_id, :type, :filsys_id,
2382 :phys_id, :quota, :modby, :rowid;
2386 maybe_fixup_modby2("quota", "modby", strtrim(rowid), modby);
2387 if (type[0] == 'U' && entity_id != 0 && !hash_lookup(users, entity_id))
2388 sq_save_data(sq1, (void *)entity_id);
2389 else if (type[0] == 'G' && !hash_lookup(lists, entity_id))
2390 sq_save_data(sq4, (void *)entity_id);
2391 else if (!(f = hash_lookup(filesys, filsys_id)))
2392 sq_save_data(sq2, (void *)filsys_id);
2393 else if (phys_id != f->phys_id || !(n = hash_lookup(nfsphys, phys_id)))
2394 sq_save_data(sq3, (void *)phys_id);
2398 EXEC SQL CLOSE csr227;
2399 generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1);
2400 generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0);
2401 generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1);
2402 generic_fix(sq4, show_quota_nolist, "Delete", fix_quota_nolist, 1);
2404 dprintf("Checking zephyr...\n");
2405 EXEC SQL DECLARE csr_zc CURSOR FOR
2406 SELECT class, xmt_type, xmt_id, sub_type, sub_id, iws_type, iws_id,
2407 iui_type, iui_id, modby FROM zephyr;
2408 EXEC SQL OPEN csr_zc;
2411 EXEC SQL BEGIN DECLARE SECTION;
2412 int xmt_id, sub_id, iws_id, iui_id, modby;
2413 char class[ZEPHYR_CLASS_SIZE];
2414 char xmt_type[ZEPHYR_XMT_TYPE_SIZE];
2415 char sub_type[ZEPHYR_SUB_TYPE_SIZE];
2416 char iws_type[ZEPHYR_IWS_TYPE_SIZE];
2417 char iui_type[ZEPHYR_IUI_TYPE_SIZE];
2418 EXEC SQL END DECLARE SECTION;
2420 EXEC SQL FETCH csr_zc INTO :class, :xmt_type, :xmt_id, :sub_type,
2421 :sub_id, :iws_type, :iws_id, :iui_type, :iui_id, :modby;
2426 maybe_fixup_modby2("zephyr", "modby", strtrim(rowid), modby);
2429 if (!strcmp(xmt_type, "USER") && !hash_lookup(users, xmt_id))
2431 printf("xmt acl for %s is non-existant user %d\n", class, xmt_id);
2432 printf("Not fixing this error\n");
2434 else if (!strcmp(xmt_type, "LIST") && !hash_lookup(lists, xmt_id))
2436 printf("xmt acl for %s is non-existant list %d\n", class, xmt_id);
2437 printf("Not fixing this error\n");
2439 else if (!strcmp(xmt_type, "STRING") || !strcmp(xmt_type, "KERBEROS"))
2440 maybe_fixup_unref_string2("zephyr", "xmt_id", strtrim(rowid), xmt_id);
2443 if (!strcmp(sub_type, "USER") && !hash_lookup(users, sub_id))
2445 printf("sub acl for %s is non-existant user %d\n", class, sub_id);
2446 printf("Not fixing this error\n");
2448 else if (!strcmp(sub_type, "LIST") && !hash_lookup(lists, sub_id))
2450 printf("sub acl for %s is non-existant list %d\n", class, sub_id);
2451 printf("Not fixing this error\n");
2453 else if (!strcmp(sub_type, "STRING") || !strcmp(sub_type, "KERBEROS"))
2454 maybe_fixup_unref_string2("zephyr", "sub_id", strtrim(rowid), sub_id);
2457 if (!strcmp(iws_type, "USER") && !hash_lookup(users, iws_id))
2459 printf("iws acl for %s is non-existant user %d\n", class, iws_id);
2460 printf("Not fixing this error\n");
2462 else if (!strcmp(iws_type, "LIST") && !hash_lookup(lists, iws_id))
2464 printf("iws acl for %s is non-existant list %d\n", class, iws_id);
2465 printf("Not fixing this error\n");
2467 else if (!strcmp(iws_type, "STRING") || !strcmp(iws_type, "KERBEROS"))
2468 maybe_fixup_unref_string2("zephyr", "iws_id", strtrim(rowid), iws_id);
2471 if (!strcmp(iui_type, "USER") && !hash_lookup(users, iui_id))
2473 printf("iui acl for %s is non-existant user %d\n", class, iui_id);
2474 printf("Not fixing this error\n");
2476 else if (!strcmp(iui_type, "LIST") && !hash_lookup(lists, iui_id))
2478 printf("iui acl for %s is non-existant list %d\n", class, iui_id);
2479 printf("Not fixing this error\n");
2481 else if (!strcmp(iui_type, "STRING") || !strcmp(iui_type, "KERBEROS"))
2482 maybe_fixup_unref_string2("zephyr", "iui_id", strtrim(rowid), iui_id);
2485 dprintf("Checking hostaccess...\n");
2486 EXEC SQL DECLARE csr228 CURSOR FOR
2487 SELECT mach_id, acl_type, acl_id, modby, rowid FROM hostaccess
2488 FOR UPDATE OF modby;
2489 EXEC SQL OPEN csr228;
2492 EXEC SQL BEGIN DECLARE SECTION;
2493 int mach_id, acl_id, modby;
2494 char acl_type[HOSTACCESS_ACL_TYPE_SIZE];
2495 EXEC SQL END DECLARE SECTION;
2497 EXEC SQL FETCH csr228 INTO :mach_id, :acl_type, :acl_id, :modby, :rowid;
2501 maybe_fixup_modby2("hostaccess", "modby", strtrim(rowid), modby);
2503 if (!hash_lookup(machines, mach_id))
2505 printf("Hostaccess for non-existant host %d\n", mach_id);
2506 printf("Not fixing this error\n");
2508 if (!strcmp(acl_type, "USER") && !hash_lookup(users, acl_id))
2510 printf("Hostaccess for %d is non-existant user %d\n", mach_id, acl_id);
2511 printf("Not fixing this error\n");
2513 else if (!strcmp(acl_type, "LIST") && !hash_lookup(lists, acl_id))
2515 printf("Hostaccess for %d is non-existant list %d\n", mach_id, acl_id);
2516 printf("Not fixing this error\n");
2519 EXEC SQL CLOSE csr228;
2521 dprintf("Checking krbmap...\n");
2524 EXEC SQL DECLARE csr230 CURSOR FOR
2525 SELECT users_id, string_id, rowid FROM krbmap
2526 FOR UPDATE OF string_id;
2527 EXEC SQL OPEN csr230;
2530 EXEC SQL BEGIN DECLARE SECTION;
2531 int users_id, string_id;
2532 EXEC SQL END DECLARE SECTION;
2534 EXEC SQL FETCH csr230 INTO :users_id, :string_id, :rowid;
2538 if (!hash_lookup(users, users_id))
2539 sq_save_unique_data(sq1, (void *)users_id);
2540 else if (!maybe_fixup_unref_string2("krbmap", "string_id", strtrim(rowid), string_id))
2541 sq_save_unique_data(sq2, (void *)string_id);
2543 EXEC SQL CLOSE csr230;
2544 generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1);
2545 generic_delete(sq2, show_krb_str, "krbmap", "string_id", 1);
2547 dprintf("Checking capacls...\n");
2548 EXEC SQL DECLARE csr231 CURSOR FOR
2549 SELECT list_id, tag FROM capacls;
2550 EXEC SQL OPEN csr231;
2553 EXEC SQL BEGIN DECLARE SECTION;
2555 char tag[CAPACLS_TAG_SIZE];
2556 EXEC SQL END DECLARE SECTION;
2558 EXEC SQL FETCH csr231 INTO :list_id, :tag;
2562 if (!hash_lookup(lists, list_id))
2564 printf("Capacl for %s is non-existant list %d\n", tag, list_id);
2565 printf("Not fixing this error\n");
2568 EXEC SQL CLOSE csr231;
2570 dprintf("Checking hostaliases...\n");
2572 EXEC SQL DECLARE csr232 CURSOR FOR
2573 SELECT mach_id FROM hostalias;
2574 EXEC SQL OPEN csr232;
2577 EXEC SQL BEGIN DECLARE SECTION;
2579 EXEC SQL END DECLARE SECTION;
2581 EXEC SQL FETCH csr232 INTO :mach_id;
2585 if (!hash_lookup(machines, mach_id))
2586 sq_save_unique_data(sq1, (void *)mach_id);
2588 EXEC SQL CLOSE csr232;
2589 generic_delete(sq1, show_hostalias, "hostalias", "mach_id", 1);
2591 dprintf("Checking printers...\n");
2598 EXEC SQL DECLARE csr233 CURSOR FOR
2599 SELECT mach_id, loghost, rm, rq, ac, lpc_acl, modby, rowid FROM printers;
2600 EXEC SQL OPEN csr233;
2603 EXEC SQL BEGIN DECLARE SECTION;
2604 int mach_id, loghost, rm, rq, ac, lpc_acl, modby;
2605 EXEC SQL END DECLARE SECTION;
2607 EXEC SQL FETCH csr233 INTO :mach_id, :loghost, :rm, :rq, :ac,
2608 :lpc_acl, :modby, :rowid;
2612 maybe_fixup_modby2("printers", "modby", strtrim(rowid), modby);
2613 if (!hash_lookup(machines, mach_id))
2614 sq_save_unique_data(sq1, (void *)mach_id);
2615 else if (!hash_lookup(machines, rm))
2616 sq_save_unique_data(sq2, (void *)rm);
2617 else if (!hash_lookup(printservers, rm))
2618 sq_save_unique_data(sq6, (void *)mach_id);
2619 else if (!hash_lookup(machines, rq))
2620 sq_save_unique_data(sq3, (void *)rq);
2622 if (!hash_lookup(lists, ac))
2623 sq_save_unique_data(sq4, (void *)ac);
2624 if (!hash_lookup(lists, lpc_acl))
2625 sq_save_unique_data(sq5, (void *)lpc_acl);
2626 if (!hash_lookup(machines, loghost))
2628 show_printer_loghost((void *)loghost);
2633 EXEC SQL CLOSE csr233;
2634 generic_delete(sq1, show_printer_mach, "printers", "mach_id", 1);
2635 generic_delete(sq6, show_printer_server, "printers", "mach_id", 1);
2636 generic_delete(sq2, show_printer_spool, "printers", "rm", 1);
2637 generic_delete(sq3, show_printer_quota, "printers", "rq", 1);
2638 generic_fix(sq4, show_printer_ac, "Clear", fix_printer_ac, 1);
2639 generic_fix(sq5, show_printer_lpc_acl, "Clear", fix_printer_lpc_acl, 1);
2641 dprintf("Checking printservers...\n");
2642 hash_step(printservers, check_ps, NULL);
2644 dprintf("Checking containers...\n");
2645 hash_step(containers, check_container, NULL);
2647 dprintf("Checking mcntmap...\n");
2650 EXEC SQL DECLARE csr_mcntmap CURSOR FOR
2651 SELECT mach_id, cnt_id FROM mcntmap;
2652 EXEC SQL OPEN csr_mcntmap;
2655 EXEC SQL BEGIN DECLARE SECTION;
2656 int mach_id, cnt_id;
2657 EXEC SQL END DECLARE SECTION;
2659 EXEC SQL FETCH csr_mcntmap INTO :mach_id, :cnt_id;
2663 if (!(m = hash_lookup(machines, mach_id)))
2664 sq_save_unique_data(sq1, (void *)mach_id);
2665 else if (!hash_lookup(containers, cnt_id))
2666 sq_save_unique_data(sq2, (void *)cnt_id);
2668 EXEC SQL CLOSE csr_mcntmap;
2669 generic_delete(sq1, show_mcntmap_mach, "mcntmap", "mach_id", 1);
2670 generic_delete(sq2, show_mcntmap_cnt, "mcntmap", "cnt_id", 1);