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