]> andersk Git - moira.git/blobdiff - dbck/phase2.dc
increase machine name length
[moira.git] / dbck / phase2.dc
index c5b977bc3abf97529851f6e31e33cfe6908d3d51..a9aea9d66787b0e217bcadd7da949293b0848dd7 100644 (file)
@@ -118,6 +118,71 @@ int id;
     modified("users");
 }
 
+
+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");
+}
+
+
 show_svc(id)
 int id;
 {
@@ -1124,6 +1189,9 @@ phase2()
     dprintf("Checking users...\n");
     hash_step(users, pobox_check, NULL);
 
+    dprintf("Checking machines...\n");
+    hash_step(machines, mach_check, NULL);
+
     dprintf("Checking mcmap...\n");
     sq1 = sq_create();
     sq2 = sq_create();
This page took 0.034195 seconds and 4 git commands to generate.