]> andersk Git - moira.git/blob - dbck/phase2.dc
Initial revision
[moira.git] / dbck / phase2.dc
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 EXEC SQL INCLUDE sqlca;
13
14 static char phase2_qc_rcsid[] = "$Header$";
15
16
17 show_mcm_mach(id)
18 int id;
19 {
20     EXEC SQL BEGIN DECLARE SECTION; 
21     int iid = id, found = 1;
22     char name[33];
23     EXEC SQL END DECLARE SECTION; 
24
25     EXEC SQL DECLARE csr201 CURSOR FOR
26       SELECT cluster.name FROM cluster, mcmap
27         WHERE cluster.clu_id=mcmap.clu_id AND mcmap.mach_id = :iid;
28     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
29     EXEC SQL OPEN csr201;
30     while(1) {
31         EXEC SQL FETCH csr201 INTO :name;
32         if (sqlca.sqlcode != 0) {
33           ingerr(&sqlca.sqlcode);
34           break;
35         } 
36
37         strtrim(name);
38         found = 0;
39         printf("Clusqter %s, non-existant machine %d in cluster map\n", name, id);
40     }
41     EXEC SQL CLOSE csr201; 
42     return(found);
43 }
44
45 show_mcm_clu(id)
46 int id;
47 {
48     EXEC SQL BEGIN DECLARE SECTION; 
49     int iid = id, found = 1;
50     char name[33];
51     EXEC SQL END DECLARE SECTION; 
52
53     EXEC SQL DECLARE csr202 CURSOR FOR
54         SELECT machine.name FROM machine, mcmap
55             WHERE machine.mach_id=mcmap.mach_id AND mcmap.clu_id=:iid;
56     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
57     EXEC SQL OPEN csr202;
58     while(1) {
59         EXEC SQL FETCH csr202 INTO :name;
60         if (sqlca.sqlcode != 0) {
61           ingerr(&sqlca.sqlcode);
62           break;
63         } 
64
65         strtrim(name);
66         found = 0;
67         printf("Machine %s, non-existant cluster %d in cluster map\n", name, id);
68     }
69     EXEC SQL CLOSE csr202; 
70     return(found);
71 }
72
73 pobox_check(id, u, hint)
74 int id;
75 struct user *u;
76 int hint;
77 {
78     switch (u->potype) {
79     case 'P':
80         if (!hash_lookup(machines, u->pobox_id)) {
81             printf("User %s(%s) has P.O.Box on non-existant machine %d\n",
82                    u->login, u->fullname, u->pobox_id);
83             if (single_fix("Delete", 0)) {
84                 remove_pobox(u->users_id);
85                 u->potype = 'N';
86             }
87         }
88         break;
89     case 'S':
90         if (!string_check(u->pobox_id)) {
91             printf("User %s(%s) has P.O.Box with non-existant string %d\n",
92                    u->login, u->fullname, u->pobox_id);
93             if (single_fix("Delete", 0)) {
94                 remove_pobox(u->users_id);
95                 u->potype = 'N';
96             }
97         }
98         break;
99     default:
100         ;
101     }
102 }
103
104
105 remove_pobox(id)
106 int id;
107 {
108     EXEC SQL BEGIN DECLARE SECTION; 
109     int rowcount, iid = id;
110     EXEC SQL END DECLARE SECTION; 
111
112     EXEC SQL UPDATE users SET potype='NONE' WHERE users.users_id = :iid;
113     EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
114     if (rowcount > 0)
115       printf("%d entr%s removed\n", rowcount, rowcount==1?"y":"ies");
116     else
117       printf("Not removed\n");
118     modified("users");
119 }
120
121 show_svc(id)
122 int id;
123 {
124     EXEC SQL BEGIN DECLARE SECTION; 
125     int iid = id, found = 1;
126     char label[17], data[33];
127     EXEC SQL END DECLARE SECTION; 
128
129     EXEC SQL DECLARE csr203 CURSOR FOR
130         SELECT serv_label, serv_cluster FROM svc
131             WHERE clu_id = :iid;
132     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
133     EXEC SQL OPEN csr203;
134     while(1) {
135         EXEC SQL FETCH csr203 INTO :label, :data;
136         if (sqlca.sqlcode != 0) {
137           ingerr(&sqlca.sqlcode);
138           break;
139         }
140
141         strtrim(label);
142         strtrim(data);
143         found = 0;
144         printf("Cluster data [%s] %s for non-existant cluster %d\n",
145                label, data, id);
146     }
147     EXEC SQL CLOSE csr203; 
148     return(found);
149 }
150
151 list_check(id, l, hint)
152 int id;
153 struct list *l;
154 int hint;
155 {
156     switch (l->acl_type) {
157     case 'L':
158         if (!hash_lookup(lists, l->acl_id)) {
159             printf("List %s has bad LIST acl %d\n", l->name, l->acl_id);
160             if (single_fix("Patch", 1)) {
161                 fix_list_acl(l->list_id);
162             }
163         }
164         break;
165     case 'U':
166         if (!hash_lookup(users, l->acl_id)) {
167             printf("List %s has bad USER acl %d\n", l->name, l->acl_id);
168             if (single_fix("Patch", 1)) {
169                 fix_list_acl(l->list_id);
170             }
171         }
172         break;
173     }
174 }
175
176 fix_list_acl(id)
177 int id;
178 {
179     EXEC SQL BEGIN DECLARE SECTION; 
180     int rowcount, iid = id;
181     EXEC SQL END DECLARE SECTION; 
182
183     EXEC SQL UPDATE list SET acl_id = :iid, acl_type='LIST'
184         WHERE list_id = :iid;
185     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
186     if (rowcount > 0)
187       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
188     else
189       printf("Not fixed\n");
190     modified("list");
191 }
192
193
194 show_member_list(id)
195 int id;
196 {
197     EXEC SQL BEGIN DECLARE SECTION; 
198     int mid, iid = id, found = 1;
199     char mtype[9], *name = "";
200     EXEC SQL END DECLARE SECTION;
201
202     EXEC SQL DECLARE csr204 CURSOR FOR
203         SELECT member_type, member_id FROM imembers
204             WHERE list_id = :iid AND direct=1;
205     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
206     EXEC SQL OPEN csr204;
207     while(1) {
208         EXEC SQL FETCH csr204 INTO :mtype, :mid;
209         if (sqlca.sqlcode != 0) {
210           ingerr(&sqlca.sqlcode);
211           break;
212         } 
213
214         strtrim(mtype);
215         found = 0;
216         if (mtype[0] == 'L')
217             name = ((struct list *) hash_lookup(lists, mid))->name;
218         else if (mtype[0] == 'U')
219             name = ((struct user *) hash_lookup(users, mid))->login;
220         else if (mtype[0] == 'S' || mtype[0] == 'K')
221             name = ((struct string *) hash_lookup(strings, mid))->name;
222         printf("Non-existant list %d has member %s %s\n", iid, mtype, name);
223     }
224     EXEC SQL CLOSE csr204; 
225     return(found);
226 }
227
228 show_mem_user(id)
229 int id;
230 {
231     EXEC SQL BEGIN DECLARE SECTION; 
232     int lid, iid = id, found = 1;
233     char name[33];
234     EXEC SQL END DECLARE SECTION; 
235
236     EXEC SQL DECLARE csr205 CURSOR FOR
237       SELECT list_id FROM imembers
238         WHERE member_id = :iid AND member_type='USER' AND direct=1;
239     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
240     EXEC SQL OPEN csr205;
241     while(1) {
242         EXEC SQL FETCH csr205 INTO :lid;
243         if (sqlca.sqlcode != 0) {
244           ingerr(&sqlca.sqlcode);
245           break;
246         }       
247         
248         found = 0;
249         printf("List %s has non-existant user member, id %d\n",
250                ((struct list *)hash_lookup(lists, lid))->name, iid);
251     }
252     EXEC SQL CLOSE csr205;
253     return(found);
254 }
255
256 show_mem_list(id)
257 int id;
258 {
259     EXEC SQL BEGIN DECLARE SECTION; 
260     int lid, iid = id, found = 1;
261     char name[33];
262     EXEC SQL END DECLARE SECTION; 
263
264     EXEC SQL DECLARE csr206 CURSOR FOR
265         SELECT list_id FROM imembers
266             WHERE member_id = :iid AND member_type='LIST' AND direct=1;
267     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
268     EXEC SQL OPEN csr206;
269     while(1) {
270         EXEC SQL FETCH csr206 INTO :lid;
271         if (sqlca.sqlcode != 0) {
272           ingerr(&sqlca.sqlcode);
273           break;
274         } 
275
276         found = 0;
277         printf("List %s has non-existant list member, id %d\n",
278                ((struct list *)hash_lookup(lists, lid))->name, iid);
279     }
280     EXEC SQL CLOSE csr206; 
281     return(found);
282 }
283
284 show_mem_str(id)
285 int id;
286 {
287     EXEC SQL BEGIN DECLARE SECTION; 
288     int lid, iid = id, found = 1;
289     char name[33];
290     EXEC SQL END DECLARE SECTION; 
291
292     EXEC SQL DECLARE csr207 CURSOR FOR
293         SELECT list_id FROM imembers
294             WHERE member_id = :iid AND member_type='STRING' AND direct=1;
295     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
296     EXEC SQL OPEN csr207;
297     while(1) {
298         EXEC SQL FETCH csr207 INTO :lid;
299         if (sqlca.sqlcode != 0) {
300           ingerr(&sqlca.sqlcode);
301           break;
302         } 
303         
304         found = 0;
305         printf("List %s has non-existant string member, id %d\n",
306                ((struct list *)hash_lookup(lists, lid))->name, iid);
307     }
308     EXEC SQL CLOSE csr207; 
309     return(found);
310 }
311
312
313 show_mem_krb(id)
314 int id;
315 {
316     EXEC SQL BEGIN DECLARE SECTION; 
317     int lid, iid = id, found = 1;
318     char name[33];
319     EXEC SQL END DECLARE SECTION; 
320
321     EXEC SQL DECLARE csr208 CURSOR FOR
322         SELECT list_id FROM imembers
323             WHERE member_id = :iid AND member_type='KERBEROS' AND direct=1;
324     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
325     EXEC SQL OPEN csr208;
326     while(1) {
327         EXEC SQL FETCH csr208 INTO :lid;
328         if (sqlca.sqlcode != 0) {
329           ingerr(&sqlca.sqlcode);
330           break;
331         } 
332
333         found = 0;
334         printf("List %s has non-existant kerberos member, id %d\n",
335                ((struct list *)hash_lookup(lists, lid))->name, iid);
336     }
337     EXEC SQL CLOSE csr208; 
338     return(found);
339 }
340
341
342 del_mem_user(id)
343 EXEC SQL BEGIN DECLARE SECTION; 
344 int id;
345 EXEC SQL END DECLARE SECTION; 
346 {
347     EXEC SQL BEGIN DECLARE SECTION; 
348     int rowcount;
349     EXEC SQL END DECLARE SECTION; 
350
351     EXEC SQL DELETE FROM imembers WHERE member_type='USER' AND
352         member_id = :id AND direct = 1;
353     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
354     if (rowcount > 0)
355       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
356     else
357       printf("Not deleted\n");
358     modified("imembers");
359 }
360
361 del_mem_list(id)
362 EXEC SQL BEGIN DECLARE SECTION; 
363 int id;
364 EXEC SQL END DECLARE SECTION; 
365 {
366     EXEC SQL BEGIN DECLARE SECTION; 
367     int rowcount;
368     EXEC SQL END DECLARE SECTION; 
369
370     EXEC SQL DELETE FROM imembers WHERE member_type='LIST' AND
371         member_id = :id AND direct=1;
372     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
373     if (rowcount > 0)
374       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
375     else
376       printf("Not deleted\n");
377     modified("imembers");
378 }
379
380 del_mem_str(id)
381 EXEC SQL BEGIN DECLARE SECTION; 
382 int id;
383 EXEC SQL END DECLARE SECTION; 
384 {
385     EXEC SQL BEGIN DECLARE SECTION; 
386     int rowcount;
387     EXEC SQL END DECLARE SECTION; 
388
389     EXEC SQL DELETE FROM imembers WHERE member_type='STRING' AND
390         member_id = :id AND direct=1;
391     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
392     if (rowcount > 0)
393       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
394     else
395       printf("Not deleted\n");
396     modified("imembers");
397 }
398
399
400 del_mem_krb(id)
401 EXEC SQL BEGIN DECLARE SECTION; 
402 int id;
403 EXEC SQL END DECLARE SECTION; 
404 {
405     EXEC SQL BEGIN DECLARE SECTION; 
406     int rowcount;
407     EXEC SQL END DECLARE SECTION; 
408
409     EXEC SQL DELETE FROM imembers WHERE member_type='KERBEROS' AND
410         member_id = :id AND direct=1;
411     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
412     if (rowcount > 0)
413       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
414     else
415       printf("Not deleted\n");
416     modified("imembers");
417 }
418
419
420 show_sh(id)
421 EXEC SQL BEGIN DECLARE SECTION; 
422 int id;
423 EXEC SQL END DECLARE SECTION; 
424 {
425     EXEC SQL BEGIN DECLARE SECTION; 
426     char name[33];
427     EXEC SQL END DECLARE SECTION; 
428     int found = 1;
429
430     EXEC SQL DECLARE csr209 CURSOR FOR
431         SELECT service FROM serverhosts
432             WHERE mach_id = :id;
433     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
434     EXEC SQL OPEN csr209;
435     while(1) {
436         EXEC SQL FETCH csr209 INTO :name;
437         if (sqlca.sqlcode != 0) {
438           ingerr(&sqlca.sqlcode);
439           break;
440         } 
441
442         found = 0;
443         printf("ServerHost entry for service %s non-existant host %d\n",
444                name, id);
445     }
446     EXEC SQL CLOSE csr209; 
447     return(found);
448 }
449
450 del_sh_mach(id)
451 EXEC SQL BEGIN DECLARE SECTION; 
452 int id;
453 EXEC SQL END DECLARE SECTION; 
454 {
455     EXEC SQL BEGIN DECLARE SECTION; 
456     int rowcount;
457     EXEC SQL END DECLARE SECTION; 
458
459     EXEC SQL DELETE FROM serverhosts WHERE mach_id = :id;
460     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
461     if (rowcount > 0)
462       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
463     else
464       printf("Not deleted\n");
465     modified("serverhosts");
466 }
467
468
469 static int fnchecklen;
470
471 fsmatch(id, n, f)
472 int id;
473 struct nfsphys *n;
474 struct filesys *f;
475 {
476     if (n->mach_id == f->mach_id &&
477         !strncmp(f->dir, n->dir, strlen(n->dir)) &&
478         strlen(n->dir) > fnchecklen) {
479         f->phys_id = id;
480         fnchecklen = strlen(n->dir);
481     }
482 }
483
484
485 check_fs(id, f, hint)
486 EXEC SQL BEGIN DECLARE SECTION; 
487 int id;
488 EXEC SQL END DECLARE SECTION; 
489 register struct filesys *f;
490 int hint;
491 {
492     EXEC SQL BEGIN DECLARE SECTION; 
493     int id1, id2, id3, rowcount;
494     char *dir;
495     EXEC SQL END DECLARE SECTION; 
496     struct nfsphys *n;
497     struct machine *m;
498
499     if (!hash_lookup(machines, f->mach_id)) {
500         printf("Filesys %s with bad machine %d\n", f->name, f->mach_id);
501         if (single_fix("Fix", 0)) {
502             EXEC SQL UPDATE filesys SET mach_id = 0 WHERE filsys_id = :id;
503             EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
504             if (rowcount > 0)
505               printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
506             else
507               printf("Not fixed\n");
508             modified("filesys");
509             f->mach_id = 0;
510         }
511     }
512
513     if (!hash_lookup(users, f->owner)) {
514         printf("Filesys %s with bad owning user %d\n", f->name, f->owner);
515         if (single_fix("Fix", 1)) {
516             zero_fix("filesys", "owner", "filsys_id", f->filsys_id);
517             f->owner = 0;
518         }
519     }
520     if (!hash_lookup(lists, f->owners)) {
521         printf("Filesys %s with bad owning group %d\n", f->name, f->owners);
522         if (single_fix("Fix", 1)) {
523             zero_fix("filesys", "owners", "filsys_id", f->filsys_id);
524             f->owners = 0;
525         }
526     }
527
528     if (f->type == 'N') {
529         if (!hash_lookup(nfsphys, f->phys_id)) {
530             m = (struct machine *)hash_lookup(machines, f->mach_id);
531             printf("Filesys %s with bad phys_id %d\n", f->name, f->phys_id);
532             if (single_fix("Fix", 1)) {
533                 fnchecklen = 0;
534                 hash_step(nfsphys, fsmatch, f);
535                 if (fnchecklen != 0) {
536                   id1 = f->phys_id;
537                   id2 = f->filsys_id;
538                   id3 = f->mach_id;
539                   EXEC SQL UPDATE filesys SET phys_id = :id1 WHERE filsys_id = :id2;
540                   EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
541                   if (rowcount > 0)
542                     printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
543                   else
544                     printf("Not fixed\n");
545                   modified("filesys");
546                 } else {
547                     printf("No NFSphys exsits for %s:%s\n", m->name, f->dir);
548                     if (single_fix("Create", 0)) {
549                         dir = f->dir;
550                         id1 = f->phys_id;
551                         id2 = f->filsys_id;
552                         id3 = f->mach_id;
553                         if (set_next_object_id("nfsphys_id", "nfsphys") !=
554                                 MR_SUCCESS) {
555                             printf("Unable to assign unique ID\n");
556                             return;
557                         }
558                         EXEC SQL SELECT COUNT(*) INTO :rowcount FROM numvalues 
559                             WHERE name='nfsphys_id';
560                         if (rowcount != 1) {
561                             printf("Unable to retrieve unique ID\n");
562                             return;
563                         }
564                         EXEC SQL INSERT INTO mfsphys (mfsphys_id, mach_id,
565                             device, dir, status, allocated, size, modtime,
566                             modby, modwith) VALUES (:id1, :id3, '???', :dir,
567                             0, 0, 0, 'now', 0, 'dbck');
568                         EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
569                         if (rowcount > 0)
570                           printf("%d entr%s created\n", rowcount,
571                                  rowcount==1?"y":"ies");
572                         else
573                           printf("Not created\n");
574                         modified("nfsphys");
575                         n = (struct nfsphys *)malloc(sizeof(struct nfsphys));
576                         if (n == NULL)
577                           out_of_mem("storing new nfsphys");
578                         strcpy(n->dir, dir);
579                         n->mach_id = id3;
580                         n->nfsphys_id = id1;
581                         n->allocated = 0;
582                         n->count = 0;
583                         hash_store(nfsphys, id1, n);
584                         EXEC SQL UPDATE filesys SET phys_id = :id1
585                             WHERE filsys_id = :id2;
586                         EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
587                         if (rowcount > 0)
588                           printf("%d filesys entr%s fixed\n", rowcount,
589                                  rowcount==1?"y":"ies");
590                         else
591                           printf("Not fixed\n");
592                         modified("filesys");
593                     }
594                 }
595             }
596         }
597     }
598 }
599
600
601 check_nfsphys(id, n, hint)
602 int id;
603 struct nfsphys *n;
604 int hint;
605 {
606     if (!hash_lookup(machines, n->mach_id)) {
607         printf("NFSphys %d(%s) on non-existant machine %d\n",
608                id, n->dir, n->mach_id);
609         if (single_fix("Delete", 0))
610           single_delete("nfsphys", "nfsphys_id", id);
611     }
612 }
613
614 show_fsg_missing(id)
615 EXEC SQL BEGIN DECLARE SECTION; 
616 int id;
617 EXEC SQL END DECLARE SECTION; 
618 {
619     EXEC SQL BEGIN DECLARE SECTION; 
620     int id1, found = 1;
621     EXEC SQL END DECLARE SECTION; 
622     struct filesys *f;
623
624     EXEC SQL DECLARE csr210 CURSOR FOR
625         SELECT filsys_id FROM fsgroup
626             WHERE group_id = :id;
627     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
628     EXEC SQL OPEN csr210;
629     while(1) {
630         EXEC SQL FETCH csr210 INTO :id1;
631         if (sqlca.sqlcode != 0) {
632           ingerr(&sqlca.sqlcode);
633           break;
634         } 
635
636         found = 0;
637         if (f = (struct filesys *) hash_lookup(filesys, id1))
638             printf("Missing fsgroup %d has member filesystem %s\n", id, f->name);
639         else
640             printf("Missing fsgroup %d has member filesystem %d\n", id, id1);
641     }
642     EXEC SQL CLOSE csr210; 
643     return(found);
644 }
645
646 show_fsg_type(f)
647 struct filesys *f;
648 {
649     char *t;
650
651     switch (f->type) {
652     case 'N':
653         t = "NFS";
654         break;
655     case 'R':
656         t = "RVD";
657         break;
658     case 'A':
659         t = "AFS";
660         break;
661     case 'E':
662         t = "ERR";
663         break;
664     case 'F':
665         t = "FSGROUP";
666         break;
667     case 'M':
668         t = "MUL";
669         break;
670     default:
671         t = "???";
672     }
673     printf("FSGroup %s has type %s instead of FSGROUP\n", f->name, t);
674     return(0);
675 }
676
677 fix_fsg_type(f)
678 struct filesys *f;
679 {
680     EXEC SQL BEGIN DECLARE SECTION; 
681     int rowcount, id = f->filsys_id;
682     EXEC SQL END DECLARE SECTION; 
683
684     EXEC SQL UPDATE filesys SET type='FSGROUP' WHERE filsys_id = :id;
685     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
686     if (rowcount > 0)
687       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
688     else
689       printf("Not fixed\n");
690     modified("filesys");
691 }
692
693 show_fsg_nomember(id)
694 EXEC SQL BEGIN DECLARE SECTION; 
695 int id;
696 EXEC SQL END DECLARE SECTION; 
697 {
698     EXEC SQL BEGIN DECLARE SECTION; 
699     int id1, found = 1;
700     EXEC SQL END DECLARE SECTION; 
701     struct filesys *f;
702
703     EXEC SQL DECLARE csr211 CURSOR FOR
704         SELECT group_id FROM fsgroup
705             WHERE filsys_id = :id;
706     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
707     EXEC SQL OPEN csr211;
708     while(1) {
709         EXEC SQL FETCH csr211 INTO :id1;
710         if (sqlca.sqlcode != 0) {
711           ingerr(&sqlca.sqlcode);
712           break;
713         } 
714
715         found = 0;
716         if (f = (struct filesys *) hash_lookup(filesys, id1))
717             printf("FSGroup %s has missing member %d\n", f->name, id);
718         else
719             printf("FSGroup %d has missing member %d\n", id1, id);
720     }
721     EXEC SQL CLOSE csr211; 
722     return(found);
723 }
724
725 show_quota_nouser(id)
726 EXEC SQL BEGIN DECLARE SECTION; 
727 int id;
728 EXEC SQL END DECLARE SECTION; 
729 {
730     EXEC SQL BEGIN DECLARE SECTION; 
731     int id1, found = 1;
732     EXEC SQL END DECLARE SECTION; 
733
734     EXEC SQL DECLARE csr212 CURSOR FOR
735         SELECT filsys_id FROM quota
736             WHERE entity_id = :id AND type='USER';
737     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
738     EXEC SQL OPEN csr212;
739     while(1) {
740         EXEC SQL FETCH csr212 INTO :id1;
741         if (sqlca.sqlcode != 0) {
742           ingerr(&sqlca.sqlcode);
743           break;
744         } 
745
746         found = 0;
747         printf("Quota on fs %d for non-existant user %d\n", id1, id);
748     }
749     EXEC SQL CLOSE csr212; 
750     return(found);
751 }
752
753 show_quota_nolist(id)
754 EXEC SQL BEGIN DECLARE SECTION; 
755 int id;
756 EXEC SQL END DECLARE SECTION; 
757 {
758     EXEC SQL BEGIN DECLARE SECTION; 
759     int id1, found = 1;
760     EXEC SQL END DECLARE SECTION; 
761
762     EXEC SQL DECLARE csr213 CURSOR FOR
763         SELECT filsys_id FROM quota 
764             WHERE entity_id = :id AND type='GROUP';
765     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
766     EXEC SQL OPEN csr213;
767     while(1) {
768         EXEC SQL FETCH csr213 INTO :id1;
769         if (sqlca.sqlcode != 0) {
770           ingerr(&sqlca.sqlcode);
771           break;
772         }
773  
774         found = 0;
775         printf("Quota on fs %d for non-existant list %d\n", id1, id);
776     }
777     EXEC SQL CLOSE csr213; 
778     return(found);
779 }
780
781 fix_quota_nouser(id)
782 EXEC SQL BEGIN DECLARE SECTION; 
783 int id;
784 EXEC SQL END DECLARE SECTION; 
785 {
786     EXEC SQL BEGIN DECLARE SECTION; 
787     int rowcount, id1;
788     EXEC SQL END DECLARE SECTION; 
789
790     id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
791     EXEC SQL DELETE FROM quota 
792         WHERE entity_id = :id AND type = 'USER';
793     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
794     if (rowcount > 0)
795       printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies");
796     else
797       printf("Not deleted\n");
798     modified("quota");
799 }
800
801 fix_quota_nolist(id)
802 EXEC SQL BEGIN DECLARE SECTION; 
803 int id;
804 EXEC SQL END DECLARE SECTION; 
805 {
806     EXEC SQL BEGIN DECLARE SECTION; 
807     int rowcount, id1;
808     EXEC SQL END DECLARE SECTION; 
809
810     id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
811     EXEC SQL DELETE FROM quota WHERE entity_id = :id AND type='GROUP';
812     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
813     if (rowcount > 0)
814       printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies");
815     else
816       printf("Not deleted\n");
817     modified("quota");
818 }
819
820 show_quota_nofs(id)
821 EXEC SQL BEGIN DECLARE SECTION; 
822 int id;
823 EXEC SQL END DECLARE SECTION; 
824 {
825     EXEC SQL BEGIN DECLARE SECTION; 
826     int id1, found = 1;
827     char type[9];
828     EXEC SQL END DECLARE SECTION; 
829
830     EXEC SQL DECLARE csr214 CURSOR FOR
831         SELECT entity_id, type FROM quota
832             WHERE filsys_id = :id;
833     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
834     EXEC SQL OPEN csr214;
835     while(1) {
836         EXEC SQL FETCH csr214 INTO :id1, :type;
837         if (sqlca.sqlcode != 0) {
838           ingerr(&sqlca.sqlcode);
839           break;
840         } 
841         
842         found = 0;
843         printf("Quota for %s %d on non-existant filesys %d\n", type, id1, id);
844     }
845     EXEC SQL CLOSE csr214;
846     return(found);
847 }
848
849 fix_quota_nofs(id)
850 {
851     single_delete("quota", "filsys_id", id);
852 }
853
854 show_quota_wrongpid(id)
855 EXEC SQL BEGIN DECLARE SECTION; 
856 int id;
857 EXEC SQL END DECLARE SECTION; 
858 {
859     EXEC SQL BEGIN DECLARE SECTION; 
860     int id1, found = 1;
861     char type[9];
862     EXEC SQL END DECLARE SECTION; 
863     struct user *u;
864     struct filesys *f;
865
866     f = (struct filesys *)hash_lookup(filesys, id);
867     EXEC SQL DECLARE csr215 CURSOR FOR
868         SELECT entity_id, type FROM quota
869             WHERE filsys_id = :id;
870     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
871     EXEC SQL OPEN csr215;
872     while(1) {
873         EXEC SQL FETCH csr215 INTO :id1, :type;
874         if (sqlca.sqlcode != 0) {
875           ingerr(&sqlca.sqlcode);
876           break;
877         } 
878
879         found = 0;
880         printf("Quota for %s %d on filesys %s has wrong phys_id %d\n",
881                type, id1, f->name, id);
882     }
883     EXEC SQL CLOSE csr215; 
884     return(found);
885 }
886
887 fix_quota_physid(id)
888 EXEC SQL BEGIN DECLARE SECTION; 
889 int id;
890 EXEC SQL END DECLARE SECTION; 
891 {
892     EXEC SQL BEGIN DECLARE SECTION; 
893     int rowcount, id1;
894     EXEC SQL END DECLARE SECTION; 
895
896     id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
897     EXEC SQL UPDATE quota SET phys_id = :id1 
898         WHERE filsys_id = :id AND phys_id != :id1;
899     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
900     if (rowcount > 0)
901       printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
902     else
903       printf("Not fixed\n");
904     modified("quota");
905 }
906
907 show_srv_user(id)
908 EXEC SQL BEGIN DECLARE SECTION; 
909 int id;
910 EXEC SQL END DECLARE SECTION; 
911 {
912     EXEC SQL BEGIN DECLARE SECTION; 
913     char name[33];
914     EXEC SQL END DECLARE SECTION; 
915     int found = 1;
916
917     EXEC SQL DECLARE csr216 CURSOR FOR
918         SELECT name FROM servers
919             WHERE acl_type='USER' and acl_id = :id;
920     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
921     EXEC SQL OPEN csr216;
922     while(1) {
923         EXEC SQL FETCH csr216 INTO :name;
924         if (sqlca.sqlcode != 0) {
925           ingerr(&sqlca.sqlcode);
926           break;
927         } 
928         
929         strtrim(name);
930         printf("Service %s has acl non-existant user %d\n", name, id);
931         found = 0;
932     }
933     EXEC SQL CLOSE csr216; 
934     return(found);
935 }
936
937 show_srv_list(id)
938 EXEC SQL BEGIN DECLARE SECTION; 
939 int id;
940 EXEC SQL END DECLARE SECTION; 
941 {
942     EXEC SQL BEGIN DECLARE SECTION; 
943     char name[33];
944     EXEC SQL END DECLARE SECTION; 
945     int found = 1;
946
947     EXEC SQL DECLARE csr217 CURSOR FOR
948         SELECT name FROM servers
949             WHERE acl_type='LIST' AND acl_id = :id;
950     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
951     EXEC SQL OPEN csr217;
952     while(1) {
953         EXEC SQL FETCH csr217 INTO :name;
954         if (sqlca.sqlcode != 0) {
955           ingerr(&sqlca.sqlcode);
956           break;
957         } 
958
959         strtrim(name);
960         printf("Service %s has acl non-existant list %d\n", name, id);
961         found = 0;
962     }
963     EXEC SQL CLOSE csr217; 
964     return(found);
965 }
966
967 zero_srv_user(id)
968 EXEC SQL BEGIN DECLARE SECTION; 
969 int id;
970 EXEC SQL END DECLARE SECTION; 
971 {
972     EXEC SQL BEGIN DECLARE SECTION; 
973     int rowcount;
974     EXEC SQL END DECLARE SECTION; 
975
976     EXEC SQL UPDATE servers SET acl_id=0 WHERE acl_id = :id AND
977         acl_type='USER';
978     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
979     if (rowcount > 0)
980       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
981     else
982       printf("Not fixed\n");
983     modified("servers");
984 }
985
986 zero_srv_list(id)
987 EXEC SQL BEGIN DECLARE SECTION; 
988 int id;
989 EXEC SQL END DECLARE SECTION; 
990 {
991     EXEC SQL BEGIN DECLARE SECTION; 
992     int rowcount;
993     EXEC SQL END DECLARE SECTION; 
994
995     EXEC SQL UPDATE servers SET acl_id=0 WHERE acl_id = :id AND
996         acl_type='LIST';
997     EXEC SQL INQUIRE_SQL(:rowcount = rowcount); 
998     if (rowcount > 0)
999       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
1000     else
1001       printf("Not fixed\n");
1002     modified("servers");
1003 }
1004
1005
1006 show_krb_usr(id)
1007 EXEC SQL BEGIN DECLARE SECTION; 
1008 int id;
1009 EXEC SQL END DECLARE SECTION; 
1010 {
1011     EXEC SQL BEGIN DECLARE SECTION; 
1012     int found = 1, id1;
1013     EXEC SQL END DECLARE SECTION; 
1014     struct string *s;
1015     char *ss;
1016
1017     EXEC SQL DECLARE csr218 CURSOR FOR
1018         SELECT string_id FROM krbmap
1019             WHERE users_id = :id ;
1020     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1021     EXEC SQL OPEN csr218;
1022     while(1) {
1023         EXEC SQL FETCH csr218 INTO :id1;
1024         if (sqlca.sqlcode != 0) {
1025           ingerr(&sqlca.sqlcode);
1026           break;
1027         } 
1028
1029         if (s = ((struct string *)hash_lookup(strings, id1)))
1030             ss = s->name;
1031         else
1032             ss = "[unknown]";
1033         found = 0;
1034         printf("Kerberos map for non-existant user %d to principal %s\n",
1035                id, s);
1036     }
1037     EXEC SQL CLOSE csr218; 
1038     return(found);
1039 }
1040
1041
1042 show_krb_str(id)
1043 EXEC SQL BEGIN DECLARE SECTION; 
1044 int id;
1045 EXEC SQL END DECLARE SECTION; 
1046 {
1047     EXEC SQL BEGIN DECLARE SECTION; 
1048     int found = 1, id1;
1049     EXEC SQL END DECLARE SECTION; 
1050     struct user *u;
1051     char *s;
1052
1053     EXEC SQL DECLARE csr219 CURSOR FOR
1054         SELECT users_id FROM krbmap
1055             WHERE string_id = :id;
1056     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1057     EXEC SQL OPEN csr219;
1058     while(1) {
1059         EXEC SQL FETCH csr219 INTO :id1;
1060         if (sqlca.sqlcode != 0) {
1061           ingerr(&sqlca.sqlcode);
1062           break;
1063         } 
1064
1065         if (u = ((struct user *)hash_lookup(users, id1)))
1066             s = u->login;
1067         else
1068             s = "[???]";
1069         found = 0;
1070         printf("Kerberos map for user %s (%d) to non-existant string %d\n",
1071                s, id1, id);
1072         }
1073     EXEC SQL CLOSE csr219; 
1074     return(found);
1075 }
1076
1077
1078 show_pdm_mach(id)
1079 EXEC SQL BEGIN DECLARE SECTION; 
1080 int id;
1081 EXEC SQL END DECLARE SECTION; 
1082 {
1083     EXEC SQL BEGIN DECLARE SECTION; 
1084     char name[33];
1085     EXEC SQL END DECLARE SECTION; 
1086     int found = 1;
1087
1088     EXEC SQL DECLARE csr220 CURSOR FOR
1089         SELECT name FROM palladium
1090             WHERE mach_id = :id;
1091     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1092     EXEC SQL OPEN csr220;
1093     while(1) {
1094         EXEC SQL FETCH csr220 INTO :name;
1095         if (sqlca.sqlcode != 0) {
1096           ingerr(&sqlca.sqlcode);
1097           break;
1098         } 
1099
1100         strtrim(name);
1101         printf("Palladium server/supervisor %s is on non-existant machine %d\n",
1102                name, id);
1103         found = 0;
1104         }
1105     EXEC SQL CLOSE csr220; 
1106     return(found);
1107 }
1108
1109
1110 phase2()
1111 {
1112     EXEC SQL BEGIN DECLARE SECTION; 
1113     int id1, id2, id3, id4, id5;
1114     char type[9], name[33];
1115     EXEC SQL END DECLARE SECTION; 
1116     struct save_queue *sq, *sq1, *sq2, *sq3, *sq4, *sq5;
1117     struct filesys *f;
1118     struct list *l;
1119     struct nfsphys *n;
1120     struct machine *m;
1121
1122     printf("Phase 2 - Checking references\n");
1123
1124     dprintf("Checking users...\n");
1125     hash_step(users, pobox_check, NULL);
1126
1127     dprintf("Checking mcmap...\n");
1128     sq1 = sq_create();
1129     sq2 = sq_create();
1130     EXEC SQL DECLARE csr221 CURSOR FOR
1131         SELECT mach_id, clu_id FROM mcmap;
1132     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1133     EXEC SQL OPEN csr221;
1134     while(1) {
1135         EXEC SQL FETCH csr221 INTO :id1, :id2;
1136         if (sqlca.sqlcode != 0) {
1137           ingerr(&sqlca.sqlcode);
1138           break;
1139         } 
1140
1141         if (!(m = (struct machine *)hash_lookup(machines, id1)))
1142             sq_save_unique_data(sq1, id1);
1143         if (!hash_lookup(clusters, id2))
1144             sq_save_unique_data(sq2, id2);
1145         if (m) m->clucount++;
1146         }
1147     EXEC SQL CLOSE csr221; 
1148     generic_delete(sq1, show_mcm_mach, "mcmap", "mach_id", 1);
1149     generic_delete(sq2, show_mcm_clu, "mcmap", "clu_id", 1);
1150
1151     dprintf("Checking service clusters...\n");
1152     sq1 = sq_create();
1153     EXEC SQL DECLARE csr222 CURSOR FOR
1154         SELECT clu_id FROM svc;
1155     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1156     EXEC SQL OPEN csr222;
1157     while(1) {
1158         EXEC SQL FETCH csr222 INTO :id1;
1159         if (sqlca.sqlcode != 0) {
1160           ingerr(&sqlca.sqlcode);
1161           break;
1162         } 
1163
1164         if (!hash_lookup(clusters, id1))
1165           sq_save_unique_data(sq1, id1);
1166     }
1167     EXEC SQL CLOSE csr222; 
1168     generic_delete(sq1, show_svc, "svc", "clu_id", 1);
1169
1170     dprintf("Checking lists...\n");
1171     hash_step(lists, list_check, NULL);
1172
1173     dprintf("Checking members...\n");
1174     sq1 = sq_create();
1175     sq2 = sq_create();
1176     sq3 = sq_create();
1177     sq4 = sq_create();
1178     sq5 = sq_create();
1179
1180     EXEC SQL DECLARE csr223 CURSOR FOR
1181         SELECT list_id, member_type, member_id, ref_count, direct 
1182         FROM imembers ORDER BY list_id;
1183     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1184     EXEC SQL OPEN csr223;
1185     while(1) {
1186         EXEC SQL FETCH csr223 INTO :id1, :type, :id2, :id3, :id4;
1187         if (sqlca.sqlcode != 0) {
1188           ingerr(&sqlca.sqlcode);
1189           break;
1190         } 
1191
1192         if ((l = (struct list *) hash_lookup(lists, id1)) == NULL)
1193           sq_save_unique_data(sq1, id1);
1194         else if (type[0] == 'U' && !hash_lookup(users, id2))
1195           sq_save_unique_data(sq2, id2);
1196         else if (type[0] == 'L' && !hash_lookup(lists, id2))
1197           sq_save_unique_data(sq3, id2);
1198         else if (type[0] == 'S' && !string_check(id2))
1199           sq_save_unique_data(sq4, id2);
1200         else if (type[0] == 'K' && !string_check(id2))
1201           sq_save_unique_data(sq5, id2);
1202         else
1203           l->members++;
1204         }
1205     EXEC SQL CLOSE csr223; 
1206     generic_delete(sq1, show_member_list, "imembers", "list_id", 1);
1207     generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1);
1208     generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1);
1209     generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1);
1210     generic_fix(sq5, show_mem_krb, "Delete", del_mem_krb, 1);
1211
1212     dprintf("Checking servers...\n");
1213     sq1 = sq_create();
1214     sq2 = sq_create();
1215     EXEC SQL DECLARE csr224 CURSOR FOR
1216         SELECT name, acl_type, acl_id FROM servers;
1217     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1218     EXEC SQL OPEN csr224;
1219     while(1) {
1220         EXEC SQL FETCH csr224 INTO :name, :type, :id1;
1221         if (sqlca.sqlcode != 0) {
1222           ingerr(&sqlca.sqlcode);
1223           break;
1224         } 
1225
1226         strtrim(type);
1227         if (!strcmp(type, "USER") && !hash_lookup(users, id1)) {
1228             sq_save_data(sq1, id1);
1229         } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id1)) {
1230             sq_save_data(sq2, id1);
1231         }
1232     }
1233     EXEC SQL CLOSE csr224; 
1234     generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
1235     generic_fix(sq2, show_srv_list, "Fix", zero_srv_list, 1);
1236
1237     dprintf("Checking serverhosts...\n");
1238     sq = sq_create();
1239     EXEC SQL DECLARE csr225 CURSOR FOR
1240         SELECT mach_id FROM serverhosts;
1241     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1242     EXEC SQL OPEN csr225;
1243     while(1) {
1244         EXEC SQL FETCH csr225 INTO :id1;
1245         if (sqlca.sqlcode != 0) {
1246           ingerr(&sqlca.sqlcode);
1247           break;
1248         } 
1249
1250         if (!hash_lookup(machines, id1))
1251           sq_save_data(sq, id1);
1252         }
1253     EXEC SQL CLOSE csr225; 
1254     generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
1255
1256     dprintf("Checking nfsphys...\n");
1257     hash_step(nfsphys, check_nfsphys, NULL);
1258
1259     dprintf("Checking filesys...\n");
1260     hash_step(filesys, check_fs, NULL);
1261
1262     dprintf("Checking filesystem groups...\n");
1263     sq1 = sq_create();
1264     sq2 = sq_create();
1265     sq3 = sq_create();
1266     EXEC SQL DECLARE csr226 CURSOR FOR
1267         SELECT group_id, filsys_id FROM fsgroup;
1268     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1269     EXEC SQL OPEN csr226;
1270     while(1) {
1271         EXEC SQL FETCH csr226 INTO :id1, :id2;
1272         if (sqlca.sqlcode != 0) {
1273           ingerr(&sqlca.sqlcode);
1274           break;
1275         } 
1276
1277         if (!(f = (struct filesys *) hash_lookup(filesys, id1)))
1278           sq_save_data(sq1, id1);
1279         if (!hash_lookup(filesys, id2))
1280           sq_save_data(sq3, id2);
1281     }
1282     EXEC SQL CLOSE csr226; 
1283     generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0);
1284     generic_delete(sq3, show_fsg_nomember, "fsgroup", "filsys_id", 1);
1285
1286     dprintf("Checking quotas...\n");
1287     sq1 = sq_create();
1288     sq2 = sq_create();
1289     sq3 = sq_create();
1290     sq4 = sq_create();
1291     EXEC SQL DECLARE csr227 CURSOR FOR
1292         SELECT entity_id, type, filsys_id, phys_id, quota FROM quota;
1293     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1294     EXEC SQL OPEN csr227;
1295     while(1) {
1296         EXEC SQL FETCH csr227 INTO :id1, :type, :id2, :id3, :id4;
1297         if (sqlca.sqlcode != 0) {
1298           ingerr(&sqlca.sqlcode);
1299           break;
1300         } 
1301
1302         if (type[0] == 'U' && id1 != 0 && !hash_lookup(users, id1))
1303           sq_save_data(sq1, id1);
1304         else if (type[0] == 'G' && !hash_lookup(lists, id1))
1305           sq_save_data(sq4, id1);
1306         else if (!(f = (struct filesys *) hash_lookup(filesys, id2)))
1307           sq_save_data(sq2, id2);
1308         else if (id3 != f->phys_id ||
1309             ((n = (struct nfsphys*) hash_lookup(nfsphys, id3)) ==
1310             (struct nfsphys *)NULL))
1311           sq_save_data(sq3, id2);
1312         else
1313           n->count += id4;
1314     }
1315     EXEC SQL CLOSE csr227; 
1316     generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1);
1317     generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0);
1318     generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1);
1319     generic_fix(sq4, show_quota_nolist, "Delete", fix_quota_nolist, 1);
1320
1321     dprintf("Not checking zephyr.\n");
1322
1323     dprintf("Checking hostaccess...\n");
1324     EXEC SQL DECLARE csr228 CURSOR FOR
1325         SELECT mach_id, acl_type, acl_id FROM hostaccess;
1326     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1327     EXEC SQL OPEN csr228;
1328     while(1) {
1329         EXEC SQL FETCH csr228 INTO :id1, :type, :id2;
1330         if (sqlca.sqlcode != 0) {
1331           ingerr(&sqlca.sqlcode);
1332           break;
1333         } 
1334
1335         strtrim(type);
1336         if (!hash_lookup(machines, id1)) {
1337             printf("Hostaccess for non-existant host %d\n", id1);
1338             printf("Not fixing this error\n");
1339         }
1340         if (!strcmp(type, "USER") && !hash_lookup(users, id2)) {
1341             printf("Hostaccess for %d is non-existant user %d\n", id1, id2);
1342             printf("Not fixing this error\n");
1343         } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2)) {
1344             printf("Hostaccess for %d is non-existant list %d\n", id1, id2);
1345             printf("Not fixing this error\n");
1346         }
1347     }
1348     EXEC SQL CLOSE csr228; 
1349
1350     dprintf("Checking palladium...\n");
1351     sq1 = sq_create();
1352     EXEC SQL DECLARE csr229 CURSOR FOR
1353         SELECT mach_id FROM palladium;
1354     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1355     EXEC SQL OPEN csr229;
1356     while(1) {
1357         EXEC SQL FETCH csr229 INTO :id1;
1358         if (sqlca.sqlcode != 0) {
1359           ingerr(&sqlca.sqlcode);
1360           break;
1361         } 
1362
1363         if (!hash_lookup(machines, id1)) {
1364             sq_save_unique_data(sq1, id1);
1365         }
1366     }
1367     EXEC SQL CLOSE csr229;
1368     generic_delete(sq1, show_pdm_mach, "palladium", "mach_id", 1);
1369
1370     dprintf("Checking krbmap...\n");
1371     sq1 = sq_create();
1372     sq2 = sq_create();
1373     EXEC SQL DECLARE csr230 CURSOR FOR
1374         SELECT users_id, string_id FROM krbmap;
1375     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1376     EXEC SQL OPEN csr230;
1377     while(1) {
1378         EXEC SQL FETCH csr230 INTO :id1, :id2;
1379         if (sqlca.sqlcode != 0) {
1380           ingerr(&sqlca.sqlcode);
1381           break;
1382         } 
1383
1384         if (!hash_lookup(users, id1))
1385           sq_save_unique_data(sq1, id1);
1386         if (!string_check(id2))
1387           sq_save_unique_data(sq2, id2);
1388         }
1389     EXEC SQL CLOSE csr230; 
1390     generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1);
1391     generic_delete(sq2, show_krb_str, "krbmap", "string_id", 1);
1392
1393     dprintf("Checking capacls...\n");
1394     EXEC SQL DECLARE csr231 CURSOR FOR
1395         SELECT list_id, tag FROM capacls;
1396     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1397     EXEC SQL OPEN csr231;
1398     while(1) {
1399         EXEC SQL FETCH csr231 INTO :id1, :name;
1400         if (sqlca.sqlcode != 0) {
1401           ingerr(&sqlca.sqlcode);
1402           break;
1403         } 
1404
1405         if (!hash_lookup(lists, id1)) {
1406             printf("Capacl for %s is non-existant list %d\n", name, id1);
1407             printf("Not fixing this error\n");
1408         }
1409     }
1410     EXEC SQL CLOSE csr231; 
1411
1412 }
1413
This page took 0.143223 seconds and 5 git commands to generate.