]> andersk Git - moira.git/blob - dbck/phase2.qc
sms -> moira
[moira.git] / dbck / phase2.qc
1 /* $Header$
2  *
3  *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
4  *  For copying and distribution information, please see the file
5  *  <mit-copyright.h>.
6  */
7
8 #include <mit-copyright.h>
9 #include <stdio.h>
10 #include <moira.h>
11 #include "dbck.h"
12
13 static char phase2_qc_rcsid[] = "$Header$";
14
15
16 show_mcm_mach(id)
17 int id;
18 ##{
19 ##  int iid = id, found = 1;
20 ##  char name[33];
21
22 ##  retrieve (name = cluster.#name) where cluster.clu_id = mcmap.clu_id
23 ##      and mcmap.mach_id = iid {
24       strtrim(name);
25       found = 0;
26       printf("Cluster %s, non-existant machine %d in cluster map\n", name, id);
27 ##  }
28     return(found);
29 ##}
30
31 show_mcm_clu(id)
32 int id;
33 ##{
34 ##  int iid = id, found = 1;
35 ##  char name[33];
36
37 ##  retrieve (name = machine.#name) where machine.mach_id = mcmap.mach_id
38 ##      and mcmap.clu_id = iid {
39       strtrim(name);
40       found = 0;
41       printf("Machine %s, non-existant cluster %d in cluster map\n", name, id);
42 ##  }
43     return(found);
44 ##}
45
46 pobox_check(id, u, hint)
47 int id;
48 struct user *u;
49 int hint;
50 {
51     switch (u->potype) {
52     case 'P':
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);
58                 u->potype = 'N';
59             }
60         }
61         break;
62     case 'S':
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);
68                 u->potype = 'N';
69             }
70         }
71         break;
72     default:
73         ;
74     }
75 }
76
77
78 remove_pobox(id)
79 int id;
80 ##{
81 ##  int rowcount, iid = id;
82 ##  replace users (potype = "NONE") where users.users_id = iid
83 ##  inquire_equel(rowcount = "rowcount")
84     if (rowcount > 0)
85       printf("%d entr%s removed\n", rowcount, rowcount==1?"y":"ies");
86     else
87       printf("Not removed\n");
88     modified("users");
89 ##}
90
91 show_svc(id)
92 int id;
93 ##{
94 ##  int iid = id, found = 1;
95 ##  char label[17], data[33];
96
97 ##  retrieve (label = svc.serv_label, data = svc.serv_cluster) 
98 ##      where svc.clu_id = iid {
99       strtrim(label);
100       strtrim(data);
101       found = 0;
102       printf("Cluster data [%s] %s for non-existant cluster %d\n",
103              label, data, id);
104 ##  }
105     return(found);
106 ##}
107
108 list_check(id, l, hint)
109 int id;
110 struct list *l;
111 int hint;
112 {
113     switch (l->acl_type) {
114     case 'L':
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);
119             }
120         }
121         break;
122     case 'U':
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);
127             }
128         }
129         break;
130     }
131 }
132
133 fix_list_acl(id)
134 int id;
135 ##{
136 ##  int rowcount, iid = id;
137 ##  replace list (acl_id = iid, acl_type = "LIST") where list.list_id = iid
138 ##  inquire_equel(rowcount = "rowcount")
139     if (rowcount > 0)
140       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
141     else
142       printf("Not fixed\n");
143     modified("list");
144 ##}
145
146
147 show_member_list(id)
148 int id;
149 ##{
150 ##  int mid, iid = id, found = 1;
151 ##  char mtype[9], *name = "";
152
153 ##  retrieve (mtype = imembers.member_type, mid = imembers.member_id)
154 ##      where imembers.list_id = iid and imembers.direct = 1 {
155       strtrim(mtype);
156       found = 0;
157       if (mtype[0] == 'L')
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);
164 ##  }
165     return(found);
166 ##}
167
168 show_mem_user(id)
169 int id;
170 ##{
171 ##  int lid, iid = id, found = 1;
172 ##  char name[33];
173
174 ##  retrieve (lid = imembers.list_id)
175 ##      where imembers.member_id = iid and imembers.member_type = "USER" and
176 ##            imembers.direct = 1 {
177       found = 0;
178       printf("List %s has non-existant user member, id %d\n",
179              ((struct list *)hash_lookup(lists, lid))->name, iid);
180 ##  }
181     return(found);
182 ##}
183
184 show_mem_list(id)
185 int id;
186 ##{
187 ##  int lid, iid = id, found = 1;
188 ##  char name[33];
189
190 ##  retrieve (lid = imembers.list_id)
191 ##      where imembers.member_id = iid and imembers.member_type = "LIST" and
192 ##            imembers.direct = 1 {
193       found = 0;
194       printf("List %s has non-existant list member, id %d\n",
195              ((struct list *)hash_lookup(lists, lid))->name, iid);
196 ##  }
197     return(found);
198 ##}
199
200 show_mem_str(id)
201 int id;
202 ##{
203 ##  int lid, iid = id, found = 1;
204 ##  char name[33];
205
206 ##  retrieve (lid = imembers.list_id)
207 ##      where imembers.member_id = iid and imembers.member_type = "STRING" and
208 ##            imembers.direct = 1 {
209       found = 0;
210       printf("List %s has non-existant string member, id %d\n",
211              ((struct list *)hash_lookup(lists, lid))->name, iid);
212 ##  }
213     return(found);
214 ##}
215
216
217 show_mem_krb(id)
218 int id;
219 ##{
220 ##  int lid, iid = id, found = 1;
221 ##  char name[33];
222
223 ##  retrieve (lid = imembers.list_id)
224 ##      where imembers.member_id = iid and imembers.member_type = "KERBEROS" and
225 ##            imembers.direct = 1 {
226       found = 0;
227       printf("List %s has non-existant kerberos member, id %d\n",
228              ((struct list *)hash_lookup(lists, lid))->name, iid);
229 ##  }
230     return(found);
231 ##}
232
233
234 ##del_mem_user(id)
235 ##int id;
236 ##{
237 ##  int rowcount;
238
239 ##  delete imembers where imembers.member_type = "USER" and
240 ##      imembers.member_id = id and imembers.direct = 1
241 ##  inquire_equel(rowcount = "rowcount");
242     if (rowcount > 0)
243       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
244     else
245       printf("Not deleted\n");
246     modified("imembers");
247 ##}
248
249 ##del_mem_list(id)
250 ##int id;
251 ##{
252 ##  int rowcount;
253
254 ##  delete imembers where imembers.member_type = "LIST" and
255 ##      imembers.member_id = id and imembers.direct = 1
256 ##  inquire_equel(rowcount = "rowcount");
257     if (rowcount > 0)
258       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
259     else
260       printf("Not deleted\n");
261     modified("imembers");
262 ##}
263
264 ##del_mem_str(id)
265 ##int id;
266 ##{
267 ##  int rowcount;
268
269 ##  delete imembers where imembers.member_type = "STRING" and
270 ##      imembers.member_id = id and imembers.direct = 1
271 ##  inquire_equel(rowcount = "rowcount");
272     if (rowcount > 0)
273       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
274     else
275       printf("Not deleted\n");
276     modified("imembers");
277 ##}
278
279
280 ##del_mem_krb(id)
281 ##int id;
282 ##{
283 ##  int rowcount;
284
285 ##  delete imembers where imembers.member_type = "KERBEROS" and
286 ##      imembers.member_id = id and imembers.direct = 1
287 ##  inquire_equel(rowcount = "rowcount");
288     if (rowcount > 0)
289       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
290     else
291       printf("Not deleted\n");
292     modified("imembers");
293 ##}
294
295
296 ##show_sh(id)
297 ##int id;
298 ##{
299 ##  char name[33];
300     int found = 1;
301
302 ##  retrieve (name = serverhosts.service) where serverhosts.mach_id = id {
303       found = 0;
304       printf("ServerHost entry for service %s non-existant host %d\n",
305              name, id);
306 ##  }
307     return(found);
308 ##}
309
310 ##del_sh_mach(id)
311 ##int id;
312 ##{
313 ##  int rowcount;
314
315 ##  delete serverhosts where serverhosts.mach_id = id
316 ##  inquire_equel(rowcount = "rowcount");
317     if (rowcount > 0)
318       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
319     else
320       printf("Not deleted\n");
321     modified("serverhosts");
322 ##}
323
324
325 static int fnchecklen;
326
327 fsmatch(id, n, f)
328 int id;
329 struct nfsphys *n;
330 struct filesys *f;
331 {
332     if (n->mach_id == f->mach_id &&
333         !strncmp(f->dir, n->dir, strlen(n->dir)) &&
334         strlen(n->dir) > fnchecklen) {
335         f->phys_id = id;
336         fnchecklen = strlen(n->dir);
337     }
338 }
339
340
341 ##check_fs(id, f, hint)
342 ##int id;
343 register struct filesys *f;
344 int hint;
345 ##{
346 ##  int id1, id2, id3, rowcount;
347 ##  char *dir;
348     struct nfsphys *n;
349     struct machine *m;
350
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")
357                 if (rowcount > 0)
358                   printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
359                 else
360                   printf("Not fixed\n");
361                 modified("filesys");
362                 f->mach_id = 0;
363             }
364         }
365     }
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);
371                 f->owner = 0;
372             }
373         }
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);
378                 f->owners = 0;
379             }
380         }
381     }
382
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)) {
388                 fnchecklen = 0;
389                 hash_step(nfsphys, fsmatch, f);
390                 if (fnchecklen != 0) {
391                   id1 = f->phys_id;
392                   id2 = f->filsys_id;
393                   id3 = f->mach_id;
394 ##                replace filesys (phys_id = id1) where filesys.filsys_id = id2
395 ##                inquire_equel(rowcount = "rowcount")
396                   if (rowcount > 0)
397                     printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
398                   else
399                     printf("Not fixed\n");
400                   modified("filesys");
401                 } else {
402                     printf("No NFSphys exsits for %s:%s\n", m->name, f->dir);
403                     if (single_fix("Create", 0)) {
404                         dir = f->dir;
405                         id1 = f->phys_id;
406                         id2 = f->filsys_id;
407                         id3 = f->mach_id;
408                         if (set_next_object_id("nfsphys_id", "nfsphys") !=
409                                 MR_SUCCESS) {
410                             printf("Unable to assign unique ID\n");
411                             return;
412                         }
413 ##                      retrieve (id1 = values.value)
414 ##                        where values.name = "nfsphys_id"
415 ##                      inquire_equel(rowcount = "rowcount")
416                         if (rowcount != 1) {
417                             printf("Unable to retrieve unique ID\n");
418                             return;
419                         }
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,
424 ##                                      modwith = "dbck")
425 ##                      inquire_equel(rowcount = "rowcount")
426                         if (rowcount > 0)
427                           printf("%d entr%s created\n", rowcount,
428                                  rowcount==1?"y":"ies");
429                         else
430                           printf("Not created\n");
431                         modified("nfsphys");
432                         n = (struct nfsphys *)malloc(sizeof(struct nfsphys));
433                         if (n == NULL)
434                           out_of_mem("storing new nfsphys");
435                         strcpy(n->dir, dir);
436                         n->mach_id = id3;
437                         n->nfsphys_id = id1;
438                         n->allocated = 0;
439                         n->count = 0;
440                         hash_store(nfsphys, id1, n);
441 ##                      replace filesys (phys_id = id1)
442 ##                        where filesys.filsys_id = id2
443 ##                      inquire_equel(rowcount = "rowcount")
444                         if (rowcount > 0)
445                           printf("%d filesys entr%s fixed\n", rowcount,
446                                  rowcount==1?"y":"ies");
447                         else
448                           printf("Not fixed\n");
449                         modified("filesys");
450                     }
451                 }
452             }
453         }
454     }
455 ##}
456
457
458 check_nfsphys(id, n, hint)
459 int id;
460 struct nfsphys *n;
461 int hint;
462 {
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);
468     }
469 }
470
471 ##show_fsg_missing(id)
472 ##int id;
473 ##{
474 ##  int id1, found = 1;
475     struct filesys *f;
476
477 ##  retrieve (id1 = fsgroup.filsys_id) where fsgroup.group_id = id {
478       found = 0;
479       if (f = (struct filesys *) hash_lookup(filesys, id1))
480         printf("Missing fsgroup %d has member filesystem %s\n", id, f->name);
481       else
482         printf("Missing fsgroup %d has member filesystem %d\n", id, id1);
483 ##  }
484     return(found);
485 ##}
486
487 show_fsg_type(f)
488 struct filesys *f;
489 {
490     char *t;
491
492     switch (f->type) {
493     case 'N':
494         t = "NFS";
495         break;
496     case 'R':
497         t = "RVD";
498         break;
499     case 'A':
500         t = "AFS";
501         break;
502     case 'E':
503         t = "ERR";
504         break;
505     case 'F':
506         t = "FSGROUP";
507         break;
508     default:
509         t = "???";
510     }
511     printf("FSGroup %s has type %s instead of FSGROUP\n", f->name, t);
512     return(0);
513 }
514
515 fix_fsg_type(f)
516 struct filesys *f;
517 ##{
518 ##  int rowcount, id = f->filsys_id;
519
520 ##  replace filesys (type = "FSGROUP") where filesys.filsys_id = id
521 ##  inquire_equel(rowcount = "rowcount")
522     if (rowcount > 0)
523       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
524     else
525       printf("Not fixed\n");
526     modified("filesys");
527 ##}
528
529 ##show_fsg_nomember(id)
530 ##int id;
531 ##{
532 ##  int id1, found = 1;
533     struct filesys *f;
534
535 ##  retrieve (id1 = fsgroup.group_id) where fsgroup.filsys_id = id {
536       found = 0;
537       if (f = (struct filesys *) hash_lookup(filesys, id1))
538         printf("FSGroup %s has missing member %d\n", f->name, id);
539       else
540         printf("FSGroup %d has missing member %d\n", id1, id);
541 ##  }
542     return(found);
543 ##}
544
545 ##show_quota_nouser(id)
546 ##int id;
547 ##{
548 ##  int id1, found = 1;
549
550 ##  retrieve (id1 = nfsquota.filsys_id) where nfsquota.users_id = id {
551       found = 0;
552       printf("NFSquota on fs %d for non-existant user %d\n", id1, id);
553 ##  }
554     return(found);
555 ##}
556
557 fix_quota_nouser(id)
558 {
559     single_delete("nfsquota", "users_id", id);
560 }
561
562 ##show_quota_nofs(id)
563 ##int id;
564 ##{
565 ##  int id1, found = 1;
566     struct user *u;
567
568 ##  retrieve (id1 = nfsquota.users_id) where nfsquota.filsys_id = id {
569       u = (struct user *)hash_lookup(users, id1);
570       found = 0;
571       printf("NFSquota for user %s on non-existant filesys %d\n", u->login, id);
572 ##  }
573     return(found);
574 ##}
575
576 fix_quota_nofs(id)
577 {
578     single_delete("nfsquota", "filsys_id", id);
579 }
580
581 ##show_quota_wrongpid(id)
582 ##int id;
583 ##{
584 ##  int id1, found = 1;
585     struct user *u;
586     struct filesys *f;
587
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);
591       found = 0;
592       printf("NFSquota for user %s on filesys %s has wrong phys_id %d\n",
593              u->login, f->name, id);
594 ##  }
595     return(found);
596 ##}
597
598 ##fix_quota_physid(id)
599 ##int id;
600 ##{
601 ##  int rowcount, id1;
602
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")
607     if (rowcount > 0)
608       printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
609     else
610       printf("Not fixed\n");
611     modified("nfsquota");
612 ##}
613
614 ##show_srv_user(id)
615 ##int id;
616 ##{
617 ##  char name[33];
618     int found = 1;
619
620 ##  retrieve (name = s.#name) where s.acl_type = "USER" and s.acl_id = id {
621         strtrim(name);
622         printf("Service %s has acl non-existant user %d\n", name, id);
623         found = 0;
624 ##  }
625     return(found);
626 ##}
627
628 ##show_srv_list(id)
629 ##int id;
630 ##{
631 ##  char name[33];
632     int found = 1;
633
634 ##  retrieve (name = s.#name) where s.acl_type = "LIST" and s.acl_id = id {
635         strtrim(name);
636         printf("Service %s has acl non-existant list %d\n", name, id);
637         found = 0;
638 ##  }
639     return(found);
640 ##}
641
642 ##zero_srv_user(id)
643 ##int id;
644 ##{
645 ##  int rowcount;
646
647 ##  replace servers (acl_id = 0) where servers.acl_id = id and
648 ##      servers.acl_type = "USER"
649 ##  inquire_equel(rowcount = "rowcount")
650     if (rowcount > 0)
651       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
652     else
653       printf("Not fixed\n");
654     modified("servers");
655 ##}
656
657 ##zero_srv_list(id)
658 ##int id;
659 ##{
660 ##  int rowcount;
661
662 ##  replace servers (acl_id = 0) where servers.acl_id = id and
663 ##      servers.acl_type = "LIST"
664 ##  inquire_equel(rowcount = "rowcount")
665     if (rowcount > 0)
666       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
667     else
668       printf("Not fixed\n");
669     modified("servers");
670 ##}
671
672
673 ##show_krb_usr(id)
674 ##int id;
675 ##{
676 ##  int found = 1, id1;
677     struct string *s;
678     char *ss;
679
680 ##  retrieve (id1 = krbmap.string_id) where krbmap.users_id = id {
681         if (s = ((struct string *)hash_lookup(strings, id1)))
682           ss = s->name;
683         else
684           ss = "[unknown]";
685         found = 0;
686         printf("Kerberos map for non-existant user %d to principal %s\n",
687                id, s);
688 ##  }
689     return(found);
690 ##}
691
692
693 ##show_krb_str(id)
694 ##int id;
695 ##{
696 ##  int found = 1, id1;
697     struct user *u;
698     char *s;
699
700 ##  retrieve (id1 = krbmap.users_id) where krbmap.string_id = id {
701         if (u = ((struct user *)hash_lookup(users, id1)))
702           s = u->login;
703         else
704           s = "[???]";
705         found = 0;
706         printf("Kerberos map for user %s (%d) to non-existant string %d\n",
707                s, id1, id);
708 ##  }
709     return(found);
710 ##}
711
712
713 ##show_pdm_mach(id)
714 ##int id;
715 ##{
716 ##  char name[33];
717     int found = 1;
718
719 ##  retrieve (name = palladium.#name) where palladium.mach_id = id {
720         strtrim(name);
721         printf("Palladium server/supervisor %s is on non-existant machine %d\n",
722                name, id);
723         found = 0;
724 ##  }
725     return(found);
726 ##}
727
728
729 phase2()
730 ##{
731 ##  int id1, id2, id3, id4, id5;
732 ##  char type[9], name[33];
733     struct save_queue *sq, *sq1, *sq2, *sq3, *sq4, *sq5;
734     struct filesys *f;
735     struct list *l;
736     struct nfsphys *n;
737     struct machine *m;
738
739     printf("Phase 2 - Checking references\n");
740
741     dprintf("Checking users...\n");
742     hash_step(users, pobox_check, NULL);
743
744     dprintf("Checking mcmap...\n");
745     sq1 = sq_create();
746     sq2 = sq_create();
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++;
753 ##  }
754     generic_delete(sq1, show_mcm_mach, "mcmap", "mach_id", 1);
755     generic_delete(sq2, show_mcm_clu, "mcmap", "clu_id", 1);
756
757     dprintf("Checking service clusters...\n");
758     sq1 = sq_create();
759 ##  retrieve (id1 = svc.clu_id) {
760         if (!hash_lookup(clusters, id1))
761           sq_save_unique_data(sq1, id1);
762 ##  }
763     generic_delete(sq1, show_svc, "svc", "clu_id", 1);
764
765     dprintf("Checking lists...\n");
766     hash_step(lists, list_check, NULL);
767
768     dprintf("Checking members...\n");
769     sq1 = sq_create();
770     sq2 = sq_create();
771     sq3 = sq_create();
772     sq4 = sq_create();
773     sq5 = sq_create();
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);
787         else
788           l->members++;
789 ##  }
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);
795
796     dprintf("Checking servers...\n");
797     sq1 = sq_create();
798     sq2 = sq_create();
799 ##  range of s is servers
800 ##  retrieve (name = s.#name, type = s.acl_type, id1 = s.acl_id) {
801         strtrim(type);
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);
806         }
807 ##  }
808     generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
809     generic_fix(sq2, show_srv_list, "Fix", zero_srv_list, 1);
810
811     dprintf("Checking servershosts...\n");
812     sq = sq_create();
813 ##  retrieve (id1 = serverhosts.mach_id) {
814         if (!hash_lookup(machines, id1))
815           sq_save_data(sq, id1);
816 ##  }
817     generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
818
819     dprintf("Checking nfsphys...\n");
820     hash_step(nfsphys, check_nfsphys, NULL);
821
822     dprintf("Checking filesys...\n");
823     hash_step(filesys, check_fs, NULL);
824
825     dprintf("Checking filesystem groups...\n");
826     sq1 = sq_create();
827     sq2 = sq_create();
828     sq3 = sq_create();
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);
832         if (f->type  != 'F')
833           sq_save_data(sq2, f);
834         if (!hash_lookup(filesys, id2))
835           sq_save_data(sq3, id2);
836 ##  }
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);
840
841     dprintf("Checking nfsquota...\n");
842     sq1 = sq_create();
843     sq2 = sq_create();
844     sq3 = sq_create();
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);
855         else
856           n->count += id4;
857 ##  }
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);
861
862     dprintf("Not checking zephyr.\n");
863
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) {
867         strtrim(type);
868         if (!hash_lookup(machines, id1)) {
869             printf("Hostaccess for non-existant host %d\n", id1);
870             printf("Not fixing this error\n");
871         }
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");
878         }
879 ##  }
880
881     dprintf("Checking palladium...\n");
882     sq1 = sq_create();
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);
887         }
888 ##  }
889     generic_delete(sq1, show_pdm_mach, "palladium", "mach_id", 1);
890
891     dprintf("Checking krbmap...\n");
892     sq1 = sq_create();
893     sq2 = sq_create();
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);
900 ##  }
901     generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1);
902     generic_delete(sq2, show_krb_str, "krbmap", "string_id", 1);
903
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");
909         }
910 ##  }
911
912 ##}
913
This page took 0.113963 seconds and 5 git commands to generate.