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");
503 ## int id1, id2, id3, id4, id5;
504 ## char type[9], name[33];
505 struct save_queue *sq, *sq1, *sq2, *sq3, *sq4;
511 printf("Phase 2 - Checking references\n");
513 dprintf("Checking users...\n");
514 hash_step(users, pobox_check, NULL);
516 dprintf("Checking mcmap...\n");
519 ## retrieve (id1 = mcmap.mach_id, id2 = mcmap.clu_id) {
520 if (!(m = (struct machine *)hash_lookup(machines, id1)))
521 sq_save_unique_data(sq1, id1);
522 if (!hash_lookup(clusters, id2))
523 sq_save_unique_data(sq2, id2);
526 generic_delete(sq1, show_mcm_mach, "mcmap", "mach_id", 1);
527 generic_delete(sq2, show_mcm_clu, "mcmap", "clu_id", 1);
529 dprintf("Checking service clusters...\n");
531 ## retrieve (id1 = svc.clu_id) {
532 if (!hash_lookup(clusters, id1))
533 sq_save_unique_data(sq1, id1);
535 generic_delete(sq1, show_svc, "svc", "clu_id", 1);
537 dprintf("Checking lists...\n");
538 hash_step(lists, list_check, NULL);
540 dprintf("Checking members...\n");
545 ## range of m is members
546 ## retrieve (id1 = m.list_id, type = m.member_type, id2 = m.member_id) {
548 if ((l = (struct list *) hash_lookup(lists, id1)) == NULL)
549 sq_save_unique_data(sq1, id1);
551 if (!strcmp(type, "USER") && !hash_lookup(users, id2))
552 sq_save_unique_data(sq2, id2);
553 else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2))
554 sq_save_unique_data(sq3, id2);
555 else if (!strcmp(type, "STRING") && !string_check(id2))
556 sq_save_unique_data(sq4, id2);
558 generic_delete(sq1, show_member_list, "members", "list_id", 1);
559 generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1);
560 generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1);
561 generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1);
563 dprintf("Checking servers...\n");
564 ## range of s is servers
565 ## retrieve (name = s.#name, type = s.acl_type, id1 = s.acl_id) {
567 if (!strcmp(type, "USER") && !hash_lookup(users, id1)) {
568 printf("Service %s has acl non-existant user %d\n", name, id1);
569 printf("Not fixing this error\n");
570 } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id1)) {
571 printf("Service %s has acl non-existant list %d\n", name, id1);
572 printf("Not fixing this error\n");
576 dprintf("Checking servershosts...\n");
578 ## retrieve (id1 = serverhosts.mach_id) {
579 if (!hash_lookup(machines, id1))
580 sq_save_data(sq, id1);
582 generic_fix(sq, show_sh, "Delete", del_sh_mach, 1);
584 dprintf("Checking nfsphys...\n");
585 hash_step(nfsphys, check_nfsphys, NULL);
587 dprintf("Checking filesys...\n");
588 hash_step(filesys, check_fs, NULL);
590 dprintf("Checking nfsquota...\n");
594 ## retrieve (id1 = nfsquota.users_id, id2 = nfsquota.filsys_id,
595 ## id3 = nfsquota.phys_id, id4 = nfsquota.quota) {
596 if (!hash_lookup(users, id1))
597 sq_save_data(sq1, id1);
598 else if (!(f = (struct filesys *) hash_lookup(filesys, id2)))
599 sq_save_data(sq2, id2);
600 else if (id3 != f->phys_id ||
601 ((n = (struct nfsphys*) hash_lookup(nfsphys, id3)) ==
602 (struct nfsphys *)NULL))
603 sq_save_data(sq3, id2);
607 generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1);
608 generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0);
609 generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1);
611 dprintf("Not checking zephyr.\n");
613 dprintf("Checking hostaccess...\n");
614 ## range of h is hostaccess
615 ## retrieve (id1 = h.mach_id, type = h.acl_type, id2 = h.acl_id) {
617 if (!hash_lookup(machines, id1)) {
618 printf("Hostaccess for non-existant host %d\n", id1);
619 printf("Not fixing this error\n");
621 if (!strcmp(type, "USER") && !hash_lookup(users, id2)) {
622 printf("Hostaccess for %d is non-existant user %d\n", id1, id2);
623 printf("Not fixing this error\n");
624 } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2)) {
625 printf("Hostaccess for %d is non-existant list %d\n", id1, id2);
626 printf("Not fixing this error\n");
630 dprintf("Checking capacls...\n");
631 ## retrieve (id1 = capacls.list_id, name = capacls.tag) {
632 if (!hash_lookup(lists, id1)) {
633 printf("Capacl for %s is non-existant list %d\n", name, id1);
634 printf("Not fixing this error\n");