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>
16 ## int iid = id, found = 1;
19 ## retrieve (name = cluster.#name) where cluster.clu_id = mcmap.clu_id
20 ## and mcmap.mach_id = iid {
23 printf("Cluster %s, non-existant machine %d in cluster map\n", name, id);
31 ## int iid = id, found = 1;
34 ## retrieve (name = machine.#name) where machine.mach_id = mcmap.mach_id
35 ## and mcmap.clu_id = iid {
38 printf("Machine %s, non-existant cluster %d in cluster map\n", name, id);
43 pobox_check(id, u, hint)
50 if (!hash_lookup(machines, u->pobox_id)) {
51 printf("User %s(%s) has P.O.Box on non-existant machine %d\n",
52 u->login, u->fullname, u->pobox_id);
53 if (single_fix("Delete", 0)) {
54 remove_pobox(u->users_id);
60 if (!string_check(u->pobox_id)) {
61 printf("User %s(%s) has P.O.Box with non-existant string %d\n",
62 u->login, u->fullname, u->pobox_id);
63 if (single_fix("Delete", 0)) {
64 remove_pobox(u->users_id);
78 ## int rowcount, iid = id;
79 ## replace users (potype = "NONE") where users.users_id = iid
80 ## inquire_equel(rowcount = "rowcount")
82 printf("%d entr%s removed\n", rowcount, rowcount==1?"y":"ies");
84 printf("Not removed\n");
90 ## int iid = id, found = 1;
91 ## char label[17], data[33];
93 ## retrieve (label = svc.serv_label, data = svc.serv_cluster)
94 ## where svc.clu_id = iid {
98 printf("Cluster data [%s] %s for non-existant cluster %d\n",
104 list_check(id, l, hint)
109 switch (l->acl_type) {
111 if (!hash_lookup(lists, l->acl_id)) {
112 printf("List %s has bad LIST acl %d\n", l->name, l->acl_id);
113 if (single_fix("Patch", 1)) {
114 fix_list_acl(l->list_id);
119 if (!hash_lookup(users, l->acl_id)) {
120 printf("List %s has bad USER acl %d\n", l->name, l->acl_id);
121 if (single_fix("Patch", 1)) {
122 fix_list_acl(l->list_id);
132 ## int rowcount, iid = id;
133 ## replace list (acl_id = iid, acl_type = "LIST") where list.list_id = iid
134 ## inquire_equel(rowcount = "rowcount")
136 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
138 printf("Not fixed\n");
145 ## int mid, iid = id, found = 1;
146 ## char mtype[9], *name;
148 ## retrieve (mtype = member.member_type, mid = member.member_id)
149 ## where member.list_id = iid {
153 strcpy(name, ((struct list *) hash_lookup(lists, mid))->name);
154 else if (mtype[0] == 'U')
155 strcpy(name, ((struct user *) hash_lookup(users, mid))->login);
156 else if (mtype[0] == 'S')
157 strcpy(name, ((struct string *) hash_lookup(strings, mid))->name);
158 printf("Non-existant list %d has member %s %s\n", iid, mtype, name);
166 ## int lid, iid = id, found = 1;
169 ## retrieve (lid = members.list_id)
170 ## where members.member_id = iid and members.member_type = "USER" {
172 printf("List %s has non-existant user member, id %d\n",
173 ((struct list *)hash_lookup(lists, lid))->name, iid);
181 ## int lid, iid = id, found = 1;
184 ## retrieve (lid = members.list_id)
185 ## where members.member_id = iid and members.member_type = "LIST" {
187 printf("List %s has non-existant list member, id %d\n",
188 ((struct list *)hash_lookup(lists, lid))->name, iid);
196 ## int lid, iid = id, found = 1;
199 ## retrieve (lid = members.list_id)
200 ## where members.member_id = iid and members.member_type = "STRING" {
202 printf("List %s has non-existant string member, id %d\n",
203 ((struct list *)hash_lookup(lists, lid))->name, iid);
214 ## delete members where members.member_type = "USER" and
215 ## members.member_id = id
216 ## inquire_equel(rowcount = "rowcount");
218 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
220 printf("Not deleted\n");
228 ## delete members where members.member_type = "LIST" and
229 ## members.member_id = id
230 ## inquire_equel(rowcount = "rowcount");
232 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
234 printf("Not deleted\n");
242 ## delete members where members.member_type = "STRING" and
243 ## members.member_id = id
244 ## inquire_equel(rowcount = "rowcount");
246 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
248 printf("Not deleted\n");
258 ## retrieve (name = serverhosts.service) where serverhosts.mach_id = id {
260 printf("ServerHost entry for service %s non-existant host %d\n",
271 ## delete serverhosts where serverhosts.mach_id = id
272 ## inquire_equel(rowcount = "rowcount");
274 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
276 printf("Not deleted\n");
280 static int fnchecklen;
287 if (n->mach_id == f->mach_id &&
288 !strncmp(f->dir, n->dir, strlen(n->dir)) &&
289 strlen(n->dir) > fnchecklen) {
291 fnchecklen = strlen(n->dir);
296 ##check_fs(id, f, hint)
298 register struct filesys *f;
301 ## int id1, id2, id3, rowcount;
306 if (f->type == 'N' || f->type == 'R') {
307 if (!hash_lookup(machines, f->mach_id)) {
308 printf("Filesys %s with bad machine %d\n", f->name, f->mach_id);
309 if (single_fix("Fix", 0)) {
310 ## replace filesys (mach_id = 0) where filesys.filsys_id = id
311 ## inquire_equel(rowcount = "rowcount")
313 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
315 printf("Not fixed\n");
319 if (!hash_lookup(users, f->owner)) {
320 printf("Filesys %s with bad owning user %d\n", f->name, f->owner);
321 if (single_fix("Fix", 1)) {
322 zero_fix("filesys", "owner", "filsys_id", f->filsys_id);
326 if (!hash_lookup(lists, f->owners)) {
327 printf("Filesys %s with bad owning group %d\n", f->name, f->owners);
328 if (single_fix("Fix", 1)) {
329 zero_fix("filesys", "owners", "filsys_id", f->filsys_id);
335 if (f->type == 'N') {
336 if (!hash_lookup(nfsphys, f->phys_id)) {
337 m = (struct machine *)hash_lookup(machines, f->mach_id);
338 printf("Filesys %s with bad phys_id %d\n", f->name, f->phys_id);
339 if (single_fix("Fix", 1)) {
341 hash_step(nfsphys, fsmatch, f);
342 if (fnchecklen != 0) {
346 ## replace filesys (phys_id = id1) where filesys.filsys_id = id2
347 ## inquire_equel(rowcount = "rowcount")
349 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
351 printf("Not fixed\n");
353 printf("No NFSphys exsits for %s:%s\n", m->name, f->dir);
354 if (single_fix("Create", 0)) {
359 if (set_next_object_id("nfsphys_id", "nfsphys") !=
361 printf("Unable to assign unique ID\n");
364 ## retrieve (id1 = values.value)
365 ## where values.name = "nfsphys_id"
366 ## inquire_equel(rowcount = "rowcount")
368 printf("Unable to retrieve unique ID\n");
371 ## append nfsphys (nfsphys_id = id1, mach_id = id3,
372 ## device = "???", #dir = dir, status = 0,
373 ## allocated = 0, size = 0,
374 ## modtime = "now", modby = 0,
376 ## inquire_equel(rowcount = "rowcount")
378 printf("%d entr%s created\n", rowcount,
379 rowcount==1?"y":"ies");
381 printf("Not created\n");
382 n = (struct nfsphys *)malloc(sizeof(struct nfsphys));
388 hash_store(nfsphys, id1, n);
389 ## replace filesys (phys_id = id1)
390 ## where filesys.filsys_id = id
391 ## inquire_equel(rowcount = "rowcount")
393 printf("%d filesys entr%s fixed\n", rowcount,
394 rowcount==1?"y":"ies");
396 printf("Not fixed\n");
405 check_nfsphys(id, n, hint)
410 if (!hash_lookup(machines, n->mach_id)) {
411 printf("NFSphys %d(%s) on non-existant machine %d\n",
412 id, n->dir, n->mach_id);
413 if (single_fix("Delete", 0))
414 single_delete("nfsphys", "nfsphys_id", id);
418 ##show_quota_nouser(id)
421 ## int id1, found = 1;
423 ## retrieve (id1 = nfsquota.filsys_id) where nfsquota.users_id = id {
425 printf("NFSquota on fs %d for non-existant user %d\n", id1, id);
432 single_delete("nfsquota", "users_id", id);
435 ##show_quota_nofs(id)
438 ## int id1, found = 1;
441 ## retrieve (id1 = nfsquota.users_id) where nfsquota.filsys_id = id {
442 u = (struct user *)hash_lookup(users, id1);
444 printf("NFSquota for user %s on non-existant filesys %d\n", u->login, id);
451 single_delete("nfsquota", "filsys_id", id);
454 ##show_quota_wrongpid(id)
457 ## int id1, found = 1;
461 f = (struct filesys *)hash_lookup(filesys, id);
462 ## retrieve (id1 = nfsquota.users_id) where nfsquota.filsys_id = id {
463 u = (struct user *)hash_lookup(users, id1);
465 printf("NFSquota for user %s on filesys %s has wrong phys_id %d\n",
466 u->login, f->name, id);
471 ##fix_quota_physid(id)
474 ## int rowcount, id1;
476 id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
477 ## replace nfsquota (phys_id = id1) where nfsquota.filsys_id = id and
478 ## nfsquota.phys_id != id1
479 ## inquire_equel(rowcount = "rowcount")
481 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
483 printf("Not fixed\n");
489 ## int id1, id2, id3, id4, id5;
490 ## char type[9], name[33];
491 struct save_queue *sq, *sq1, *sq2, *sq3, *sq4;
497 printf("Phase 2 - Checking references\n");
499 dprintf("Checking users...\n");
500 hash_step(users, pobox_check, NULL);
502 dprintf("Checking mcmap...\n");
505 ## retrieve (id1 = mcmap.mach_id, id2 = mcmap.clu_id) {
506 if (!(m = (struct machine *)hash_lookup(machines, id1)))
507 sq_save_unique_data(sq1, id1);
508 if (!hash_lookup(clusters, id2))
509 sq_save_unique_data(sq2, id2);
512 generic_delete(sq1, show_mcm_mach, "mcmap", "mach_id", 1);
513 generic_delete(sq2, show_mcm_clu, "mcmap", "clu_id", 1);
515 dprintf("Checking service clusters...\n");
517 ## retrieve (id1 = svc.clu_id) {
518 if (!hash_lookup(clusters, id1))
519 sq_save_unique_data(sq1, id1);
521 generic_delete(sq1, show_svc, "svc", "clu_id", 1);
523 dprintf("Checking lists...\n");
524 hash_step(lists, list_check, NULL);
526 dprintf("Checking members...\n");
531 ## range of m is members
532 ## retrieve (id1 = m.list_id, type = m.member_type, id2 = m.member_id) {
534 if ((l = (struct list *) hash_lookup(lists, id1)) == NULL)
535 sq_save_unique_data(sq1, id1);
537 if (!strcmp(type, "USER") && !hash_lookup(users, id2))
538 sq_save_unique_data(sq2, id2);
539 else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2))
540 sq_save_unique_data(sq3, id2);
541 else if (!strcmp(type, "STRING") && !string_check(id2))
542 sq_save_unique_data(sq4, id2);
544 generic_delete(sq1, show_member_list, "members", "list_id", 1);
545 generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1);
546 generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1);
547 generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1);
549 dprintf("Checking servers...\n");
550 ## range of s is servers
551 ## retrieve (name = s.#name, type = s.acl_type, id1 = s.acl_id) {
553 if (!strcmp(type, "USER") && !hash_lookup(users, id1))
554 printf("Service %s has acl non-existant user %d\n", name, id1);
555 else if (!strcmp(type, "LIST") && !hash_lookup(lists, id1))
556 printf("Service %s has acl non-existant list %d\n", name, id1);
559 dprintf("Checking servershosts...\n");
561 ## retrieve (id1 = serverhosts.mach_id) {
562 if (!hash_lookup(machines, id1))
563 sq_save_data(sq, id1);
565 generic_fix(sq, show_sh, "Delete", del_sh_mach, 1);
567 dprintf("Checking nfsphys...\n");
568 hash_step(nfsphys, check_nfsphys, NULL);
570 dprintf("Checking filesys...\n");
571 hash_step(filesys, check_fs, NULL);
573 dprintf("Checking nfsquota...\n");
577 ## retrieve (id1 = nfsquota.users_id, id2 = nfsquota.filsys_id,
578 ## id3 = nfsquota.phys_id, id4 = nfsquota.quota) {
579 if (!hash_lookup(users, id1))
580 sq_save_data(sq1, id1);
581 else if (!(f = (struct filesys *) hash_lookup(filesys, id2)))
582 sq_save_data(sq2, id2);
583 else if (id3 != f->phys_id ||
584 ((n = (struct nfsphys*) hash_lookup(nfsphys, id3)) ==
585 (struct nfsphys *)NULL))
586 sq_save_data(sq3, id2);
590 generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1);
591 generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0);
592 generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1);
594 dprintf("Not checking zephyr.\n");
596 dprintf("Checking hostaccess...\n");
597 ## range of h is hostaccess
598 ## retrieve (id1 = h.mach_id, type = h.acl_type, id2 = h.acl_id) {
600 if (!hash_lookup(machines, id1))
601 printf("Hostaccess for non-existant host %d\n", id1);
602 if (!strcmp(type, "USER") && !hash_lookup(users, id2))
603 printf("Hostaccess for %d is non-existant user %d\n", id1, id2);
604 else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2))
605 printf("Hostaccess for %d is non-existant list %d\n", id1, id2);
608 dprintf("Checking capacls...\n");
609 ## retrieve (id1 = capacls.list_id, name = capacls.tag) {
610 if (!hash_lookup(lists, id1))
611 printf("Capacl for %s is non-existant list %d\n", name, id1);