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