+static void clear_ps_owner(struct printserver *ps)
+{
+ EXEC SQL BEGIN DECLARE SECTION;
+ int rowcount, id = ps->mach_id;
+ EXEC SQL END DECLARE SECTION;
+
+ EXEC SQL UPDATE printserver SET owner_type = 'NONE', owner_id = 0
+ WHERE mach_id = :id;
+ rowcount = sqlca.sqlerrd[2];
+ if (rowcount > 0)
+ printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
+ else
+ printf("Not fixed\n");
+ modified("printservers");
+}
+
+static void clear_ps_lpc(struct printserver *ps)
+{
+ EXEC SQL BEGIN DECLARE SECTION;
+ int rowcount, id = ps->mach_id;
+ EXEC SQL END DECLARE SECTION;
+
+ EXEC SQL UPDATE printserver SET lpc_acl = 0
+ WHERE mach_id = :id;
+ rowcount = sqlca.sqlerrd[2];
+ if (rowcount > 0)
+ printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
+ else
+ printf("Not fixed\n");
+ modified("printservers");
+}
+
+void check_ps(int id, void *printserver, void *hint)
+{
+ struct printserver *ps = printserver;
+ struct machine *m;
+ char *name;
+
+ m = hash_lookup(machines, id);
+ if (!m)
+ {
+ printf("Printserver on non-existant machine %d\n", id);
+ if (single_fix("Delete", 0))
+ {
+ single_delete("printserver", "mach_id", id);
+ return;
+ }
+ else
+ name = "[UNKNOWN]";
+ }
+ else
+ name = m->name;
+
+ ps->modby = maybe_fixup_modby(ps->modby, id, name, "printserver",
+ "modby", "mach_id");
+ ps->printer_types = maybe_fixup_unref_string(ps->printer_types, id, name,
+ "printservers", "printer_types",
+ "mach_id");
+
+ switch (ps->owner_type)
+ {
+ case 'U':
+ if (!hash_lookup(users, ps->owner_id))
+ {
+ printf("Printserver %s has non-existant USER owner %d\n",
+ name, ps->owner_id);
+ if (single_fix("Set to no owner", 1))
+ clear_ps_owner(ps);
+ }
+ break;
+ case 'L':
+ if (!hash_lookup(lists, ps->owner_id))
+ {
+ printf("Printserver %s has non-existant LIST owner %d\n",
+ name, ps->owner_id);
+ if (single_fix("Set to no owner", 1))
+ clear_ps_owner(ps);
+ }
+ break;
+ case 'K':
+ if (ps->owner_id)
+ ps->owner_id = maybe_fixup_unref_string(ps->owner_id, id, name,
+ "printserver", "owner_id",
+ "mach_id");
+ if (ps->owner_id == 0)
+ clear_ps_owner(ps);
+ }
+
+ if (!hash_lookup(lists, ps->lpc_acl))
+ {
+ printf("Printserver %s has non-existent lpc_acl %d\n",
+ name, ps->lpc_acl);
+ if (single_fix("Set to no lpc_acl", 1))
+ clear_ps_lpc(ps);
+ }
+}
+