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 = member.member_type, mid = member.member_id)
154 ## where member.list_id = iid {
158 strcpy(name, ((struct list *) hash_lookup(lists, mid))->name);
159 else if (mtype[0] == 'U')
160 strcpy(name, ((struct user *) hash_lookup(users, mid))->login);
161 else if (mtype[0] == 'S')
162 strcpy(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 = members.list_id)
175 ## where members.member_id = iid and members.member_type = "USER" {
177 printf("List %s has non-existant user member, id %d\n",
178 ((struct list *)hash_lookup(lists, lid))->name, iid);
186 ## int lid, iid = id, found = 1;
189 ## retrieve (lid = members.list_id)
190 ## where members.member_id = iid and members.member_type = "LIST" {
192 printf("List %s has non-existant list member, id %d\n",
193 ((struct list *)hash_lookup(lists, lid))->name, iid);
201 ## int lid, iid = id, found = 1;
204 ## retrieve (lid = members.list_id)
205 ## where members.member_id = iid and members.member_type = "STRING" {
207 printf("List %s has non-existant string member, id %d\n",
208 ((struct list *)hash_lookup(lists, lid))->name, iid);
219 ## delete members where members.member_type = "USER" and
220 ## members.member_id = id
221 ## inquire_equel(rowcount = "rowcount");
223 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
225 printf("Not deleted\n");
234 ## delete members where members.member_type = "LIST" and
235 ## members.member_id = id
236 ## inquire_equel(rowcount = "rowcount");
238 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
240 printf("Not deleted\n");
249 ## delete members where members.member_type = "STRING" and
250 ## members.member_id = id
251 ## inquire_equel(rowcount = "rowcount");
253 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
255 printf("Not deleted\n");
266 ## retrieve (name = serverhosts.service) where serverhosts.mach_id = id {
268 printf("ServerHost entry for service %s non-existant host %d\n",
279 ## delete serverhosts where serverhosts.mach_id = id
280 ## inquire_equel(rowcount = "rowcount");
282 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
284 printf("Not deleted\n");
285 modified("serverhosts");
289 static int fnchecklen;
296 if (n->mach_id == f->mach_id &&
297 !strncmp(f->dir, n->dir, strlen(n->dir)) &&
298 strlen(n->dir) > fnchecklen) {
300 fnchecklen = strlen(n->dir);
305 ##check_fs(id, f, hint)
307 register struct filesys *f;
310 ## int id1, id2, id3, rowcount;
315 if (f->type == 'N' || f->type == 'R') {
316 if (!hash_lookup(machines, f->mach_id)) {
317 printf("Filesys %s with bad machine %d\n", f->name, f->mach_id);
318 if (single_fix("Fix", 0)) {
319 ## replace filesys (mach_id = 0) where filesys.filsys_id = id
320 ## inquire_equel(rowcount = "rowcount")
322 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
324 printf("Not fixed\n");
329 if (!hash_lookup(users, f->owner)) {
330 printf("Filesys %s with bad owning user %d\n", f->name, f->owner);
331 if (single_fix("Fix", 1)) {
332 zero_fix("filesys", "owner", "filsys_id", f->filsys_id);
336 if (!hash_lookup(lists, f->owners)) {
337 printf("Filesys %s with bad owning group %d\n", f->name, f->owners);
338 if (single_fix("Fix", 1)) {
339 zero_fix("filesys", "owners", "filsys_id", f->filsys_id);
345 if (f->type == 'N') {
346 if (!hash_lookup(nfsphys, f->phys_id)) {
347 m = (struct machine *)hash_lookup(machines, f->mach_id);
348 printf("Filesys %s with bad phys_id %d\n", f->name, f->phys_id);
349 if (single_fix("Fix", 1)) {
351 hash_step(nfsphys, fsmatch, f);
352 if (fnchecklen != 0) {
356 ## replace filesys (phys_id = id1) where filesys.filsys_id = id2
357 ## inquire_equel(rowcount = "rowcount")
359 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
361 printf("Not fixed\n");
364 printf("No NFSphys exsits for %s:%s\n", m->name, f->dir);
365 if (single_fix("Create", 0)) {
370 if (set_next_object_id("nfsphys_id", "nfsphys") !=
372 printf("Unable to assign unique ID\n");
375 ## retrieve (id1 = values.value)
376 ## where values.name = "nfsphys_id"
377 ## inquire_equel(rowcount = "rowcount")
379 printf("Unable to retrieve unique ID\n");
382 ## append nfsphys (nfsphys_id = id1, mach_id = id3,
383 ## device = "???", #dir = dir, status = 0,
384 ## allocated = 0, size = 0,
385 ## modtime = "now", modby = 0,
387 ## inquire_equel(rowcount = "rowcount")
389 printf("%d entr%s created\n", rowcount,
390 rowcount==1?"y":"ies");
392 printf("Not created\n");
394 n = (struct nfsphys *)malloc(sizeof(struct nfsphys));
400 hash_store(nfsphys, id1, n);
401 ## replace filesys (phys_id = id1)
402 ## where filesys.filsys_id = id2
403 ## inquire_equel(rowcount = "rowcount")
405 printf("%d filesys entr%s fixed\n", rowcount,
406 rowcount==1?"y":"ies");
408 printf("Not fixed\n");
418 check_nfsphys(id, n, hint)
423 if (!hash_lookup(machines, n->mach_id)) {
424 printf("NFSphys %d(%s) on non-existant machine %d\n",
425 id, n->dir, n->mach_id);
426 if (single_fix("Delete", 0))
427 single_delete("nfsphys", "nfsphys_id", id);
431 ##show_quota_nouser(id)
434 ## int id1, found = 1;
436 ## retrieve (id1 = nfsquota.filsys_id) where nfsquota.users_id = id {
438 printf("NFSquota on fs %d for non-existant user %d\n", id1, id);
445 single_delete("nfsquota", "users_id", id);
448 ##show_quota_nofs(id)
451 ## int id1, found = 1;
454 ## retrieve (id1 = nfsquota.users_id) where nfsquota.filsys_id = id {
455 u = (struct user *)hash_lookup(users, id1);
457 printf("NFSquota for user %s on non-existant filesys %d\n", u->login, id);
464 single_delete("nfsquota", "filsys_id", id);
467 ##show_quota_wrongpid(id)
470 ## int id1, found = 1;
474 f = (struct filesys *)hash_lookup(filesys, id);
475 ## retrieve (id1 = nfsquota.users_id) where nfsquota.filsys_id = id {
476 u = (struct user *)hash_lookup(users, id1);
478 printf("NFSquota for user %s on filesys %s has wrong phys_id %d\n",
479 u->login, f->name, id);
484 ##fix_quota_physid(id)
487 ## int rowcount, id1;
489 id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
490 ## replace nfsquota (phys_id = id1) where nfsquota.filsys_id = id and
491 ## nfsquota.phys_id != id1
492 ## inquire_equel(rowcount = "rowcount")
494 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
496 printf("Not fixed\n");
497 modified("nfsquota");
506 ## retrieve (name = s.#name) where s.acl_type = "USER" and s.acl_id = id {
508 printf("Service %s has acl non-existant user %d\n", name, id);
520 ## retrieve (name = s.#name) where s.acl_type = "LIST" and s.acl_id = id {
522 printf("Service %s has acl non-existant list %d\n", name, id);
533 ## replace servers (acl_id = 0) where servers.acl_id = id and
534 ## servers.acl_type = "USER"
535 ## inquire_equel(rowcount = "rowcount")
537 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
539 printf("Not fixed\n");
548 ## replace servers (acl_id = 0) where servers.acl_id = id and
549 ## servers.acl_type = "LIST"
550 ## inquire_equel(rowcount = "rowcount")
552 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
554 printf("Not fixed\n");
562 ## int id1, id2, id3, id4, id5;
563 ## char type[9], name[33];
564 struct save_queue *sq, *sq1, *sq2, *sq3, *sq4;
570 printf("Phase 2 - Checking references\n");
572 dprintf("Checking users...\n");
573 hash_step(users, pobox_check, NULL);
575 dprintf("Checking mcmap...\n");
578 ## retrieve (id1 = mcmap.mach_id, id2 = mcmap.clu_id) {
579 if (!(m = (struct machine *)hash_lookup(machines, id1)))
580 sq_save_unique_data(sq1, id1);
581 if (!hash_lookup(clusters, id2))
582 sq_save_unique_data(sq2, id2);
585 generic_delete(sq1, show_mcm_mach, "mcmap", "mach_id", 1);
586 generic_delete(sq2, show_mcm_clu, "mcmap", "clu_id", 1);
588 dprintf("Checking service clusters...\n");
590 ## retrieve (id1 = svc.clu_id) {
591 if (!hash_lookup(clusters, id1))
592 sq_save_unique_data(sq1, id1);
594 generic_delete(sq1, show_svc, "svc", "clu_id", 1);
596 dprintf("Checking lists...\n");
597 hash_step(lists, list_check, NULL);
599 dprintf("Checking members...\n");
604 ## range of m is members
605 ## retrieve (id1 = m.list_id, type = m.member_type, id2 = m.member_id) {
607 if ((l = (struct list *) hash_lookup(lists, id1)) == NULL)
608 sq_save_unique_data(sq1, id1);
610 if (!strcmp(type, "USER") && !hash_lookup(users, id2))
611 sq_save_unique_data(sq2, id2);
612 else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2))
613 sq_save_unique_data(sq3, id2);
614 else if (!strcmp(type, "STRING") && !string_check(id2))
615 sq_save_unique_data(sq4, id2);
617 generic_delete(sq1, show_member_list, "members", "list_id", 1);
618 generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1);
619 generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1);
620 generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1);
622 dprintf("Checking servers...\n");
625 ## range of s is servers
626 ## retrieve (name = s.#name, type = s.acl_type, id1 = s.acl_id) {
628 if (!strcmp(type, "USER") && !hash_lookup(users, id1)) {
629 sq_save_data(sq1, id1);
630 } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id1)) {
631 sq_save_data(sq2, id1);
634 generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
635 generic_fix(sq2, show_srv_list, "Fix", zero_srv_list, 1);
637 dprintf("Checking servershosts...\n");
639 ## retrieve (id1 = serverhosts.mach_id) {
640 if (!hash_lookup(machines, id1))
641 sq_save_data(sq, id1);
643 generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
645 dprintf("Checking nfsphys...\n");
646 hash_step(nfsphys, check_nfsphys, NULL);
648 dprintf("Checking filesys...\n");
649 hash_step(filesys, check_fs, NULL);
651 dprintf("Checking nfsquota...\n");
655 ## retrieve (id1 = nfsquota.users_id, id2 = nfsquota.filsys_id,
656 ## id3 = nfsquota.phys_id, id4 = nfsquota.quota) {
657 if (!hash_lookup(users, id1))
658 sq_save_data(sq1, id1);
659 else if (!(f = (struct filesys *) hash_lookup(filesys, id2)))
660 sq_save_data(sq2, id2);
661 else if (id3 != f->phys_id ||
662 ((n = (struct nfsphys*) hash_lookup(nfsphys, id3)) ==
663 (struct nfsphys *)NULL))
664 sq_save_data(sq3, id2);
668 generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1);
669 generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0);
670 generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1);
672 dprintf("Not checking zephyr.\n");
674 dprintf("Checking hostaccess...\n");
675 ## range of h is hostaccess
676 ## retrieve (id1 = h.mach_id, type = h.acl_type, id2 = h.acl_id) {
678 if (!hash_lookup(machines, id1)) {
679 printf("Hostaccess for non-existant host %d\n", id1);
680 printf("Not fixing this error\n");
682 if (!strcmp(type, "USER") && !hash_lookup(users, id2)) {
683 printf("Hostaccess for %d is non-existant user %d\n", id1, id2);
684 printf("Not fixing this error\n");
685 } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2)) {
686 printf("Hostaccess for %d is non-existant list %d\n", id1, id2);
687 printf("Not fixing this error\n");
691 dprintf("Checking capacls...\n");
692 ## retrieve (id1 = capacls.list_id, name = capacls.tag) {
693 if (!hash_lookup(lists, id1)) {
694 printf("Capacl for %s is non-existant list %d\n", name, id1);
695 printf("Not fixing this error\n");