+
+mach_check(id, m, hint)
+int id;
+struct machine *m;
+int hint;
+{
+ if (!hash_lookup(subnets, m->snet_id)) {
+ printf("Machine %s is on a non-existant subnet %d\n",
+ m->name, m->snet_id);
+ if (single_fix("Move to null-subnet", 1)) {
+ EXEC SQL BEGIN DECLARE SECTION;
+ int rowcount, iid = id;
+ EXEC SQL END DECLARE SECTION;
+
+ EXEC SQL UPDATE machine SET snet_id=0 WHERE mach_id = :iid;
+ EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
+ if (rowcount > 0)
+ printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
+ else
+ printf("Not fixed\n");
+ modified("machine");
+ }
+ }
+
+ switch (m->owner_type) {
+ case 'U':
+ if (!hash_lookup(users, m->owner_id)) {
+ printf("Machine %s has non-existant USER owner %d\n",
+ m->name, m->owner_id);
+ if (single_fix("Set to no owner", 1)) {
+ clear_mach_owner(m);
+ }
+ }
+ break;
+ case 'L':
+ if (!hash_lookup(lists, m->owner_id)) {
+ printf("Machine %s has non-existant LIST owner %d\n",
+ m->name, m->owner_id);
+ if (single_fix("Set to no owner", 1)) {
+ clear_mach_owner(m);
+ }
+ }
+ break;
+ }
+}
+
+
+clear_mach_owner(m)
+struct machine *m;
+{
+ EXEC SQL BEGIN DECLARE SECTION;
+ int rowcount, id = m->mach_id;
+ EXEC SQL END DECLARE SECTION;
+
+ EXEC SQL UPDATE machine SET owner_type='NONE', owner_id=0
+ WHERE mach_id = :id;
+ EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
+ if (rowcount > 0)
+ printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
+ else
+ printf("Not fixed\n");
+ modified("machine");
+}
+
+