3 * (c) Copyright 1988 by the Massachusetts Institute of Technology.
4 * For copying and distribution information, please see the file
8 #include <mit-copyright.h>
13 static char phase2_qc_rcsid[] = "$Header$";
19 ## int iid = id, found = 1;
22 ## retrieve (name = cluster.#name) where cluster.clu_id = mcmap.clu_id
23 ## and mcmap.mach_id = iid {
26 printf("Cluster %s, non-existant machine %d in cluster map\n", name, id);
34 ## int iid = id, found = 1;
37 ## retrieve (name = machine.#name) where machine.mach_id = mcmap.mach_id
38 ## and mcmap.clu_id = iid {
41 printf("Machine %s, non-existant cluster %d in cluster map\n", name, id);
46 pobox_check(id, u, hint)
53 if (!hash_lookup(machines, u->pobox_id)) {
54 printf("User %s(%s) has P.O.Box on non-existant machine %d\n",
55 u->login, u->fullname, u->pobox_id);
56 if (single_fix("Delete", 0)) {
57 remove_pobox(u->users_id);
63 if (!string_check(u->pobox_id)) {
64 printf("User %s(%s) has P.O.Box with non-existant string %d\n",
65 u->login, u->fullname, u->pobox_id);
66 if (single_fix("Delete", 0)) {
67 remove_pobox(u->users_id);
81 ## int rowcount, iid = id;
82 ## replace users (potype = "NONE") where users.users_id = iid
83 ## inquire_equel(rowcount = "rowcount")
85 printf("%d entr%s removed\n", rowcount, rowcount==1?"y":"ies");
87 printf("Not removed\n");
94 ## int iid = id, found = 1;
95 ## char label[17], data[33];
97 ## retrieve (label = svc.serv_label, data = svc.serv_cluster)
98 ## where svc.clu_id = iid {
102 printf("Cluster data [%s] %s for non-existant cluster %d\n",
108 list_check(id, l, hint)
113 switch (l->acl_type) {
115 if (!hash_lookup(lists, l->acl_id)) {
116 printf("List %s has bad LIST acl %d\n", l->name, l->acl_id);
117 if (single_fix("Patch", 1)) {
118 fix_list_acl(l->list_id);
123 if (!hash_lookup(users, l->acl_id)) {
124 printf("List %s has bad USER acl %d\n", l->name, l->acl_id);
125 if (single_fix("Patch", 1)) {
126 fix_list_acl(l->list_id);
136 ## int rowcount, iid = id;
137 ## replace list (acl_id = iid, acl_type = "LIST") where list.list_id = iid
138 ## inquire_equel(rowcount = "rowcount")
140 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
142 printf("Not fixed\n");
150 ## int mid, iid = id, found = 1;
151 ## char mtype[9], *name = "";
153 ## retrieve (mtype = imembers.member_type, mid = imembers.member_id)
154 ## where imembers.list_id = iid and imembers.direct = 1 {
158 name = ((struct list *) hash_lookup(lists, mid))->name;
159 else if (mtype[0] == 'U')
160 name = ((struct user *) hash_lookup(users, mid))->login;
161 else if (mtype[0] == 'S' || mtype[0] == 'K')
162 name = ((struct string *) hash_lookup(strings, mid))->name;
163 printf("Non-existant list %d has member %s %s\n", iid, mtype, name);
171 ## int lid, iid = id, found = 1;
174 ## retrieve (lid = imembers.list_id)
175 ## where imembers.member_id = iid and imembers.member_type = "USER" and
176 ## imembers.direct = 1 {
178 printf("List %s has non-existant user member, id %d\n",
179 ((struct list *)hash_lookup(lists, lid))->name, iid);
187 ## int lid, iid = id, found = 1;
190 ## retrieve (lid = imembers.list_id)
191 ## where imembers.member_id = iid and imembers.member_type = "LIST" and
192 ## imembers.direct = 1 {
194 printf("List %s has non-existant list member, id %d\n",
195 ((struct list *)hash_lookup(lists, lid))->name, iid);
203 ## int lid, iid = id, found = 1;
206 ## retrieve (lid = imembers.list_id)
207 ## where imembers.member_id = iid and imembers.member_type = "STRING" and
208 ## imembers.direct = 1 {
210 printf("List %s has non-existant string member, id %d\n",
211 ((struct list *)hash_lookup(lists, lid))->name, iid);
220 ## int lid, iid = id, found = 1;
223 ## retrieve (lid = imembers.list_id)
224 ## where imembers.member_id = iid and imembers.member_type = "KERBEROS" and
225 ## imembers.direct = 1 {
227 printf("List %s has non-existant kerberos member, id %d\n",
228 ((struct list *)hash_lookup(lists, lid))->name, iid);
239 ## delete imembers where imembers.member_type = "USER" and
240 ## imembers.member_id = id and imembers.direct = 1
241 ## inquire_equel(rowcount = "rowcount");
243 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
245 printf("Not deleted\n");
246 modified("imembers");
254 ## delete imembers where imembers.member_type = "LIST" and
255 ## imembers.member_id = id and imembers.direct = 1
256 ## inquire_equel(rowcount = "rowcount");
258 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
260 printf("Not deleted\n");
261 modified("imembers");
269 ## delete imembers where imembers.member_type = "STRING" and
270 ## imembers.member_id = id and imembers.direct = 1
271 ## inquire_equel(rowcount = "rowcount");
273 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
275 printf("Not deleted\n");
276 modified("imembers");
285 ## delete imembers where imembers.member_type = "KERBEROS" and
286 ## imembers.member_id = id and imembers.direct = 1
287 ## inquire_equel(rowcount = "rowcount");
289 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
291 printf("Not deleted\n");
292 modified("imembers");
302 ## retrieve (name = serverhosts.service) where serverhosts.mach_id = id {
304 printf("ServerHost entry for service %s non-existant host %d\n",
315 ## delete serverhosts where serverhosts.mach_id = id
316 ## inquire_equel(rowcount = "rowcount");
318 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
320 printf("Not deleted\n");
321 modified("serverhosts");
325 static int fnchecklen;
332 if (n->mach_id == f->mach_id &&
333 !strncmp(f->dir, n->dir, strlen(n->dir)) &&
334 strlen(n->dir) > fnchecklen) {
336 fnchecklen = strlen(n->dir);
341 ##check_fs(id, f, hint)
343 register struct filesys *f;
346 ## int id1, id2, id3, rowcount;
351 if (!hash_lookup(machines, f->mach_id)) {
352 printf("Filesys %s with bad machine %d\n", f->name, f->mach_id);
353 if (single_fix("Fix", 0)) {
354 ## replace filesys (mach_id = 0) where filesys.filsys_id = id
355 ## inquire_equel(rowcount = "rowcount")
357 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
359 printf("Not fixed\n");
365 if (!hash_lookup(users, f->owner)) {
366 printf("Filesys %s with bad owning user %d\n", f->name, f->owner);
367 if (single_fix("Fix", 1)) {
368 zero_fix("filesys", "owner", "filsys_id", f->filsys_id);
372 if (!hash_lookup(lists, f->owners)) {
373 printf("Filesys %s with bad owning group %d\n", f->name, f->owners);
374 if (single_fix("Fix", 1)) {
375 zero_fix("filesys", "owners", "filsys_id", f->filsys_id);
380 if (f->type == 'N') {
381 if (!hash_lookup(nfsphys, f->phys_id)) {
382 m = (struct machine *)hash_lookup(machines, f->mach_id);
383 printf("Filesys %s with bad phys_id %d\n", f->name, f->phys_id);
384 if (single_fix("Fix", 1)) {
386 hash_step(nfsphys, fsmatch, f);
387 if (fnchecklen != 0) {
391 ## replace filesys (phys_id = id1) where filesys.filsys_id = id2
392 ## inquire_equel(rowcount = "rowcount")
394 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
396 printf("Not fixed\n");
399 printf("No NFSphys exsits for %s:%s\n", m->name, f->dir);
400 if (single_fix("Create", 0)) {
405 if (set_next_object_id("nfsphys_id", "nfsphys") !=
407 printf("Unable to assign unique ID\n");
410 ## retrieve (id1 = values.value)
411 ## where values.name = "nfsphys_id"
412 ## inquire_equel(rowcount = "rowcount")
414 printf("Unable to retrieve unique ID\n");
417 ## append nfsphys (nfsphys_id = id1, mach_id = id3,
418 ## device = "???", #dir = dir, status = 0,
419 ## allocated = 0, size = 0,
420 ## modtime = "now", modby = 0,
422 ## inquire_equel(rowcount = "rowcount")
424 printf("%d entr%s created\n", rowcount,
425 rowcount==1?"y":"ies");
427 printf("Not created\n");
429 n = (struct nfsphys *)malloc(sizeof(struct nfsphys));
431 out_of_mem("storing new nfsphys");
437 hash_store(nfsphys, id1, n);
438 ## replace filesys (phys_id = id1)
439 ## where filesys.filsys_id = id2
440 ## inquire_equel(rowcount = "rowcount")
442 printf("%d filesys entr%s fixed\n", rowcount,
443 rowcount==1?"y":"ies");
445 printf("Not fixed\n");
455 check_nfsphys(id, n, hint)
460 if (!hash_lookup(machines, n->mach_id)) {
461 printf("NFSphys %d(%s) on non-existant machine %d\n",
462 id, n->dir, n->mach_id);
463 if (single_fix("Delete", 0))
464 single_delete("nfsphys", "nfsphys_id", id);
468 ##show_fsg_missing(id)
471 ## int id1, found = 1;
474 ## retrieve (id1 = fsgroup.filsys_id) where fsgroup.group_id = id {
476 if (f = (struct filesys *) hash_lookup(filesys, id1))
477 printf("Missing fsgroup %d has member filesystem %s\n", id, f->name);
479 printf("Missing fsgroup %d has member filesystem %d\n", id, id1);
511 printf("FSGroup %s has type %s instead of FSGROUP\n", f->name, t);
518 ## int rowcount, id = f->filsys_id;
520 ## replace filesys (type = "FSGROUP") where filesys.filsys_id = id
521 ## inquire_equel(rowcount = "rowcount")
523 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
525 printf("Not fixed\n");
529 ##show_fsg_nomember(id)
532 ## int id1, found = 1;
535 ## retrieve (id1 = fsgroup.group_id) where fsgroup.filsys_id = id {
537 if (f = (struct filesys *) hash_lookup(filesys, id1))
538 printf("FSGroup %s has missing member %d\n", f->name, id);
540 printf("FSGroup %d has missing member %d\n", id1, id);
545 ##show_quota_nouser(id)
548 ## int id1, found = 1;
550 ## retrieve (id1 = quota.filsys_id) where quota.entity_id = id and
551 ## quota.type = "USER" {
553 printf("Quota on fs %d for non-existant user %d\n", id1, id);
558 ##show_quota_nolist(id)
561 ## int id1, found = 1;
563 ## retrieve (id1 = quota.filsys_id) where quota.entity_id = id and
564 ## quota.type = "GROUP" {
566 printf("Quota on fs %d for non-existant list %d\n", id1, id);
571 ##fix_quota_nouser(id)
574 ## int rowcount, id1;
576 id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
577 ## delete quota where quota.entity_id = id and quota.type = "USER"
578 ## inquire_equel(rowcount = "rowcount")
580 printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies");
582 printf("Not deleted\n");
586 ##fix_quota_nolist(id)
589 ## int rowcount, id1;
591 id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
592 ## delete quota where quota.entity_id = id and quota.type = "GROUP"
593 ## inquire_equel(rowcount = "rowcount")
595 printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies");
597 printf("Not deleted\n");
601 ##show_quota_nofs(id)
604 ## int id1, found = 1;
607 ## retrieve (id1 = quota.entity_id, type = quota.#type)
608 ## where quota.filsys_id = id {
610 printf("Quota for %s %d on non-existant filesys %d\n", type, id1, id);
617 single_delete("quota", "filsys_id", id);
620 ##show_quota_wrongpid(id)
623 ## int id1, found = 1;
628 f = (struct filesys *)hash_lookup(filesys, id);
629 ## retrieve (id1 = quota.entity_id, type = quota.#type)
630 ## where quota.filsys_id = id {
632 printf("Quota for %s %d on filesys %s has wrong phys_id %d\n",
633 type, id1, f->name, id);
638 ##fix_quota_physid(id)
641 ## int rowcount, id1;
643 id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
644 ## replace quota (phys_id = id1) where quota.filsys_id = id and
645 ## quota.phys_id != id1
646 ## inquire_equel(rowcount = "rowcount")
648 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
650 printf("Not fixed\n");
660 ## retrieve (name = s.#name) where s.acl_type = "USER" and s.acl_id = id {
662 printf("Service %s has acl non-existant user %d\n", name, id);
674 ## retrieve (name = s.#name) where s.acl_type = "LIST" and s.acl_id = id {
676 printf("Service %s has acl non-existant list %d\n", name, id);
687 ## replace servers (acl_id = 0) where servers.acl_id = id and
688 ## servers.acl_type = "USER"
689 ## inquire_equel(rowcount = "rowcount")
691 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
693 printf("Not fixed\n");
702 ## replace servers (acl_id = 0) where servers.acl_id = id and
703 ## servers.acl_type = "LIST"
704 ## inquire_equel(rowcount = "rowcount")
706 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
708 printf("Not fixed\n");
716 ## int found = 1, id1;
720 ## retrieve (id1 = krbmap.string_id) where krbmap.users_id = id {
721 if (s = ((struct string *)hash_lookup(strings, id1)))
726 printf("Kerberos map for non-existant user %d to principal %s\n",
736 ## int found = 1, id1;
740 ## retrieve (id1 = krbmap.users_id) where krbmap.string_id = id {
741 if (u = ((struct user *)hash_lookup(users, id1)))
746 printf("Kerberos map for user %s (%d) to non-existant string %d\n",
759 ## retrieve (name = palladium.#name) where palladium.mach_id = id {
761 printf("Palladium server/supervisor %s is on non-existant machine %d\n",
771 ## int id1, id2, id3, id4, id5;
772 ## char type[9], name[33];
773 struct save_queue *sq, *sq1, *sq2, *sq3, *sq4, *sq5;
779 printf("Phase 2 - Checking references\n");
781 dprintf("Checking users...\n");
782 hash_step(users, pobox_check, NULL);
784 dprintf("Checking mcmap...\n");
787 ## retrieve (id1 = mcmap.mach_id, id2 = mcmap.clu_id) {
788 if (!(m = (struct machine *)hash_lookup(machines, id1)))
789 sq_save_unique_data(sq1, id1);
790 if (!hash_lookup(clusters, id2))
791 sq_save_unique_data(sq2, id2);
792 if (m) m->clucount++;
794 generic_delete(sq1, show_mcm_mach, "mcmap", "mach_id", 1);
795 generic_delete(sq2, show_mcm_clu, "mcmap", "clu_id", 1);
797 dprintf("Checking service clusters...\n");
799 ## retrieve (id1 = svc.clu_id) {
800 if (!hash_lookup(clusters, id1))
801 sq_save_unique_data(sq1, id1);
803 generic_delete(sq1, show_svc, "svc", "clu_id", 1);
805 dprintf("Checking lists...\n");
806 hash_step(lists, list_check, NULL);
808 dprintf("Checking members...\n");
814 ## range of m is imembers
815 ## retrieve (id1 = m.list_id, type = m.member_type, id2 = m.member_id,
816 ## id3 = m.ref_count, id4 = m.direct) {
817 if ((l = (struct list *) hash_lookup(lists, id1)) == NULL)
818 sq_save_unique_data(sq1, id1);
819 else if (type[0] == 'U' && !hash_lookup(users, id2))
820 sq_save_unique_data(sq2, id2);
821 else if (type[0] == 'L' && !hash_lookup(lists, id2))
822 sq_save_unique_data(sq3, id2);
823 else if (type[0] == 'S' && !string_check(id2))
824 sq_save_unique_data(sq4, id2);
825 else if (type[0] == 'K' && !string_check(id2))
826 sq_save_unique_data(sq5, id2);
830 generic_delete(sq1, show_member_list, "imembers", "list_id", 1);
831 generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1);
832 generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1);
833 generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1);
834 generic_fix(sq5, show_mem_krb, "Delete", del_mem_krb, 1);
836 dprintf("Checking servers...\n");
839 ## range of s is servers
840 ## retrieve (name = s.#name, type = s.acl_type, id1 = s.acl_id) {
842 if (!strcmp(type, "USER") && !hash_lookup(users, id1)) {
843 sq_save_data(sq1, id1);
844 } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id1)) {
845 sq_save_data(sq2, id1);
848 generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
849 generic_fix(sq2, show_srv_list, "Fix", zero_srv_list, 1);
851 dprintf("Checking servershosts...\n");
853 ## retrieve (id1 = serverhosts.mach_id) {
854 if (!hash_lookup(machines, id1))
855 sq_save_data(sq, id1);
857 generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
859 dprintf("Checking nfsphys...\n");
860 hash_step(nfsphys, check_nfsphys, NULL);
862 dprintf("Checking filesys...\n");
863 hash_step(filesys, check_fs, NULL);
865 dprintf("Checking filesystem groups...\n");
869 ## retrieve (id1 = fsgroup.group_id, id2 = fsgroup.filsys_id) {
870 if (!(f = (struct filesys *) hash_lookup(filesys, id1)))
871 sq_save_data(sq1, id1);
872 if (!hash_lookup(filesys, id2))
873 sq_save_data(sq3, id2);
875 generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0);
876 generic_delete(sq3, show_fsg_nomember, "fsgroup", "filsys_id", 1);
878 dprintf("Checking quotas...\n");
883 ## retrieve (id1 = quota.entity_id, type = quota.#type, id2 = quota.filsys_id,
884 ## id3 = quota.phys_id, id4 = quota.quota) {
885 if (type[0] == 'U' && id1 != 0 && !hash_lookup(users, id1))
886 sq_save_data(sq1, id1);
887 else if (type[0] == 'G' && !hash_lookup(lists, id1))
888 sq_save_data(sq4, id1);
889 else if (!(f = (struct filesys *) hash_lookup(filesys, id2)))
890 sq_save_data(sq2, id2);
891 else if (id3 != f->phys_id ||
892 ((n = (struct nfsphys*) hash_lookup(nfsphys, id3)) ==
893 (struct nfsphys *)NULL))
894 sq_save_data(sq3, id2);
898 generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1);
899 generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0);
900 generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1);
901 generic_fix(sq4, show_quota_nolist, "Delete", fix_quota_nolist, 1);
903 dprintf("Not checking zephyr.\n");
905 dprintf("Checking hostaccess...\n");
906 ## range of h is hostaccess
907 ## retrieve (id1 = h.mach_id, type = h.acl_type, id2 = h.acl_id) {
909 if (!hash_lookup(machines, id1)) {
910 printf("Hostaccess for non-existant host %d\n", id1);
911 printf("Not fixing this error\n");
913 if (!strcmp(type, "USER") && !hash_lookup(users, id2)) {
914 printf("Hostaccess for %d is non-existant user %d\n", id1, id2);
915 printf("Not fixing this error\n");
916 } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2)) {
917 printf("Hostaccess for %d is non-existant list %d\n", id1, id2);
918 printf("Not fixing this error\n");
922 dprintf("Checking palladium...\n");
924 ## range of p is palladium
925 ## retrieve (id1 = p.mach_id) {
926 if (!hash_lookup(machines, id1)) {
927 sq_save_unique_data(sq1, id1);
930 generic_delete(sq1, show_pdm_mach, "palladium", "mach_id", 1);
932 dprintf("Checking krbmap...\n");
935 ## range of k is krbmap
936 ## retrieve (id1 = k.users_id, id2 = k.string_id) {
937 if (!hash_lookup(users, id1))
938 sq_save_unique_data(sq1, id1);
939 if (!string_check(id2))
940 sq_save_unique_data(sq2, id2);
942 generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1);
943 generic_delete(sq2, show_krb_str, "krbmap", "string_id", 1);
945 dprintf("Checking capacls...\n");
946 ## retrieve (id1 = capacls.list_id, name = capacls.tag) {
947 if (!hash_lookup(lists, id1)) {
948 printf("Capacl for %s is non-existant list %d\n", name, id1);
949 printf("Not fixing this error\n");