]> andersk Git - moira.git/blame - dbck/phase2.dc
Fixed an Imakefile glitch
[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;
ab05f33a 39 printf("Cluster %s, non-existant machine %d in cluster map\n", name, id);
208a4f4a 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
ab05f33a 53 EXEC SQL DECLARE csr202 CURSOR
54
55
56 FOR
208a4f4a 57 SELECT machine.name FROM machine, mcmap
58 WHERE machine.mach_id=mcmap.mach_id AND mcmap.clu_id=:iid;
ced12e61 59 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 60 EXEC SQL OPEN csr202;
61 while(1) {
62 EXEC SQL FETCH csr202 INTO :name;
7bf0a6f3 63 if (sqlca.sqlcode != 0) {
64 ingerr(&sqlca.sqlcode);
65 break;
66 }
68bbc9c3 67
208a4f4a 68 strtrim(name);
ab05f33a 69
208a4f4a 70 found = 0;
71 printf("Machine %s, non-existant cluster %d in cluster map\n", name, id);
72 }
73 EXEC SQL CLOSE csr202;
68bbc9c3 74 return(found);
208a4f4a 75}
68bbc9c3 76
ab05f33a 77show_hostalias(id)
78int id;
79{
80 EXEC SQL BEGIN DECLARE SECTION;
81 int iid = id, found = 1;
82 char name[33];
83 EXEC SQL END DECLARE SECTION;
84
85 EXEC SQL DECLARE csr234 CURSOR FOR
86 SELECT name FROM hostalias WHERE mach_id=:iid;
87 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
88 EXEC SQL OPEN csr234;
89 while(1) {
90 EXEC SQL FETCH csr234 INTO :name;
91 if (sqlca.sqlcode != 0) {
92 ingerr(&sqlca.sqlcode);
93 break;
94 }
95
96 strtrim(name);
97
98 found = 0;
99 printf("Alias %s, non-existant machine %d in hostalias map\n", name, id);
100 }
101 EXEC SQL CLOSE csr234;
102 return(found);
103}
104
105show_pcap_mach(id)
106int id;
107{
108 EXEC SQL BEGIN DECLARE SECTION;
109 int iid = id, found = 1;
110 char name[33];
111 EXEC SQL END DECLARE SECTION;
112
113 EXEC SQL DECLARE csr235 CURSOR FOR
114 SELECT name FROM printcap WHERE mach_id=:iid;
115 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
116 EXEC SQL OPEN csr235;
117 while(1) {
118 EXEC SQL FETCH csr235 INTO :name;
119 if (sqlca.sqlcode != 0) {
120 ingerr(&sqlca.sqlcode);
121 break;
122 }
123
124 strtrim(name);
125
126 found = 0;
127 printf("Printer %s, non-existant spool machine %d in printcap table\n", name, id);
128 }
129 EXEC SQL CLOSE csr235;
130 return(found);
131}
132
133show_pcap_quota(id)
134int id;
135{
136 EXEC SQL BEGIN DECLARE SECTION;
137 int iid = id, found = 1;
138 char name[33];
139 EXEC SQL END DECLARE SECTION;
140
141 EXEC SQL DECLARE csr236 CURSOR FOR
142 SELECT name FROM printcap WHERE quotaserver=:iid;
143 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
144 EXEC SQL OPEN csr236;
145 while(1) {
146 EXEC SQL FETCH csr236 INTO :name;
147 if (sqlca.sqlcode != 0) {
148 ingerr(&sqlca.sqlcode);
149 break;
150 }
151
152 strtrim(name);
153
154 found = 0;
155 printf("Printer %s, non-existant quota server %d in printcap table\n", name, id);
156 }
157 EXEC SQL CLOSE csr236;
158 return(found);
159}
160
161user_check(id, u, hint)
162 int id;
163 struct user *u;
164 int hint;
165{
166 u->comment=maybe_fixup_unref_string(u->comment, id, u->login, "users",
167 "comment", "users_id");
168
169 u->modby=maybe_fixup_modby(u->modby, id, u->login, "users",
170 "modby", "users_id");
171
172 u->fmodby=maybe_fixup_modby(u->fmodby, id, u->login, "users",
173 "fmodby", "users_id");
174
175 u->pmodby=maybe_fixup_modby(u->pmodby, id, u->login, "users",
176 "pmodby", "users_id");
177
178 u->sigwho=maybe_fixup_unref_string(u->sigwho, id, u->login, "users",
179 "sigwho", "users_id");
180
181 pobox_check(id, u, hint);
182}
183
184maybe_fixup_unref_string(sid, oid, oname, table, field, idfield)
185 int sid, oid;
186 char *oname, *table;
187 char *field, *idfield;
188{
189 int ret=(sid<0)?-sid:sid, doit=0, newid;
190 EXEC SQL BEGIN DECLARE SECTION;
191 int rowcount;
192 char stmt_buf[500];
193 EXEC SQL END DECLARE SECTION;
194
195 if(newid=int_hash_lookup(string_dups, ret)) {
196 printf("%s entry %s(%d) has a %s with duplicate string %d\n",
197 table, oname, oid, field, ret);
198 if(single_fix("Replace duplicate", 0)){
199 ret = newid;
200 string_check(newid);
201 doit=1;
202 }
203 } else if(!string_check(ret)) {
204 printf("%s entry %s(%d) has a %s with non-existant string %d\n",
205 table, oname, oid, field, ret);
206 if (single_fix("Delete", 1)) {
207 ret=0;
208 doit=1;
209 }
210 }
211
212 if(doit){
213 sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE %s = %d",
214 table, field, (sid<0)?-ret:ret, idfield, oid);
215 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
216 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
217 if (rowcount == 1)
218 printf("Fixed\n");
219 else
220 printf("Not fixed, rowcount = %d\n", rowcount);
221 modified(table);
222 }
223
224 return((sid<0)?-ret:ret);
225
226}
227
228maybe_fixup_modby(sid, oid, oname, table, field, idfield)
229 int sid, oid;
230 char *oname, *table;
231 char *field, *idfield;
232{
233 EXEC SQL BEGIN DECLARE SECTION;
234 char stmt_buf[500];
235 int rowcount;
236 EXEC SQL END DECLARE SECTION;
237
238 if(sid<0)
239 return maybe_fixup_unref_string(sid, oid, oname, table, field, idfield);
240 else {
241 if(!hash_lookup(users, sid)) {
242 printf("%s entry %s(%d) has a %s with non-existant user %d\n",
243 table, oname, oid, field, sid);
244 if (single_fix("Delete", 1)) {
245 sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE %s=%d",
246 table, field, 0, idfield, oid);
247 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
248 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
249 if (rowcount == 1)
250 printf("Fixed\n");
251 else
252 printf("Not fixed, rowcount = %d\n", rowcount);
253 modified(table);
254 }
255 return 0;
256 }
257 }
258 return sid;
259}
260
261maybe_fixup_unref_string2(table, field, cursor, sid)
262 int sid;
263 char *field, *table, *cursor;
264{
265 int ret=(sid<0)?-sid:sid, doit=0, newid;
266 EXEC SQL BEGIN DECLARE SECTION;
267 int rowcount;
268 char stmt_buf[500];
269 EXEC SQL END DECLARE SECTION;
270
271 if(newid=int_hash_lookup(string_dups, ret)) {
272 printf("%s entry has a %s with duplicate string %d\n",
273 table, field, ret);
274 if(single_fix("Replace duplicate", 0)){
275 ret = newid;
276 string_check(newid);
277 doit=1;
278 }
279 } else if(!string_check(ret)) {
280 printf("%s entry has a %s with non-existant string %d\n",
281 table, field, ret);
282 if (single_fix("Delete", 1)) {
283 ret=0;
284 doit=1;
285 }
286 }
287
288 if(doit){
289 sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE CURRENT OF %s",
290 table, field, (sid<0)?-ret:ret, cursor);
291 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
292 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
293 if (rowcount == 1)
294 printf("Fixed\n");
295 else
296 printf("Not fixed, rowcount = %d\n", rowcount);
297 modified(table);
298 }
299 return((sid<0)?-ret:ret);
300}
301
302maybe_fixup_modby2(table, field, cursor, id)
303{
304 EXEC SQL BEGIN DECLARE SECTION;
305 char stmt_buf[500];
306 int rowcount;
307 EXEC SQL END DECLARE SECTION;
308
309 if(id<0) return maybe_fixup_unref_string2(table, field, cursor, id);
310 else {
311 if(!hash_lookup(users, id)) {
312 printf("%s entry has a %s with non-existant user %d\n",
313 table, field, id);
314 if (single_fix("Delete", 1)) {
315 sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE CURRENT OF %s",
316 table, field, 0, cursor);
317 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
318 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
319 if (rowcount == 1)
320 printf("Fixed\n");
321 else
322 printf("Not fixed, rowcount = %d\n", rowcount);
323 modified(table);
324 }
325 return 0;
326 }
327 }
328 return 1;
329}
330
68bbc9c3 331pobox_check(id, u, hint)
332int id;
333struct user *u;
334int hint;
335{
ab05f33a 336 switch (u->potype) {
337 case 'P':
338 if (!hash_lookup(machines, u->pobox_id)) {
339 printf("User %s(%s) has P.O.Box on non-existant machine %d\n",
340 u->login, u->fullname, u->pobox_id);
341 if (single_fix("Delete", 0)) {
342 remove_pobox(u->users_id);
343 u->potype = 'N';
344 }
345 }
346 break;
347 case 'S':
348 if( int_hash_lookup( string_dups, u->pobox_id ) ) {
349 printf("User %s(%s) has P.O.Box with duplicate string %d\n",
350 u->login, u->fullname, u->pobox_id);
351 if(single_fix("Update", 0)){
352 printf("Replacing box_id dup string ID %d with %d\n",
353 u->pobox_id,
354 int_hash_lookup(string_dups, u->pobox_id));
355 u->pobox_id = int_hash_lookup( string_dups, u->pobox_id );
356 fix_smtp_pobox(u->users_id, u->pobox_id);
357 string_check(u->pobox_id);
358 }
359 } else if (!string_check(u->pobox_id)) {
360 printf("User %s(%s) has P.O.Box with non-existant string %d\n",
361 u->login, u->fullname, u->pobox_id);
362 if (single_fix("Delete", 0)) {
363 remove_pobox(u->users_id);
364 u->potype = 'N';
365 }
68bbc9c3 366 }
ab05f33a 367 break;
368 default:
369 ;
370 }
68bbc9c3 371}
372
373
374remove_pobox(id)
375int id;
208a4f4a 376{
377 EXEC SQL BEGIN DECLARE SECTION;
378 int rowcount, iid = id;
379 EXEC SQL END DECLARE SECTION;
7bf0a6f3 380
208a4f4a 381 EXEC SQL UPDATE users SET potype='NONE' WHERE users.users_id = :iid;
382 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
68bbc9c3 383 if (rowcount > 0)
384 printf("%d entr%s removed\n", rowcount, rowcount==1?"y":"ies");
385 else
386 printf("Not removed\n");
387 modified("users");
208a4f4a 388}
68bbc9c3 389
ab05f33a 390fix_smtp_pobox(id, sid)
391int id, sid;
392{
393 EXEC SQL BEGIN DECLARE SECTION;
394 int rowcount, iid = id, isid=sid;
395 EXEC SQL END DECLARE SECTION;
396
397 EXEC SQL UPDATE users SET box_id=:isid WHERE users.users_id = :iid;
398 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
399 if (rowcount > 0)
400 printf("%d entr%s updated\n", rowcount, rowcount==1?"y":"ies");
401 else
402 printf("Not updated\n");
403 modified("users");
404}
772b7afc 405
406mach_check(id, m, hint)
407int id;
408struct machine *m;
409int hint;
410{
411 if (!hash_lookup(subnets, m->snet_id)) {
412 printf("Machine %s is on a non-existant subnet %d\n",
413 m->name, m->snet_id);
414 if (single_fix("Move to null-subnet", 1)) {
415 EXEC SQL BEGIN DECLARE SECTION;
416 int rowcount, iid = id;
417 EXEC SQL END DECLARE SECTION;
418
419 EXEC SQL UPDATE machine SET snet_id=0 WHERE mach_id = :iid;
420 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
421 if (rowcount > 0)
422 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
423 else
424 printf("Not fixed\n");
425 modified("machine");
426 }
427 }
428
429 switch (m->owner_type) {
430 case 'U':
431 if (!hash_lookup(users, m->owner_id)) {
432 printf("Machine %s has non-existant USER owner %d\n",
433 m->name, m->owner_id);
434 if (single_fix("Set to no owner", 1)) {
435 clear_mach_owner(m);
436 }
437 }
438 break;
439 case 'L':
440 if (!hash_lookup(lists, m->owner_id)) {
441 printf("Machine %s has non-existant LIST owner %d\n",
442 m->name, m->owner_id);
443 if (single_fix("Set to no owner", 1)) {
444 clear_mach_owner(m);
445 }
446 }
447 break;
ab05f33a 448 case 'S':
449 case 'K':
450 if(m->owner_id)
451 m->owner_id=maybe_fixup_unref_string(m->owner_id, id, m->name,
452 "machine", "owner_id", "mach_id");
453 if(m->owner_id==0)
454 clear_mach_owner(m);
772b7afc 455 }
ab05f33a 456
457 if(m->acomment)
458 m->acomment=maybe_fixup_unref_string(m->acomment, id, m->name,
459 "machine", "acomment", "mach_id");
460 if(m->ocomment)
461 m->ocomment=maybe_fixup_unref_string(m->ocomment, id, m->name,
462 "machine", "ocomment", "mach_id");
463
464 m->creator=maybe_fixup_modby(m->creator, id, m->name, "machine",
465 "creator", "mach_id");
466 m->modby=maybe_fixup_modby(m->modby, id, m->name, "machine",
467 "modby", "mach_id");
772b7afc 468}
469
ab05f33a 470subnet_check(id, s, hint)
471int id;
472struct subnet *s;
473int hint;
474{
475 switch (s->owner_type) {
476 case 'U':
477 if (!hash_lookup(users, s->owner_id)) {
478 printf("Subnet %s has non-existant USER owner %d\n",
479 s->name, s->owner_id);
480 if (single_fix("Set to no owner", 1)) {
481 clear_subnet_owner(s);
482 }
483 }
484 break;
485 case 'L':
486 if (!hash_lookup(lists, s->owner_id)) {
487 printf("Machine %s has non-existant LIST owner %d\n",
488 s->name, s->owner_id);
489 if (single_fix("Set to no owner", 1)) {
490 clear_subnet_owner(s);
491 }
492 }
493 break;
494 case 'S':
495 case 'K':
496 if(s->owner_id)
497 s->owner_id=maybe_fixup_unref_string(s->owner_id, id, s->name,
498 "machine", "owner_id", "mach_id");
499 if(s->owner_id==0)
500 clear_subnet_owner(s);
501 }
502
503 s->modby=maybe_fixup_modby(s->modby, id, s->name, "subnet",
504 "modby", "snet_id");
505}
506
507
508clear_subnet_owner(s)
509struct subnet *s;
510{
511 EXEC SQL BEGIN DECLARE SECTION;
512 int rowcount, id = s->snet_id;
513 EXEC SQL END DECLARE SECTION;
514
515 EXEC SQL UPDATE subnet SET owner_type='NONE', owner_id=0
516 WHERE snet_id = :id;
517 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
518 if (rowcount > 0)
519 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
520 else
521 printf("Not fixed\n");
522 modified("subnet");
523}
772b7afc 524
525clear_mach_owner(m)
526struct machine *m;
527{
528 EXEC SQL BEGIN DECLARE SECTION;
529 int rowcount, id = m->mach_id;
530 EXEC SQL END DECLARE SECTION;
531
532 EXEC SQL UPDATE machine SET owner_type='NONE', owner_id=0
533 WHERE mach_id = :id;
534 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
535 if (rowcount > 0)
536 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
537 else
538 printf("Not fixed\n");
539 modified("machine");
540}
541
ab05f33a 542cluster_check(id, c, hint)
543int id;
544struct cluster *c;
545int hint;
546{
547 c->modby=maybe_fixup_modby(c->modby, id, c->name, "cluster",
548 "modby", "clu_id");
549}
550
551
772b7afc 552
68bbc9c3 553show_svc(id)
554int id;
208a4f4a 555{
556 EXEC SQL BEGIN DECLARE SECTION;
557 int iid = id, found = 1;
558 char label[17], data[33];
559 EXEC SQL END DECLARE SECTION;
560
208a4f4a 561 EXEC SQL DECLARE csr203 CURSOR FOR
562 SELECT serv_label, serv_cluster FROM svc
563 WHERE clu_id = :iid;
ced12e61 564 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 565 EXEC SQL OPEN csr203;
566 while(1) {
567 EXEC SQL FETCH csr203 INTO :label, :data;
7bf0a6f3 568 if (sqlca.sqlcode != 0) {
569 ingerr(&sqlca.sqlcode);
570 break;
571 }
208a4f4a 572
573 strtrim(label);
574 strtrim(data);
575 found = 0;
576 printf("Cluster data [%s] %s for non-existant cluster %d\n",
577 label, data, id);
578 }
579 EXEC SQL CLOSE csr203;
68bbc9c3 580 return(found);
208a4f4a 581}
68bbc9c3 582
583list_check(id, l, hint)
584int id;
585struct list *l;
586int hint;
587{
588 switch (l->acl_type) {
589 case 'L':
590 if (!hash_lookup(lists, l->acl_id)) {
591 printf("List %s has bad LIST acl %d\n", l->name, l->acl_id);
592 if (single_fix("Patch", 1)) {
593 fix_list_acl(l->list_id);
594 }
595 }
596 break;
597 case 'U':
598 if (!hash_lookup(users, l->acl_id)) {
599 printf("List %s has bad USER acl %d\n", l->name, l->acl_id);
600 if (single_fix("Patch", 1)) {
601 fix_list_acl(l->list_id);
602 }
603 }
604 break;
ab05f33a 605 case 'K':
606 l->acl_id = maybe_fixup_unref_string(l->acl_id, id, l->name,
607 "list", "acl_id", "list_id");
608 if (!l->acl_id) {
609 printf("List %s has bad KERBEROS acl %d\n", l->name, l->acl_id);
610 if(single_fix("Patch", 1)) {
611 fix_list_acl(l->list_id);
612 }
613 }
614 break;
68bbc9c3 615 }
616}
617
618fix_list_acl(id)
619int id;
208a4f4a 620{
621 EXEC SQL BEGIN DECLARE SECTION;
622 int rowcount, iid = id;
623 EXEC SQL END DECLARE SECTION;
624
208a4f4a 625 EXEC SQL UPDATE list SET acl_id = :iid, acl_type='LIST'
626 WHERE list_id = :iid;
627 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
68bbc9c3 628 if (rowcount > 0)
629 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
630 else
631 printf("Not fixed\n");
632 modified("list");
208a4f4a 633}
68bbc9c3 634
635
636show_member_list(id)
637int id;
208a4f4a 638{
639 EXEC SQL BEGIN DECLARE SECTION;
640 int mid, iid = id, found = 1;
641 char mtype[9], *name = "";
642 EXEC SQL END DECLARE SECTION;
643
208a4f4a 644 EXEC SQL DECLARE csr204 CURSOR FOR
645 SELECT member_type, member_id FROM imembers
646 WHERE list_id = :iid AND direct=1;
ced12e61 647 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 648 EXEC SQL OPEN csr204;
649 while(1) {
650 EXEC SQL FETCH csr204 INTO :mtype, :mid;
7bf0a6f3 651 if (sqlca.sqlcode != 0) {
652 ingerr(&sqlca.sqlcode);
653 break;
654 }
208a4f4a 655
656 strtrim(mtype);
657 found = 0;
658 if (mtype[0] == 'L')
659 name = ((struct list *) hash_lookup(lists, mid))->name;
660 else if (mtype[0] == 'U')
661 name = ((struct user *) hash_lookup(users, mid))->login;
662 else if (mtype[0] == 'S' || mtype[0] == 'K')
663 name = ((struct string *) hash_lookup(strings, mid))->name;
664 printf("Non-existant list %d has member %s %s\n", iid, mtype, name);
665 }
666 EXEC SQL CLOSE csr204;
68bbc9c3 667 return(found);
208a4f4a 668}
68bbc9c3 669
670show_mem_user(id)
671int id;
208a4f4a 672{
673 EXEC SQL BEGIN DECLARE SECTION;
674 int lid, iid = id, found = 1;
675 char name[33];
676 EXEC SQL END DECLARE SECTION;
677
208a4f4a 678 EXEC SQL DECLARE csr205 CURSOR FOR
679 SELECT list_id FROM imembers
680 WHERE member_id = :iid AND member_type='USER' AND direct=1;
ced12e61 681 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 682 EXEC SQL OPEN csr205;
683 while(1) {
684 EXEC SQL FETCH csr205 INTO :lid;
7bf0a6f3 685 if (sqlca.sqlcode != 0) {
686 ingerr(&sqlca.sqlcode);
687 break;
688 }
208a4f4a 689
690 found = 0;
691 printf("List %s has non-existant user member, id %d\n",
692 ((struct list *)hash_lookup(lists, lid))->name, iid);
693 }
694 EXEC SQL CLOSE csr205;
68bbc9c3 695 return(found);
208a4f4a 696}
68bbc9c3 697
698show_mem_list(id)
699int id;
208a4f4a 700{
701 EXEC SQL BEGIN DECLARE SECTION;
702 int lid, iid = id, found = 1;
703 char name[33];
704 EXEC SQL END DECLARE SECTION;
705
208a4f4a 706 EXEC SQL DECLARE csr206 CURSOR FOR
707 SELECT list_id FROM imembers
708 WHERE member_id = :iid AND member_type='LIST' AND direct=1;
ced12e61 709 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 710 EXEC SQL OPEN csr206;
711 while(1) {
712 EXEC SQL FETCH csr206 INTO :lid;
7bf0a6f3 713 if (sqlca.sqlcode != 0) {
714 ingerr(&sqlca.sqlcode);
715 break;
716 }
208a4f4a 717
718 found = 0;
719 printf("List %s has non-existant list member, id %d\n",
720 ((struct list *)hash_lookup(lists, lid))->name, iid);
721 }
722 EXEC SQL CLOSE csr206;
68bbc9c3 723 return(found);
208a4f4a 724}
68bbc9c3 725
726show_mem_str(id)
727int id;
208a4f4a 728{
729 EXEC SQL BEGIN DECLARE SECTION;
730 int lid, iid = id, found = 1;
731 char name[33];
732 EXEC SQL END DECLARE SECTION;
733
208a4f4a 734 EXEC SQL DECLARE csr207 CURSOR FOR
735 SELECT list_id FROM imembers
736 WHERE member_id = :iid AND member_type='STRING' AND direct=1;
ced12e61 737 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 738 EXEC SQL OPEN csr207;
739 while(1) {
740 EXEC SQL FETCH csr207 INTO :lid;
7bf0a6f3 741 if (sqlca.sqlcode != 0) {
742 ingerr(&sqlca.sqlcode);
743 break;
744 }
208a4f4a 745
746 found = 0;
747 printf("List %s has non-existant string member, id %d\n",
748 ((struct list *)hash_lookup(lists, lid))->name, iid);
749 }
750 EXEC SQL CLOSE csr207;
68bbc9c3 751 return(found);
208a4f4a 752}
68bbc9c3 753
754
755show_mem_krb(id)
756int id;
208a4f4a 757{
758 EXEC SQL BEGIN DECLARE SECTION;
759 int lid, iid = id, found = 1;
760 char name[33];
761 EXEC SQL END DECLARE SECTION;
762
208a4f4a 763 EXEC SQL DECLARE csr208 CURSOR FOR
764 SELECT list_id FROM imembers
765 WHERE member_id = :iid AND member_type='KERBEROS' AND direct=1;
ced12e61 766 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 767 EXEC SQL OPEN csr208;
768 while(1) {
769 EXEC SQL FETCH csr208 INTO :lid;
7bf0a6f3 770 if (sqlca.sqlcode != 0) {
771 ingerr(&sqlca.sqlcode);
772 break;
773 }
68bbc9c3 774
208a4f4a 775 found = 0;
776 printf("List %s has non-existant kerberos member, id %d\n",
777 ((struct list *)hash_lookup(lists, lid))->name, iid);
778 }
779 EXEC SQL CLOSE csr208;
780 return(found);
781}
68bbc9c3 782
68bbc9c3 783
208a4f4a 784del_mem_user(id)
785EXEC SQL BEGIN DECLARE SECTION;
786int id;
787EXEC SQL END DECLARE SECTION;
788{
789 EXEC SQL BEGIN DECLARE SECTION;
790 int rowcount;
791 EXEC SQL END DECLARE SECTION;
792
208a4f4a 793 EXEC SQL DELETE FROM imembers WHERE member_type='USER' AND
794 member_id = :id AND direct = 1;
795 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
68bbc9c3 796 if (rowcount > 0)
797 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
798 else
799 printf("Not deleted\n");
800 modified("imembers");
208a4f4a 801}
68bbc9c3 802
208a4f4a 803del_mem_list(id)
804EXEC SQL BEGIN DECLARE SECTION;
805int id;
806EXEC SQL END DECLARE SECTION;
807{
808 EXEC SQL BEGIN DECLARE SECTION;
809 int rowcount;
810 EXEC SQL END DECLARE SECTION;
811
208a4f4a 812 EXEC SQL DELETE FROM imembers WHERE member_type='LIST' AND
813 member_id = :id AND direct=1;
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("imembers");
208a4f4a 820}
68bbc9c3 821
208a4f4a 822del_mem_str(id)
823EXEC SQL BEGIN DECLARE SECTION;
824int id;
825EXEC SQL END DECLARE SECTION;
826{
827 EXEC SQL BEGIN DECLARE SECTION;
828 int rowcount;
829 EXEC SQL END DECLARE SECTION;
830
208a4f4a 831 EXEC SQL DELETE FROM imembers WHERE member_type='STRING' AND
832 member_id = :id AND direct=1;
833 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
68bbc9c3 834 if (rowcount > 0)
835 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
836 else
837 printf("Not deleted\n");
838 modified("imembers");
208a4f4a 839}
68bbc9c3 840
68bbc9c3 841
208a4f4a 842del_mem_krb(id)
843EXEC SQL BEGIN DECLARE SECTION;
844int id;
845EXEC SQL END DECLARE SECTION;
846{
847 EXEC SQL BEGIN DECLARE SECTION;
848 int rowcount;
849 EXEC SQL END DECLARE SECTION;
850
208a4f4a 851 EXEC SQL DELETE FROM imembers WHERE member_type='KERBEROS' AND
852 member_id = :id AND direct=1;
853 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
68bbc9c3 854 if (rowcount > 0)
855 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
856 else
857 printf("Not deleted\n");
858 modified("imembers");
208a4f4a 859}
68bbc9c3 860
861
208a4f4a 862show_sh(id)
863EXEC SQL BEGIN DECLARE SECTION;
864int id;
865EXEC SQL END DECLARE SECTION;
866{
867 EXEC SQL BEGIN DECLARE SECTION;
868 char name[33];
869 EXEC SQL END DECLARE SECTION;
68bbc9c3 870 int found = 1;
871
208a4f4a 872 EXEC SQL DECLARE csr209 CURSOR FOR
873 SELECT service FROM serverhosts
874 WHERE mach_id = :id;
ced12e61 875 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 876 EXEC SQL OPEN csr209;
877 while(1) {
878 EXEC SQL FETCH csr209 INTO :name;
7bf0a6f3 879 if (sqlca.sqlcode != 0) {
880 ingerr(&sqlca.sqlcode);
881 break;
882 }
208a4f4a 883
884 found = 0;
885 printf("ServerHost entry for service %s non-existant host %d\n",
886 name, id);
887 }
888 EXEC SQL CLOSE csr209;
68bbc9c3 889 return(found);
208a4f4a 890}
68bbc9c3 891
208a4f4a 892del_sh_mach(id)
893EXEC SQL BEGIN DECLARE SECTION;
894int id;
895EXEC SQL END DECLARE SECTION;
896{
897 EXEC SQL BEGIN DECLARE SECTION;
898 int rowcount;
899 EXEC SQL END DECLARE SECTION;
68bbc9c3 900
208a4f4a 901 EXEC SQL DELETE FROM serverhosts WHERE mach_id = :id;
902 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
68bbc9c3 903 if (rowcount > 0)
904 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
905 else
906 printf("Not deleted\n");
907 modified("serverhosts");
208a4f4a 908}
68bbc9c3 909
910
911static int fnchecklen;
912
913fsmatch(id, n, f)
914int id;
915struct nfsphys *n;
916struct filesys *f;
917{
918 if (n->mach_id == f->mach_id &&
919 !strncmp(f->dir, n->dir, strlen(n->dir)) &&
920 strlen(n->dir) > fnchecklen) {
921 f->phys_id = id;
922 fnchecklen = strlen(n->dir);
923 }
924}
925
926
208a4f4a 927check_fs(id, f, hint)
928EXEC SQL BEGIN DECLARE SECTION;
929int id;
930EXEC SQL END DECLARE SECTION;
68bbc9c3 931register struct filesys *f;
932int hint;
208a4f4a 933{
934 EXEC SQL BEGIN DECLARE SECTION;
935 int id1, id2, id3, rowcount;
936 char *dir;
937 EXEC SQL END DECLARE SECTION;
68bbc9c3 938 struct nfsphys *n;
939 struct machine *m;
940
941 if (!hash_lookup(machines, f->mach_id)) {
942 printf("Filesys %s with bad machine %d\n", f->name, f->mach_id);
943 if (single_fix("Fix", 0)) {
208a4f4a 944 EXEC SQL UPDATE filesys SET mach_id = 0 WHERE filsys_id = :id;
945 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
68bbc9c3 946 if (rowcount > 0)
947 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
948 else
949 printf("Not fixed\n");
950 modified("filesys");
951 f->mach_id = 0;
952 }
953 }
954
955 if (!hash_lookup(users, f->owner)) {
956 printf("Filesys %s with bad owning user %d\n", f->name, f->owner);
957 if (single_fix("Fix", 1)) {
958 zero_fix("filesys", "owner", "filsys_id", f->filsys_id);
959 f->owner = 0;
960 }
961 }
962 if (!hash_lookup(lists, f->owners)) {
963 printf("Filesys %s with bad owning group %d\n", f->name, f->owners);
964 if (single_fix("Fix", 1)) {
965 zero_fix("filesys", "owners", "filsys_id", f->filsys_id);
966 f->owners = 0;
967 }
968 }
969
970 if (f->type == 'N') {
971 if (!hash_lookup(nfsphys, f->phys_id)) {
972 m = (struct machine *)hash_lookup(machines, f->mach_id);
973 printf("Filesys %s with bad phys_id %d\n", f->name, f->phys_id);
974 if (single_fix("Fix", 1)) {
975 fnchecklen = 0;
976 hash_step(nfsphys, fsmatch, f);
977 if (fnchecklen != 0) {
978 id1 = f->phys_id;
979 id2 = f->filsys_id;
980 id3 = f->mach_id;
208a4f4a 981 EXEC SQL UPDATE filesys SET phys_id = :id1 WHERE filsys_id = :id2;
982 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
68bbc9c3 983 if (rowcount > 0)
984 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
985 else
986 printf("Not fixed\n");
987 modified("filesys");
988 } else {
989 printf("No NFSphys exsits for %s:%s\n", m->name, f->dir);
990 if (single_fix("Create", 0)) {
991 dir = f->dir;
992 id1 = f->phys_id;
993 id2 = f->filsys_id;
994 id3 = f->mach_id;
995 if (set_next_object_id("nfsphys_id", "nfsphys") !=
996 MR_SUCCESS) {
997 printf("Unable to assign unique ID\n");
998 return;
999 }
208a4f4a 1000 EXEC SQL SELECT COUNT(*) INTO :rowcount FROM numvalues
1001 WHERE name='nfsphys_id';
68bbc9c3 1002 if (rowcount != 1) {
1003 printf("Unable to retrieve unique ID\n");
1004 return;
1005 }
208a4f4a 1006 EXEC SQL INSERT INTO mfsphys (mfsphys_id, mach_id,
1007 device, dir, status, allocated, size, modtime,
1008 modby, modwith) VALUES (:id1, :id3, '???', :dir,
1009 0, 0, 0, 'now', 0, 'dbck');
1010 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
68bbc9c3 1011 if (rowcount > 0)
1012 printf("%d entr%s created\n", rowcount,
1013 rowcount==1?"y":"ies");
1014 else
1015 printf("Not created\n");
1016 modified("nfsphys");
1017 n = (struct nfsphys *)malloc(sizeof(struct nfsphys));
1018 if (n == NULL)
1019 out_of_mem("storing new nfsphys");
1020 strcpy(n->dir, dir);
1021 n->mach_id = id3;
1022 n->nfsphys_id = id1;
1023 n->allocated = 0;
1024 n->count = 0;
ab05f33a 1025 if( hash_store(nfsphys, id1, n) == -1 ) {
1026 out_of_mem("storing nfsphys in hash table");
1027 }
208a4f4a 1028 EXEC SQL UPDATE filesys SET phys_id = :id1
1029 WHERE filsys_id = :id2;
1030 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
68bbc9c3 1031 if (rowcount > 0)
1032 printf("%d filesys entr%s fixed\n", rowcount,
1033 rowcount==1?"y":"ies");
1034 else
1035 printf("Not fixed\n");
1036 modified("filesys");
1037 }
1038 }
1039 }
1040 }
1041 }
208a4f4a 1042}
68bbc9c3 1043
1044
1045check_nfsphys(id, n, hint)
1046int id;
1047struct nfsphys *n;
1048int hint;
1049{
1050 if (!hash_lookup(machines, n->mach_id)) {
1051 printf("NFSphys %d(%s) on non-existant machine %d\n",
1052 id, n->dir, n->mach_id);
1053 if (single_fix("Delete", 0))
1054 single_delete("nfsphys", "nfsphys_id", id);
1055 }
1056}
1057
208a4f4a 1058show_fsg_missing(id)
1059EXEC SQL BEGIN DECLARE SECTION;
1060int id;
1061EXEC SQL END DECLARE SECTION;
1062{
1063 EXEC SQL BEGIN DECLARE SECTION;
1064 int id1, found = 1;
1065 EXEC SQL END DECLARE SECTION;
68bbc9c3 1066 struct filesys *f;
1067
208a4f4a 1068 EXEC SQL DECLARE csr210 CURSOR FOR
1069 SELECT filsys_id FROM fsgroup
1070 WHERE group_id = :id;
ced12e61 1071 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1072 EXEC SQL OPEN csr210;
1073 while(1) {
1074 EXEC SQL FETCH csr210 INTO :id1;
7bf0a6f3 1075 if (sqlca.sqlcode != 0) {
1076 ingerr(&sqlca.sqlcode);
1077 break;
1078 }
208a4f4a 1079
1080 found = 0;
1081 if (f = (struct filesys *) hash_lookup(filesys, id1))
1082 printf("Missing fsgroup %d has member filesystem %s\n", id, f->name);
1083 else
1084 printf("Missing fsgroup %d has member filesystem %d\n", id, id1);
1085 }
1086 EXEC SQL CLOSE csr210;
68bbc9c3 1087 return(found);
208a4f4a 1088}
68bbc9c3 1089
1090show_fsg_type(f)
1091struct filesys *f;
1092{
1093 char *t;
1094
1095 switch (f->type) {
1096 case 'N':
1097 t = "NFS";
1098 break;
1099 case 'R':
1100 t = "RVD";
1101 break;
1102 case 'A':
1103 t = "AFS";
1104 break;
1105 case 'E':
1106 t = "ERR";
1107 break;
1108 case 'F':
1109 t = "FSGROUP";
1110 break;
1111 case 'M':
1112 t = "MUL";
1113 break;
1114 default:
1115 t = "???";
1116 }
1117 printf("FSGroup %s has type %s instead of FSGROUP\n", f->name, t);
1118 return(0);
1119}
1120
1121fix_fsg_type(f)
1122struct filesys *f;
208a4f4a 1123{
1124 EXEC SQL BEGIN DECLARE SECTION;
1125 int rowcount, id = f->filsys_id;
1126 EXEC SQL END DECLARE SECTION;
68bbc9c3 1127
208a4f4a 1128 EXEC SQL UPDATE filesys SET type='FSGROUP' WHERE filsys_id = :id;
1129 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
68bbc9c3 1130 if (rowcount > 0)
1131 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
1132 else
1133 printf("Not fixed\n");
1134 modified("filesys");
208a4f4a 1135}
68bbc9c3 1136
208a4f4a 1137show_fsg_nomember(id)
1138EXEC SQL BEGIN DECLARE SECTION;
1139int id;
1140EXEC SQL END DECLARE SECTION;
1141{
1142 EXEC SQL BEGIN DECLARE SECTION;
1143 int id1, found = 1;
1144 EXEC SQL END DECLARE SECTION;
68bbc9c3 1145 struct filesys *f;
1146
208a4f4a 1147 EXEC SQL DECLARE csr211 CURSOR FOR
1148 SELECT group_id FROM fsgroup
1149 WHERE filsys_id = :id;
ced12e61 1150 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1151 EXEC SQL OPEN csr211;
1152 while(1) {
1153 EXEC SQL FETCH csr211 INTO :id1;
7bf0a6f3 1154 if (sqlca.sqlcode != 0) {
1155 ingerr(&sqlca.sqlcode);
1156 break;
1157 }
208a4f4a 1158
1159 found = 0;
1160 if (f = (struct filesys *) hash_lookup(filesys, id1))
1161 printf("FSGroup %s has missing member %d\n", f->name, id);
1162 else
1163 printf("FSGroup %d has missing member %d\n", id1, id);
1164 }
1165 EXEC SQL CLOSE csr211;
68bbc9c3 1166 return(found);
208a4f4a 1167}
1168
1169show_quota_nouser(id)
1170EXEC SQL BEGIN DECLARE SECTION;
1171int id;
1172EXEC SQL END DECLARE SECTION;
1173{
1174 EXEC SQL BEGIN DECLARE SECTION;
1175 int id1, found = 1;
1176 EXEC SQL END DECLARE SECTION;
1177
208a4f4a 1178 EXEC SQL DECLARE csr212 CURSOR FOR
1179 SELECT filsys_id FROM quota
1180 WHERE entity_id = :id AND type='USER';
ced12e61 1181 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1182 EXEC SQL OPEN csr212;
1183 while(1) {
1184 EXEC SQL FETCH csr212 INTO :id1;
7bf0a6f3 1185 if (sqlca.sqlcode != 0) {
1186 ingerr(&sqlca.sqlcode);
1187 break;
1188 }
208a4f4a 1189
1190 found = 0;
1191 printf("Quota on fs %d for non-existant user %d\n", id1, id);
1192 }
1193 EXEC SQL CLOSE csr212;
68bbc9c3 1194 return(found);
208a4f4a 1195}
1196
1197show_quota_nolist(id)
1198EXEC SQL BEGIN DECLARE SECTION;
1199int id;
1200EXEC SQL END DECLARE SECTION;
1201{
1202 EXEC SQL BEGIN DECLARE SECTION;
1203 int id1, found = 1;
1204 EXEC SQL END DECLARE SECTION;
1205
208a4f4a 1206 EXEC SQL DECLARE csr213 CURSOR FOR
1207 SELECT filsys_id FROM quota
1208 WHERE entity_id = :id AND type='GROUP';
ced12e61 1209 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1210 EXEC SQL OPEN csr213;
1211 while(1) {
1212 EXEC SQL FETCH csr213 INTO :id1;
7bf0a6f3 1213 if (sqlca.sqlcode != 0) {
1214 ingerr(&sqlca.sqlcode);
1215 break;
1216 }
208a4f4a 1217
1218 found = 0;
1219 printf("Quota on fs %d for non-existant list %d\n", id1, id);
1220 }
1221 EXEC SQL CLOSE csr213;
68bbc9c3 1222 return(found);
208a4f4a 1223}
68bbc9c3 1224
208a4f4a 1225fix_quota_nouser(id)
1226EXEC SQL BEGIN DECLARE SECTION;
1227int id;
1228EXEC SQL END DECLARE SECTION;
1229{
1230 EXEC SQL BEGIN DECLARE SECTION;
1231 int rowcount, id1;
1232 EXEC SQL END DECLARE SECTION;
68bbc9c3 1233
1234 id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
208a4f4a 1235 EXEC SQL DELETE FROM quota
1236 WHERE entity_id = :id AND type = 'USER';
1237 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
68bbc9c3 1238 if (rowcount > 0)
1239 printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies");
1240 else
1241 printf("Not deleted\n");
1242 modified("quota");
208a4f4a 1243}
68bbc9c3 1244
208a4f4a 1245fix_quota_nolist(id)
1246EXEC SQL BEGIN DECLARE SECTION;
1247int id;
1248EXEC SQL END DECLARE SECTION;
1249{
1250 EXEC SQL BEGIN DECLARE SECTION;
1251 int rowcount, id1;
1252 EXEC SQL END DECLARE SECTION;
68bbc9c3 1253
1254 id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
208a4f4a 1255 EXEC SQL DELETE FROM quota WHERE entity_id = :id AND type='GROUP';
1256 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
68bbc9c3 1257 if (rowcount > 0)
1258 printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies");
1259 else
1260 printf("Not deleted\n");
1261 modified("quota");
208a4f4a 1262}
1263
1264show_quota_nofs(id)
1265EXEC SQL BEGIN DECLARE SECTION;
1266int id;
1267EXEC SQL END DECLARE SECTION;
1268{
1269 EXEC SQL BEGIN DECLARE SECTION;
1270 int id1, found = 1;
1271 char type[9];
1272 EXEC SQL END DECLARE SECTION;
1273
208a4f4a 1274 EXEC SQL DECLARE csr214 CURSOR FOR
1275 SELECT entity_id, type FROM quota
1276 WHERE filsys_id = :id;
ced12e61 1277 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1278 EXEC SQL OPEN csr214;
1279 while(1) {
1280 EXEC SQL FETCH csr214 INTO :id1, :type;
7bf0a6f3 1281 if (sqlca.sqlcode != 0) {
1282 ingerr(&sqlca.sqlcode);
1283 break;
1284 }
208a4f4a 1285
1286 found = 0;
1287 printf("Quota for %s %d on non-existant filesys %d\n", type, id1, id);
1288 }
1289 EXEC SQL CLOSE csr214;
68bbc9c3 1290 return(found);
208a4f4a 1291}
68bbc9c3 1292
1293fix_quota_nofs(id)
1294{
1295 single_delete("quota", "filsys_id", id);
1296}
1297
208a4f4a 1298show_quota_wrongpid(id)
1299EXEC SQL BEGIN DECLARE SECTION;
1300int id;
1301EXEC SQL END DECLARE SECTION;
1302{
1303 EXEC SQL BEGIN DECLARE SECTION;
1304 int id1, found = 1;
1305 char type[9];
1306 EXEC SQL END DECLARE SECTION;
68bbc9c3 1307 struct user *u;
1308 struct filesys *f;
1309
1310 f = (struct filesys *)hash_lookup(filesys, id);
208a4f4a 1311 EXEC SQL DECLARE csr215 CURSOR FOR
1312 SELECT entity_id, type FROM quota
1313 WHERE filsys_id = :id;
ced12e61 1314 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1315 EXEC SQL OPEN csr215;
1316 while(1) {
1317 EXEC SQL FETCH csr215 INTO :id1, :type;
7bf0a6f3 1318 if (sqlca.sqlcode != 0) {
1319 ingerr(&sqlca.sqlcode);
1320 break;
1321 }
208a4f4a 1322
1323 found = 0;
1324 printf("Quota for %s %d on filesys %s has wrong phys_id %d\n",
1325 type, id1, f->name, id);
1326 }
1327 EXEC SQL CLOSE csr215;
68bbc9c3 1328 return(found);
208a4f4a 1329}
68bbc9c3 1330
208a4f4a 1331fix_quota_physid(id)
1332EXEC SQL BEGIN DECLARE SECTION;
1333int id;
1334EXEC SQL END DECLARE SECTION;
1335{
1336 EXEC SQL BEGIN DECLARE SECTION;
1337 int rowcount, id1;
1338 EXEC SQL END DECLARE SECTION;
68bbc9c3 1339
1340 id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
208a4f4a 1341 EXEC SQL UPDATE quota SET phys_id = :id1
1342 WHERE filsys_id = :id AND phys_id != :id1;
1343 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
68bbc9c3 1344 if (rowcount > 0)
1345 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
1346 else
1347 printf("Not fixed\n");
1348 modified("quota");
208a4f4a 1349}
68bbc9c3 1350
208a4f4a 1351show_srv_user(id)
1352EXEC SQL BEGIN DECLARE SECTION;
1353int id;
1354EXEC SQL END DECLARE SECTION;
1355{
1356 EXEC SQL BEGIN DECLARE SECTION;
1357 char name[33];
1358 EXEC SQL END DECLARE SECTION;
68bbc9c3 1359 int found = 1;
1360
208a4f4a 1361 EXEC SQL DECLARE csr216 CURSOR FOR
1362 SELECT name FROM servers
1363 WHERE acl_type='USER' and acl_id = :id;
ced12e61 1364 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1365 EXEC SQL OPEN csr216;
1366 while(1) {
1367 EXEC SQL FETCH csr216 INTO :name;
7bf0a6f3 1368 if (sqlca.sqlcode != 0) {
1369 ingerr(&sqlca.sqlcode);
1370 break;
1371 }
208a4f4a 1372
68bbc9c3 1373 strtrim(name);
1374 printf("Service %s has acl non-existant user %d\n", name, id);
1375 found = 0;
208a4f4a 1376 }
1377 EXEC SQL CLOSE csr216;
68bbc9c3 1378 return(found);
208a4f4a 1379}
68bbc9c3 1380
208a4f4a 1381show_srv_list(id)
1382EXEC SQL BEGIN DECLARE SECTION;
1383int id;
1384EXEC SQL END DECLARE SECTION;
1385{
1386 EXEC SQL BEGIN DECLARE SECTION;
1387 char name[33];
1388 EXEC SQL END DECLARE SECTION;
68bbc9c3 1389 int found = 1;
1390
208a4f4a 1391 EXEC SQL DECLARE csr217 CURSOR FOR
1392 SELECT name FROM servers
1393 WHERE acl_type='LIST' AND acl_id = :id;
ced12e61 1394 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1395 EXEC SQL OPEN csr217;
1396 while(1) {
1397 EXEC SQL FETCH csr217 INTO :name;
7bf0a6f3 1398 if (sqlca.sqlcode != 0) {
1399 ingerr(&sqlca.sqlcode);
1400 break;
1401 }
208a4f4a 1402
68bbc9c3 1403 strtrim(name);
1404 printf("Service %s has acl non-existant list %d\n", name, id);
1405 found = 0;
208a4f4a 1406 }
1407 EXEC SQL CLOSE csr217;
68bbc9c3 1408 return(found);
208a4f4a 1409}
68bbc9c3 1410
208a4f4a 1411zero_srv_user(id)
1412EXEC SQL BEGIN DECLARE SECTION;
1413int id;
1414EXEC SQL END DECLARE SECTION;
1415{
1416 EXEC SQL BEGIN DECLARE SECTION;
1417 int rowcount;
1418 EXEC SQL END DECLARE SECTION;
1419
208a4f4a 1420 EXEC SQL UPDATE servers SET acl_id=0 WHERE acl_id = :id AND
1421 acl_type='USER';
1422 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
68bbc9c3 1423 if (rowcount > 0)
1424 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
1425 else
1426 printf("Not fixed\n");
1427 modified("servers");
208a4f4a 1428}
68bbc9c3 1429
208a4f4a 1430zero_srv_list(id)
1431EXEC SQL BEGIN DECLARE SECTION;
1432int id;
1433EXEC SQL END DECLARE SECTION;
1434{
1435 EXEC SQL BEGIN DECLARE SECTION;
1436 int rowcount;
1437 EXEC SQL END DECLARE SECTION;
1438
208a4f4a 1439 EXEC SQL UPDATE servers SET acl_id=0 WHERE acl_id = :id AND
1440 acl_type='LIST';
1441 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
68bbc9c3 1442 if (rowcount > 0)
1443 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
1444 else
1445 printf("Not fixed\n");
1446 modified("servers");
208a4f4a 1447}
68bbc9c3 1448
1449
208a4f4a 1450show_krb_usr(id)
1451EXEC SQL BEGIN DECLARE SECTION;
1452int id;
1453EXEC SQL END DECLARE SECTION;
1454{
1455 EXEC SQL BEGIN DECLARE SECTION;
1456 int found = 1, id1;
1457 EXEC SQL END DECLARE SECTION;
68bbc9c3 1458 struct string *s;
1459 char *ss;
1460
208a4f4a 1461 EXEC SQL DECLARE csr218 CURSOR FOR
1462 SELECT string_id FROM krbmap
1463 WHERE users_id = :id ;
ced12e61 1464 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1465 EXEC SQL OPEN csr218;
1466 while(1) {
1467 EXEC SQL FETCH csr218 INTO :id1;
7bf0a6f3 1468 if (sqlca.sqlcode != 0) {
1469 ingerr(&sqlca.sqlcode);
1470 break;
1471 }
208a4f4a 1472
68bbc9c3 1473 if (s = ((struct string *)hash_lookup(strings, id1)))
208a4f4a 1474 ss = s->name;
68bbc9c3 1475 else
208a4f4a 1476 ss = "[unknown]";
68bbc9c3 1477 found = 0;
1478 printf("Kerberos map for non-existant user %d to principal %s\n",
1479 id, s);
208a4f4a 1480 }
1481 EXEC SQL CLOSE csr218;
68bbc9c3 1482 return(found);
208a4f4a 1483}
68bbc9c3 1484
1485
208a4f4a 1486show_krb_str(id)
1487EXEC SQL BEGIN DECLARE SECTION;
1488int id;
1489EXEC SQL END DECLARE SECTION;
1490{
1491 EXEC SQL BEGIN DECLARE SECTION;
1492 int found = 1, id1;
1493 EXEC SQL END DECLARE SECTION;
68bbc9c3 1494 struct user *u;
1495 char *s;
1496
208a4f4a 1497 EXEC SQL DECLARE csr219 CURSOR FOR
1498 SELECT users_id FROM krbmap
1499 WHERE string_id = :id;
ced12e61 1500 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1501 EXEC SQL OPEN csr219;
1502 while(1) {
1503 EXEC SQL FETCH csr219 INTO :id1;
7bf0a6f3 1504 if (sqlca.sqlcode != 0) {
1505 ingerr(&sqlca.sqlcode);
1506 break;
1507 }
208a4f4a 1508
68bbc9c3 1509 if (u = ((struct user *)hash_lookup(users, id1)))
208a4f4a 1510 s = u->login;
68bbc9c3 1511 else
208a4f4a 1512 s = "[???]";
68bbc9c3 1513 found = 0;
1514 printf("Kerberos map for user %s (%d) to non-existant string %d\n",
1515 s, id1, id);
208a4f4a 1516 }
1517 EXEC SQL CLOSE csr219;
68bbc9c3 1518 return(found);
208a4f4a 1519}
68bbc9c3 1520
1521
208a4f4a 1522show_pdm_mach(id)
1523EXEC SQL BEGIN DECLARE SECTION;
1524int id;
1525EXEC SQL END DECLARE SECTION;
1526{
1527 EXEC SQL BEGIN DECLARE SECTION;
1528 char name[33];
1529 EXEC SQL END DECLARE SECTION;
68bbc9c3 1530 int found = 1;
1531
208a4f4a 1532 EXEC SQL DECLARE csr220 CURSOR FOR
1533 SELECT name FROM palladium
1534 WHERE mach_id = :id;
ced12e61 1535 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1536 EXEC SQL OPEN csr220;
1537 while(1) {
1538 EXEC SQL FETCH csr220 INTO :name;
7bf0a6f3 1539 if (sqlca.sqlcode != 0) {
1540 ingerr(&sqlca.sqlcode);
1541 break;
1542 }
208a4f4a 1543
68bbc9c3 1544 strtrim(name);
1545 printf("Palladium server/supervisor %s is on non-existant machine %d\n",
1546 name, id);
1547 found = 0;
208a4f4a 1548 }
1549 EXEC SQL CLOSE csr220;
68bbc9c3 1550 return(found);
208a4f4a 1551}
68bbc9c3 1552
1553
1554phase2()
208a4f4a 1555{
1556 EXEC SQL BEGIN DECLARE SECTION;
1557 int id1, id2, id3, id4, id5;
1558 char type[9], name[33];
1559 EXEC SQL END DECLARE SECTION;
68bbc9c3 1560 struct save_queue *sq, *sq1, *sq2, *sq3, *sq4, *sq5;
1561 struct filesys *f;
1562 struct list *l;
1563 struct nfsphys *n;
1564 struct machine *m;
1565
1566 printf("Phase 2 - Checking references\n");
1567
1568 dprintf("Checking users...\n");
ab05f33a 1569 hash_step(users, user_check, NULL);
68bbc9c3 1570
772b7afc 1571 dprintf("Checking machines...\n");
1572 hash_step(machines, mach_check, NULL);
1573
ab05f33a 1574 dprintf("Checking subnets...\n");
1575 hash_step(subnets, subnet_check, NULL);
1576
1577 dprintf("Checking clusters...\n");
1578 hash_step(clusters, cluster_check, NULL);
1579
68bbc9c3 1580 dprintf("Checking mcmap...\n");
1581 sq1 = sq_create();
1582 sq2 = sq_create();
208a4f4a 1583 EXEC SQL DECLARE csr221 CURSOR FOR
ab05f33a 1584 SELECT mach_id, clu_id FROM mcmap;
ced12e61 1585 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1586 EXEC SQL OPEN csr221;
ab05f33a 1587 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1588 while(1) {
1589 EXEC SQL FETCH csr221 INTO :id1, :id2;
7bf0a6f3 1590 if (sqlca.sqlcode != 0) {
1591 ingerr(&sqlca.sqlcode);
1592 break;
1593 }
208a4f4a 1594
68bbc9c3 1595 if (!(m = (struct machine *)hash_lookup(machines, id1)))
208a4f4a 1596 sq_save_unique_data(sq1, id1);
ab05f33a 1597 else if (!hash_lookup(clusters, id2))
208a4f4a 1598 sq_save_unique_data(sq2, id2);
68bbc9c3 1599 if (m) m->clucount++;
ab05f33a 1600 }
208a4f4a 1601 EXEC SQL CLOSE csr221;
68bbc9c3 1602 generic_delete(sq1, show_mcm_mach, "mcmap", "mach_id", 1);
1603 generic_delete(sq2, show_mcm_clu, "mcmap", "clu_id", 1);
1604
1605 dprintf("Checking service clusters...\n");
1606 sq1 = sq_create();
208a4f4a 1607 EXEC SQL DECLARE csr222 CURSOR FOR
ab05f33a 1608 SELECT clu_id FROM svc;
ced12e61 1609 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1610 EXEC SQL OPEN csr222;
1611 while(1) {
1612 EXEC SQL FETCH csr222 INTO :id1;
7bf0a6f3 1613 if (sqlca.sqlcode != 0) {
1614 ingerr(&sqlca.sqlcode);
1615 break;
1616 }
208a4f4a 1617
68bbc9c3 1618 if (!hash_lookup(clusters, id1))
1619 sq_save_unique_data(sq1, id1);
208a4f4a 1620 }
1621 EXEC SQL CLOSE csr222;
68bbc9c3 1622 generic_delete(sq1, show_svc, "svc", "clu_id", 1);
1623
1624 dprintf("Checking lists...\n");
1625 hash_step(lists, list_check, NULL);
1626
1627 dprintf("Checking members...\n");
1628 sq1 = sq_create();
1629 sq2 = sq_create();
1630 sq3 = sq_create();
1631 sq4 = sq_create();
1632 sq5 = sq_create();
64842aba 1633
208a4f4a 1634 EXEC SQL DECLARE csr223 CURSOR FOR
ab05f33a 1635 SELECT list_id, member_type, member_id, ref_count, direct
1636 FROM imembers FOR DEFERRED UPDATE OF member_id;
ced12e61 1637 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1638 EXEC SQL OPEN csr223;
1639 while(1) {
1640 EXEC SQL FETCH csr223 INTO :id1, :type, :id2, :id3, :id4;
7bf0a6f3 1641 if (sqlca.sqlcode != 0) {
1642 ingerr(&sqlca.sqlcode);
1643 break;
1644 }
208a4f4a 1645
68bbc9c3 1646 if ((l = (struct list *) hash_lookup(lists, id1)) == NULL)
1647 sq_save_unique_data(sq1, id1);
1648 else if (type[0] == 'U' && !hash_lookup(users, id2))
1649 sq_save_unique_data(sq2, id2);
1650 else if (type[0] == 'L' && !hash_lookup(lists, id2))
1651 sq_save_unique_data(sq3, id2);
ab05f33a 1652 else if (type[0] == 'S' && !maybe_fixup_unref_string2("imembers","member_id","csr223",id2))
68bbc9c3 1653 sq_save_unique_data(sq4, id2);
ab05f33a 1654 else if (type[0] == 'K' && !maybe_fixup_unref_string2("imembers","member_id","csr223",id2))
68bbc9c3 1655 sq_save_unique_data(sq5, id2);
1656 else
1657 l->members++;
208a4f4a 1658 }
1659 EXEC SQL CLOSE csr223;
68bbc9c3 1660 generic_delete(sq1, show_member_list, "imembers", "list_id", 1);
1661 generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1);
1662 generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1);
1663 generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1);
1664 generic_fix(sq5, show_mem_krb, "Delete", del_mem_krb, 1);
1665
1666 dprintf("Checking servers...\n");
1667 sq1 = sq_create();
1668 sq2 = sq_create();
208a4f4a 1669 EXEC SQL DECLARE csr224 CURSOR FOR
ab05f33a 1670 SELECT name, acl_type, acl_id, modby FROM servers
1671 FOR DEFERRED UPDATE of modby;
ced12e61 1672 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1673 EXEC SQL OPEN csr224;
1674 while(1) {
ab05f33a 1675 EXEC SQL FETCH csr224 INTO :name, :type, :id1, :id2;
7bf0a6f3 1676 if (sqlca.sqlcode != 0) {
1677 ingerr(&sqlca.sqlcode);
1678 break;
1679 }
208a4f4a 1680
ab05f33a 1681 maybe_fixup_modby2("servers","modby","csr224",id2);
68bbc9c3 1682 strtrim(type);
1683 if (!strcmp(type, "USER") && !hash_lookup(users, id1)) {
1684 sq_save_data(sq1, id1);
1685 } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id1)) {
1686 sq_save_data(sq2, id1);
1687 }
208a4f4a 1688 }
1689 EXEC SQL CLOSE csr224;
68bbc9c3 1690 generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
1691 generic_fix(sq2, show_srv_list, "Fix", zero_srv_list, 1);
1692
7bf0a6f3 1693 dprintf("Checking serverhosts...\n");
68bbc9c3 1694 sq = sq_create();
208a4f4a 1695 EXEC SQL DECLARE csr225 CURSOR FOR
ab05f33a 1696 SELECT mach_id, modby FROM serverhosts
1697 FOR DEFERRED UPDATE OF modby;
ced12e61 1698 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1699 EXEC SQL OPEN csr225;
1700 while(1) {
ab05f33a 1701 EXEC SQL FETCH csr225 INTO :id1, :id2;
7bf0a6f3 1702 if (sqlca.sqlcode != 0) {
1703 ingerr(&sqlca.sqlcode);
1704 break;
1705 }
208a4f4a 1706
ab05f33a 1707 maybe_fixup_modby2("serverhosts", "modby", "csr225", id2);
68bbc9c3 1708 if (!hash_lookup(machines, id1))
1709 sq_save_data(sq, id1);
208a4f4a 1710 }
1711 EXEC SQL CLOSE csr225;
68bbc9c3 1712 generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
1713
1714 dprintf("Checking nfsphys...\n");
1715 hash_step(nfsphys, check_nfsphys, NULL);
1716
1717 dprintf("Checking filesys...\n");
1718 hash_step(filesys, check_fs, NULL);
1719
1720 dprintf("Checking filesystem groups...\n");
1721 sq1 = sq_create();
1722 sq2 = sq_create();
1723 sq3 = sq_create();
208a4f4a 1724 EXEC SQL DECLARE csr226 CURSOR FOR
ab05f33a 1725 SELECT group_id, filsys_id FROM fsgroup;
ced12e61 1726 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1727 EXEC SQL OPEN csr226;
1728 while(1) {
1729 EXEC SQL FETCH csr226 INTO :id1, :id2;
7bf0a6f3 1730 if (sqlca.sqlcode != 0) {
1731 ingerr(&sqlca.sqlcode);
1732 break;
1733 }
208a4f4a 1734
68bbc9c3 1735 if (!(f = (struct filesys *) hash_lookup(filesys, id1)))
1736 sq_save_data(sq1, id1);
1737 if (!hash_lookup(filesys, id2))
1738 sq_save_data(sq3, id2);
208a4f4a 1739 }
1740 EXEC SQL CLOSE csr226;
68bbc9c3 1741 generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0);
1742 generic_delete(sq3, show_fsg_nomember, "fsgroup", "filsys_id", 1);
1743
1744 dprintf("Checking quotas...\n");
1745 sq1 = sq_create();
1746 sq2 = sq_create();
1747 sq3 = sq_create();
1748 sq4 = sq_create();
208a4f4a 1749 EXEC SQL DECLARE csr227 CURSOR FOR
ab05f33a 1750 SELECT entity_id, type, filsys_id, phys_id, quota, modby
1751 FROM quota FOR DEFERRED UPDATE OF modby;
ced12e61 1752 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1753 EXEC SQL OPEN csr227;
1754 while(1) {
ab05f33a 1755 EXEC SQL FETCH csr227 INTO :id1, :type, :id2, :id3, :id4, :id5;
7bf0a6f3 1756 if (sqlca.sqlcode != 0) {
1757 ingerr(&sqlca.sqlcode);
1758 break;
1759 }
208a4f4a 1760
ab05f33a 1761 maybe_fixup_modby2("quota", "modby", "csr227", id5);
68bbc9c3 1762 if (type[0] == 'U' && id1 != 0 && !hash_lookup(users, id1))
1763 sq_save_data(sq1, id1);
1764 else if (type[0] == 'G' && !hash_lookup(lists, id1))
1765 sq_save_data(sq4, id1);
1766 else if (!(f = (struct filesys *) hash_lookup(filesys, id2)))
1767 sq_save_data(sq2, id2);
1768 else if (id3 != f->phys_id ||
1769 ((n = (struct nfsphys*) hash_lookup(nfsphys, id3)) ==
1770 (struct nfsphys *)NULL))
1771 sq_save_data(sq3, id2);
1772 else
1773 n->count += id4;
208a4f4a 1774 }
1775 EXEC SQL CLOSE csr227;
68bbc9c3 1776 generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1);
1777 generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0);
1778 generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1);
1779 generic_fix(sq4, show_quota_nolist, "Delete", fix_quota_nolist, 1);
1780
1781 dprintf("Not checking zephyr.\n");
1782
1783 dprintf("Checking hostaccess...\n");
208a4f4a 1784 EXEC SQL DECLARE csr228 CURSOR FOR
ab05f33a 1785 SELECT mach_id, acl_type, acl_id, modby FROM hostaccess
1786 FOR DEFERRED UPDATE OF modby;
ced12e61 1787 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1788 EXEC SQL OPEN csr228;
1789 while(1) {
ab05f33a 1790 EXEC SQL FETCH csr228 INTO :id1, :type, :id2, :id3;
7bf0a6f3 1791 if (sqlca.sqlcode != 0) {
1792 ingerr(&sqlca.sqlcode);
1793 break;
1794 }
208a4f4a 1795
ab05f33a 1796 maybe_fixup_modby2("hostaccess", "modby", "csr228", id3);
68bbc9c3 1797 strtrim(type);
1798 if (!hash_lookup(machines, id1)) {
1799 printf("Hostaccess for non-existant host %d\n", id1);
1800 printf("Not fixing this error\n");
1801 }
1802 if (!strcmp(type, "USER") && !hash_lookup(users, id2)) {
1803 printf("Hostaccess for %d is non-existant user %d\n", id1, id2);
1804 printf("Not fixing this error\n");
1805 } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2)) {
1806 printf("Hostaccess for %d is non-existant list %d\n", id1, id2);
1807 printf("Not fixing this error\n");
1808 }
208a4f4a 1809 }
1810 EXEC SQL CLOSE csr228;
68bbc9c3 1811
1812 dprintf("Checking palladium...\n");
1813 sq1 = sq_create();
208a4f4a 1814 EXEC SQL DECLARE csr229 CURSOR FOR
ab05f33a 1815 SELECT mach_id, modby FROM palladium
1816 FOR DEFERRED UPDATE OF modby;
ced12e61 1817 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1818 EXEC SQL OPEN csr229;
1819 while(1) {
ab05f33a 1820 EXEC SQL FETCH csr229 INTO :id1, :id2;
7bf0a6f3 1821 if (sqlca.sqlcode != 0) {
1822 ingerr(&sqlca.sqlcode);
1823 break;
1824 }
208a4f4a 1825
ab05f33a 1826 maybe_fixup_modby2("palladium", "modby", "csr229", id2);
68bbc9c3 1827 if (!hash_lookup(machines, id1)) {
1828 sq_save_unique_data(sq1, id1);
1829 }
208a4f4a 1830 }
1831 EXEC SQL CLOSE csr229;
68bbc9c3 1832 generic_delete(sq1, show_pdm_mach, "palladium", "mach_id", 1);
1833
1834 dprintf("Checking krbmap...\n");
1835 sq1 = sq_create();
1836 sq2 = sq_create();
208a4f4a 1837 EXEC SQL DECLARE csr230 CURSOR FOR
ab05f33a 1838 SELECT users_id, string_id FROM krbmap
1839 FOR DEFERRED UPDATE OF string_id;
ced12e61 1840 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1841 EXEC SQL OPEN csr230;
1842 while(1) {
1843 EXEC SQL FETCH csr230 INTO :id1, :id2;
7bf0a6f3 1844 if (sqlca.sqlcode != 0) {
1845 ingerr(&sqlca.sqlcode);
1846 break;
1847 }
208a4f4a 1848
68bbc9c3 1849 if (!hash_lookup(users, id1))
1850 sq_save_unique_data(sq1, id1);
ab05f33a 1851 else if (!maybe_fixup_unref_string2("krbmap","string_id","csr230",id2))
68bbc9c3 1852 sq_save_unique_data(sq2, id2);
208a4f4a 1853 }
1854 EXEC SQL CLOSE csr230;
68bbc9c3 1855 generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1);
1856 generic_delete(sq2, show_krb_str, "krbmap", "string_id", 1);
1857
1858 dprintf("Checking capacls...\n");
208a4f4a 1859 EXEC SQL DECLARE csr231 CURSOR FOR
ab05f33a 1860 SELECT list_id, tag FROM capacls;
ced12e61 1861 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
208a4f4a 1862 EXEC SQL OPEN csr231;
1863 while(1) {
1864 EXEC SQL FETCH csr231 INTO :id1, :name;
7bf0a6f3 1865 if (sqlca.sqlcode != 0) {
1866 ingerr(&sqlca.sqlcode);
1867 break;
1868 }
208a4f4a 1869
68bbc9c3 1870 if (!hash_lookup(lists, id1)) {
1871 printf("Capacl for %s is non-existant list %d\n", name, id1);
1872 printf("Not fixing this error\n");
1873 }
208a4f4a 1874 }
ab05f33a 1875 EXEC SQL CLOSE csr231;
68bbc9c3 1876
ab05f33a 1877 dprintf("Checking hostaliases\n");
1878 sq1 = sq_create();
1879 EXEC SQL DECLARE csr232 CURSOR FOR
1880 SELECT mach_id FROM hostalias;
1881 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1882 EXEC SQL OPEN csr232;
1883 while(1) {
1884 EXEC SQL FETCH csr232 INTO :id1;
1885 if (sqlca.sqlcode != 0) {
1886 ingerr(&sqlca.sqlcode);
1887 break;
1888 }
68bbc9c3 1889
ab05f33a 1890 if (!hash_lookup(machines, id1))
1891 sq_save_unique_data(sq1, id1);
1892 }
1893 EXEC SQL CLOSE csr232;
1894 generic_delete(sq1, show_hostalias, "hostalias", "mach_id", 1);
1895
1896 dprintf("Checking printcaps\n");
1897 sq1 = sq_create();
1898 sq2 = sq_create();
1899 EXEC SQL DECLARE csr233 CURSOR FOR
1900 SELECT mach_id, quotaserver, modby FROM printcap;
1901 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1902 EXEC SQL OPEN csr233;
1903 while(1) {
1904 EXEC SQL FETCH csr233 INTO :id1, :id2, :id3;
1905 if (sqlca.sqlcode != 0) {
1906 ingerr(&sqlca.sqlcode);
1907 break;
1908 }
1909
1910 maybe_fixup_modby2("printcap", "modby", "csr233", id3);
1911 if (!hash_lookup(machines, id1))
1912 sq_save_unique_data(sq1, id1);
1913 else if(!hash_lookup(machines, id2))
1914 sq_save_unique_data(sq2, id2);
1915 }
1916 EXEC SQL CLOSE csr233;
1917 generic_delete(sq1, show_pcap_mach, "printcap", "mach_id", 1);
1918 generic_delete(sq2, show_pcap_quota, "printcap", "quotaserver", 1);
1919}
This page took 0.468806 seconds and 5 git commands to generate.