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)
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
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;
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
struct machine {
char name[33];
+ char owner_type;
+ int owner_id;
+ int snet_id;
int mach_id;
int clucount;
+
};
struct cluster {
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;
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);
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);
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;
{
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();