3 * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
4 * For copying and distribution information, please see the file
8 #include <mit-copyright.h>
16 EXEC SQL INCLUDE sqlca;
20 EXEC SQL WHENEVER SQLERROR DO dbmserr();
22 int show_mcm_mach(void *id);
23 int show_mcm_clu(void *id);
24 int show_hostalias(void *id);
25 int show_pcap_mach(void *id);
26 int show_pcap_quota(void *id);
27 void user_check(int id, void *user, void *hint);
28 int maybe_fixup_unref_string(int sid, int oid, char *oname, char *table,
29 char *field, char *idfield);
30 int maybe_fixup_modby(int sid, int oid, char *oname, char *table,
31 char *field, char *idfield);
32 int maybe_fixup_unref_string2(char *table, char *field, char *cursor, int sid);
33 int maybe_fixup_modby2(char *table, char *field, char *cursor, int id);
34 void pobox_check(int id, struct user *u);
35 void remove_pobox(int id);
36 void fix_smtp_pobox(int id, int sid);
37 void mach_check(int id, void *machine, void *hint);
38 void subnet_check(int id, void *subnet, void *hint);
39 void clear_subnet_owner(struct subnet *s);
40 void clear_mach_owner(struct machine *m);
41 void cluster_check(int id, void *cluster, void *hint);
42 int show_svc(void *id);
43 void list_check(int id, void *list, void *hint);
44 void fix_list_acl(int id);
45 int show_member_list(void *id);
46 int show_mem_user(void *id);
47 int show_mem_list(void *id);
48 int show_mem_str(void *id);
49 int show_mem_krb(void *id);
50 void del_mem_user(void *id);
51 void del_mem_list(void *id);
52 void del_mem_str(void *id);
53 void del_mem_krb(void *id);
54 int show_sh(void *id);
55 void del_sh_mach(void *id);
56 void fsmatch(int id, void *nfsphys, void *filesys);
57 void check_fs(int id, void *filesys, void *hint);
58 void check_nfsphys(int id, void *nfsphys, void *hint);
59 int show_fsg_missing(void *id);
60 int show_fsg_type(void *filesys);
61 void fix_fsg_type(void *filesys);
62 int show_fsg_nomember(void *id);
63 int show_quota_nouser(void *id);
64 int show_quota_nolist(void *id);
65 void fix_quota_nouser(void *id);
66 void fix_quota_nolist(void *id);
67 int show_quota_nofs(void *id);
68 void fix_quota_nofs(void *id);
69 int show_quota_wrongpid(void *id);
70 void fix_quota_physid(void *id);
71 int show_srv_user(void *id);
72 int show_srv_list(void *id);
73 void zero_srv_user(void *id);
74 void zero_srv_list(void *id);
75 int show_krb_usr(void *id);
76 int show_krb_str(void *id);
77 int show_pdm_mach(void *id);
79 int show_mcm_mach(void *id)
81 EXEC SQL BEGIN DECLARE SECTION;
82 int iid = (int)id, found = 1;
83 char name[CLUSTERS_NAME_SIZE];
84 EXEC SQL END DECLARE SECTION;
86 EXEC SQL DECLARE csr201 CURSOR FOR
87 SELECT clusters.name FROM clusters, mcmap
88 WHERE clusters.clu_id = mcmap.clu_id AND mcmap.mach_id = :iid;
92 EXEC SQL FETCH csr201 INTO :name;
98 printf("Cluster %s, non-existant machine %d in cluster map\n",
101 EXEC SQL CLOSE csr201;
105 int show_mcm_clu(void *id)
107 EXEC SQL BEGIN DECLARE SECTION;
108 int iid = (int)id, found = 1;
109 char name[MACHINE_NAME_SIZE];
110 EXEC SQL END DECLARE SECTION;
112 EXEC SQL DECLARE csr202 CURSOR FOR
113 SELECT machine.name FROM machine, mcmap
114 WHERE machine.mach_id = mcmap.mach_id AND mcmap.clu_id = :iid;
115 EXEC SQL OPEN csr202;
118 EXEC SQL FETCH csr202 INTO :name;
125 printf("Machine %s, non-existant cluster %d in cluster map\n",
128 EXEC SQL CLOSE csr202;
132 int show_hostalias(void *id)
134 EXEC SQL BEGIN DECLARE SECTION;
135 int iid = (int)id, found = 1;
136 char name[HOSTALIAS_NAME_SIZE];
137 EXEC SQL END DECLARE SECTION;
139 EXEC SQL DECLARE csr234 CURSOR FOR
140 SELECT name FROM hostalias WHERE mach_id = :iid;
141 EXEC SQL OPEN csr234;
144 EXEC SQL FETCH csr234 INTO :name;
151 printf("Alias %s, non-existant machine %d in hostalias map\n",
154 EXEC SQL CLOSE csr234;
158 int show_pcap_mach(void *id)
160 EXEC SQL BEGIN DECLARE SECTION;
161 int iid = (int)id, found = 1;
162 char name[PRINTCAP_NAME_SIZE];
163 EXEC SQL END DECLARE SECTION;
165 EXEC SQL DECLARE csr235 CURSOR FOR
166 SELECT name FROM printcap WHERE mach_id = :iid;
167 EXEC SQL OPEN csr235;
170 EXEC SQL FETCH csr235 INTO :name;
177 printf("Printer %s, non-existant spool machine %d in printcap table\n",
180 EXEC SQL CLOSE csr235;
184 int show_pcap_quota(void *id)
186 EXEC SQL BEGIN DECLARE SECTION;
187 int iid = (int)id, found = 1;
188 char name[PRINTCAP_NAME_SIZE];
189 EXEC SQL END DECLARE SECTION;
191 EXEC SQL DECLARE csr236 CURSOR FOR
192 SELECT name FROM printcap WHERE quotaserver = :iid;
193 EXEC SQL OPEN csr236;
196 EXEC SQL FETCH csr236 INTO :name;
203 printf("Printer %s, non-existant quota server %d in printcap table\n",
206 EXEC SQL CLOSE csr236;
210 void user_check(int id, void *user, void *hint)
212 struct user *u = user;
214 u->comment = maybe_fixup_unref_string(u->comment, id, u->login, "users",
215 "comments", "users_id");
217 u->modby = maybe_fixup_modby(u->modby, id, u->login, "users",
218 "modby", "users_id");
220 u->fmodby = maybe_fixup_modby(u->fmodby, id, u->login, "users",
221 "fmodby", "users_id");
223 u->pmodby = maybe_fixup_modby(u->pmodby, id, u->login, "users",
224 "pmodby", "users_id");
226 u->sigwho = maybe_fixup_unref_string(u->sigwho, id, u->login, "users",
227 "sigwho", "users_id");
232 int maybe_fixup_unref_string(int sid, int oid, char *oname, char *table,
233 char *field, char *idfield)
235 int ret = (sid < 0) ? -sid : sid, doit = 0, newid;
236 EXEC SQL BEGIN DECLARE SECTION;
239 EXEC SQL END DECLARE SECTION;
241 if ((newid = (int)hash_lookup(string_dups, ret)))
243 printf("%s entry %s(%d) has a %s with duplicate string %d\n",
244 table, oname, oid, field, ret);
245 if (single_fix("Replace duplicate", 0))
252 else if (!string_check(ret))
254 printf("%s entry %s(%d) has a %s with non-existant string %d\n",
255 table, oname, oid, field, ret);
256 if (single_fix("Delete", 1))
265 sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE %s = %d",
266 table, field, (sid < 0) ? -ret : ret, idfield, oid);
267 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
268 rowcount = sqlca.sqlerrd[2];
272 printf("Not fixed, rowcount = %d\n", rowcount);
276 return (sid < 0) ? -ret : ret;
279 int maybe_fixup_modby(int sid, int oid, char *oname, char *table,
280 char *field, char *idfield)
282 EXEC SQL BEGIN DECLARE SECTION;
285 EXEC SQL END DECLARE SECTION;
288 return maybe_fixup_unref_string(sid, oid, oname, table, field, idfield);
291 if (!hash_lookup(users, sid))
293 printf("%s entry %s(%d) has a %s with non-existant user %d\n",
294 table, oname, oid, field, sid);
295 if (single_fix("Delete", 1))
297 sprintf(stmt_buf, "UPDATE %s SET %s = 0 WHERE %s = %d",
298 table, field, idfield, oid);
299 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
300 rowcount = sqlca.sqlerrd[2];
304 printf("Not fixed, rowcount = %d\n", rowcount);
313 int maybe_fixup_unref_string2(char *table, char *field, char *cursor, int sid)
315 int ret = (sid < 0) ? -sid : sid, doit = 0, newid;
316 EXEC SQL BEGIN DECLARE SECTION;
319 EXEC SQL END DECLARE SECTION;
321 if ((newid = (int)hash_lookup(string_dups, ret)))
323 printf("%s entry has a %s with duplicate string %d\n",
325 if (single_fix("Replace duplicate", 0))
332 else if (!string_check(ret))
334 printf("%s entry has a %s with non-existant string %d\n",
336 if (single_fix("Delete", 1))
345 sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE CURRENT OF %s",
346 table, field, (sid < 0) ? -ret : ret, cursor);
347 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
348 rowcount = sqlca.sqlerrd[2];
352 printf("Not fixed, rowcount = %d\n", rowcount);
355 return (sid < 0) ? -ret : ret;
358 int maybe_fixup_modby2(char *table, char *field, char *cursor, int id)
360 EXEC SQL BEGIN DECLARE SECTION;
363 EXEC SQL END DECLARE SECTION;
366 return maybe_fixup_unref_string2(table, field, cursor, id);
369 if (!hash_lookup(users, id))
371 printf("%s entry has a %s with non-existant user %d\n",
373 if (single_fix("Delete", 1))
375 sprintf(stmt_buf, "UPDATE %s SET %s = 0 WHERE CURRENT OF %s",
376 table, field, cursor);
377 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
378 rowcount = sqlca.sqlerrd[2];
382 printf("Not fixed, rowcount = %d\n", rowcount);
391 void pobox_check(int id, struct user *u)
396 if (!hash_lookup(machines, u->pobox_id))
398 printf("User %s(%s) has P.O.Box on non-existant machine %d\n",
399 u->login, u->fullname, u->pobox_id);
400 if (single_fix("Delete", 0))
402 remove_pobox(u->users_id);
408 if (hash_lookup(string_dups, u->pobox_id))
410 printf("User %s(%s) has P.O.Box with duplicate string %d\n",
411 u->login, u->fullname, u->pobox_id);
412 if (single_fix("Update", 0))
414 printf("Replacing box_id dup string ID %d with %d\n",
416 (int)hash_lookup(string_dups, u->pobox_id));
417 u->pobox_id = (int)hash_lookup(string_dups, u->pobox_id);
418 fix_smtp_pobox(u->users_id, u->pobox_id);
419 string_check(u->pobox_id);
422 else if (!string_check(u->pobox_id))
424 printf("User %s(%s) has P.O.Box with non-existant string %d\n",
425 u->login, u->fullname, u->pobox_id);
426 if (single_fix("Delete", 0))
428 remove_pobox(u->users_id);
439 void remove_pobox(int id)
441 EXEC SQL BEGIN DECLARE SECTION;
442 int rowcount, iid = (int)id;
443 EXEC SQL END DECLARE SECTION;
445 EXEC SQL UPDATE users SET potype = 'NONE' WHERE users.users_id = :iid;
446 rowcount = sqlca.sqlerrd[2];
448 printf("%d entr%s removed\n", rowcount, rowcount == 1 ? "y" : "ies");
450 printf("Not removed\n");
454 void fix_smtp_pobox(int id, int sid)
456 EXEC SQL BEGIN DECLARE SECTION;
457 int rowcount, iid = id, isid = sid;
458 EXEC SQL END DECLARE SECTION;
460 EXEC SQL UPDATE users SET box_id = :isid WHERE users.users_id = :iid;
461 rowcount = sqlca.sqlerrd[2];
463 printf("%d entr%s updated\n", rowcount, rowcount == 1 ? "y" : "ies");
465 printf("Not updated\n");
469 void mach_check(int id, void *machine, void *hint)
471 struct machine *m = machine;
473 if (!hash_lookup(subnets, m->snet_id))
475 printf("Machine %s is on a non-existant subnet %d\n",
476 m->name, m->snet_id);
477 if (single_fix("Move to null-subnet", 1))
479 EXEC SQL BEGIN DECLARE SECTION;
480 int rowcount, iid = id;
481 EXEC SQL END DECLARE SECTION;
483 EXEC SQL UPDATE machine SET snet_id = 0 WHERE mach_id = :iid;
484 rowcount = sqlca.sqlerrd[2];
486 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
488 printf("Not fixed\n");
493 switch (m->owner_type)
496 if (!hash_lookup(users, m->owner_id))
498 printf("Machine %s has non-existant USER owner %d\n",
499 m->name, m->owner_id);
500 if (single_fix("Set to no owner", 1))
505 if (!hash_lookup(lists, m->owner_id))
507 printf("Machine %s has non-existant LIST owner %d\n",
508 m->name, m->owner_id);
509 if (single_fix("Set to no owner", 1))
516 m->owner_id = maybe_fixup_unref_string(m->owner_id, id, m->name,
517 "machine", "owner_id",
519 if (m->owner_id == 0)
524 m->acomment = maybe_fixup_unref_string(m->acomment, id, m->name,
525 "machine", "acomment", "mach_id");
527 m->ocomment = maybe_fixup_unref_string(m->ocomment, id, m->name,
528 "machine", "ocomment", "mach_id");
530 m->creator = maybe_fixup_modby(m->creator, id, m->name, "machine",
531 "creator", "mach_id");
532 m->modby = maybe_fixup_modby(m->modby, id, m->name, "machine",
536 void subnet_check(int id, void *subnet, void *hint)
538 struct subnet *s = subnet;
540 switch (s->owner_type)
543 if (!hash_lookup(users, s->owner_id))
545 printf("Subnet %s has non-existant USER owner %d\n",
546 s->name, s->owner_id);
547 if (single_fix("Set to no owner", 1))
548 clear_subnet_owner(s);
552 if (!hash_lookup(lists, s->owner_id))
554 printf("Machine %s has non-existant LIST owner %d\n",
555 s->name, s->owner_id);
556 if (single_fix("Set to no owner", 1))
557 clear_subnet_owner(s);
563 s->owner_id = maybe_fixup_unref_string(s->owner_id, id, s->name,
564 "machine", "owner_id",
566 if (s->owner_id == 0)
567 clear_subnet_owner(s);
570 s->modby = maybe_fixup_modby(s->modby, id, s->name, "subnet",
574 void clear_subnet_owner(struct subnet *s)
576 EXEC SQL BEGIN DECLARE SECTION;
577 int rowcount, id = s->snet_id;
578 EXEC SQL END DECLARE SECTION;
580 EXEC SQL UPDATE subnet SET owner_type = 'NONE', owner_id = 0
582 rowcount = sqlca.sqlerrd[2];
584 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
586 printf("Not fixed\n");
590 void clear_mach_owner(struct machine *m)
592 EXEC SQL BEGIN DECLARE SECTION;
593 int rowcount, id = m->mach_id;
594 EXEC SQL END DECLARE SECTION;
596 EXEC SQL UPDATE machine SET owner_type = 'NONE', owner_id = 0
598 rowcount = sqlca.sqlerrd[2];
600 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
602 printf("Not fixed\n");
606 void cluster_check(int id, void *cluster, void *hint)
608 struct cluster *c = cluster;
610 c->modby = maybe_fixup_modby(c->modby, id, c->name, "clusters",
614 int show_svc(void *id)
616 EXEC SQL BEGIN DECLARE SECTION;
617 int iid = (int)id, found = 1;
618 char label[SVC_SERV_LABEL_SIZE], data[SVC_SERV_CLUSTER_SIZE];
619 EXEC SQL END DECLARE SECTION;
621 EXEC SQL DECLARE csr203 CURSOR FOR
622 SELECT serv_label, serv_cluster FROM svc
624 EXEC SQL OPEN csr203;
627 EXEC SQL FETCH csr203 INTO :label, :data;
634 printf("Cluster data [%s] %s for non-existant cluster %d\n",
637 EXEC SQL CLOSE csr203;
641 void list_check(int id, void *list, void *hint)
643 struct list *l = list;
645 l->modby = maybe_fixup_modby(l->modby, id, l->name, "list",
651 if (!hash_lookup(lists, l->acl_id))
653 printf("List %s has bad LIST acl %d\n", l->name, l->acl_id);
654 if (single_fix("Patch", 1))
655 fix_list_acl(l->list_id);
659 if (!hash_lookup(users, l->acl_id))
661 printf("List %s has bad USER acl %d\n", l->name, l->acl_id);
662 if (single_fix("Patch", 1))
663 fix_list_acl(l->list_id);
667 l->acl_id = maybe_fixup_unref_string(l->acl_id, id, l->name,
668 "list", "acl_id", "list_id");
671 printf("List %s has bad KERBEROS acl %d\n", l->name, l->acl_id);
672 if (single_fix("Patch", 1))
673 fix_list_acl(l->list_id);
679 void fix_list_acl(int id)
681 EXEC SQL BEGIN DECLARE SECTION;
682 int rowcount, iid = (int)id;
683 EXEC SQL END DECLARE SECTION;
685 EXEC SQL UPDATE list SET acl_id = :iid, acl_type = 'LIST'
686 WHERE list_id = :iid;
687 rowcount = sqlca.sqlerrd[2];
689 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
691 printf("Not fixed\n");
695 int show_member_list(void *id)
697 EXEC SQL BEGIN DECLARE SECTION;
698 int mid, iid = (int)id, found = 1;
699 char mtype[IMEMBERS_MEMBER_TYPE_SIZE], *name = "";
700 EXEC SQL END DECLARE SECTION;
702 EXEC SQL DECLARE csr204 CURSOR FOR
703 SELECT member_type, member_id FROM imembers
704 WHERE list_id = :iid AND direct = 1;
705 EXEC SQL OPEN csr204;
708 EXEC SQL FETCH csr204 INTO :mtype, :mid;
715 name = ((struct list *) hash_lookup(lists, mid))->name;
716 else if (mtype[0] == 'U')
717 name = ((struct user *) hash_lookup(users, mid))->login;
718 else if (mtype[0] == 'S' || mtype[0] == 'K')
719 name = ((struct string *) hash_lookup(strings, mid))->name;
720 printf("Non-existant list %d has member %s %s\n", iid, mtype, name);
722 EXEC SQL CLOSE csr204;
726 int show_mem_user(void *id)
728 EXEC SQL BEGIN DECLARE SECTION;
729 int lid, iid = (int)id, found = 1;
730 EXEC SQL END DECLARE SECTION;
732 EXEC SQL DECLARE csr205 CURSOR FOR
733 SELECT list_id FROM imembers
734 WHERE member_id = :iid AND member_type = 'USER' AND direct = 1;
735 EXEC SQL OPEN csr205;
738 EXEC SQL FETCH csr205 INTO :lid;
743 printf("List %s has non-existant user member, id %d\n",
744 ((struct list *)hash_lookup(lists, lid))->name, iid);
746 EXEC SQL CLOSE csr205;
750 int show_mem_list(void *id)
752 EXEC SQL BEGIN DECLARE SECTION;
753 int lid, iid = (int)id, found = 1;
754 EXEC SQL END DECLARE SECTION;
756 EXEC SQL DECLARE csr206 CURSOR FOR
757 SELECT list_id FROM imembers
758 WHERE member_id = :iid AND member_type = 'LIST' AND direct = 1;
759 EXEC SQL OPEN csr206;
762 EXEC SQL FETCH csr206 INTO :lid;
767 printf("List %s has non-existant list member, id %d\n",
768 ((struct list *)hash_lookup(lists, lid))->name, iid);
770 EXEC SQL CLOSE csr206;
774 int show_mem_str(void *id)
776 EXEC SQL BEGIN DECLARE SECTION;
777 int lid, iid = (int)id, found = 1;
778 EXEC SQL END DECLARE SECTION;
780 EXEC SQL DECLARE csr207 CURSOR FOR
781 SELECT list_id FROM imembers
782 WHERE member_id = :iid AND member_type = 'STRING' AND direct = 1;
783 EXEC SQL OPEN csr207;
786 EXEC SQL FETCH csr207 INTO :lid;
791 printf("List %s has non-existant string member, id %d\n",
792 ((struct list *)hash_lookup(lists, lid))->name, iid);
794 EXEC SQL CLOSE csr207;
799 int show_mem_krb(void *id)
801 EXEC SQL BEGIN DECLARE SECTION;
802 int lid, iid = (int)id, found = 1;
803 EXEC SQL END DECLARE SECTION;
805 EXEC SQL DECLARE csr208 CURSOR FOR
806 SELECT list_id FROM imembers
807 WHERE member_id = :iid AND member_type = 'KERBEROS' AND direct = 1;
808 EXEC SQL OPEN csr208;
811 EXEC SQL FETCH csr208 INTO :lid;
816 printf("List %s has non-existant kerberos member, id %d\n",
817 ((struct list *)hash_lookup(lists, lid))->name, iid);
819 EXEC SQL CLOSE csr208;
824 void del_mem_user(void *id)
826 EXEC SQL BEGIN DECLARE SECTION;
827 int iid = (int)id, rowcount;
828 EXEC SQL END DECLARE SECTION;
830 EXEC SQL DELETE FROM imembers WHERE member_type = 'USER' AND
831 member_id = :iid AND direct = 1;
832 rowcount = sqlca.sqlerrd[2];
834 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
836 printf("Not deleted\n");
837 modified("imembers");
840 void del_mem_list(void *id)
842 EXEC SQL BEGIN DECLARE SECTION;
843 int iid = (int)id, rowcount;
844 EXEC SQL END DECLARE SECTION;
846 EXEC SQL DELETE FROM imembers WHERE member_type = 'LIST' AND
847 member_id = :iid AND direct = 1;
848 rowcount = sqlca.sqlerrd[2];
850 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
852 printf("Not deleted\n");
853 modified("imembers");
856 void del_mem_str(void *id)
858 EXEC SQL BEGIN DECLARE SECTION;
859 int iid = (int)id, rowcount;
860 EXEC SQL END DECLARE SECTION;
862 EXEC SQL DELETE FROM imembers WHERE member_type = 'STRING' AND
863 member_id = :iid AND direct = 1;
864 rowcount = sqlca.sqlerrd[2];
866 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
868 printf("Not deleted\n");
869 modified("imembers");
873 void del_mem_krb(void *id)
875 EXEC SQL BEGIN DECLARE SECTION;
876 int iid = (int)id, rowcount;
877 EXEC SQL END DECLARE SECTION;
879 EXEC SQL DELETE FROM imembers WHERE member_type = 'KERBEROS' AND
880 member_id = :iid AND direct = 1;
881 rowcount = sqlca.sqlerrd[2];
883 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
885 printf("Not deleted\n");
886 modified("imembers");
890 int show_sh(void *id)
892 EXEC SQL BEGIN DECLARE SECTION;
893 char name[SERVERHOSTS_SERVICE_SIZE];
895 EXEC SQL END DECLARE SECTION;
898 EXEC SQL DECLARE csr209 CURSOR FOR
899 SELECT service FROM serverhosts
900 WHERE mach_id = :iid;
901 EXEC SQL OPEN csr209;
904 EXEC SQL FETCH csr209 INTO :name;
909 printf("ServerHost entry for service %s non-existant host %d\n",
912 EXEC SQL CLOSE csr209;
916 void del_sh_mach(void *id)
918 EXEC SQL BEGIN DECLARE SECTION;
919 int iid = (int)id, rowcount;
920 EXEC SQL END DECLARE SECTION;
922 EXEC SQL DELETE FROM serverhosts WHERE mach_id = :iid;
923 rowcount = sqlca.sqlerrd[2];
925 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
927 printf("Not deleted\n");
928 modified("serverhosts");
932 static int fnchecklen;
934 void fsmatch(int id, void *nfsphys, void *filesys)
936 struct nfsphys *n = nfsphys;
937 struct filesys *f = filesys;
939 if (n->mach_id == f->mach_id &&
940 !strncmp(f->dir, n->dir, strlen(n->dir)) &&
941 strlen(n->dir) > fnchecklen)
944 fnchecklen = strlen(n->dir);
949 void check_fs(int id, void *filesys, void *hint)
951 EXEC SQL BEGIN DECLARE SECTION;
952 int iid = id, id1, id2, id3, rowcount;
954 EXEC SQL END DECLARE SECTION;
955 struct filesys *f = filesys;
959 if (!hash_lookup(machines, f->mach_id))
961 printf("Filesys %s with bad machine %d\n", f->name, f->mach_id);
962 if (single_fix("Fix", 0))
964 EXEC SQL UPDATE filesys SET mach_id = 0 WHERE filsys_id = :iid;
965 rowcount = sqlca.sqlerrd[2];
967 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
969 printf("Not fixed\n");
975 if (!hash_lookup(users, f->owner))
977 printf("Filesys %s with bad owning user %d\n", f->name, f->owner);
978 if (single_fix("Fix", 1))
980 zero_fix("filesys", "owner", "filsys_id", f->filsys_id);
984 if (!hash_lookup(lists, f->owners))
986 printf("Filesys %s with bad owning group %d\n", f->name, f->owners);
987 if (single_fix("Fix", 1))
989 zero_fix("filesys", "owners", "filsys_id", f->filsys_id);
996 if (!hash_lookup(nfsphys, f->phys_id))
998 m = hash_lookup(machines, f->mach_id);
999 printf("Filesys %s with bad phys_id %d\n", f->name, f->phys_id);
1000 if (single_fix("Fix", 1))
1003 hash_step(nfsphys, fsmatch, f);
1004 if (fnchecklen != 0)
1009 EXEC SQL UPDATE filesys SET phys_id = :id1
1010 WHERE filsys_id = :id2;
1011 rowcount = sqlca.sqlerrd[2];
1013 printf("%d entr%s fixed\n", rowcount,
1014 rowcount == 1 ? "y" : "ies");
1016 printf("Not fixed\n");
1017 modified("filesys");
1021 printf("No NFSphys exsits for %s:%s\n", m->name, f->dir);
1022 if (single_fix("Create", 0))
1028 if (set_next_object_id("nfsphys_id", "nfsphys") !=
1031 printf("Unable to assign unique ID\n");
1034 EXEC SQL SELECT COUNT(*) INTO :rowcount FROM numvalues
1035 WHERE name = 'nfsphys_id';
1038 printf("Unable to retrieve unique ID\n");
1041 EXEC SQL INSERT INTO nfsphys
1042 (nfsphys_id, mach_id, device, dir, status, allocated,
1043 size, modtime, modby, modwith) VALUES
1044 (:id1, :id3, '\?\?\?', :dir, 0, 0, 0, SYSDATE, 0,
1046 rowcount = sqlca.sqlerrd[2];
1049 printf("%d entr%s created\n", rowcount,
1050 rowcount == 1 ? "y" : "ies");
1053 printf("Not created\n");
1054 modified("nfsphys");
1055 n = malloc(sizeof(struct nfsphys));
1057 out_of_mem("storing new nfsphys");
1058 strcpy(n->dir, dir);
1060 n->nfsphys_id = id1;
1063 if (hash_store(nfsphys, id1, n) == -1)
1064 out_of_mem("storing nfsphys in hash table");
1065 EXEC SQL UPDATE filesys SET phys_id = :id1
1066 WHERE filsys_id = :id2;
1067 rowcount = sqlca.sqlerrd[2];
1070 printf("%d filesys entr%s fixed\n", rowcount,
1071 rowcount == 1 ? "y" : "ies");
1074 printf("Not fixed\n");
1075 modified("filesys");
1083 void check_nfsphys(int id, void *nfsphys, void *hint)
1085 struct nfsphys *n = nfsphys;
1087 n->modby = maybe_fixup_modby(n->modby, id, n->dir, "nfsphys",
1088 "modby", "nfsphys_id");
1090 if (!hash_lookup(machines, n->mach_id))
1092 printf("NFSphys %d(%s) on non-existant machine %d\n",
1093 id, n->dir, n->mach_id);
1094 if (single_fix("Delete", 0))
1095 single_delete("nfsphys", "nfsphys_id", id);
1099 int show_fsg_missing(void *id)
1101 EXEC SQL BEGIN DECLARE SECTION;
1102 int iid = (int)id, id1, found = 1;
1103 EXEC SQL END DECLARE SECTION;
1106 EXEC SQL DECLARE csr210 CURSOR FOR
1107 SELECT filsys_id FROM fsgroup
1108 WHERE group_id = :iid;
1109 EXEC SQL OPEN csr210;
1112 EXEC SQL FETCH csr210 INTO :id1;
1117 if ((f = hash_lookup(filesys, id1)))
1118 printf("Missing fsgroup %d has member filesystem %s\n", iid, f->name);
1120 printf("Missing fsgroup %d has member filesystem %d\n", iid, id1);
1122 EXEC SQL CLOSE csr210;
1126 int show_fsg_type(void *filesys)
1128 struct filesys *f = filesys;
1154 printf("FSGroup %s has type %s instead of FSGROUP\n", f->name, t);
1158 void fix_fsg_type(void *filesys)
1160 struct filesys *f = filesys;
1161 EXEC SQL BEGIN DECLARE SECTION;
1162 int rowcount, id = f->filsys_id;
1163 EXEC SQL END DECLARE SECTION;
1165 EXEC SQL UPDATE filesys SET type = 'FSGROUP' WHERE filsys_id = :id;
1166 rowcount = sqlca.sqlerrd[2];
1168 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1170 printf("Not fixed\n");
1171 modified("filesys");
1174 int show_fsg_nomember(void *id)
1176 EXEC SQL BEGIN DECLARE SECTION;
1177 int iid = (int)id, id1, found = 1;
1178 EXEC SQL END DECLARE SECTION;
1181 EXEC SQL DECLARE csr211 CURSOR FOR
1182 SELECT group_id FROM fsgroup
1183 WHERE filsys_id = :iid;
1184 EXEC SQL OPEN csr211;
1187 EXEC SQL FETCH csr211 INTO :id1;
1192 if ((f = hash_lookup(filesys, id1)))
1193 printf("FSGroup %s has missing member %d\n", f->name, iid);
1195 printf("FSGroup %d has missing member %d\n", id1, iid);
1197 EXEC SQL CLOSE csr211;
1201 int show_quota_nouser(void *id)
1203 EXEC SQL BEGIN DECLARE SECTION;
1204 int iid = (int)id, id1, found = 1;
1205 EXEC SQL END DECLARE SECTION;
1207 EXEC SQL DECLARE csr212 CURSOR FOR
1208 SELECT filsys_id FROM quota
1209 WHERE entity_id = :iid AND type = 'USER';
1210 EXEC SQL OPEN csr212;
1213 EXEC SQL FETCH csr212 INTO :id1;
1218 printf("Quota on fs %d for non-existant user %d\n", id1, iid);
1220 EXEC SQL CLOSE csr212;
1224 int show_quota_nolist(void *id)
1226 EXEC SQL BEGIN DECLARE SECTION;
1227 int iid = (int)id, id1, found = 1;
1228 EXEC SQL END DECLARE SECTION;
1230 EXEC SQL DECLARE csr213 CURSOR FOR
1231 SELECT filsys_id FROM quota
1232 WHERE entity_id = :iid AND type = 'GROUP';
1233 EXEC SQL OPEN csr213;
1236 EXEC SQL FETCH csr213 INTO :id1;
1241 printf("Quota on fs %d for non-existant list %d\n", id1, iid);
1243 EXEC SQL CLOSE csr213;
1247 void fix_quota_nouser(void *id)
1249 EXEC SQL BEGIN DECLARE SECTION;
1250 int iid = (int)id, rowcount, id1;
1251 EXEC SQL END DECLARE SECTION;
1253 id1 = ((struct filesys *)hash_lookup(filesys, iid))->phys_id;
1254 EXEC SQL DELETE FROM quota
1255 WHERE entity_id = :iid AND type = 'USER';
1256 rowcount = sqlca.sqlerrd[2];
1258 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1260 printf("Not deleted\n");
1264 void fix_quota_nolist(void *id)
1266 EXEC SQL BEGIN DECLARE SECTION;
1267 int iid = (int)id, rowcount, id1;
1268 EXEC SQL END DECLARE SECTION;
1270 id1 = ((struct filesys *)hash_lookup(filesys, iid))->phys_id;
1271 EXEC SQL DELETE FROM quota WHERE entity_id = :iid AND type = 'GROUP';
1272 rowcount = sqlca.sqlerrd[2];
1274 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1276 printf("Not deleted\n");
1280 int show_quota_nofs(void *id)
1282 EXEC SQL BEGIN DECLARE SECTION;
1283 int iid = (int)id, id1, found = 1;
1284 char type[QUOTA_TYPE_SIZE];
1285 EXEC SQL END DECLARE SECTION;
1287 EXEC SQL DECLARE csr214 CURSOR FOR
1288 SELECT entity_id, type FROM quota
1289 WHERE filsys_id = :iid;
1290 EXEC SQL OPEN csr214;
1293 EXEC SQL FETCH csr214 INTO :id1, :type;
1298 printf("Quota for %s %d on non-existant filesys %d\n", type, id1, iid);
1300 EXEC SQL CLOSE csr214;
1304 void fix_quota_nofs(void *id)
1306 single_delete("quota", "filsys_id", (int)id);
1309 int show_quota_wrongpid(void *id)
1311 EXEC SQL BEGIN DECLARE SECTION;
1312 int iid = (int)id, id1, found = 1;
1313 char type[QUOTA_TYPE_SIZE];
1314 EXEC SQL END DECLARE SECTION;
1317 f = hash_lookup(filesys, iid);
1318 EXEC SQL DECLARE csr215 CURSOR FOR
1319 SELECT entity_id, type FROM quota
1320 WHERE filsys_id = :iid;
1321 EXEC SQL OPEN csr215;
1324 EXEC SQL FETCH csr215 INTO :id1, :type;
1329 printf("Quota for %s %d on filesys %s has wrong phys_id %d\n",
1330 type, id1, f->name, iid);
1332 EXEC SQL CLOSE csr215;
1336 void fix_quota_physid(void *id)
1338 EXEC SQL BEGIN DECLARE SECTION;
1339 int iid = (int)id, rowcount, id1;
1340 EXEC SQL END DECLARE SECTION;
1342 id1 = ((struct filesys *)hash_lookup(filesys, iid))->phys_id;
1343 EXEC SQL UPDATE quota SET phys_id = :id1
1344 WHERE filsys_id = :iid AND phys_id != :id1;
1345 rowcount = sqlca.sqlerrd[2];
1347 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1349 printf("Not fixed\n");
1353 int show_srv_user(void *id)
1355 EXEC SQL BEGIN DECLARE SECTION;
1356 char name[SERVERS_NAME_SIZE];
1358 EXEC SQL END DECLARE SECTION;
1361 EXEC SQL DECLARE csr216 CURSOR FOR
1362 SELECT name FROM servers
1363 WHERE acl_type = 'USER' and acl_id = :iid;
1364 EXEC SQL OPEN csr216;
1367 EXEC SQL FETCH csr216 INTO :name;
1372 printf("Service %s has acl non-existant user %d\n", name, iid);
1375 EXEC SQL CLOSE csr216;
1379 int show_srv_list(void *id)
1381 EXEC SQL BEGIN DECLARE SECTION;
1382 char name[SERVERS_NAME_SIZE];
1384 EXEC SQL END DECLARE SECTION;
1387 EXEC SQL DECLARE csr217 CURSOR FOR
1388 SELECT name FROM servers
1389 WHERE acl_type = 'LIST' AND acl_id = :iid;
1390 EXEC SQL OPEN csr217;
1393 EXEC SQL FETCH csr217 INTO :name;
1398 printf("Service %s has acl non-existant list %d\n", name, iid);
1401 EXEC SQL CLOSE csr217;
1405 void zero_srv_user(void *id)
1407 EXEC SQL BEGIN DECLARE SECTION;
1408 int iid = (int)id, rowcount;
1409 EXEC SQL END DECLARE SECTION;
1411 EXEC SQL UPDATE servers SET acl_id = 0 WHERE acl_id = :iid AND
1413 rowcount = sqlca.sqlerrd[2];
1415 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1417 printf("Not fixed\n");
1418 modified("servers");
1421 void zero_srv_list(void *id)
1423 EXEC SQL BEGIN DECLARE SECTION;
1424 int iid = (int)id, rowcount;
1425 EXEC SQL END DECLARE SECTION;
1427 EXEC SQL UPDATE servers SET acl_id = 0 WHERE acl_id = :iid AND
1429 rowcount = sqlca.sqlerrd[2];
1431 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1433 printf("Not fixed\n");
1434 modified("servers");
1437 int show_krb_usr(void *id)
1439 EXEC SQL BEGIN DECLARE SECTION;
1440 int iid = (int)id, found = 1, id1;
1441 EXEC SQL END DECLARE SECTION;
1445 EXEC SQL DECLARE csr218 CURSOR FOR
1446 SELECT string_id FROM krbmap
1447 WHERE users_id = :iid;
1448 EXEC SQL OPEN csr218;
1451 EXEC SQL FETCH csr218 INTO :id1;
1455 if ((s = hash_lookup(strings, id1)))
1460 printf("Kerberos map for non-existant user %d to principal %s\n",
1463 EXEC SQL CLOSE csr218;
1467 int show_krb_str(void *id)
1469 EXEC SQL BEGIN DECLARE SECTION;
1470 int iid = (int)id, found = 1, id1;
1471 EXEC SQL END DECLARE SECTION;
1475 EXEC SQL DECLARE csr219 CURSOR FOR
1476 SELECT users_id FROM krbmap
1477 WHERE string_id = :iid;
1478 EXEC SQL OPEN csr219;
1481 EXEC SQL FETCH csr219 INTO :id1;
1485 if ((u = hash_lookup(users, id1)))
1490 printf("Kerberos map for user %s (%d) to non-existant string %d\n",
1493 EXEC SQL CLOSE csr219;
1497 int show_pdm_mach(void *id)
1499 EXEC SQL BEGIN DECLARE SECTION;
1500 char name[PALLADIUM_NAME_SIZE];
1502 EXEC SQL END DECLARE SECTION;
1505 EXEC SQL DECLARE csr220 CURSOR FOR
1506 SELECT name FROM palladium
1507 WHERE mach_id = :iid;
1508 EXEC SQL OPEN csr220;
1511 EXEC SQL FETCH csr220 INTO :name;
1516 printf("Palladium server/supervisor %s is on non-existant machine %d\n",
1520 EXEC SQL CLOSE csr220;
1527 struct save_queue *sq, *sq1, *sq2, *sq3, *sq4, *sq5;
1533 printf("Phase 2 - Checking references\n");
1535 dprintf("Checking users...\n");
1536 hash_step(users, user_check, NULL);
1538 dprintf("Checking machines...\n");
1539 hash_step(machines, mach_check, NULL);
1541 dprintf("Checking subnets...\n");
1542 hash_step(subnets, subnet_check, NULL);
1544 dprintf("Checking clusters...\n");
1545 hash_step(clusters, cluster_check, NULL);
1547 dprintf("Checking mcmap...\n");
1550 EXEC SQL DECLARE csr221 CURSOR FOR
1551 SELECT mach_id, clu_id FROM mcmap;
1552 EXEC SQL OPEN csr221;
1555 EXEC SQL BEGIN DECLARE SECTION;
1556 int mach_id, clu_id;
1557 EXEC SQL END DECLARE SECTION;
1559 EXEC SQL FETCH csr221 INTO :mach_id, :clu_id;
1563 if (!(m = hash_lookup(machines, mach_id)))
1564 sq_save_unique_data(sq1, (void *)mach_id);
1565 else if (!hash_lookup(clusters, clu_id))
1566 sq_save_unique_data(sq2, (void *)clu_id);
1570 EXEC SQL CLOSE csr221;
1571 generic_delete(sq1, show_mcm_mach, "mcmap", "mach_id", 1);
1572 generic_delete(sq2, show_mcm_clu, "mcmap", "clu_id", 1);
1574 dprintf("Checking service clusters...\n");
1576 EXEC SQL DECLARE csr222 CURSOR FOR
1577 SELECT clu_id FROM svc;
1578 EXEC SQL OPEN csr222;
1581 EXEC SQL BEGIN DECLARE SECTION;
1583 EXEC SQL END DECLARE SECTION;
1585 EXEC SQL FETCH csr222 INTO :clu_id;
1589 if (!hash_lookup(clusters, clu_id))
1590 sq_save_unique_data(sq1, (void *)clu_id);
1592 EXEC SQL CLOSE csr222;
1593 generic_delete(sq1, show_svc, "svc", "clu_id", 1);
1595 dprintf("Checking lists...\n");
1596 hash_step(lists, list_check, NULL);
1598 dprintf("Checking members...\n");
1605 EXEC SQL DECLARE csr223 CURSOR FOR
1606 SELECT list_id, member_type, member_id, ref_count, direct
1607 FROM imembers FOR UPDATE OF member_id;
1608 EXEC SQL OPEN csr223;
1611 EXEC SQL BEGIN DECLARE SECTION;
1612 int list_id, id, ref_count, direct;
1613 char type[IMEMBERS_MEMBER_TYPE_SIZE];
1614 EXEC SQL END DECLARE SECTION;
1616 EXEC SQL FETCH csr223 INTO :list_id, :type, :id,
1617 :ref_count, :direct;
1621 if (!(l = hash_lookup(lists, list_id)))
1622 sq_save_unique_data(sq1, (void *)list_id);
1623 else if (type[0] == 'U' && !hash_lookup(users, id))
1624 sq_save_unique_data(sq2, (void *)id);
1625 else if (type[0] == 'L' && !hash_lookup(lists, id))
1626 sq_save_unique_data(sq3, (void *)id);
1627 else if (type[0] == 'S' && !maybe_fixup_unref_string2("imembers", "member_id", "csr223", id))
1628 sq_save_unique_data(sq4, (void *)id);
1629 else if (type[0] == 'K' && !maybe_fixup_unref_string2("imembers", "member_id", "csr223", id))
1630 sq_save_unique_data(sq5, (void *)id);
1634 EXEC SQL CLOSE csr223;
1635 generic_delete(sq1, show_member_list, "imembers", "list_id", 1);
1636 generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1);
1637 generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1);
1638 generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1);
1639 generic_fix(sq5, show_mem_krb, "Delete", del_mem_krb, 1);
1641 dprintf("Checking servers...\n");
1644 EXEC SQL DECLARE csr224 CURSOR FOR
1645 SELECT name, acl_type, acl_id, modby FROM servers
1646 FOR UPDATE of modby;
1647 EXEC SQL OPEN csr224;
1650 EXEC SQL BEGIN DECLARE SECTION;
1652 char name[SERVERS_NAME_SIZE], acl_type[SERVERS_ACL_TYPE_SIZE];
1653 EXEC SQL END DECLARE SECTION;
1655 EXEC SQL FETCH csr224 INTO :name, :acl_type, :acl_id, :modby;
1659 maybe_fixup_modby2("servers", "modby", "csr224", modby);
1661 if (!strcmp(acl_type, "USER") && !hash_lookup(users, acl_id))
1662 sq_save_data(sq1, (void *)acl_id);
1663 else if (!strcmp(acl_type, "LIST") && !hash_lookup(lists, acl_id))
1664 sq_save_data(sq2, (void *)acl_id);
1666 EXEC SQL CLOSE csr224;
1667 generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
1668 generic_fix(sq2, show_srv_list, "Fix", zero_srv_list, 1);
1670 dprintf("Checking serverhosts...\n");
1672 EXEC SQL DECLARE csr225 CURSOR FOR
1673 SELECT mach_id, modby FROM serverhosts
1674 FOR UPDATE OF modby;
1675 EXEC SQL OPEN csr225;
1678 EXEC SQL BEGIN DECLARE SECTION;
1680 EXEC SQL END DECLARE SECTION;
1682 EXEC SQL FETCH csr225 INTO :mach_id, :modby;
1686 maybe_fixup_modby2("serverhosts", "modby", "csr225", modby);
1687 if (!hash_lookup(machines, mach_id))
1688 sq_save_data(sq, (void *)mach_id);
1690 EXEC SQL CLOSE csr225;
1691 generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
1693 dprintf("Checking nfsphys...\n");
1694 hash_step(nfsphys, check_nfsphys, NULL);
1696 dprintf("Checking filesys...\n");
1697 hash_step(filesys, check_fs, NULL);
1699 dprintf("Checking filesystem groups...\n");
1703 EXEC SQL DECLARE csr226 CURSOR FOR
1704 SELECT group_id, filsys_id FROM fsgroup;
1705 EXEC SQL OPEN csr226;
1708 EXEC SQL BEGIN DECLARE SECTION;
1709 int group_id, filsys_id;
1710 EXEC SQL END DECLARE SECTION;
1712 EXEC SQL FETCH csr226 INTO :group_id, :filsys_id;
1716 if (!(f = hash_lookup(filesys, group_id)))
1717 sq_save_data(sq1, (void *)group_id);
1718 if (!hash_lookup(filesys, filsys_id))
1719 sq_save_data(sq3, (void *)filsys_id);
1721 EXEC SQL CLOSE csr226;
1722 generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0);
1723 generic_delete(sq3, show_fsg_nomember, "fsgroup", "filsys_id", 1);
1725 dprintf("Checking quotas...\n");
1730 EXEC SQL DECLARE csr227 CURSOR FOR
1731 SELECT entity_id, type, filsys_id, phys_id, quota, modby
1732 FROM quota FOR UPDATE OF modby;
1733 EXEC SQL OPEN csr227;
1736 EXEC SQL BEGIN DECLARE SECTION;
1737 int entity_id, filsys_id, phys_id, quota, modby;
1738 char type[QUOTA_TYPE_SIZE];
1739 EXEC SQL END DECLARE SECTION;
1741 EXEC SQL FETCH csr227 INTO :entity_id, :type, :filsys_id,
1742 :phys_id, :quota, :modby;
1746 maybe_fixup_modby2("quota", "modby", "csr227", modby);
1747 if (type[0] == 'U' && entity_id != 0 && !hash_lookup(users, entity_id))
1748 sq_save_data(sq1, (void *)entity_id);
1749 else if (type[0] == 'G' && !hash_lookup(lists, entity_id))
1750 sq_save_data(sq4, (void *)entity_id);
1751 else if (!(f = hash_lookup(filesys, filsys_id)))
1752 sq_save_data(sq2, (void *)filsys_id);
1753 else if (phys_id != f->phys_id || !(n = hash_lookup(nfsphys, phys_id)))
1754 sq_save_data(sq3, (void *)phys_id);
1758 EXEC SQL CLOSE csr227;
1759 generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1);
1760 generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0);
1761 generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1);
1762 generic_fix(sq4, show_quota_nolist, "Delete", fix_quota_nolist, 1);
1764 dprintf("Not checking zephyr.\n");
1766 dprintf("Checking hostaccess...\n");
1767 EXEC SQL DECLARE csr228 CURSOR FOR
1768 SELECT mach_id, acl_type, acl_id, modby FROM hostaccess
1769 FOR UPDATE OF modby;
1770 EXEC SQL OPEN csr228;
1773 EXEC SQL BEGIN DECLARE SECTION;
1774 int mach_id, acl_id, modby;
1775 char acl_type[HOSTACCESS_ACL_TYPE_SIZE];
1776 EXEC SQL END DECLARE SECTION;
1778 EXEC SQL FETCH csr228 INTO :mach_id, :acl_type, :acl_id, :modby;
1782 maybe_fixup_modby2("hostaccess", "modby", "csr228", modby);
1784 if (!hash_lookup(machines, mach_id))
1786 printf("Hostaccess for non-existant host %d\n", mach_id);
1787 printf("Not fixing this error\n");
1789 if (!strcmp(acl_type, "USER") && !hash_lookup(users, acl_id))
1791 printf("Hostaccess for %d is non-existant user %d\n", mach_id, acl_id);
1792 printf("Not fixing this error\n");
1794 else if (!strcmp(acl_type, "LIST") && !hash_lookup(lists, acl_id))
1796 printf("Hostaccess for %d is non-existant list %d\n", mach_id, acl_id);
1797 printf("Not fixing this error\n");
1800 EXEC SQL CLOSE csr228;
1802 dprintf("Checking palladium...\n");
1804 EXEC SQL DECLARE csr229 CURSOR FOR
1805 SELECT mach_id, modby FROM palladium
1806 FOR UPDATE OF modby;
1807 EXEC SQL OPEN csr229;
1810 EXEC SQL BEGIN DECLARE SECTION;
1812 EXEC SQL END DECLARE SECTION;
1814 EXEC SQL FETCH csr229 INTO :mach_id, :modby;
1818 maybe_fixup_modby2("palladium", "modby", "csr229", modby);
1819 if (!hash_lookup(machines, mach_id))
1820 sq_save_unique_data(sq1, (void *)mach_id);
1822 EXEC SQL CLOSE csr229;
1823 generic_delete(sq1, show_pdm_mach, "palladium", "mach_id", 1);
1825 dprintf("Checking krbmap...\n");
1828 EXEC SQL DECLARE csr230 CURSOR FOR
1829 SELECT users_id, string_id FROM krbmap
1830 FOR UPDATE OF string_id;
1831 EXEC SQL OPEN csr230;
1834 EXEC SQL BEGIN DECLARE SECTION;
1835 int users_id, string_id;
1836 EXEC SQL END DECLARE SECTION;
1838 EXEC SQL FETCH csr230 INTO :users_id, :string_id;
1842 if (!hash_lookup(users, users_id))
1843 sq_save_unique_data(sq1, (void *)users_id);
1844 else if (!maybe_fixup_unref_string2("krbmap", "string_id", "csr230", string_id))
1845 sq_save_unique_data(sq2, (void *)string_id);
1847 EXEC SQL CLOSE csr230;
1848 generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1);
1849 generic_delete(sq2, show_krb_str, "krbmap", "string_id", 1);
1851 dprintf("Checking capacls...\n");
1852 EXEC SQL DECLARE csr231 CURSOR FOR
1853 SELECT list_id, tag FROM capacls;
1854 EXEC SQL OPEN csr231;
1857 EXEC SQL BEGIN DECLARE SECTION;
1859 char tag[CAPACLS_TAG_SIZE];
1860 EXEC SQL END DECLARE SECTION;
1862 EXEC SQL FETCH csr231 INTO :list_id, :tag;
1866 if (!hash_lookup(lists, list_id))
1868 printf("Capacl for %s is non-existant list %d\n", tag, list_id);
1869 printf("Not fixing this error\n");
1872 EXEC SQL CLOSE csr231;
1874 dprintf("Checking hostaliases\n");
1876 EXEC SQL DECLARE csr232 CURSOR FOR
1877 SELECT mach_id FROM hostalias;
1878 EXEC SQL OPEN csr232;
1881 EXEC SQL BEGIN DECLARE SECTION;
1883 EXEC SQL END DECLARE SECTION;
1885 EXEC SQL FETCH csr232 INTO :mach_id;
1889 if (!hash_lookup(machines, mach_id))
1890 sq_save_unique_data(sq1, (void *)mach_id);
1892 EXEC SQL CLOSE csr232;
1893 generic_delete(sq1, show_hostalias, "hostalias", "mach_id", 1);
1895 dprintf("Checking printcaps\n");
1898 EXEC SQL DECLARE csr233 CURSOR FOR
1899 SELECT mach_id, quotaserver, modby FROM printcap;
1900 EXEC SQL OPEN csr233;
1903 EXEC SQL BEGIN DECLARE SECTION;
1904 int mach_id, quotaserver, modby;
1905 EXEC SQL END DECLARE SECTION;
1907 EXEC SQL FETCH csr233 INTO :mach_id, :quotaserver, :modby;
1911 maybe_fixup_modby2("printcap", "modby", "csr233", modby);
1912 if (!hash_lookup(machines, mach_id))
1913 sq_save_unique_data(sq1, (void *)mach_id);
1914 else if (!hash_lookup(machines, quotaserver))
1915 sq_save_unique_data(sq2, (void *)quotaserver);
1917 EXEC SQL CLOSE csr233;
1918 generic_delete(sq1, show_pcap_mach, "printcap", "mach_id", 1);
1919 generic_delete(sq2, show_pcap_quota, "printcap", "quotaserver", 1);