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