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 (f->type == 'N' || f->type == 'R') {
352 if (!hash_lookup(machines, f->mach_id)) {
353 printf("Filesys %s with bad machine %d\n", f->name, f->mach_id);
354 if (single_fix("Fix", 0)) {
355 ## replace filesys (mach_id = 0) where filesys.filsys_id = id
356 ## inquire_equel(rowcount = "rowcount")
358 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
360 printf("Not fixed\n");
366 if (f->type == 'N' || f->type == 'R' || f->type == 'A') {
367 if (!hash_lookup(users, f->owner)) {
368 printf("Filesys %s with bad owning user %d\n", f->name, f->owner);
369 if (single_fix("Fix", 1)) {
370 zero_fix("filesys", "owner", "filsys_id", f->filsys_id);
374 if (!hash_lookup(lists, f->owners)) {
375 printf("Filesys %s with bad owning group %d\n", f->name, f->owners);
376 if (single_fix("Fix", 1)) {
377 zero_fix("filesys", "owners", "filsys_id", f->filsys_id);
383 if (f->type == 'N') {
384 if (!hash_lookup(nfsphys, f->phys_id)) {
385 m = (struct machine *)hash_lookup(machines, f->mach_id);
386 printf("Filesys %s with bad phys_id %d\n", f->name, f->phys_id);
387 if (single_fix("Fix", 1)) {
389 hash_step(nfsphys, fsmatch, f);
390 if (fnchecklen != 0) {
394 ## replace filesys (phys_id = id1) where filesys.filsys_id = id2
395 ## inquire_equel(rowcount = "rowcount")
397 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
399 printf("Not fixed\n");
402 printf("No NFSphys exsits for %s:%s\n", m->name, f->dir);
403 if (single_fix("Create", 0)) {
408 if (set_next_object_id("nfsphys_id", "nfsphys") !=
410 printf("Unable to assign unique ID\n");
413 ## retrieve (id1 = values.value)
414 ## where values.name = "nfsphys_id"
415 ## inquire_equel(rowcount = "rowcount")
417 printf("Unable to retrieve unique ID\n");
420 ## append nfsphys (nfsphys_id = id1, mach_id = id3,
421 ## device = "???", #dir = dir, status = 0,
422 ## allocated = 0, size = 0,
423 ## modtime = "now", modby = 0,
425 ## inquire_equel(rowcount = "rowcount")
427 printf("%d entr%s created\n", rowcount,
428 rowcount==1?"y":"ies");
430 printf("Not created\n");
432 n = (struct nfsphys *)malloc(sizeof(struct nfsphys));
434 out_of_mem("storing new nfsphys");
440 hash_store(nfsphys, id1, n);
441 ## replace filesys (phys_id = id1)
442 ## where filesys.filsys_id = id2
443 ## inquire_equel(rowcount = "rowcount")
445 printf("%d filesys entr%s fixed\n", rowcount,
446 rowcount==1?"y":"ies");
448 printf("Not fixed\n");
458 check_nfsphys(id, n, hint)
463 if (!hash_lookup(machines, n->mach_id)) {
464 printf("NFSphys %d(%s) on non-existant machine %d\n",
465 id, n->dir, n->mach_id);
466 if (single_fix("Delete", 0))
467 single_delete("nfsphys", "nfsphys_id", id);
471 ##show_fsg_missing(id)
474 ## int id1, found = 1;
477 ## retrieve (id1 = fsgroup.filsys_id) where fsgroup.group_id = id {
479 if (f = (struct filesys *) hash_lookup(filesys, id1))
480 printf("Missing fsgroup %d has member filesystem %s\n", id, f->name);
482 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 = nfsquota.filsys_id) where nfsquota.users_id = id {
552 printf("NFSquota on fs %d for non-existant user %d\n", id1, id);
559 single_delete("nfsquota", "users_id", id);
562 ##show_quota_nofs(id)
565 ## int id1, found = 1;
568 ## retrieve (id1 = nfsquota.users_id) where nfsquota.filsys_id = id {
569 u = (struct user *)hash_lookup(users, id1);
571 printf("NFSquota for user %s on non-existant filesys %d\n", u->login, id);
578 single_delete("nfsquota", "filsys_id", id);
581 ##show_quota_wrongpid(id)
584 ## int id1, found = 1;
588 f = (struct filesys *)hash_lookup(filesys, id);
589 ## retrieve (id1 = nfsquota.users_id) where nfsquota.filsys_id = id {
590 u = (struct user *)hash_lookup(users, id1);
592 printf("NFSquota for user %s on filesys %s has wrong phys_id %d\n",
593 u->login, f->name, id);
598 ##fix_quota_physid(id)
601 ## int rowcount, id1;
603 id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
604 ## replace nfsquota (phys_id = id1) where nfsquota.filsys_id = id and
605 ## nfsquota.phys_id != id1
606 ## inquire_equel(rowcount = "rowcount")
608 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
610 printf("Not fixed\n");
611 modified("nfsquota");
620 ## retrieve (name = s.#name) where s.acl_type = "USER" and s.acl_id = id {
622 printf("Service %s has acl non-existant user %d\n", name, id);
634 ## retrieve (name = s.#name) where s.acl_type = "LIST" and s.acl_id = id {
636 printf("Service %s has acl non-existant list %d\n", name, id);
647 ## replace servers (acl_id = 0) where servers.acl_id = id and
648 ## servers.acl_type = "USER"
649 ## inquire_equel(rowcount = "rowcount")
651 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
653 printf("Not fixed\n");
662 ## replace servers (acl_id = 0) where servers.acl_id = id and
663 ## servers.acl_type = "LIST"
664 ## inquire_equel(rowcount = "rowcount")
666 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
668 printf("Not fixed\n");
676 ## int found = 1, id1;
680 ## retrieve (id1 = krbmap.string_id) where krbmap.users_id = id {
681 if (s = ((struct string *)hash_lookup(strings, id1)))
686 printf("Kerberos map for non-existant user %d to principal %s\n",
696 ## int found = 1, id1;
700 ## retrieve (id1 = krbmap.users_id) where krbmap.string_id = id {
701 if (u = ((struct user *)hash_lookup(users, id1)))
706 printf("Kerberos map for user %s (%d) to non-existant string %d\n",
719 ## retrieve (name = palladium.#name) where palladium.mach_id = id {
721 printf("Palladium server/supervisor %s is on non-existant machine %d\n",
731 ## int id1, id2, id3, id4, id5;
732 ## char type[9], name[33];
733 struct save_queue *sq, *sq1, *sq2, *sq3, *sq4, *sq5;
739 printf("Phase 2 - Checking references\n");
741 dprintf("Checking users...\n");
742 hash_step(users, pobox_check, NULL);
744 dprintf("Checking mcmap...\n");
747 ## retrieve (id1 = mcmap.mach_id, id2 = mcmap.clu_id) {
748 if (!(m = (struct machine *)hash_lookup(machines, id1)))
749 sq_save_unique_data(sq1, id1);
750 if (!hash_lookup(clusters, id2))
751 sq_save_unique_data(sq2, id2);
752 if (m) m->clucount++;
754 generic_delete(sq1, show_mcm_mach, "mcmap", "mach_id", 1);
755 generic_delete(sq2, show_mcm_clu, "mcmap", "clu_id", 1);
757 dprintf("Checking service clusters...\n");
759 ## retrieve (id1 = svc.clu_id) {
760 if (!hash_lookup(clusters, id1))
761 sq_save_unique_data(sq1, id1);
763 generic_delete(sq1, show_svc, "svc", "clu_id", 1);
765 dprintf("Checking lists...\n");
766 hash_step(lists, list_check, NULL);
768 dprintf("Checking members...\n");
774 ## range of m is imembers
775 ## retrieve (id1 = m.list_id, type = m.member_type, id2 = m.member_id,
776 ## id3 = m.ref_count, id4 = m.direct) {
777 if ((l = (struct list *) hash_lookup(lists, id1)) == NULL)
778 sq_save_unique_data(sq1, id1);
779 else if (type[0] == 'U' && !hash_lookup(users, id2))
780 sq_save_unique_data(sq2, id2);
781 else if (type[0] == 'L' && !hash_lookup(lists, id2))
782 sq_save_unique_data(sq3, id2);
783 else if (type[0] == 'S' && !string_check(id2))
784 sq_save_unique_data(sq4, id2);
785 else if (type[0] == 'K' && !string_check(id2))
786 sq_save_unique_data(sq5, id2);
790 generic_delete(sq1, show_member_list, "imembers", "list_id", 1);
791 generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1);
792 generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1);
793 generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1);
794 generic_fix(sq5, show_mem_krb, "Delete", del_mem_krb, 1);
796 dprintf("Checking servers...\n");
799 ## range of s is servers
800 ## retrieve (name = s.#name, type = s.acl_type, id1 = s.acl_id) {
802 if (!strcmp(type, "USER") && !hash_lookup(users, id1)) {
803 sq_save_data(sq1, id1);
804 } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id1)) {
805 sq_save_data(sq2, id1);
808 generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
809 generic_fix(sq2, show_srv_list, "Fix", zero_srv_list, 1);
811 dprintf("Checking servershosts...\n");
813 ## retrieve (id1 = serverhosts.mach_id) {
814 if (!hash_lookup(machines, id1))
815 sq_save_data(sq, id1);
817 generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
819 dprintf("Checking nfsphys...\n");
820 hash_step(nfsphys, check_nfsphys, NULL);
822 dprintf("Checking filesys...\n");
823 hash_step(filesys, check_fs, NULL);
825 dprintf("Checking filesystem groups...\n");
829 ## retrieve (id1 = fsgroup.group_id, id2 = fsgroup.filsys_id) {
830 if (!(f = (struct filesys *) hash_lookup(filesys, id1)))
831 sq_save_data(sq1, id1);
833 sq_save_data(sq2, f);
834 if (!hash_lookup(filesys, id2))
835 sq_save_data(sq3, id2);
837 generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0);
838 generic_fix(sq2, show_fsg_type, "Change to \"FSTYPE\"", fix_fsg_type, 0);
839 generic_delete(sq3, show_fsg_nomember, "fsgroup", "filsys_id", 1);
841 dprintf("Checking nfsquota...\n");
845 ## retrieve (id1 = nfsquota.users_id, id2 = nfsquota.filsys_id,
846 ## id3 = nfsquota.phys_id, id4 = nfsquota.quota) {
847 if (id1 != 0 && !hash_lookup(users, id1))
848 sq_save_data(sq1, id1);
849 else if (!(f = (struct filesys *) hash_lookup(filesys, id2)))
850 sq_save_data(sq2, id2);
851 else if (id3 != f->phys_id ||
852 ((n = (struct nfsphys*) hash_lookup(nfsphys, id3)) ==
853 (struct nfsphys *)NULL))
854 sq_save_data(sq3, id2);
858 generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1);
859 generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0);
860 generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1);
862 dprintf("Not checking zephyr.\n");
864 dprintf("Checking hostaccess...\n");
865 ## range of h is hostaccess
866 ## retrieve (id1 = h.mach_id, type = h.acl_type, id2 = h.acl_id) {
868 if (!hash_lookup(machines, id1)) {
869 printf("Hostaccess for non-existant host %d\n", id1);
870 printf("Not fixing this error\n");
872 if (!strcmp(type, "USER") && !hash_lookup(users, id2)) {
873 printf("Hostaccess for %d is non-existant user %d\n", id1, id2);
874 printf("Not fixing this error\n");
875 } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2)) {
876 printf("Hostaccess for %d is non-existant list %d\n", id1, id2);
877 printf("Not fixing this error\n");
881 dprintf("Checking palladium...\n");
883 ## range of p is palladium
884 ## retrieve (id1 = p.mach_id) {
885 if (!hash_lookup(machines, id1)) {
886 sq_save_unique_data(sq1, id1);
889 generic_delete(sq1, show_pdm_mach, "palladium", "mach_id", 1);
891 dprintf("Checking krbmap...\n");
894 ## range of k is krbmap
895 ## retrieve (id1 = k.users_id, id2 = k.string_id) {
896 if (!hash_lookup(users, id1))
897 sq_save_unique_data(sq1, id1);
898 if (!string_check(id2))
899 sq_save_unique_data(sq2, id2);
901 generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1);
902 generic_delete(sq2, show_krb_str, "krbmap", "string_id", 1);
904 dprintf("Checking capacls...\n");
905 ## retrieve (id1 = capacls.list_id, name = capacls.tag) {
906 if (!hash_lookup(lists, id1)) {
907 printf("Capacl for %s is non-existant list %d\n", name, id1);
908 printf("Not fixing this error\n");