]> andersk Git - moira.git/blame - dbck/phase2.pc
Support MACHINE members of lists.
[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);
dabf20aa 25int show_printer_mach(void *id);
fe0a844a 26int show_printer_server(void *id);
dabf20aa 27int show_printer_loghost(void *id);
28int show_printer_spool(void *id);
29int show_printer_quota(void *id);
30int show_printer_ac(void *id);
31int show_printer_lpc_acl(void *id);
c96b70a5 32void fix_printer_ac(void *id);
33void fix_printer_lpc_acl(void *id);
7ac48069 34void user_check(int id, void *user, void *hint);
35int maybe_fixup_unref_string(int sid, int oid, char *oname, char *table,
36 char *field, char *idfield);
37int maybe_fixup_modby(int sid, int oid, char *oname, char *table,
38 char *field, char *idfield);
c978c079 39int maybe_fixup_unref_string2(char *table, char *field, char *rowid, int sid);
40int maybe_fixup_modby2(char *table, char *field, char *rowid, int id);
7ac48069 41void pobox_check(int id, struct user *u);
42void remove_pobox(int id);
43void fix_smtp_pobox(int id, int sid);
44void mach_check(int id, void *machine, void *hint);
45void subnet_check(int id, void *subnet, void *hint);
46void clear_subnet_owner(struct subnet *s);
47void clear_mach_owner(struct machine *m);
48void cluster_check(int id, void *cluster, void *hint);
49int show_svc(void *id);
50void list_check(int id, void *list, void *hint);
51void fix_list_acl(int id);
ad47bcbe 52void fix_list_memacl(int id);
7ac48069 53int show_member_list(void *id);
54int show_mem_user(void *id);
55int show_mem_list(void *id);
56int show_mem_str(void *id);
57int show_mem_krb(void *id);
5f7b0741 58int show_mem_mach(void *id);
7ac48069 59void del_mem_user(void *id);
60void del_mem_list(void *id);
61void del_mem_str(void *id);
62void del_mem_krb(void *id);
5f7b0741 63void del_mem_mach(void *id);
7ac48069 64int show_sh(void *id);
65void del_sh_mach(void *id);
66void fsmatch(int id, void *nfsphys, void *filesys);
67void check_fs(int id, void *filesys, void *hint);
68void check_nfsphys(int id, void *nfsphys, void *hint);
fe0a844a 69void check_ps(int id, void *printserver, void *hint);
7ac48069 70int show_fsg_missing(void *id);
71int show_fsg_type(void *filesys);
72void fix_fsg_type(void *filesys);
73int show_fsg_nomember(void *id);
74int show_quota_nouser(void *id);
75int show_quota_nolist(void *id);
76void fix_quota_nouser(void *id);
77void fix_quota_nolist(void *id);
78int show_quota_nofs(void *id);
79void fix_quota_nofs(void *id);
80int show_quota_wrongpid(void *id);
81void fix_quota_physid(void *id);
82int show_srv_user(void *id);
83int show_srv_list(void *id);
84void zero_srv_user(void *id);
85void zero_srv_list(void *id);
86int show_krb_usr(void *id);
87int show_krb_str(void *id);
88int show_pdm_mach(void *id);
89
90int show_mcm_mach(void *id)
208a4f4a 91{
5eaef520 92 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 93 int iid = (int)id, found = 1;
cfc4f91e 94 char name[CLUSTERS_NAME_SIZE];
5eaef520 95 EXEC SQL END DECLARE SECTION;
96
97 EXEC SQL DECLARE csr201 CURSOR FOR
98 SELECT clusters.name FROM clusters, mcmap
99 WHERE clusters.clu_id = mcmap.clu_id AND mcmap.mach_id = :iid;
100 EXEC SQL OPEN csr201;
101 while (1)
102 {
103 EXEC SQL FETCH csr201 INTO :name;
104 if (sqlca.sqlcode)
105 break;
106
107 strtrim(name);
108 found = 0;
7ac48069 109 printf("Cluster %s, non-existant machine %d in cluster map\n",
110 name, iid);
208a4f4a 111 }
5eaef520 112 EXEC SQL CLOSE csr201;
113 return found;
208a4f4a 114}
68bbc9c3 115
7ac48069 116int show_mcm_clu(void *id)
208a4f4a 117{
5eaef520 118 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 119 int iid = (int)id, found = 1;
cfc4f91e 120 char name[MACHINE_NAME_SIZE];
5eaef520 121 EXEC SQL END DECLARE SECTION;
122
123 EXEC SQL DECLARE csr202 CURSOR FOR
124 SELECT machine.name FROM machine, mcmap
125 WHERE machine.mach_id = mcmap.mach_id AND mcmap.clu_id = :iid;
126 EXEC SQL OPEN csr202;
127 while (1)
128 {
129 EXEC SQL FETCH csr202 INTO :name;
130 if (sqlca.sqlcode)
131 break;
132
133 strtrim(name);
134
135 found = 0;
7ac48069 136 printf("Machine %s, non-existant cluster %d in cluster map\n",
137 name, iid);
208a4f4a 138 }
5eaef520 139 EXEC SQL CLOSE csr202;
140 return found;
208a4f4a 141}
68bbc9c3 142
7ac48069 143int show_hostalias(void *id)
ab05f33a 144{
5eaef520 145 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 146 int iid = (int)id, found = 1;
cfc4f91e 147 char name[HOSTALIAS_NAME_SIZE];
5eaef520 148 EXEC SQL END DECLARE SECTION;
149
150 EXEC SQL DECLARE csr234 CURSOR FOR
151 SELECT name FROM hostalias WHERE mach_id = :iid;
152 EXEC SQL OPEN csr234;
153 while (1)
154 {
155 EXEC SQL FETCH csr234 INTO :name;
156 if (sqlca.sqlcode)
157 break;
158
159 strtrim(name);
160
161 found = 0;
7ac48069 162 printf("Alias %s, non-existant machine %d in hostalias map\n",
163 name, iid);
ab05f33a 164 }
5eaef520 165 EXEC SQL CLOSE csr234;
166 return found;
ab05f33a 167}
168
dabf20aa 169int show_printer_mach(void *id)
ab05f33a 170{
5eaef520 171 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 172 int iid = (int)id, found = 1;
dabf20aa 173 char name[PRINTERS_NAME_SIZE];
5eaef520 174 EXEC SQL END DECLARE SECTION;
175
176 EXEC SQL DECLARE csr235 CURSOR FOR
dabf20aa 177 SELECT name FROM printers WHERE mach_id = :iid;
5eaef520 178 EXEC SQL OPEN csr235;
179 while (1)
180 {
181 EXEC SQL FETCH csr235 INTO :name;
182 if (sqlca.sqlcode)
183 break;
184
185 strtrim(name);
186
187 found = 0;
dabf20aa 188 printf("Printer %s, non-existant machine %d in printers table\n",
7ac48069 189 name, iid);
ab05f33a 190 }
5eaef520 191 EXEC SQL CLOSE csr235;
192 return found;
ab05f33a 193}
194
fe0a844a 195int show_printer_server(void *id)
196{
197 EXEC SQL BEGIN DECLARE SECTION;
198 int iid = (int)id, found = 1;
199 char name[PRINTERS_NAME_SIZE];
200 EXEC SQL END DECLARE SECTION;
201
202 EXEC SQL DECLARE csr_sps CURSOR FOR
203 SELECT name FROM printers WHERE mach_id = :iid;
204 EXEC SQL OPEN csr_sps;
205 while (1)
206 {
207 EXEC SQL FETCH csr_sps INTO :name;
208 if (sqlca.sqlcode)
209 break;
210
211 strtrim(name);
212
213 found = 0;
214 printf("Printer %s, non-existant printserver %d in printers table\n",
215 name, iid);
216 }
217 EXEC SQL CLOSE csr_sps;
218 return found;
219}
220
dabf20aa 221int show_printer_loghost(void *id)
ab05f33a 222{
5eaef520 223 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 224 int iid = (int)id, found = 1;
dabf20aa 225 char name[PRINTERS_NAME_SIZE];
226 EXEC SQL END DECLARE SECTION;
227
c96b70a5 228 EXEC SQL DECLARE csr236 CURSOR FOR
dabf20aa 229 SELECT name FROM printers WHERE loghost = :iid;
c96b70a5 230 EXEC SQL OPEN csr236;
dabf20aa 231 while (1)
232 {
c96b70a5 233 EXEC SQL FETCH csr236 INTO :name;
dabf20aa 234 if (sqlca.sqlcode)
235 break;
236
237 strtrim(name);
238
239 found = 0;
240 printf("Printer %s, non-existant spool machine %d in printers table\n",
241 name, iid);
242 }
c96b70a5 243 EXEC SQL CLOSE csr236;
dabf20aa 244 return found;
245}
246
247int show_printer_spool(void *id)
248{
249 EXEC SQL BEGIN DECLARE SECTION;
250 int iid = (int)id, found = 1;
251 char name[PRINTERS_NAME_SIZE];
252 EXEC SQL END DECLARE SECTION;
253
c96b70a5 254 EXEC SQL DECLARE csr237 CURSOR FOR
dabf20aa 255 SELECT name FROM printers WHERE rm = :iid;
c96b70a5 256 EXEC SQL OPEN csr237;
dabf20aa 257 while (1)
258 {
c96b70a5 259 EXEC SQL FETCH csr237 INTO :name;
dabf20aa 260 if (sqlca.sqlcode)
261 break;
262
263 strtrim(name);
264
265 found = 0;
266 printf("Printer %s, non-existant spool machine %d in printers table\n",
267 name, iid);
268 }
c96b70a5 269 EXEC SQL CLOSE csr237;
dabf20aa 270 return found;
271}
272
273int show_printer_quota(void *id)
274{
275 EXEC SQL BEGIN DECLARE SECTION;
276 int iid = (int)id, found = 1;
277 char name[PRINTERS_NAME_SIZE];
278 EXEC SQL END DECLARE SECTION;
279
c96b70a5 280 EXEC SQL DECLARE csr238 CURSOR FOR
dabf20aa 281 SELECT name FROM printers WHERE rq = :iid;
c96b70a5 282 EXEC SQL OPEN csr238;
dabf20aa 283 while (1)
284 {
c96b70a5 285 EXEC SQL FETCH csr238 INTO :name;
dabf20aa 286 if (sqlca.sqlcode)
287 break;
288
289 strtrim(name);
290
291 found = 0;
292 printf("Printer %s, non-existant quota server %d in printers table\n",
293 name, iid);
294 }
c96b70a5 295 EXEC SQL CLOSE csr238;
dabf20aa 296 return found;
297}
298
299int show_printer_ac(void *id)
300{
301 EXEC SQL BEGIN DECLARE SECTION;
302 int iid = (int)id, found = 1;
303 char name[PRINTERS_NAME_SIZE];
5eaef520 304 EXEC SQL END DECLARE SECTION;
305
c96b70a5 306 EXEC SQL DECLARE csr239 CURSOR FOR
dabf20aa 307 SELECT name FROM printers WHERE ac = :iid;
c96b70a5 308 EXEC SQL OPEN csr239;
5eaef520 309 while (1)
310 {
c96b70a5 311 EXEC SQL FETCH csr239 INTO :name;
5eaef520 312 if (sqlca.sqlcode)
313 break;
314
315 strtrim(name);
316
317 found = 0;
dabf20aa 318 printf("Printer %s, non-existant restrict list %d in printers table\n",
7ac48069 319 name, iid);
ab05f33a 320 }
c96b70a5 321 EXEC SQL CLOSE csr239;
5eaef520 322 return found;
ab05f33a 323}
324
dabf20aa 325int show_printer_lpc_acl(void *id)
326{
327 EXEC SQL BEGIN DECLARE SECTION;
328 int iid = (int)id, found = 1;
329 char name[PRINTERS_NAME_SIZE];
330 EXEC SQL END DECLARE SECTION;
331
c96b70a5 332 EXEC SQL DECLARE csr240 CURSOR FOR
dabf20aa 333 SELECT name FROM printers WHERE lpc_acl = :iid;
c96b70a5 334 EXEC SQL OPEN csr240;
dabf20aa 335 while (1)
336 {
c96b70a5 337 EXEC SQL FETCH csr240 INTO :name;
dabf20aa 338 if (sqlca.sqlcode)
339 break;
340
341 strtrim(name);
342
343 found = 0;
344 printf("Printer %s, non-existant lpc ACL %d in printers table\n",
345 name, iid);
346 }
c96b70a5 347 EXEC SQL CLOSE csr240;
dabf20aa 348 return found;
349}
350
c96b70a5 351void fix_printer_ac(void *id)
dabf20aa 352{
353 EXEC SQL BEGIN DECLARE SECTION;
354 int rowcount, iid = (int)id;
355 EXEC SQL END DECLARE SECTION;
356
357 EXEC SQL UPDATE printers SET ac = 0 WHERE ac = :iid;
358 rowcount = sqlca.sqlerrd[2];
359 if (rowcount > 0)
360 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
361 else
362 printf("Not fixed\n");
363 modified("printers");
364}
365
c96b70a5 366void fix_printer_lpc_acl(void *id)
dabf20aa 367{
368 EXEC SQL BEGIN DECLARE SECTION;
369 int rowcount, iid = (int)id;
370 EXEC SQL END DECLARE SECTION;
371
372 EXEC SQL UPDATE printers SET lpc_acl = 0 WHERE lpc_acl = :iid;
373 rowcount = sqlca.sqlerrd[2];
374 if (rowcount > 0)
375 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
376 else
377 printf("Not fixed\n");
378 modified("printers");
379}
380
7ac48069 381void user_check(int id, void *user, void *hint)
ab05f33a 382{
7ac48069 383 struct user *u = user;
384
5eaef520 385 u->comment = maybe_fixup_unref_string(u->comment, id, u->login, "users",
386 "comments", "users_id");
387
388 u->modby = maybe_fixup_modby(u->modby, id, u->login, "users",
389 "modby", "users_id");
ab05f33a 390
5eaef520 391 u->fmodby = maybe_fixup_modby(u->fmodby, id, u->login, "users",
392 "fmodby", "users_id");
ab05f33a 393
5eaef520 394 u->pmodby = maybe_fixup_modby(u->pmodby, id, u->login, "users",
395 "pmodby", "users_id");
ab05f33a 396
5eaef520 397 u->sigwho = maybe_fixup_unref_string(u->sigwho, id, u->login, "users",
398 "sigwho", "users_id");
ab05f33a 399
7ac48069 400 pobox_check(id, u);
ab05f33a 401}
402
5eaef520 403int maybe_fixup_unref_string(int sid, int oid, char *oname, char *table,
404 char *field, char *idfield)
ab05f33a 405{
5eaef520 406 int ret = (sid < 0) ? -sid : sid, doit = 0, newid;
ab05f33a 407 EXEC SQL BEGIN DECLARE SECTION;
408 int rowcount;
409 char stmt_buf[500];
410 EXEC SQL END DECLARE SECTION;
5eaef520 411
7ac48069 412 if ((newid = (int)hash_lookup(string_dups, ret)))
5eaef520 413 {
414 printf("%s entry %s(%d) has a %s with duplicate string %d\n",
415 table, oname, oid, field, ret);
416 if (single_fix("Replace duplicate", 0))
417 {
418 ret = newid;
5eaef520 419 doit = 1;
420 }
fd3a1fc5 421 string_check(ret);
ab05f33a 422 }
5eaef520 423 else if (!string_check(ret))
424 {
425 printf("%s entry %s(%d) has a %s with non-existant string %d\n",
426 table, oname, oid, field, ret);
427 if (single_fix("Delete", 1))
428 {
429 ret = 0;
430 doit = 1;
431 }
432 }
433
434 if (doit)
435 {
436 sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE %s = %d",
437 table, field, (sid < 0) ? -ret : ret, idfield, oid);
438 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
439 rowcount = sqlca.sqlerrd[2];
440 if (rowcount == 1)
441 printf("Fixed\n");
442 else
443 printf("Not fixed, rowcount = %d\n", rowcount);
444 modified(table);
ab05f33a 445 }
ab05f33a 446
5eaef520 447 return (sid < 0) ? -ret : ret;
ab05f33a 448}
449
5eaef520 450int maybe_fixup_modby(int sid, int oid, char *oname, char *table,
451 char *field, char *idfield)
ab05f33a 452{
453 EXEC SQL BEGIN DECLARE SECTION;
454 char stmt_buf[500];
455 int rowcount;
456 EXEC SQL END DECLARE SECTION;
457
5eaef520 458 if (sid < 0)
ab05f33a 459 return maybe_fixup_unref_string(sid, oid, oname, table, field, idfield);
5eaef520 460 else
461 {
462 if (!hash_lookup(users, sid))
463 {
464 printf("%s entry %s(%d) has a %s with non-existant user %d\n",
465 table, oname, oid, field, sid);
466 if (single_fix("Delete", 1))
467 {
468 sprintf(stmt_buf, "UPDATE %s SET %s = 0 WHERE %s = %d",
469 table, field, idfield, oid);
470 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
471 rowcount = sqlca.sqlerrd[2];
472 if (rowcount == 1)
473 printf("Fixed\n");
474 else
475 printf("Not fixed, rowcount = %d\n", rowcount);
476 modified(table);
477 }
478 return 0;
479 }
ab05f33a 480 }
ab05f33a 481 return sid;
482}
483
c978c079 484int maybe_fixup_unref_string2(char *table, char *field, char *rowid, int sid)
ab05f33a 485{
5eaef520 486 int ret = (sid < 0) ? -sid : sid, doit = 0, newid;
ab05f33a 487 EXEC SQL BEGIN DECLARE SECTION;
488 int rowcount;
489 char stmt_buf[500];
490 EXEC SQL END DECLARE SECTION;
5eaef520 491
7ac48069 492 if ((newid = (int)hash_lookup(string_dups, ret)))
5eaef520 493 {
494 printf("%s entry has a %s with duplicate string %d\n",
495 table, field, ret);
496 if (single_fix("Replace duplicate", 0))
497 {
498 ret = newid;
5eaef520 499 doit = 1;
500 }
fd3a1fc5 501 string_check(ret);
5eaef520 502 }
503 else if (!string_check(ret))
504 {
505 printf("%s entry has a %s with non-existant string %d\n",
506 table, field, ret);
11975951 507 if (single_fix("Clear", 1))
5eaef520 508 {
509 ret = 0;
510 doit = 1;
511 }
ab05f33a 512 }
5eaef520 513
514 if (doit)
515 {
c978c079 516 sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE rowid = '%s'",
517 table, field, (sid < 0) ? -ret : ret, rowid);
5eaef520 518 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
519 rowcount = sqlca.sqlerrd[2];
520 if (rowcount == 1)
521 printf("Fixed\n");
522 else
523 printf("Not fixed, rowcount = %d\n", rowcount);
524 modified(table);
ab05f33a 525 }
5eaef520 526 return (sid < 0) ? -ret : ret;
ab05f33a 527}
528
c978c079 529int maybe_fixup_modby2(char *table, char *field, char *rowid, int id)
ab05f33a 530{
531 EXEC SQL BEGIN DECLARE SECTION;
532 char stmt_buf[500];
533 int rowcount;
534 EXEC SQL END DECLARE SECTION;
535
5eaef520 536 if (id < 0)
c978c079 537 return maybe_fixup_unref_string2(table, field, rowid, id);
5eaef520 538 else
539 {
540 if (!hash_lookup(users, id))
541 {
542 printf("%s entry has a %s with non-existant user %d\n",
543 table, field, id);
11975951 544 if (single_fix("Clear", 1))
5eaef520 545 {
c978c079 546 sprintf(stmt_buf, "UPDATE %s SET %s = 0 WHERE rowid = '%s'",
547 table, field, rowid);
5eaef520 548 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
549 rowcount = sqlca.sqlerrd[2];
550 if (rowcount == 1)
551 printf("Fixed\n");
552 else
553 printf("Not fixed, rowcount = %d\n", rowcount);
554 modified(table);
555 }
556 return 0;
557 }
ab05f33a 558 }
ab05f33a 559 return 1;
560}
561
7ac48069 562void pobox_check(int id, struct user *u)
68bbc9c3 563{
fc6165db 564 struct filesys *fs;
565
5eaef520 566 switch (u->potype)
567 {
568 case 'P':
569 if (!hash_lookup(machines, u->pobox_id))
570 {
571 printf("User %s(%s) has P.O.Box on non-existant machine %d\n",
572 u->login, u->fullname, u->pobox_id);
573 if (single_fix("Delete", 0))
574 {
575 remove_pobox(u->users_id);
576 u->potype = 'N';
577 }
578 }
579 break;
fc6165db 580
5eaef520 581 case 'S':
7ac48069 582 if (hash_lookup(string_dups, u->pobox_id))
5eaef520 583 {
584 printf("User %s(%s) has P.O.Box with duplicate string %d\n",
585 u->login, u->fullname, u->pobox_id);
586 if (single_fix("Update", 0))
587 {
588 printf("Replacing box_id dup string ID %d with %d\n",
589 u->pobox_id,
7ac48069 590 (int)hash_lookup(string_dups, u->pobox_id));
591 u->pobox_id = (int)hash_lookup(string_dups, u->pobox_id);
5eaef520 592 fix_smtp_pobox(u->users_id, u->pobox_id);
593 string_check(u->pobox_id);
594 }
595 }
596 else if (!string_check(u->pobox_id))
597 {
598 printf("User %s(%s) has P.O.Box with non-existant string %d\n",
599 u->login, u->fullname, u->pobox_id);
600 if (single_fix("Delete", 0))
601 {
602 remove_pobox(u->users_id);
603 u->potype = 'N';
604 }
605 }
606 break;
fc6165db 607
608 case 'I':
609 fs = hash_lookup(filesys, u->pobox_id);
610 if (!fs)
611 {
612 printf("User %s(%s) has P.O.Box on non-existant filesystem %d\n",
613 u->login, u->fullname, u->pobox_id);
614 if (single_fix("Delete", 0))
615 {
616 remove_pobox(u->users_id);
617 u->potype = 'N';
618 }
619 }
620 else if (fs->type != 'I')
621 {
622 printf("User %s(%s) has IMAP P.O.Box on non-IMAP filesystem %s\n",
623 u->login, u->fullname, fs->name);
624 if (single_fix("Delete", 0))
625 {
626 remove_pobox(u->users_id);
627 u->potype = 'N';
628 }
629 }
630 break;
631
5eaef520 632 default:
633 ;
68bbc9c3 634 }
635}
636
637
7ac48069 638void remove_pobox(int id)
208a4f4a 639{
5eaef520 640 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 641 int rowcount, iid = (int)id;
5eaef520 642 EXEC SQL END DECLARE SECTION;
643
644 EXEC SQL UPDATE users SET potype = 'NONE' WHERE users.users_id = :iid;
645 rowcount = sqlca.sqlerrd[2];
646 if (rowcount > 0)
647 printf("%d entr%s removed\n", rowcount, rowcount == 1 ? "y" : "ies");
648 else
649 printf("Not removed\n");
650 modified("users");
208a4f4a 651}
68bbc9c3 652
7ac48069 653void fix_smtp_pobox(int id, int sid)
ab05f33a 654{
5eaef520 655 EXEC SQL BEGIN DECLARE SECTION;
656 int rowcount, iid = id, isid = sid;
657 EXEC SQL END DECLARE SECTION;
658
659 EXEC SQL UPDATE users SET box_id = :isid WHERE users.users_id = :iid;
660 rowcount = sqlca.sqlerrd[2];
661 if (rowcount > 0)
662 printf("%d entr%s updated\n", rowcount, rowcount == 1 ? "y" : "ies");
663 else
664 printf("Not updated\n");
665 modified("users");
ab05f33a 666}
772b7afc 667
7ac48069 668void mach_check(int id, void *machine, void *hint)
772b7afc 669{
7ac48069 670 struct machine *m = machine;
671
5eaef520 672 if (!hash_lookup(subnets, m->snet_id))
673 {
674 printf("Machine %s is on a non-existant subnet %d\n",
675 m->name, m->snet_id);
676 if (single_fix("Move to null-subnet", 1))
677 {
678 EXEC SQL BEGIN DECLARE SECTION;
679 int rowcount, iid = id;
680 EXEC SQL END DECLARE SECTION;
681
682 EXEC SQL UPDATE machine SET snet_id = 0 WHERE mach_id = :iid;
683 rowcount = sqlca.sqlerrd[2];
684 if (rowcount > 0)
685 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
686 else
687 printf("Not fixed\n");
688 modified("machine");
772b7afc 689 }
690 }
691
5eaef520 692 switch (m->owner_type)
693 {
772b7afc 694 case 'U':
5eaef520 695 if (!hash_lookup(users, m->owner_id))
696 {
697 printf("Machine %s has non-existant USER owner %d\n",
698 m->name, m->owner_id);
699 if (single_fix("Set to no owner", 1))
700 clear_mach_owner(m);
772b7afc 701 }
5eaef520 702 break;
772b7afc 703 case 'L':
5eaef520 704 if (!hash_lookup(lists, m->owner_id))
705 {
706 printf("Machine %s has non-existant LIST owner %d\n",
707 m->name, m->owner_id);
708 if (single_fix("Set to no owner", 1))
709 clear_mach_owner(m);
772b7afc 710 }
5eaef520 711 break;
ab05f33a 712 case 'S':
713 case 'K':
5eaef520 714 if (m->owner_id)
715 m->owner_id = maybe_fixup_unref_string(m->owner_id, id, m->name,
716 "machine", "owner_id",
717 "mach_id");
718 if (m->owner_id == 0)
ab05f33a 719 clear_mach_owner(m);
772b7afc 720 }
ab05f33a 721
5eaef520 722 if (m->acomment)
723 m->acomment = maybe_fixup_unref_string(m->acomment, id, m->name,
ab05f33a 724 "machine", "acomment", "mach_id");
5eaef520 725 if (m->ocomment)
726 m->ocomment = maybe_fixup_unref_string(m->ocomment, id, m->name,
ab05f33a 727 "machine", "ocomment", "mach_id");
5eaef520 728
729 m->creator = maybe_fixup_modby(m->creator, id, m->name, "machine",
ab05f33a 730 "creator", "mach_id");
5eaef520 731 m->modby = maybe_fixup_modby(m->modby, id, m->name, "machine",
ab05f33a 732 "modby", "mach_id");
772b7afc 733}
734
7ac48069 735void subnet_check(int id, void *subnet, void *hint)
ab05f33a 736{
7ac48069 737 struct subnet *s = subnet;
738
5eaef520 739 switch (s->owner_type)
740 {
ab05f33a 741 case 'U':
5eaef520 742 if (!hash_lookup(users, s->owner_id))
743 {
744 printf("Subnet %s has non-existant USER owner %d\n",
745 s->name, s->owner_id);
746 if (single_fix("Set to no owner", 1))
747 clear_subnet_owner(s);
ab05f33a 748 }
5eaef520 749 break;
ab05f33a 750 case 'L':
5eaef520 751 if (!hash_lookup(lists, s->owner_id))
752 {
753 printf("Machine %s has non-existant LIST owner %d\n",
754 s->name, s->owner_id);
755 if (single_fix("Set to no owner", 1))
756 clear_subnet_owner(s);
ab05f33a 757 }
5eaef520 758 break;
ab05f33a 759 case 'S':
760 case 'K':
5eaef520 761 if (s->owner_id)
762 s->owner_id = maybe_fixup_unref_string(s->owner_id, id, s->name,
763 "machine", "owner_id",
764 "mach_id");
765 if (s->owner_id == 0)
ab05f33a 766 clear_subnet_owner(s);
767 }
768
5eaef520 769 s->modby = maybe_fixup_modby(s->modby, id, s->name, "subnet",
ab05f33a 770 "modby", "snet_id");
771}
772
7ac48069 773void clear_subnet_owner(struct subnet *s)
ab05f33a 774{
5eaef520 775 EXEC SQL BEGIN DECLARE SECTION;
776 int rowcount, id = s->snet_id;
777 EXEC SQL END DECLARE SECTION;
778
779 EXEC SQL UPDATE subnet SET owner_type = 'NONE', owner_id = 0
780 WHERE snet_id = :id;
781 rowcount = sqlca.sqlerrd[2];
782 if (rowcount > 0)
783 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
784 else
785 printf("Not fixed\n");
786 modified("subnet");
ab05f33a 787}
772b7afc 788
7ac48069 789void clear_mach_owner(struct machine *m)
772b7afc 790{
5eaef520 791 EXEC SQL BEGIN DECLARE SECTION;
792 int rowcount, id = m->mach_id;
793 EXEC SQL END DECLARE SECTION;
794
795 EXEC SQL UPDATE machine SET owner_type = 'NONE', owner_id = 0
796 WHERE mach_id = :id;
797 rowcount = sqlca.sqlerrd[2];
798 if (rowcount > 0)
799 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
800 else
801 printf("Not fixed\n");
802 modified("machine");
772b7afc 803}
804
7ac48069 805void cluster_check(int id, void *cluster, void *hint)
ab05f33a 806{
7ac48069 807 struct cluster *c = cluster;
808
5eaef520 809 c->modby = maybe_fixup_modby(c->modby, id, c->name, "clusters",
ab05f33a 810 "modby", "clu_id");
811}
812
7ac48069 813int show_svc(void *id)
5eaef520 814{
815 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 816 int iid = (int)id, found = 1;
cfc4f91e 817 char label[SVC_SERV_LABEL_SIZE], data[SVC_SERV_CLUSTER_SIZE];
5eaef520 818 EXEC SQL END DECLARE SECTION;
ab05f33a 819
5eaef520 820 EXEC SQL DECLARE csr203 CURSOR FOR
821 SELECT serv_label, serv_cluster FROM svc
822 WHERE clu_id = :iid;
823 EXEC SQL OPEN csr203;
824 while (1)
825 {
826 EXEC SQL FETCH csr203 INTO :label, :data;
827 if (sqlca.sqlcode)
828 break;
772b7afc 829
5eaef520 830 strtrim(label);
831 strtrim(data);
832 found = 0;
833 printf("Cluster data [%s] %s for non-existant cluster %d\n",
7ac48069 834 label, data, iid);
208a4f4a 835 }
5eaef520 836 EXEC SQL CLOSE csr203;
837 return found;
208a4f4a 838}
68bbc9c3 839
7ac48069 840void list_check(int id, void *list, void *hint)
68bbc9c3 841{
7ac48069 842 struct list *l = list;
843
cfc4f91e 844 l->modby = maybe_fixup_modby(l->modby, id, l->name, "list",
845 "modby", "list_id");
846
5eaef520 847 switch (l->acl_type)
848 {
68bbc9c3 849 case 'L':
5eaef520 850 if (!hash_lookup(lists, l->acl_id))
851 {
852 printf("List %s has bad LIST acl %d\n", l->name, l->acl_id);
853 if (single_fix("Patch", 1))
854 fix_list_acl(l->list_id);
68bbc9c3 855 }
5eaef520 856 break;
68bbc9c3 857 case 'U':
5eaef520 858 if (!hash_lookup(users, l->acl_id))
859 {
860 printf("List %s has bad USER acl %d\n", l->name, l->acl_id);
861 if (single_fix("Patch", 1))
862 fix_list_acl(l->list_id);
68bbc9c3 863 }
5eaef520 864 break;
ab05f33a 865 case 'K':
5eaef520 866 l->acl_id = maybe_fixup_unref_string(l->acl_id, id, l->name,
867 "list", "acl_id", "list_id");
868 if (!l->acl_id)
869 {
870 printf("List %s has bad KERBEROS acl %d\n", l->name, l->acl_id);
871 if (single_fix("Patch", 1))
872 fix_list_acl(l->list_id);
ab05f33a 873 }
5eaef520 874 break;
68bbc9c3 875 }
ad47bcbe 876
877 switch (l->memacl_type)
878 {
879 case 'L':
880 if (!hash_lookup(lists, l->memacl_id))
881 {
882 printf("List %s has bad LIST memacl %d\n", l->name, l->memacl_id);
883 if (single_fix("Patch", 1))
884 fix_list_memacl(l->list_id);
885 }
886 break;
887 case 'U':
888 if (!hash_lookup(users, l->memacl_id))
889 {
890 printf("List %s has bad USER acl %d\n", l->name, l->memacl_id);
891 if (single_fix("Patch", 1))
892 fix_list_memacl(l->list_id);
893 }
894 break;
895 case 'K':
896 l->memacl_id = maybe_fixup_unref_string(l->memacl_id, id, l->name,
897 "list", "memacl_id", "list_id");
898 if (!l->memacl_id)
899 {
900 printf("List %s has bad KERBEROS acl %d\n", l->name,
901 l->memacl_id);
902 if (single_fix("Patch", 1))
903 fix_list_memacl(l->list_id);
904 }
905 break;
906 }
68bbc9c3 907}
908
7ac48069 909void fix_list_acl(int id)
208a4f4a 910{
5eaef520 911 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 912 int rowcount, iid = (int)id;
5eaef520 913 EXEC SQL END DECLARE SECTION;
68bbc9c3 914
5eaef520 915 EXEC SQL UPDATE list SET acl_id = :iid, acl_type = 'LIST'
916 WHERE list_id = :iid;
917 rowcount = sqlca.sqlerrd[2];
ad47bcbe 918 if (rowcount > 0)
919 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
920 else
921 printf("Not fixed\n");
922 modified("list");
923}
924
925void fix_list_memacl(int id)
926{
927 EXEC SQL BEGIN DECLARE SECTION;
928 int rowcount, iid = (int)id;
929 EXEC SQL END DECLARE SECTION;
930
931 EXEC SQL UPDATE list SET memacl_id = 0, memacl_type = 'NONE'
932 WHERE list_id = :iid;
933 rowcount = sqlca.sqlerrd[2];
5eaef520 934 if (rowcount > 0)
935 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
936 else
937 printf("Not fixed\n");
938 modified("list");
939}
68bbc9c3 940
7ac48069 941int show_member_list(void *id)
208a4f4a 942{
5eaef520 943 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 944 int mid, iid = (int)id, found = 1;
8d1c466f 945 char mtype[IMEMBERS_MEMBER_TYPE_SIZE], *name = NULL;
5eaef520 946 EXEC SQL END DECLARE SECTION;
947
948 EXEC SQL DECLARE csr204 CURSOR FOR
949 SELECT member_type, member_id FROM imembers
8d1c466f 950 WHERE list_id = :iid;
5eaef520 951 EXEC SQL OPEN csr204;
952 while (1)
953 {
954 EXEC SQL FETCH csr204 INTO :mtype, :mid;
955 if (sqlca.sqlcode)
956 break;
957
958 strtrim(mtype);
959 found = 0;
960 if (mtype[0] == 'L')
8d1c466f 961 {
962 struct list *l = hash_lookup(lists, mid);
963 if (l)
964 name = l->name;
965 }
5eaef520 966 else if (mtype[0] == 'U')
8d1c466f 967 {
968 struct user *u = hash_lookup(users, mid);
969 if (u)
970 name = u->login;
971 }
5eaef520 972 else if (mtype[0] == 'S' || mtype[0] == 'K')
8d1c466f 973 {
974 struct string *s = hash_lookup(strings, mid);
975 if (s)
976 name = s->name;
977 }
978 if (name)
979 printf("Non-existant list %d has member %s %s\n", iid, mtype, name);
980 else
981 {
982 printf("Non-existant list %d has non-existent member %s %d\n",
983 iid, mtype, mid);
984 }
208a4f4a 985 }
5eaef520 986 EXEC SQL CLOSE csr204;
987 return found;
208a4f4a 988}
68bbc9c3 989
7ac48069 990int show_mem_user(void *id)
208a4f4a 991{
5eaef520 992 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 993 int lid, iid = (int)id, found = 1;
5eaef520 994 EXEC SQL END DECLARE SECTION;
8d1c466f 995 struct list *l;
5eaef520 996
997 EXEC SQL DECLARE csr205 CURSOR FOR
998 SELECT list_id FROM imembers
8d1c466f 999 WHERE member_id = :iid AND member_type = 'USER';
5eaef520 1000 EXEC SQL OPEN csr205;
1001 while (1)
1002 {
1003 EXEC SQL FETCH csr205 INTO :lid;
1004 if (sqlca.sqlcode)
1005 break;
8d1c466f 1006 l = hash_lookup(lists, lid);
1007 if (!l)
1008 continue;
5eaef520 1009
1010 found = 0;
8d1c466f 1011 printf("List %s has non-existant user member, id %d\n", l->name, iid);
208a4f4a 1012 }
5eaef520 1013 EXEC SQL CLOSE csr205;
1014 return found;
208a4f4a 1015}
68bbc9c3 1016
7ac48069 1017int show_mem_list(void *id)
208a4f4a 1018{
5eaef520 1019 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1020 int lid, iid = (int)id, found = 1;
5eaef520 1021 EXEC SQL END DECLARE SECTION;
8d1c466f 1022 struct list *l;
5eaef520 1023
1024 EXEC SQL DECLARE csr206 CURSOR FOR
1025 SELECT list_id FROM imembers
8d1c466f 1026 WHERE member_id = :iid AND member_type = 'LIST';
5eaef520 1027 EXEC SQL OPEN csr206;
1028 while (1)
1029 {
1030 EXEC SQL FETCH csr206 INTO :lid;
1031 if (sqlca.sqlcode)
1032 break;
8d1c466f 1033 l = hash_lookup(lists, lid);
1034 if (!l)
1035 continue;
5eaef520 1036
1037 found = 0;
8d1c466f 1038 printf("List %s has non-existant list member, id %d\n", l->name, iid);
208a4f4a 1039 }
5eaef520 1040 EXEC SQL CLOSE csr206;
1041 return found;
208a4f4a 1042}
68bbc9c3 1043
7ac48069 1044int show_mem_str(void *id)
208a4f4a 1045{
5eaef520 1046 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1047 int lid, iid = (int)id, found = 1;
5eaef520 1048 EXEC SQL END DECLARE SECTION;
8d1c466f 1049 struct list *l;
5eaef520 1050
1051 EXEC SQL DECLARE csr207 CURSOR FOR
1052 SELECT list_id FROM imembers
8d1c466f 1053 WHERE member_id = :iid AND member_type = 'STRING';
5eaef520 1054 EXEC SQL OPEN csr207;
1055 while (1)
1056 {
1057 EXEC SQL FETCH csr207 INTO :lid;
1058 if (sqlca.sqlcode)
1059 break;
8d1c466f 1060 l = hash_lookup(lists, lid);
1061 if (!l)
1062 continue;
5eaef520 1063
1064 found = 0;
8d1c466f 1065 printf("List %s has non-existant string member, id %d\n", l->name, iid);
208a4f4a 1066 }
5eaef520 1067 EXEC SQL CLOSE csr207;
1068 return found;
208a4f4a 1069}
68bbc9c3 1070
1071
7ac48069 1072int show_mem_krb(void *id)
208a4f4a 1073{
5eaef520 1074 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1075 int lid, iid = (int)id, found = 1;
5eaef520 1076 EXEC SQL END DECLARE SECTION;
8d1c466f 1077 struct list *l;
5eaef520 1078
1079 EXEC SQL DECLARE csr208 CURSOR FOR
1080 SELECT list_id FROM imembers
8d1c466f 1081 WHERE member_id = :iid AND member_type = 'KERBEROS';
5eaef520 1082 EXEC SQL OPEN csr208;
1083 while (1)
1084 {
1085 EXEC SQL FETCH csr208 INTO :lid;
1086 if (sqlca.sqlcode)
1087 break;
8d1c466f 1088 l = hash_lookup(lists, lid);
1089 if (!l)
1090 continue;
5eaef520 1091
1092 found = 0;
1093 printf("List %s has non-existant kerberos member, id %d\n",
8d1c466f 1094 l->name, iid);
208a4f4a 1095 }
5eaef520 1096 EXEC SQL CLOSE csr208;
1097 return found;
208a4f4a 1098}
68bbc9c3 1099
5f7b0741 1100int show_mem_mach(void *id)
1101{
1102 EXEC SQL BEGIN DECLARE SECTION;
1103 int lid, iid = (int)id, found = 1;
1104 EXEC SQL END DECLARE SECTION;
1105 struct list *l;
1106
1107 EXEC SQL DECLARE csr208a CURSOR FOR
1108 SELECT list_id FROM imembers
1109 WHERE member_id = :iid AND member_type = 'MACHINE';
1110 EXEC SQL OPEN csr208a;
1111 while (1)
1112 {
1113 EXEC SQL FETCH csr208a INTO :lid;
1114 if (sqlca.sqlcode)
1115 break;
1116 l = hash_lookup(lists, lid);
1117 if (!l)
1118 continue;
1119
1120 found = 0;
1121 printf("List %s has nonexistant machine member, id %d\n",
1122 l->name, iid);
1123 }
1124 EXEC SQL CLOSE csr208a;
1125 return found;
1126}
68bbc9c3 1127
7ac48069 1128void del_mem_user(void *id)
208a4f4a 1129{
5eaef520 1130 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1131 int iid = (int)id, rowcount;
5eaef520 1132 EXEC SQL END DECLARE SECTION;
1133
1134 EXEC SQL DELETE FROM imembers WHERE member_type = 'USER' AND
8d1c466f 1135 member_id = :iid;
5eaef520 1136 rowcount = sqlca.sqlerrd[2];
1137 if (rowcount > 0)
1138 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1139 else
1140 printf("Not deleted\n");
1141 modified("imembers");
208a4f4a 1142}
68bbc9c3 1143
7ac48069 1144void del_mem_list(void *id)
208a4f4a 1145{
5eaef520 1146 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1147 int iid = (int)id, rowcount;
5eaef520 1148 EXEC SQL END DECLARE SECTION;
1149
1150 EXEC SQL DELETE FROM imembers WHERE member_type = 'LIST' AND
8d1c466f 1151 member_id = :iid;
5eaef520 1152 rowcount = sqlca.sqlerrd[2];
1153 if (rowcount > 0)
1154 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1155 else
1156 printf("Not deleted\n");
1157 modified("imembers");
208a4f4a 1158}
68bbc9c3 1159
7ac48069 1160void del_mem_str(void *id)
208a4f4a 1161{
5eaef520 1162 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1163 int iid = (int)id, rowcount;
5eaef520 1164 EXEC SQL END DECLARE SECTION;
1165
1166 EXEC SQL DELETE FROM imembers WHERE member_type = 'STRING' AND
8d1c466f 1167 member_id = :iid;
5eaef520 1168 rowcount = sqlca.sqlerrd[2];
1169 if (rowcount > 0)
1170 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1171 else
1172 printf("Not deleted\n");
1173 modified("imembers");
208a4f4a 1174}
68bbc9c3 1175
68bbc9c3 1176
7ac48069 1177void del_mem_krb(void *id)
208a4f4a 1178{
5eaef520 1179 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1180 int iid = (int)id, rowcount;
5eaef520 1181 EXEC SQL END DECLARE SECTION;
1182
1183 EXEC SQL DELETE FROM imembers WHERE member_type = 'KERBEROS' AND
8d1c466f 1184 member_id = :iid;
5eaef520 1185 rowcount = sqlca.sqlerrd[2];
1186 if (rowcount > 0)
1187 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1188 else
1189 printf("Not deleted\n");
1190 modified("imembers");
208a4f4a 1191}
68bbc9c3 1192
5f7b0741 1193void del_mem_mach(void *id)
1194{
1195 EXEC SQL BEGIN DECLARE SECTION;
1196 int iid = (int)id, rowcount;
1197 EXEC SQL END DECLARE SECTION;
1198
1199 EXEC SQL DELETE FROM imembers WHERE member_type = 'MACHINE' AND
1200 member_id = :iid;
1201 rowcount = sqlca.sqlerrd[2];
1202 if (rowcount > 0)
1203 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1204 else
1205 printf("Not deleted\n");
1206 modified("imembers");
1207}
68bbc9c3 1208
7ac48069 1209int show_sh(void *id)
208a4f4a 1210{
5eaef520 1211 EXEC SQL BEGIN DECLARE SECTION;
cfc4f91e 1212 char name[SERVERHOSTS_SERVICE_SIZE];
7ac48069 1213 int iid = (int)id;
5eaef520 1214 EXEC SQL END DECLARE SECTION;
1215 int found = 1;
1216
1217 EXEC SQL DECLARE csr209 CURSOR FOR
1218 SELECT service FROM serverhosts
1219 WHERE mach_id = :iid;
1220 EXEC SQL OPEN csr209;
1221 while (1)
1222 {
1223 EXEC SQL FETCH csr209 INTO :name;
1224 if (sqlca.sqlcode)
1225 break;
1226
1227 found = 0;
1228 printf("ServerHost entry for service %s non-existant host %d\n",
7ac48069 1229 name, iid);
208a4f4a 1230 }
5eaef520 1231 EXEC SQL CLOSE csr209;
1232 return found;
208a4f4a 1233}
68bbc9c3 1234
7ac48069 1235void del_sh_mach(void *id)
208a4f4a 1236{
5eaef520 1237 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1238 int iid = (int)id, rowcount;
5eaef520 1239 EXEC SQL END DECLARE SECTION;
1240
1241 EXEC SQL DELETE FROM serverhosts WHERE mach_id = :iid;
1242 rowcount = sqlca.sqlerrd[2];
1243 if (rowcount > 0)
1244 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1245 else
1246 printf("Not deleted\n");
1247 modified("serverhosts");
208a4f4a 1248}
68bbc9c3 1249
1250
1251static int fnchecklen;
1252
7ac48069 1253void fsmatch(int id, void *nfsphys, void *filesys)
68bbc9c3 1254{
7ac48069 1255 struct nfsphys *n = nfsphys;
1256 struct filesys *f = filesys;
1257
5eaef520 1258 if (n->mach_id == f->mach_id &&
1259 !strncmp(f->dir, n->dir, strlen(n->dir)) &&
1260 strlen(n->dir) > fnchecklen)
1261 {
1262 f->phys_id = id;
1263 fnchecklen = strlen(n->dir);
68bbc9c3 1264 }
1265}
1266
1267
7ac48069 1268void check_fs(int id, void *filesys, void *hint)
208a4f4a 1269{
5eaef520 1270 EXEC SQL BEGIN DECLARE SECTION;
1271 int iid = id, id1, id2, id3, rowcount;
1272 char *dir;
1273 EXEC SQL END DECLARE SECTION;
7ac48069 1274 struct filesys *f = filesys;
5eaef520 1275 struct nfsphys *n;
1276 struct machine *m;
1277
1278 if (!hash_lookup(machines, f->mach_id))
1279 {
1280 printf("Filesys %s with bad machine %d\n", f->name, f->mach_id);
1281 if (single_fix("Fix", 0))
1282 {
1283 EXEC SQL UPDATE filesys SET mach_id = 0 WHERE filsys_id = :iid;
1284 rowcount = sqlca.sqlerrd[2];
1285 if (rowcount > 0)
1286 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1287 else
1288 printf("Not fixed\n");
1289 modified("filesys");
1290 f->mach_id = 0;
68bbc9c3 1291 }
1292 }
1293
5eaef520 1294 if (!hash_lookup(users, f->owner))
1295 {
1296 printf("Filesys %s with bad owning user %d\n", f->name, f->owner);
1297 if (single_fix("Fix", 1))
1298 {
1299 zero_fix("filesys", "owner", "filsys_id", f->filsys_id);
1300 f->owner = 0;
68bbc9c3 1301 }
1302 }
5eaef520 1303 if (!hash_lookup(lists, f->owners))
1304 {
1305 printf("Filesys %s with bad owning group %d\n", f->name, f->owners);
1306 if (single_fix("Fix", 1))
1307 {
1308 zero_fix("filesys", "owners", "filsys_id", f->filsys_id);
1309 f->owners = 0;
68bbc9c3 1310 }
1311 }
1312
fc6165db 1313 if (f->type == 'N' || f->type == 'I')
5eaef520 1314 {
1315 if (!hash_lookup(nfsphys, f->phys_id))
1316 {
7ac48069 1317 m = hash_lookup(machines, f->mach_id);
5eaef520 1318 printf("Filesys %s with bad phys_id %d\n", f->name, f->phys_id);
1319 if (single_fix("Fix", 1))
1320 {
1321 fnchecklen = 0;
1322 hash_step(nfsphys, fsmatch, f);
1323 if (fnchecklen != 0)
1324 {
68bbc9c3 1325 id1 = f->phys_id;
1326 id2 = f->filsys_id;
1327 id3 = f->mach_id;
5eaef520 1328 EXEC SQL UPDATE filesys SET phys_id = :id1
1329 WHERE filsys_id = :id2;
4b9e5c72 1330 rowcount = sqlca.sqlerrd[2];
68bbc9c3 1331 if (rowcount > 0)
5eaef520 1332 printf("%d entr%s fixed\n", rowcount,
1333 rowcount == 1 ? "y" : "ies");
68bbc9c3 1334 else
1335 printf("Not fixed\n");
1336 modified("filesys");
5eaef520 1337 }
1338 else
1339 {
1340 printf("No NFSphys exsits for %s:%s\n", m->name, f->dir);
1341 if (single_fix("Create", 0))
1342 {
1343 dir = f->dir;
1344 id1 = f->phys_id;
1345 id2 = f->filsys_id;
1346 id3 = f->mach_id;
1347 if (set_next_object_id("nfsphys_id", "nfsphys") !=
1348 MR_SUCCESS)
1349 {
1350 printf("Unable to assign unique ID\n");
1351 return;
68bbc9c3 1352 }
5eaef520 1353 EXEC SQL SELECT COUNT(*) INTO :rowcount FROM numvalues
1354 WHERE name = 'nfsphys_id';
1355 if (rowcount != 1)
1356 {
1357 printf("Unable to retrieve unique ID\n");
1358 return;
68bbc9c3 1359 }
5eaef520 1360 EXEC SQL INSERT INTO nfsphys
1361 (nfsphys_id, mach_id, device, dir, status, allocated,
1362 size, modtime, modby, modwith) VALUES
1363 (:id1, :id3, '\?\?\?', :dir, 0, 0, 0, SYSDATE, 0,
1364 'dbck');
4b9e5c72 1365 rowcount = sqlca.sqlerrd[2];
68bbc9c3 1366 if (rowcount > 0)
5eaef520 1367 {
1368 printf("%d entr%s created\n", rowcount,
1369 rowcount == 1 ? "y" : "ies");
1370 }
68bbc9c3 1371 else
1372 printf("Not created\n");
1373 modified("nfsphys");
5eaef520 1374 n = malloc(sizeof(struct nfsphys));
1375 if (!n)
68bbc9c3 1376 out_of_mem("storing new nfsphys");
1377 strcpy(n->dir, dir);
1378 n->mach_id = id3;
1379 n->nfsphys_id = id1;
1380 n->allocated = 0;
1381 n->count = 0;
5eaef520 1382 if (hash_store(nfsphys, id1, n) == -1)
ab05f33a 1383 out_of_mem("storing nfsphys in hash table");
208a4f4a 1384 EXEC SQL UPDATE filesys SET phys_id = :id1
5eaef520 1385 WHERE filsys_id = :id2;
4b9e5c72 1386 rowcount = sqlca.sqlerrd[2];
68bbc9c3 1387 if (rowcount > 0)
5eaef520 1388 {
1389 printf("%d filesys entr%s fixed\n", rowcount,
1390 rowcount == 1 ? "y" : "ies");
1391 }
68bbc9c3 1392 else
1393 printf("Not fixed\n");
1394 modified("filesys");
1395 }
1396 }
1397 }
1398 }
1399 }
208a4f4a 1400}
68bbc9c3 1401
7ac48069 1402void check_nfsphys(int id, void *nfsphys, void *hint)
68bbc9c3 1403{
7ac48069 1404 struct nfsphys *n = nfsphys;
1405
cfc4f91e 1406 n->modby = maybe_fixup_modby(n->modby, id, n->dir, "nfsphys",
1407 "modby", "nfsphys_id");
1408
5eaef520 1409 if (!hash_lookup(machines, n->mach_id))
1410 {
1411 printf("NFSphys %d(%s) on non-existant machine %d\n",
1412 id, n->dir, n->mach_id);
1413 if (single_fix("Delete", 0))
1414 single_delete("nfsphys", "nfsphys_id", id);
68bbc9c3 1415 }
1416}
1417
fe0a844a 1418static void clear_ps_owner(struct printserver *ps)
1419{
1420 EXEC SQL BEGIN DECLARE SECTION;
1421 int rowcount, id = ps->mach_id;
1422 EXEC SQL END DECLARE SECTION;
1423
1424 EXEC SQL UPDATE printserver SET owner_type = 'NONE', owner_id = 0
1425 WHERE mach_id = :id;
1426 rowcount = sqlca.sqlerrd[2];
1427 if (rowcount > 0)
1428 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1429 else
1430 printf("Not fixed\n");
1431 modified("printservers");
1432}
1433
1434static void clear_ps_lpc(struct printserver *ps)
1435{
1436 EXEC SQL BEGIN DECLARE SECTION;
1437 int rowcount, id = ps->mach_id;
1438 EXEC SQL END DECLARE SECTION;
1439
1440 EXEC SQL UPDATE printserver SET lpc_acl = 0
1441 WHERE mach_id = :id;
1442 rowcount = sqlca.sqlerrd[2];
1443 if (rowcount > 0)
1444 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1445 else
1446 printf("Not fixed\n");
1447 modified("printservers");
1448}
1449
1450void check_ps(int id, void *printserver, void *hint)
1451{
1452 struct printserver *ps = printserver;
1453 struct machine *m;
1454 char *name;
1455
1456 m = hash_lookup(machines, id);
1457 if (!m)
1458 {
1459 printf("Printserver on non-existant machine %d\n", id);
1460 if (single_fix("Delete", 0))
1461 {
61eec0b8 1462 single_delete("printservers", "mach_id", id);
fe0a844a 1463 return;
1464 }
1465 else
1466 name = "[UNKNOWN]";
1467 }
1468 else
1469 name = m->name;
1470
61eec0b8 1471 ps->modby = maybe_fixup_modby(ps->modby, id, name, "printservers",
fe0a844a 1472 "modby", "mach_id");
1473 ps->printer_types = maybe_fixup_unref_string(ps->printer_types, id, name,
1474 "printservers", "printer_types",
1475 "mach_id");
1476
1477 switch (ps->owner_type)
1478 {
1479 case 'U':
1480 if (!hash_lookup(users, ps->owner_id))
1481 {
1482 printf("Printserver %s has non-existant USER owner %d\n",
1483 name, ps->owner_id);
1484 if (single_fix("Set to no owner", 1))
1485 clear_ps_owner(ps);
1486 }
1487 break;
1488 case 'L':
1489 if (!hash_lookup(lists, ps->owner_id))
1490 {
1491 printf("Printserver %s has non-existant LIST owner %d\n",
1492 name, ps->owner_id);
1493 if (single_fix("Set to no owner", 1))
1494 clear_ps_owner(ps);
1495 }
1496 break;
1497 case 'K':
1498 if (ps->owner_id)
1499 ps->owner_id = maybe_fixup_unref_string(ps->owner_id, id, name,
1500 "printserver", "owner_id",
1501 "mach_id");
1502 if (ps->owner_id == 0)
1503 clear_ps_owner(ps);
1504 }
1505
1506 if (!hash_lookup(lists, ps->lpc_acl))
1507 {
1508 printf("Printserver %s has non-existent lpc_acl %d\n",
1509 name, ps->lpc_acl);
1510 if (single_fix("Set to no lpc_acl", 1))
1511 clear_ps_lpc(ps);
1512 }
1513}
1514
7ac48069 1515int show_fsg_missing(void *id)
208a4f4a 1516{
5eaef520 1517 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1518 int iid = (int)id, id1, found = 1;
5eaef520 1519 EXEC SQL END DECLARE SECTION;
1520 struct filesys *f;
1521
1522 EXEC SQL DECLARE csr210 CURSOR FOR
1523 SELECT filsys_id FROM fsgroup
1524 WHERE group_id = :iid;
1525 EXEC SQL OPEN csr210;
1526 while (1)
1527 {
1528 EXEC SQL FETCH csr210 INTO :id1;
1529 if (sqlca.sqlcode)
1530 break;
1531
1532 found = 0;
7ac48069 1533 if ((f = hash_lookup(filesys, id1)))
1534 printf("Missing fsgroup %d has member filesystem %s\n", iid, f->name);
5eaef520 1535 else
7ac48069 1536 printf("Missing fsgroup %d has member filesystem %d\n", iid, id1);
208a4f4a 1537 }
5eaef520 1538 EXEC SQL CLOSE csr210;
1539 return found;
208a4f4a 1540}
68bbc9c3 1541
7ac48069 1542int show_fsg_type(void *filesys)
68bbc9c3 1543{
7ac48069 1544 struct filesys *f = filesys;
5eaef520 1545 char *t;
68bbc9c3 1546
5eaef520 1547 switch (f->type)
1548 {
68bbc9c3 1549 case 'N':
5eaef520 1550 t = "NFS";
1551 break;
68bbc9c3 1552 case 'R':
5eaef520 1553 t = "RVD";
1554 break;
68bbc9c3 1555 case 'A':
5eaef520 1556 t = "AFS";
1557 break;
68bbc9c3 1558 case 'E':
5eaef520 1559 t = "ERR";
1560 break;
68bbc9c3 1561 case 'F':
5eaef520 1562 t = "FSGROUP";
1563 break;
68bbc9c3 1564 case 'M':
5eaef520 1565 t = "MUL";
1566 break;
68bbc9c3 1567 default:
5eaef520 1568 t = "\?\?\?";
68bbc9c3 1569 }
5eaef520 1570 printf("FSGroup %s has type %s instead of FSGROUP\n", f->name, t);
1571 return 0;
68bbc9c3 1572}
1573
7ac48069 1574void fix_fsg_type(void *filesys)
208a4f4a 1575{
7ac48069 1576 struct filesys *f = filesys;
5eaef520 1577 EXEC SQL BEGIN DECLARE SECTION;
1578 int rowcount, id = f->filsys_id;
1579 EXEC SQL END DECLARE SECTION;
1580
1581 EXEC SQL UPDATE filesys SET type = 'FSGROUP' WHERE filsys_id = :id;
1582 rowcount = sqlca.sqlerrd[2];
1583 if (rowcount > 0)
1584 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1585 else
1586 printf("Not fixed\n");
1587 modified("filesys");
208a4f4a 1588}
68bbc9c3 1589
7ac48069 1590int show_fsg_nomember(void *id)
208a4f4a 1591{
5eaef520 1592 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1593 int iid = (int)id, id1, found = 1;
5eaef520 1594 EXEC SQL END DECLARE SECTION;
1595 struct filesys *f;
1596
1597 EXEC SQL DECLARE csr211 CURSOR FOR
1598 SELECT group_id FROM fsgroup
1599 WHERE filsys_id = :iid;
1600 EXEC SQL OPEN csr211;
1601 while (1)
1602 {
1603 EXEC SQL FETCH csr211 INTO :id1;
1604 if (sqlca.sqlcode)
1605 break;
1606
1607 found = 0;
7ac48069 1608 if ((f = hash_lookup(filesys, id1)))
1609 printf("FSGroup %s has missing member %d\n", f->name, iid);
5eaef520 1610 else
7ac48069 1611 printf("FSGroup %d has missing member %d\n", id1, iid);
208a4f4a 1612 }
5eaef520 1613 EXEC SQL CLOSE csr211;
1614 return found;
208a4f4a 1615}
1616
7ac48069 1617int show_quota_nouser(void *id)
208a4f4a 1618{
5eaef520 1619 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1620 int iid = (int)id, id1, found = 1;
5eaef520 1621 EXEC SQL END DECLARE SECTION;
1622
1623 EXEC SQL DECLARE csr212 CURSOR FOR
1624 SELECT filsys_id FROM quota
1625 WHERE entity_id = :iid AND type = 'USER';
1626 EXEC SQL OPEN csr212;
1627 while (1)
1628 {
1629 EXEC SQL FETCH csr212 INTO :id1;
1630 if (sqlca.sqlcode)
1631 break;
1632
1633 found = 0;
7ac48069 1634 printf("Quota on fs %d for non-existant user %d\n", id1, iid);
208a4f4a 1635 }
5eaef520 1636 EXEC SQL CLOSE csr212;
1637 return found;
208a4f4a 1638}
1639
7ac48069 1640int show_quota_nolist(void *id)
208a4f4a 1641{
5eaef520 1642 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1643 int iid = (int)id, id1, found = 1;
5eaef520 1644 EXEC SQL END DECLARE SECTION;
1645
1646 EXEC SQL DECLARE csr213 CURSOR FOR
1647 SELECT filsys_id FROM quota
1648 WHERE entity_id = :iid AND type = 'GROUP';
1649 EXEC SQL OPEN csr213;
1650 while (1)
1651 {
1652 EXEC SQL FETCH csr213 INTO :id1;
1653 if (sqlca.sqlcode)
1654 break;
1655
1656 found = 0;
7ac48069 1657 printf("Quota on fs %d for non-existant list %d\n", id1, iid);
208a4f4a 1658 }
5eaef520 1659 EXEC SQL CLOSE csr213;
1660 return found;
208a4f4a 1661}
68bbc9c3 1662
7ac48069 1663void fix_quota_nouser(void *id)
208a4f4a 1664{
5eaef520 1665 EXEC SQL BEGIN DECLARE SECTION;
11975951 1666 int iid = (int)id, rowcount;
5eaef520 1667 EXEC SQL END DECLARE SECTION;
1668
5eaef520 1669 EXEC SQL DELETE FROM quota
1670 WHERE entity_id = :iid AND type = 'USER';
1671 rowcount = sqlca.sqlerrd[2];
1672 if (rowcount > 0)
1673 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1674 else
1675 printf("Not deleted\n");
1676 modified("quota");
208a4f4a 1677}
68bbc9c3 1678
7ac48069 1679void fix_quota_nolist(void *id)
208a4f4a 1680{
5eaef520 1681 EXEC SQL BEGIN DECLARE SECTION;
11975951 1682 int iid = (int)id, rowcount;
5eaef520 1683 EXEC SQL END DECLARE SECTION;
1684
5eaef520 1685 EXEC SQL DELETE FROM quota WHERE entity_id = :iid AND type = 'GROUP';
1686 rowcount = sqlca.sqlerrd[2];
1687 if (rowcount > 0)
1688 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1689 else
1690 printf("Not deleted\n");
1691 modified("quota");
208a4f4a 1692}
1693
7ac48069 1694int show_quota_nofs(void *id)
208a4f4a 1695{
5eaef520 1696 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1697 int iid = (int)id, id1, found = 1;
cfc4f91e 1698 char type[QUOTA_TYPE_SIZE];
5eaef520 1699 EXEC SQL END DECLARE SECTION;
1700
1701 EXEC SQL DECLARE csr214 CURSOR FOR
1702 SELECT entity_id, type FROM quota
1703 WHERE filsys_id = :iid;
1704 EXEC SQL OPEN csr214;
1705 while (1)
1706 {
1707 EXEC SQL FETCH csr214 INTO :id1, :type;
1708 if (sqlca.sqlcode)
1709 break;
1710
1711 found = 0;
7ac48069 1712 printf("Quota for %s %d on non-existant filesys %d\n", type, id1, iid);
208a4f4a 1713 }
5eaef520 1714 EXEC SQL CLOSE csr214;
1715 return found;
208a4f4a 1716}
68bbc9c3 1717
7ac48069 1718void fix_quota_nofs(void *id)
68bbc9c3 1719{
7ac48069 1720 single_delete("quota", "filsys_id", (int)id);
68bbc9c3 1721}
1722
7ac48069 1723int show_quota_wrongpid(void *id)
208a4f4a 1724{
5eaef520 1725 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1726 int iid = (int)id, id1, found = 1;
cfc4f91e 1727 char type[QUOTA_TYPE_SIZE];
5eaef520 1728 EXEC SQL END DECLARE SECTION;
5eaef520 1729 struct filesys *f;
1730
7ac48069 1731 f = hash_lookup(filesys, iid);
5eaef520 1732 EXEC SQL DECLARE csr215 CURSOR FOR
1733 SELECT entity_id, type FROM quota
1734 WHERE filsys_id = :iid;
1735 EXEC SQL OPEN csr215;
1736 while (1)
1737 {
1738 EXEC SQL FETCH csr215 INTO :id1, :type;
1739 if (sqlca.sqlcode)
1740 break;
1741
1742 found = 0;
1743 printf("Quota for %s %d on filesys %s has wrong phys_id %d\n",
7ac48069 1744 type, id1, f->name, iid);
208a4f4a 1745 }
5eaef520 1746 EXEC SQL CLOSE csr215;
1747 return found;
208a4f4a 1748}
68bbc9c3 1749
7ac48069 1750void fix_quota_physid(void *id)
208a4f4a 1751{
5eaef520 1752 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1753 int iid = (int)id, rowcount, id1;
5eaef520 1754 EXEC SQL END DECLARE SECTION;
1755
7ac48069 1756 id1 = ((struct filesys *)hash_lookup(filesys, iid))->phys_id;
5eaef520 1757 EXEC SQL UPDATE quota SET phys_id = :id1
1758 WHERE filsys_id = :iid AND phys_id != :id1;
1759 rowcount = sqlca.sqlerrd[2];
1760 if (rowcount > 0)
1761 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1762 else
1763 printf("Not fixed\n");
1764 modified("quota");
208a4f4a 1765}
68bbc9c3 1766
7ac48069 1767int show_srv_user(void *id)
208a4f4a 1768{
5eaef520 1769 EXEC SQL BEGIN DECLARE SECTION;
cfc4f91e 1770 char name[SERVERS_NAME_SIZE];
7ac48069 1771 int iid = (int)id;
5eaef520 1772 EXEC SQL END DECLARE SECTION;
1773 int found = 1;
1774
1775 EXEC SQL DECLARE csr216 CURSOR FOR
1776 SELECT name FROM servers
1777 WHERE acl_type = 'USER' and acl_id = :iid;
1778 EXEC SQL OPEN csr216;
1779 while (1)
1780 {
1781 EXEC SQL FETCH csr216 INTO :name;
1782 if (sqlca.sqlcode)
1783 break;
1784
1785 strtrim(name);
7ac48069 1786 printf("Service %s has acl non-existant user %d\n", name, iid);
5eaef520 1787 found = 0;
208a4f4a 1788 }
5eaef520 1789 EXEC SQL CLOSE csr216;
1790 return found;
208a4f4a 1791}
68bbc9c3 1792
7ac48069 1793int show_srv_list(void *id)
208a4f4a 1794{
5eaef520 1795 EXEC SQL BEGIN DECLARE SECTION;
cfc4f91e 1796 char name[SERVERS_NAME_SIZE];
7ac48069 1797 int iid = (int)id;
5eaef520 1798 EXEC SQL END DECLARE SECTION;
1799 int found = 1;
1800
1801 EXEC SQL DECLARE csr217 CURSOR FOR
1802 SELECT name FROM servers
1803 WHERE acl_type = 'LIST' AND acl_id = :iid;
1804 EXEC SQL OPEN csr217;
1805 while (1)
1806 {
1807 EXEC SQL FETCH csr217 INTO :name;
1808 if (sqlca.sqlcode)
1809 break;
1810
1811 strtrim(name);
7ac48069 1812 printf("Service %s has acl non-existant list %d\n", name, iid);
5eaef520 1813 found = 0;
208a4f4a 1814 }
5eaef520 1815 EXEC SQL CLOSE csr217;
1816 return found;
208a4f4a 1817}
68bbc9c3 1818
7ac48069 1819void zero_srv_user(void *id)
208a4f4a 1820{
5eaef520 1821 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1822 int iid = (int)id, rowcount;
5eaef520 1823 EXEC SQL END DECLARE SECTION;
1824
1825 EXEC SQL UPDATE servers SET acl_id = 0 WHERE acl_id = :iid AND
1826 acl_type = 'USER';
1827 rowcount = sqlca.sqlerrd[2];
1828 if (rowcount > 0)
1829 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1830 else
1831 printf("Not fixed\n");
1832 modified("servers");
208a4f4a 1833}
68bbc9c3 1834
7ac48069 1835void zero_srv_list(void *id)
208a4f4a 1836{
5eaef520 1837 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1838 int iid = (int)id, rowcount;
5eaef520 1839 EXEC SQL END DECLARE SECTION;
68bbc9c3 1840
5eaef520 1841 EXEC SQL UPDATE servers SET acl_id = 0 WHERE acl_id = :iid AND
1842 acl_type = 'LIST';
1843 rowcount = sqlca.sqlerrd[2];
1844 if (rowcount > 0)
1845 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1846 else
1847 printf("Not fixed\n");
1848 modified("servers");
1849}
68bbc9c3 1850
7ac48069 1851int show_krb_usr(void *id)
208a4f4a 1852{
5eaef520 1853 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1854 int iid = (int)id, found = 1, id1;
5eaef520 1855 EXEC SQL END DECLARE SECTION;
1856 struct string *s;
1857 char *ss;
1858
1859 EXEC SQL DECLARE csr218 CURSOR FOR
1860 SELECT string_id FROM krbmap
1861 WHERE users_id = :iid;
1862 EXEC SQL OPEN csr218;
1863 while (1)
1864 {
1865 EXEC SQL FETCH csr218 INTO :id1;
1866 if (sqlca.sqlcode)
1867 break;
1868
7ac48069 1869 if ((s = hash_lookup(strings, id1)))
5eaef520 1870 ss = s->name;
1871 else
1872 ss = "[unknown]";
1873 found = 0;
1874 printf("Kerberos map for non-existant user %d to principal %s\n",
7ac48069 1875 iid, ss);
208a4f4a 1876 }
5eaef520 1877 EXEC SQL CLOSE csr218;
1878 return found;
208a4f4a 1879}
68bbc9c3 1880
7ac48069 1881int show_krb_str(void *id)
208a4f4a 1882{
5eaef520 1883 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1884 int iid = (int)id, found = 1, id1;
5eaef520 1885 EXEC SQL END DECLARE SECTION;
1886 struct user *u;
1887 char *s;
1888
1889 EXEC SQL DECLARE csr219 CURSOR FOR
1890 SELECT users_id FROM krbmap
1891 WHERE string_id = :iid;
1892 EXEC SQL OPEN csr219;
1893 while (1)
1894 {
1895 EXEC SQL FETCH csr219 INTO :id1;
1896 if (sqlca.sqlcode)
1897 break;
68bbc9c3 1898
7ac48069 1899 if ((u = hash_lookup(users, id1)))
5eaef520 1900 s = u->login;
1901 else
1902 s = "[\?\?\?]";
1903 found = 0;
1904 printf("Kerberos map for user %s (%d) to non-existant string %d\n",
7ac48069 1905 s, id1, iid);
5eaef520 1906 }
1907 EXEC SQL CLOSE csr219;
1908 return found;
1909}
68bbc9c3 1910
7ac48069 1911void phase2(void)
208a4f4a 1912{
fe0a844a 1913 struct save_queue *sq, *sq1, *sq2, *sq3, *sq4, *sq5, *sq6;
5eaef520 1914 struct filesys *f;
1915 struct list *l;
1916 struct nfsphys *n;
1917 struct machine *m;
c978c079 1918 char rowid[32];
5eaef520 1919
1920 printf("Phase 2 - Checking references\n");
1921
1922 dprintf("Checking users...\n");
1923 hash_step(users, user_check, NULL);
1924
1925 dprintf("Checking machines...\n");
1926 hash_step(machines, mach_check, NULL);
1927
1928 dprintf("Checking subnets...\n");
1929 hash_step(subnets, subnet_check, NULL);
1930
1931 dprintf("Checking clusters...\n");
1932 hash_step(clusters, cluster_check, NULL);
1933
1934 dprintf("Checking mcmap...\n");
1935 sq1 = sq_create();
1936 sq2 = sq_create();
1937 EXEC SQL DECLARE csr221 CURSOR FOR
1938 SELECT mach_id, clu_id FROM mcmap;
1939 EXEC SQL OPEN csr221;
1940 while (1)
1941 {
cfc4f91e 1942 EXEC SQL BEGIN DECLARE SECTION;
1943 int mach_id, clu_id;
1944 EXEC SQL END DECLARE SECTION;
1945
1946 EXEC SQL FETCH csr221 INTO :mach_id, :clu_id;
5eaef520 1947 if (sqlca.sqlcode)
1948 break;
1949
cfc4f91e 1950 if (!(m = hash_lookup(machines, mach_id)))
1951 sq_save_unique_data(sq1, (void *)mach_id);
1952 else if (!hash_lookup(clusters, clu_id))
1953 sq_save_unique_data(sq2, (void *)clu_id);
5eaef520 1954 if (m)
1955 m->clucount++;
ab05f33a 1956 }
5eaef520 1957 EXEC SQL CLOSE csr221;
1958 generic_delete(sq1, show_mcm_mach, "mcmap", "mach_id", 1);
1959 generic_delete(sq2, show_mcm_clu, "mcmap", "clu_id", 1);
1960
1961 dprintf("Checking service clusters...\n");
1962 sq1 = sq_create();
1963 EXEC SQL DECLARE csr222 CURSOR FOR
1964 SELECT clu_id FROM svc;
1965 EXEC SQL OPEN csr222;
1966 while (1)
1967 {
cfc4f91e 1968 EXEC SQL BEGIN DECLARE SECTION;
1969 int clu_id;
1970 EXEC SQL END DECLARE SECTION;
1971
1972 EXEC SQL FETCH csr222 INTO :clu_id;
5eaef520 1973 if (sqlca.sqlcode)
1974 break;
1975
cfc4f91e 1976 if (!hash_lookup(clusters, clu_id))
1977 sq_save_unique_data(sq1, (void *)clu_id);
208a4f4a 1978 }
5eaef520 1979 EXEC SQL CLOSE csr222;
1980 generic_delete(sq1, show_svc, "svc", "clu_id", 1);
1981
1982 dprintf("Checking lists...\n");
1983 hash_step(lists, list_check, NULL);
1984
1985 dprintf("Checking members...\n");
1986 sq1 = sq_create();
1987 sq2 = sq_create();
1988 sq3 = sq_create();
1989 sq4 = sq_create();
1990 sq5 = sq_create();
5f7b0741 1991 sq6 = sq_create();
5eaef520 1992
1993 EXEC SQL DECLARE csr223 CURSOR FOR
c0a94410 1994 SELECT list_id, member_type, member_id, tag, ref_count, direct, rowid
5eaef520 1995 FROM imembers FOR UPDATE OF member_id;
1996 EXEC SQL OPEN csr223;
1997 while (1)
1998 {
cfc4f91e 1999 EXEC SQL BEGIN DECLARE SECTION;
c0a94410 2000 int list_id, id, tag, ref_count, direct;
cfc4f91e 2001 char type[IMEMBERS_MEMBER_TYPE_SIZE];
2002 EXEC SQL END DECLARE SECTION;
2003
38da5476 2004 EXEC SQL FETCH csr223 INTO :list_id, :type, :id, :tag,
c978c079 2005 :ref_count, :direct, :rowid;
5eaef520 2006 if (sqlca.sqlcode)
2007 break;
c0a94410 2008 strtrim(rowid);
5eaef520 2009
cfc4f91e 2010 if (!(l = hash_lookup(lists, list_id)))
2011 sq_save_unique_data(sq1, (void *)list_id);
2012 else if (type[0] == 'U' && !hash_lookup(users, id))
2013 sq_save_unique_data(sq2, (void *)id);
2014 else if (type[0] == 'L' && !hash_lookup(lists, id))
2015 sq_save_unique_data(sq3, (void *)id);
c0a94410 2016 else if (type[0] == 'S' && !maybe_fixup_unref_string2("imembers", "member_id", rowid, id))
cfc4f91e 2017 sq_save_unique_data(sq4, (void *)id);
c0a94410 2018 else if (type[0] == 'K' && !maybe_fixup_unref_string2("imembers", "member_id", rowid, id))
cfc4f91e 2019 sq_save_unique_data(sq5, (void *)id);
5f7b0741 2020 else if (type[0] == 'M' && !maybe_fixup_unref_string2("imembers", "member_id", rowid, id))
2021 sq_save_unique_data(sq6, (void *)id);
5eaef520 2022 else
2023 l->members++;
c0a94410 2024 maybe_fixup_unref_string2("imembers", "tag", rowid, tag);
208a4f4a 2025 }
5eaef520 2026 EXEC SQL CLOSE csr223;
2027 generic_delete(sq1, show_member_list, "imembers", "list_id", 1);
2028 generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1);
2029 generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1);
2030 generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1);
2031 generic_fix(sq5, show_mem_krb, "Delete", del_mem_krb, 1);
5f7b0741 2032 generic_fix(sq6, show_mem_mach, "Delete", del_mem_mach, 1);
5eaef520 2033
2034 dprintf("Checking servers...\n");
2035 sq1 = sq_create();
2036 sq2 = sq_create();
2037 EXEC SQL DECLARE csr224 CURSOR FOR
c978c079 2038 SELECT name, acl_type, acl_id, modby, rowid FROM servers
5eaef520 2039 FOR UPDATE of modby;
2040 EXEC SQL OPEN csr224;
2041 while (1)
2042 {
cfc4f91e 2043 EXEC SQL BEGIN DECLARE SECTION;
2044 int acl_id, modby;
2045 char name[SERVERS_NAME_SIZE], acl_type[SERVERS_ACL_TYPE_SIZE];
2046 EXEC SQL END DECLARE SECTION;
2047
c978c079 2048 EXEC SQL FETCH csr224 INTO :name, :acl_type, :acl_id, :modby, :rowid;
5eaef520 2049 if (sqlca.sqlcode)
2050 break;
2051
11975951 2052 maybe_fixup_modby2("servers", "modby", strtrim(rowid), modby);
cfc4f91e 2053 strtrim(acl_type);
2054 if (!strcmp(acl_type, "USER") && !hash_lookup(users, acl_id))
2055 sq_save_data(sq1, (void *)acl_id);
2056 else if (!strcmp(acl_type, "LIST") && !hash_lookup(lists, acl_id))
2057 sq_save_data(sq2, (void *)acl_id);
5eaef520 2058 }
2059 EXEC SQL CLOSE csr224;
2060 generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
2061 generic_fix(sq2, show_srv_list, "Fix", zero_srv_list, 1);
2062
2063 dprintf("Checking serverhosts...\n");
2064 sq = sq_create();
2065 EXEC SQL DECLARE csr225 CURSOR FOR
c978c079 2066 SELECT mach_id, modby, rowid FROM serverhosts
5eaef520 2067 FOR UPDATE OF modby;
2068 EXEC SQL OPEN csr225;
2069 while (1)
2070 {
cfc4f91e 2071 EXEC SQL BEGIN DECLARE SECTION;
2072 int mach_id, modby;
2073 EXEC SQL END DECLARE SECTION;
2074
c978c079 2075 EXEC SQL FETCH csr225 INTO :mach_id, :modby, :rowid;
5eaef520 2076 if (sqlca.sqlcode)
2077 break;
2078
11975951 2079 maybe_fixup_modby2("serverhosts", "modby", strtrim(rowid), modby);
cfc4f91e 2080 if (!hash_lookup(machines, mach_id))
2081 sq_save_data(sq, (void *)mach_id);
5eaef520 2082 }
2083 EXEC SQL CLOSE csr225;
2084 generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
2085
2086 dprintf("Checking nfsphys...\n");
2087 hash_step(nfsphys, check_nfsphys, NULL);
2088
2089 dprintf("Checking filesys...\n");
2090 hash_step(filesys, check_fs, NULL);
2091
2092 dprintf("Checking filesystem groups...\n");
2093 sq1 = sq_create();
2094 sq2 = sq_create();
2095 sq3 = sq_create();
2096 EXEC SQL DECLARE csr226 CURSOR FOR
2097 SELECT group_id, filsys_id FROM fsgroup;
2098 EXEC SQL OPEN csr226;
2099 while (1)
2100 {
cfc4f91e 2101 EXEC SQL BEGIN DECLARE SECTION;
2102 int group_id, filsys_id;
2103 EXEC SQL END DECLARE SECTION;
2104
2105 EXEC SQL FETCH csr226 INTO :group_id, :filsys_id;
5eaef520 2106 if (sqlca.sqlcode)
2107 break;
2108
cfc4f91e 2109 if (!(f = hash_lookup(filesys, group_id)))
2110 sq_save_data(sq1, (void *)group_id);
2111 if (!hash_lookup(filesys, filsys_id))
2112 sq_save_data(sq3, (void *)filsys_id);
208a4f4a 2113 }
5eaef520 2114 EXEC SQL CLOSE csr226;
2115 generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0);
2116 generic_delete(sq3, show_fsg_nomember, "fsgroup", "filsys_id", 1);
2117
2118 dprintf("Checking quotas...\n");
2119 sq1 = sq_create();
2120 sq2 = sq_create();
2121 sq3 = sq_create();
2122 sq4 = sq_create();
2123 EXEC SQL DECLARE csr227 CURSOR FOR
c978c079 2124 SELECT entity_id, type, filsys_id, phys_id, quota, modby, rowid
5eaef520 2125 FROM quota FOR UPDATE OF modby;
2126 EXEC SQL OPEN csr227;
2127 while (1)
2128 {
cfc4f91e 2129 EXEC SQL BEGIN DECLARE SECTION;
2130 int entity_id, filsys_id, phys_id, quota, modby;
2131 char type[QUOTA_TYPE_SIZE];
2132 EXEC SQL END DECLARE SECTION;
2133
2134 EXEC SQL FETCH csr227 INTO :entity_id, :type, :filsys_id,
c978c079 2135 :phys_id, :quota, :modby, :rowid;
5eaef520 2136 if (sqlca.sqlcode)
2137 break;
2138
11975951 2139 maybe_fixup_modby2("quota", "modby", strtrim(rowid), modby);
cfc4f91e 2140 if (type[0] == 'U' && entity_id != 0 && !hash_lookup(users, entity_id))
2141 sq_save_data(sq1, (void *)entity_id);
2142 else if (type[0] == 'G' && !hash_lookup(lists, entity_id))
2143 sq_save_data(sq4, (void *)entity_id);
2144 else if (!(f = hash_lookup(filesys, filsys_id)))
2145 sq_save_data(sq2, (void *)filsys_id);
2146 else if (phys_id != f->phys_id || !(n = hash_lookup(nfsphys, phys_id)))
2147 sq_save_data(sq3, (void *)phys_id);
5eaef520 2148 else
cfc4f91e 2149 n->count += quota;
208a4f4a 2150 }
5eaef520 2151 EXEC SQL CLOSE csr227;
2152 generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1);
2153 generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0);
2154 generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1);
2155 generic_fix(sq4, show_quota_nolist, "Delete", fix_quota_nolist, 1);
2156
37ed4e84 2157 dprintf("Checking zephyr...\n");
2158 EXEC SQL DECLARE csr_zc CURSOR FOR
2159 SELECT class, xmt_type, xmt_id, sub_type, sub_id, iws_type, iws_id,
2160 iui_type, iui_id, modby FROM zephyr;
2161 EXEC SQL OPEN csr_zc;
2162 while(1)
2163 {
2164 EXEC SQL BEGIN DECLARE SECTION;
2165 int xmt_id, sub_id, iws_id, iui_id, modby;
2166 char class[ZEPHYR_CLASS_SIZE];
2167 char xmt_type[ZEPHYR_XMT_TYPE_SIZE];
2168 char sub_type[ZEPHYR_SUB_TYPE_SIZE];
2169 char iws_type[ZEPHYR_IWS_TYPE_SIZE];
2170 char iui_type[ZEPHYR_IUI_TYPE_SIZE];
2171 EXEC SQL END DECLARE SECTION;
2172
2173 EXEC SQL FETCH csr_zc INTO :class, :xmt_type, :xmt_id, :sub_type,
2174 :sub_id, :iws_type, :iws_id, :iui_type, :iui_id, :modby;
2175
2176 if (sqlca.sqlcode)
2177 break;
2178
2179 maybe_fixup_modby2("zephyr", "modby", strtrim(rowid), modby);
2180
2181 strtrim(xmt_type);
2182 if (!strcmp(xmt_type, "USER") && !hash_lookup(users, xmt_id))
2183 {
2184 printf("xmt acl for %s is non-existant user %d\n", class, xmt_id);
2185 printf("Not fixing this error\n");
2186 }
2187 else if (!strcmp(xmt_type, "LIST") && !hash_lookup(lists, xmt_id))
2188 {
2189 printf("xmt acl for %s is non-existant list %d\n", class, xmt_id);
2190 printf("Not fixing this error\n");
2191 }
2192 else if (!strcmp(xmt_type, "STRING") || !strcmp(xmt_type, "KERBEROS"))
2193 maybe_fixup_unref_string2("zephyr", "xmt_id", strtrim(rowid), xmt_id);
2194
2195 strtrim(sub_type);
2196 if (!strcmp(sub_type, "USER") && !hash_lookup(users, sub_id))
2197 {
2198 printf("sub acl for %s is non-existant user %d\n", class, sub_id);
2199 printf("Not fixing this error\n");
2200 }
2201 else if (!strcmp(sub_type, "LIST") && !hash_lookup(lists, sub_id))
2202 {
2203 printf("sub acl for %s is non-existant list %d\n", class, sub_id);
2204 printf("Not fixing this error\n");
2205 }
2206 else if (!strcmp(sub_type, "STRING") || !strcmp(sub_type, "KERBEROS"))
2207 maybe_fixup_unref_string2("zephyr", "sub_id", strtrim(rowid), sub_id);
2208
2209 strtrim(iws_type);
2210 if (!strcmp(iws_type, "USER") && !hash_lookup(users, iws_id))
2211 {
2212 printf("iws acl for %s is non-existant user %d\n", class, iws_id);
2213 printf("Not fixing this error\n");
2214 }
2215 else if (!strcmp(iws_type, "LIST") && !hash_lookup(lists, iws_id))
2216 {
2217 printf("iws acl for %s is non-existant list %d\n", class, iws_id);
2218 printf("Not fixing this error\n");
2219 }
2220 else if (!strcmp(iws_type, "STRING") || !strcmp(iws_type, "KERBEROS"))
2221 maybe_fixup_unref_string2("zephyr", "iws_id", strtrim(rowid), iws_id);
2222
2223 strtrim(iui_type);
2224 if (!strcmp(iui_type, "USER") && !hash_lookup(users, iui_id))
2225 {
2226 printf("iui acl for %s is non-existant user %d\n", class, iui_id);
2227 printf("Not fixing this error\n");
2228 }
2229 else if (!strcmp(iui_type, "LIST") && !hash_lookup(lists, iui_id))
2230 {
2231 printf("iui acl for %s is non-existant list %d\n", class, iui_id);
2232 printf("Not fixing this error\n");
2233 }
2234 else if (!strcmp(iui_type, "STRING") || !strcmp(iui_type, "KERBEROS"))
2235 maybe_fixup_unref_string2("zephyr", "iui_id", strtrim(rowid), iui_id);
2236 }
5eaef520 2237
2238 dprintf("Checking hostaccess...\n");
2239 EXEC SQL DECLARE csr228 CURSOR FOR
c978c079 2240 SELECT mach_id, acl_type, acl_id, modby, rowid FROM hostaccess
5eaef520 2241 FOR UPDATE OF modby;
2242 EXEC SQL OPEN csr228;
2243 while (1)
2244 {
cfc4f91e 2245 EXEC SQL BEGIN DECLARE SECTION;
2246 int mach_id, acl_id, modby;
2247 char acl_type[HOSTACCESS_ACL_TYPE_SIZE];
2248 EXEC SQL END DECLARE SECTION;
2249
c978c079 2250 EXEC SQL FETCH csr228 INTO :mach_id, :acl_type, :acl_id, :modby, :rowid;
5eaef520 2251 if (sqlca.sqlcode)
2252 break;
2253
11975951 2254 maybe_fixup_modby2("hostaccess", "modby", strtrim(rowid), modby);
cfc4f91e 2255 strtrim(acl_type);
2256 if (!hash_lookup(machines, mach_id))
5eaef520 2257 {
cfc4f91e 2258 printf("Hostaccess for non-existant host %d\n", mach_id);
5eaef520 2259 printf("Not fixing this error\n");
68bbc9c3 2260 }
cfc4f91e 2261 if (!strcmp(acl_type, "USER") && !hash_lookup(users, acl_id))
5eaef520 2262 {
cfc4f91e 2263 printf("Hostaccess for %d is non-existant user %d\n", mach_id, acl_id);
5eaef520 2264 printf("Not fixing this error\n");
68bbc9c3 2265 }
cfc4f91e 2266 else if (!strcmp(acl_type, "LIST") && !hash_lookup(lists, acl_id))
5eaef520 2267 {
cfc4f91e 2268 printf("Hostaccess for %d is non-existant list %d\n", mach_id, acl_id);
5eaef520 2269 printf("Not fixing this error\n");
68bbc9c3 2270 }
208a4f4a 2271 }
5eaef520 2272 EXEC SQL CLOSE csr228;
2273
5eaef520 2274 dprintf("Checking krbmap...\n");
2275 sq1 = sq_create();
2276 sq2 = sq_create();
2277 EXEC SQL DECLARE csr230 CURSOR FOR
c978c079 2278 SELECT users_id, string_id, rowid FROM krbmap
5eaef520 2279 FOR UPDATE OF string_id;
2280 EXEC SQL OPEN csr230;
2281 while (1)
2282 {
cfc4f91e 2283 EXEC SQL BEGIN DECLARE SECTION;
2284 int users_id, string_id;
2285 EXEC SQL END DECLARE SECTION;
2286
c978c079 2287 EXEC SQL FETCH csr230 INTO :users_id, :string_id, :rowid;
5eaef520 2288 if (sqlca.sqlcode)
2289 break;
2290
cfc4f91e 2291 if (!hash_lookup(users, users_id))
2292 sq_save_unique_data(sq1, (void *)users_id);
11975951 2293 else if (!maybe_fixup_unref_string2("krbmap", "string_id", strtrim(rowid), string_id))
cfc4f91e 2294 sq_save_unique_data(sq2, (void *)string_id);
5eaef520 2295 }
2296 EXEC SQL CLOSE csr230;
2297 generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1);
2298 generic_delete(sq2, show_krb_str, "krbmap", "string_id", 1);
2299
2300 dprintf("Checking capacls...\n");
2301 EXEC SQL DECLARE csr231 CURSOR FOR
2302 SELECT list_id, tag FROM capacls;
2303 EXEC SQL OPEN csr231;
2304 while (1)
2305 {
cfc4f91e 2306 EXEC SQL BEGIN DECLARE SECTION;
2307 int list_id;
2308 char tag[CAPACLS_TAG_SIZE];
2309 EXEC SQL END DECLARE SECTION;
2310
2311 EXEC SQL FETCH csr231 INTO :list_id, :tag;
5eaef520 2312 if (sqlca.sqlcode)
2313 break;
2314
cfc4f91e 2315 if (!hash_lookup(lists, list_id))
5eaef520 2316 {
cfc4f91e 2317 printf("Capacl for %s is non-existant list %d\n", tag, list_id);
5eaef520 2318 printf("Not fixing this error\n");
68bbc9c3 2319 }
208a4f4a 2320 }
5eaef520 2321 EXEC SQL CLOSE csr231;
2322
2323 dprintf("Checking hostaliases\n");
2324 sq1 = sq_create();
2325 EXEC SQL DECLARE csr232 CURSOR FOR
2326 SELECT mach_id FROM hostalias;
2327 EXEC SQL OPEN csr232;
2328 while (1)
2329 {
cfc4f91e 2330 EXEC SQL BEGIN DECLARE SECTION;
2331 int mach_id;
2332 EXEC SQL END DECLARE SECTION;
2333
2334 EXEC SQL FETCH csr232 INTO :mach_id;
5eaef520 2335 if (sqlca.sqlcode)
2336 break;
2337
cfc4f91e 2338 if (!hash_lookup(machines, mach_id))
2339 sq_save_unique_data(sq1, (void *)mach_id);
ab05f33a 2340 }
5eaef520 2341 EXEC SQL CLOSE csr232;
2342 generic_delete(sq1, show_hostalias, "hostalias", "mach_id", 1);
2343
dabf20aa 2344 dprintf("Checking printers\n");
5eaef520 2345 sq1 = sq_create();
2346 sq2 = sq_create();
dabf20aa 2347 sq3 = sq_create();
2348 sq4 = sq_create();
2349 sq5 = sq_create();
fe0a844a 2350 sq6 = sq_create();
5eaef520 2351 EXEC SQL DECLARE csr233 CURSOR FOR
c978c079 2352 SELECT mach_id, loghost, rm, rq, ac, lpc_acl, modby, rowid FROM printers;
5eaef520 2353 EXEC SQL OPEN csr233;
2354 while (1)
2355 {
cfc4f91e 2356 EXEC SQL BEGIN DECLARE SECTION;
c96b70a5 2357 int mach_id, loghost, rm, rq, ac, lpc_acl, modby;
cfc4f91e 2358 EXEC SQL END DECLARE SECTION;
2359
11975951 2360 EXEC SQL FETCH csr233 INTO :mach_id, :loghost, :rm, :rq, :ac,
c978c079 2361 :lpc_acl, :modby, :rowid;
5eaef520 2362 if (sqlca.sqlcode)
2363 break;
2364
11975951 2365 maybe_fixup_modby2("printers", "modby", strtrim(rowid), modby);
cfc4f91e 2366 if (!hash_lookup(machines, mach_id))
2367 sq_save_unique_data(sq1, (void *)mach_id);
dabf20aa 2368 else if (!hash_lookup(machines, rm))
2369 sq_save_unique_data(sq2, (void *)rm);
fe0a844a 2370 else if (!hash_lookup(printservers, rm))
2371 sq_save_unique_data(sq6, (void *)mach_id);
dabf20aa 2372 else if (!hash_lookup(machines, rq))
2373 sq_save_unique_data(sq3, (void *)rq);
2374 else {
2375 if (!hash_lookup(lists, ac))
2376 sq_save_unique_data(sq4, (void *)ac);
2377 if (!hash_lookup(lists, lpc_acl))
2378 sq_save_unique_data(sq5, (void *)lpc_acl);
2379 if (!hash_lookup(machines, loghost))
2380 {
2381 show_printer_loghost((void *)loghost);
c96b70a5 2382 cant_fix();
dabf20aa 2383 }
c96b70a5 2384 }
ab05f33a 2385 }
5eaef520 2386 EXEC SQL CLOSE csr233;
dabf20aa 2387 generic_delete(sq1, show_printer_mach, "printers", "mach_id", 1);
fe0a844a 2388 generic_delete(sq6, show_printer_server, "printers", "mach_id", 1);
dabf20aa 2389 generic_delete(sq2, show_printer_spool, "printers", "rm", 1);
2390 generic_delete(sq3, show_printer_quota, "printers", "rq", 1);
2391 generic_fix(sq4, show_printer_ac, "Clear", fix_printer_ac, 1);
2392 generic_fix(sq5, show_printer_lpc_acl, "Clear", fix_printer_lpc_acl, 1);
fe0a844a 2393
2394 dprintf("Checking printservers\n");
2395 hash_step(printservers, check_ps, NULL);
ab05f33a 2396}
c96b70a5 2397
This page took 0.629929 seconds and 5 git commands to generate.