]> andersk Git - moira.git/commitdiff
check new hosttable info
authormar <mar>
Tue, 26 Oct 1993 16:42:47 +0000 (16:42 +0000)
committermar <mar>
Tue, 26 Oct 1993 16:42:47 +0000 (16:42 +0000)
dbck/FIXES
dbck/dbck.dc
dbck/dbck.h
dbck/phase1.dc
dbck/phase2.dc

index fb1cca78d990b670d9e447c6d3eaa5906f45ead4..a1648de5918de7187a2e596ae95c42068df80a90 100644 (file)
@@ -11,6 +11,8 @@ PHASE 1: looking for duplicates
    Each mach_id must be unique
        Alloc new ID
  * Each machine name must be unique (if -f flag not specified)
+   Each snet_id must be unique
+       Alloc new ID
    Each clu_id must be unique
        Alloc new ID
  * Each cluster must have a unique name (if -f flag not specified)
@@ -52,6 +54,10 @@ P  Every STRING member must be a real string
        Delete the member
 P  Every KERBEROS member must be a real string
        Delete the member
+P  Every machine owner must exist
+       Set dummy owner
+P  Every machine must be on a subnet
+       Set to placeholder subnet
 P  Every service USER owner must be a real user
        Make user 0 own service
 P  Every service LIST owner must be a real list
index f2405717c55d5d387532a547353c03fc9c44fd91..525d567a181e81ecd875e41c5bb13bdd7fb5ba52 100644 (file)
@@ -23,7 +23,7 @@ int fast = 0;
 int warn = 1;
 int abort_p = 0;
 struct hash *users, *machines, *clusters, *lists, *filesys, *nfsphys;
-struct hash *strings, *members;
+struct hash *strings, *members, *subnets;
 EXEC SQL BEGIN DECLARE SECTION; 
 int dcmenable;
 EXEC SQL END DECLARE SECTION; 
index f876ebbd81ad53d19365465f6a4f7cf6274762c8..1cad37ce4996df304a2a63dfbd1aa8520e5ee98d 100644 (file)
@@ -19,7 +19,7 @@
 
 extern int debug, mode, fast, dcmenable, warn;
 extern struct hash *users, *machines, *clusters, *lists;
-extern struct hash *filesys, *nfsphys, *strings;
+extern struct hash *filesys, *nfsphys, *strings, *subnets;
 
 #define MAX_ID_VALUE 32765
 #define MIN_ID_VALUE 100
@@ -37,8 +37,12 @@ struct user {
 
 struct machine {
     char name[33];
+    char owner_type;
+    int owner_id;
+    int snet_id;
     int mach_id;
     int clucount;
+    
 };
 
 struct cluster {
index 60256c0b1d85a7ead7d6a892768a8b5f77615e0b..a937cebe9b474d319b34a15279dc4badfefe6db7 100644 (file)
@@ -306,11 +306,14 @@ phase1()
     sq = sq_create();
 
     EXEC SQL DECLARE csr104 CURSOR FOR
-       SELECT mach_id, name, modby FROM machine ORDER BY mach_id;
+       SELECT mach_id, name, snet_id, owner_type, owner_id,
+               acomment, ocomment, creator, modby
+       FROM machine ORDER BY mach_id;
     if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
     EXEC SQL OPEN csr104;
     while(1) {
-       EXEC SQL FETCH csr104 INTO :id, :name, :sid;
+       EXEC SQL FETCH csr104 INTO :id, :name, :id2, :buf, :id3, :sid2,
+               :sid3, :sid4, :sid;
        if (sqlca.sqlcode != 0) {
          ingerr(&sqlca.sqlcode);
          break;
@@ -320,14 +323,19 @@ phase1()
        if (m == NULL)
          out_of_mem("storing machines");
        strcpy(m->name, strtrim(name));
+       m->owner_type = buf[0];
+       m->owner_id = id3;
+       m->snet_id = id2;
        m->mach_id = id;
        m->clucount = 0;
        if (hash_store(machines, id, m)) {
            sq_save_data(sq, hash_lookup(machines, id));
            sq_save_data(sq, m);
        }
-       if (sid < 0)
-         string_check(-sid);
+       if (sid2) string_check(sid2);
+       if (sid3) string_check(sid3);
+       if (sid4 < 0) string_check(-sid4);
+       if (sid < 0) string_check(-sid);
     }
     EXEC SQL CLOSE csr104; 
     generic_fix(sq, show_mach_id, "Change ID", fix_mach_id, 0);
@@ -353,6 +361,25 @@ phase1()
        generic_fix(sq, show_mach_name, "Change name", cant_fix, 0);
     }  
 
+    dprintf("Loading subnets...\n");
+    subnets = create_hash(254);
+
+    EXEC SQL DECLARE csr115 CURSOR FOR
+      SELECT snet_id, name from subnet;
+    if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
+    EXEC SQL OPEN csr115;
+    while(1) {
+       EXEC SQL FETCH csr115 INTO :id, :name;
+       if (sqlca.sqlcode != 0) {
+         ingerr(&sqlca.sqlcode);
+         break;
+       } 
+       if (hash_store(subnets, id, name)) {
+           printf("Duplicate subnet ID: %d (%s)\n", id, name);
+       }
+    }
+    EXEC SQL CLOSE csr115;
+
     dprintf("Loading clusters...\n");
     sq = sq_create();
     clusters = create_hash(100);
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.92594 seconds and 5 git commands to generate.