X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/blobdiff_plain/ced12e6102e5e9aacdfcdd3c194410409292871a..4e82e7cac76280026adbe913d5cedb7e54cfb41d:/dbck/phase2.dc diff --git a/dbck/phase2.dc b/dbck/phase2.dc index c5b977bc..a9aea9d6 100644 --- a/dbck/phase2.dc +++ b/dbck/phase2.dc @@ -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();