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