X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/blobdiff_plain/0e37bdb8c63400e77ce3a6f7565eff3d08c99053..67805159a972397342c342ee735c8acd640e1399:/dbck/phase2.qc diff --git a/dbck/phase2.qc b/dbck/phase2.qc index 1b50b343..9a0840d6 100644 --- a/dbck/phase2.qc +++ b/dbck/phase2.qc @@ -7,7 +7,7 @@ #include #include -#include +#include #include "dbck.h" static char phase2_qc_rcsid[] = "$Header$"; @@ -148,18 +148,18 @@ show_member_list(id) int id; ##{ ## int mid, iid = id, found = 1; -## char mtype[9], *name; +## char mtype[9], *name = ""; -## retrieve (mtype = member.member_type, mid = member.member_id) -## where member.list_id = iid { +## retrieve (mtype = imembers.member_type, mid = imembers.member_id) +## where imembers.list_id = iid and imembers.direct = 1 { strtrim(mtype); found = 0; if (mtype[0] == 'L') - strcpy(name, ((struct list *) hash_lookup(lists, mid))->name); + name = ((struct list *) hash_lookup(lists, mid))->name; else if (mtype[0] == 'U') - strcpy(name, ((struct user *) hash_lookup(users, mid))->login); - else if (mtype[0] == 'S') - strcpy(name, ((struct string *) hash_lookup(strings, mid))->name); + name = ((struct user *) hash_lookup(users, mid))->login; + else if (mtype[0] == 'S' || mtype[0] == 'K') + name = ((struct string *) hash_lookup(strings, mid))->name; printf("Non-existant list %d has member %s %s\n", iid, mtype, name); ## } return(found); @@ -171,8 +171,9 @@ int id; ## int lid, iid = id, found = 1; ## char name[33]; -## retrieve (lid = members.list_id) -## where members.member_id = iid and members.member_type = "USER" { +## retrieve (lid = imembers.list_id) +## where imembers.member_id = iid and imembers.member_type = "USER" and +## imembers.direct = 1 { found = 0; printf("List %s has non-existant user member, id %d\n", ((struct list *)hash_lookup(lists, lid))->name, iid); @@ -186,8 +187,9 @@ int id; ## int lid, iid = id, found = 1; ## char name[33]; -## retrieve (lid = members.list_id) -## where members.member_id = iid and members.member_type = "LIST" { +## retrieve (lid = imembers.list_id) +## where imembers.member_id = iid and imembers.member_type = "LIST" and +## imembers.direct = 1 { found = 0; printf("List %s has non-existant list member, id %d\n", ((struct list *)hash_lookup(lists, lid))->name, iid); @@ -201,8 +203,9 @@ int id; ## int lid, iid = id, found = 1; ## char name[33]; -## retrieve (lid = members.list_id) -## where members.member_id = iid and members.member_type = "STRING" { +## retrieve (lid = imembers.list_id) +## where imembers.member_id = iid and imembers.member_type = "STRING" and +## imembers.direct = 1 { found = 0; printf("List %s has non-existant string member, id %d\n", ((struct list *)hash_lookup(lists, lid))->name, iid); @@ -211,19 +214,36 @@ int id; ##} +show_mem_krb(id) +int id; +##{ +## int lid, iid = id, found = 1; +## char name[33]; + +## retrieve (lid = imembers.list_id) +## where imembers.member_id = iid and imembers.member_type = "KERBEROS" and +## imembers.direct = 1 { + found = 0; + printf("List %s has non-existant kerberos member, id %d\n", + ((struct list *)hash_lookup(lists, lid))->name, iid); +## } + return(found); +##} + + ##del_mem_user(id) ##int id; ##{ ## int rowcount; -## delete members where members.member_type = "USER" and -## members.member_id = id +## delete imembers where imembers.member_type = "USER" and +## imembers.member_id = id and imembers.direct = 1 ## inquire_equel(rowcount = "rowcount"); if (rowcount > 0) printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies"); else printf("Not deleted\n"); - modified("members"); + modified("imembers"); ##} ##del_mem_list(id) @@ -231,14 +251,14 @@ int id; ##{ ## int rowcount; -## delete members where members.member_type = "LIST" and -## members.member_id = id +## delete imembers where imembers.member_type = "LIST" and +## imembers.member_id = id and imembers.direct = 1 ## inquire_equel(rowcount = "rowcount"); if (rowcount > 0) printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies"); else printf("Not deleted\n"); - modified("members"); + modified("imembers"); ##} ##del_mem_str(id) @@ -246,14 +266,30 @@ int id; ##{ ## int rowcount; -## delete members where members.member_type = "STRING" and -## members.member_id = id +## delete imembers where imembers.member_type = "STRING" and +## imembers.member_id = id and imembers.direct = 1 ## inquire_equel(rowcount = "rowcount"); if (rowcount > 0) printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies"); else printf("Not deleted\n"); - modified("members"); + modified("imembers"); +##} + + +##del_mem_krb(id) +##int id; +##{ +## int rowcount; + +## delete imembers where imembers.member_type = "KERBEROS" and +## imembers.member_id = id and imembers.direct = 1 +## inquire_equel(rowcount = "rowcount"); + if (rowcount > 0) + printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies"); + else + printf("Not deleted\n"); + modified("imembers"); ##} @@ -312,33 +348,32 @@ int hint; struct nfsphys *n; struct machine *m; - if (f->type == 'N' || f->type == 'R') { - if (!hash_lookup(machines, f->mach_id)) { - printf("Filesys %s with bad machine %d\n", f->name, f->mach_id); - if (single_fix("Fix", 0)) { -## replace filesys (mach_id = 0) where filesys.filsys_id = id -## inquire_equel(rowcount = "rowcount") - if (rowcount > 0) - printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies"); - else - printf("Not fixed\n"); - modified("filesys"); - f->mach_id = 0; - } + if (!hash_lookup(machines, f->mach_id)) { + printf("Filesys %s with bad machine %d\n", f->name, f->mach_id); + if (single_fix("Fix", 0)) { +## replace filesys (mach_id = 0) where filesys.filsys_id = id +## inquire_equel(rowcount = "rowcount") + if (rowcount > 0) + printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies"); + else + printf("Not fixed\n"); + modified("filesys"); + f->mach_id = 0; } - if (!hash_lookup(users, f->owner)) { - printf("Filesys %s with bad owning user %d\n", f->name, f->owner); - if (single_fix("Fix", 1)) { - zero_fix("filesys", "owner", "filsys_id", f->filsys_id); - f->owner = 0; - } + } + + if (!hash_lookup(users, f->owner)) { + printf("Filesys %s with bad owning user %d\n", f->name, f->owner); + if (single_fix("Fix", 1)) { + zero_fix("filesys", "owner", "filsys_id", f->filsys_id); + f->owner = 0; } - if (!hash_lookup(lists, f->owners)) { - printf("Filesys %s with bad owning group %d\n", f->name, f->owners); - if (single_fix("Fix", 1)) { - zero_fix("filesys", "owners", "filsys_id", f->filsys_id); - f->owners = 0; - } + } + if (!hash_lookup(lists, f->owners)) { + printf("Filesys %s with bad owning group %d\n", f->name, f->owners); + if (single_fix("Fix", 1)) { + zero_fix("filesys", "owners", "filsys_id", f->filsys_id); + f->owners = 0; } } @@ -368,7 +403,7 @@ int hint; id2 = f->filsys_id; id3 = f->mach_id; if (set_next_object_id("nfsphys_id", "nfsphys") != - SMS_SUCCESS) { + MR_SUCCESS) { printf("Unable to assign unique ID\n"); return; } @@ -392,6 +427,8 @@ int hint; printf("Not created\n"); modified("nfsphys"); n = (struct nfsphys *)malloc(sizeof(struct nfsphys)); + if (n == NULL) + out_of_mem("storing new nfsphys"); strcpy(n->dir, dir); n->mach_id = id3; n->nfsphys_id = id1; @@ -456,12 +493,18 @@ struct filesys *f; case 'R': t = "RVD"; break; + case 'A': + t = "AFS"; + break; case 'E': t = "ERR"; break; case 'F': t = "FSGROUP"; break; + case 'M': + t = "MUL"; + break; default: t = "???"; } @@ -504,50 +547,90 @@ struct filesys *f; ##{ ## int id1, found = 1; -## retrieve (id1 = nfsquota.filsys_id) where nfsquota.users_id = id { +## retrieve (id1 = quota.filsys_id) where quota.entity_id = id and +## quota.type = "USER" { found = 0; - printf("NFSquota on fs %d for non-existant user %d\n", id1, id); + printf("Quota on fs %d for non-existant user %d\n", id1, id); ## } return(found); ##} -fix_quota_nouser(id) -{ - single_delete("nfsquota", "users_id", id); -} +##show_quota_nolist(id) +##int id; +##{ +## int id1, found = 1; + +## retrieve (id1 = quota.filsys_id) where quota.entity_id = id and +## quota.type = "GROUP" { + found = 0; + printf("Quota on fs %d for non-existant list %d\n", id1, id); +## } + return(found); +##} + +##fix_quota_nouser(id) +##int id; +##{ +## int rowcount, id1; + + id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id; +## delete quota where quota.entity_id = id and quota.type = "USER" +## inquire_equel(rowcount = "rowcount") + if (rowcount > 0) + printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies"); + else + printf("Not deleted\n"); + modified("quota"); +##} + +##fix_quota_nolist(id) +##int id; +##{ +## int rowcount, id1; + + id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id; +## delete quota where quota.entity_id = id and quota.type = "GROUP" +## inquire_equel(rowcount = "rowcount") + if (rowcount > 0) + printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies"); + else + printf("Not deleted\n"); + modified("quota"); +##} ##show_quota_nofs(id) ##int id; ##{ ## int id1, found = 1; - struct user *u; +## char type[9]; -## retrieve (id1 = nfsquota.users_id) where nfsquota.filsys_id = id { - u = (struct user *)hash_lookup(users, id1); +## retrieve (id1 = quota.entity_id, type = quota.#type) +## where quota.filsys_id = id { found = 0; - printf("NFSquota for user %s on non-existant filesys %d\n", u->login, id); + printf("Quota for %s %d on non-existant filesys %d\n", type, id1, id); ## } return(found); ##} fix_quota_nofs(id) { - single_delete("nfsquota", "filsys_id", id); + single_delete("quota", "filsys_id", id); } ##show_quota_wrongpid(id) ##int id; ##{ ## int id1, found = 1; +## char type[9]; struct user *u; struct filesys *f; f = (struct filesys *)hash_lookup(filesys, id); -## retrieve (id1 = nfsquota.users_id) where nfsquota.filsys_id = id { - u = (struct user *)hash_lookup(users, id1); +## retrieve (id1 = quota.entity_id, type = quota.#type) +## where quota.filsys_id = id { found = 0; - printf("NFSquota for user %s on filesys %s has wrong phys_id %d\n", - u->login, f->name, id); + printf("Quota for %s %d on filesys %s has wrong phys_id %d\n", + type, id1, f->name, id); ## } return(found); ##} @@ -558,14 +641,14 @@ fix_quota_nofs(id) ## int rowcount, id1; id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id; -## replace nfsquota (phys_id = id1) where nfsquota.filsys_id = id and -## nfsquota.phys_id != id1 +## replace quota (phys_id = id1) where quota.filsys_id = id and +## quota.phys_id != id1 ## inquire_equel(rowcount = "rowcount") if (rowcount > 0) printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies"); else printf("Not fixed\n"); - modified("nfsquota"); + modified("quota"); ##} ##show_srv_user(id) @@ -627,12 +710,67 @@ fix_quota_nofs(id) ##} +##show_krb_usr(id) +##int id; +##{ +## int found = 1, id1; + struct string *s; + char *ss; + +## retrieve (id1 = krbmap.string_id) where krbmap.users_id = id { + if (s = ((struct string *)hash_lookup(strings, id1))) + ss = s->name; + else + ss = "[unknown]"; + found = 0; + printf("Kerberos map for non-existant user %d to principal %s\n", + id, s); +## } + return(found); +##} + + +##show_krb_str(id) +##int id; +##{ +## int found = 1, id1; + struct user *u; + char *s; + +## retrieve (id1 = krbmap.users_id) where krbmap.string_id = id { + if (u = ((struct user *)hash_lookup(users, id1))) + s = u->login; + else + s = "[???]"; + found = 0; + printf("Kerberos map for user %s (%d) to non-existant string %d\n", + s, id1, id); +## } + return(found); +##} + + +##show_pdm_mach(id) +##int id; +##{ +## char name[33]; + int found = 1; + +## retrieve (name = palladium.#name) where palladium.mach_id = id { + strtrim(name); + printf("Palladium server/supervisor %s is on non-existant machine %d\n", + name, id); + found = 0; +## } + return(found); +##} + phase2() ##{ ## int id1, id2, id3, id4, id5; ## char type[9], name[33]; - struct save_queue *sq, *sq1, *sq2, *sq3, *sq4; + struct save_queue *sq, *sq1, *sq2, *sq3, *sq4, *sq5; struct filesys *f; struct list *l; struct nfsphys *n; @@ -672,24 +810,28 @@ phase2() sq2 = sq_create(); sq3 = sq_create(); sq4 = sq_create(); -## range of m is members -## retrieve (id1 = m.list_id, type = m.member_type, id2 = m.member_id) { - strtrim(type); + sq5 = sq_create(); +## range of m is imembers +## retrieve (id1 = m.list_id, type = m.member_type, id2 = m.member_id, +## id3 = m.ref_count, id4 = m.direct) { if ((l = (struct list *) hash_lookup(lists, id1)) == NULL) sq_save_unique_data(sq1, id1); - else - l->members++; - if (!strcmp(type, "USER") && !hash_lookup(users, id2)) + else if (type[0] == 'U' && !hash_lookup(users, id2)) sq_save_unique_data(sq2, id2); - else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2)) + else if (type[0] == 'L' && !hash_lookup(lists, id2)) sq_save_unique_data(sq3, id2); - else if (!strcmp(type, "STRING") && !string_check(id2)) + else if (type[0] == 'S' && !string_check(id2)) sq_save_unique_data(sq4, id2); + else if (type[0] == 'K' && !string_check(id2)) + sq_save_unique_data(sq5, id2); + else + l->members++; ## } - generic_delete(sq1, show_member_list, "members", "list_id", 1); + generic_delete(sq1, show_member_list, "imembers", "list_id", 1); generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1); generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1); generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1); + generic_fix(sq5, show_mem_krb, "Delete", del_mem_krb, 1); dprintf("Checking servers...\n"); sq1 = sq_create(); @@ -727,23 +869,23 @@ phase2() ## retrieve (id1 = fsgroup.group_id, id2 = fsgroup.filsys_id) { if (!(f = (struct filesys *) hash_lookup(filesys, id1))) sq_save_data(sq1, id1); - if (f->type != 'F') - sq_save_data(sq2, f); if (!hash_lookup(filesys, id2)) sq_save_data(sq3, id2); ## } generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0); - generic_fix(sq2, show_fsg_type, "Change to \"FSTYPE\"", fix_fsg_type, 0); generic_delete(sq3, show_fsg_nomember, "fsgroup", "filsys_id", 1); - dprintf("Checking nfsquota...\n"); + dprintf("Checking quotas...\n"); sq1 = sq_create(); sq2 = sq_create(); sq3 = sq_create(); -## retrieve (id1 = nfsquota.users_id, id2 = nfsquota.filsys_id, -## id3 = nfsquota.phys_id, id4 = nfsquota.quota) { - if (!hash_lookup(users, id1)) + sq4 = sq_create(); +## retrieve (id1 = quota.entity_id, type = quota.#type, id2 = quota.filsys_id, +## id3 = quota.phys_id, id4 = quota.quota) { + if (type[0] == 'U' && id1 != 0 && !hash_lookup(users, id1)) sq_save_data(sq1, id1); + else if (type[0] == 'G' && !hash_lookup(lists, id1)) + sq_save_data(sq4, id1); else if (!(f = (struct filesys *) hash_lookup(filesys, id2))) sq_save_data(sq2, id2); else if (id3 != f->phys_id || @@ -756,6 +898,7 @@ phase2() generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1); generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0); generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1); + generic_fix(sq4, show_quota_nolist, "Delete", fix_quota_nolist, 1); dprintf("Not checking zephyr.\n"); @@ -776,6 +919,29 @@ phase2() } ## } + dprintf("Checking palladium...\n"); + sq1 = sq_create(); +## range of p is palladium +## retrieve (id1 = p.mach_id) { + if (!hash_lookup(machines, id1)) { + sq_save_unique_data(sq1, id1); + } +## } + generic_delete(sq1, show_pdm_mach, "palladium", "mach_id", 1); + + dprintf("Checking krbmap...\n"); + sq1 = sq_create(); + sq2 = sq_create(); +## range of k is krbmap +## retrieve (id1 = k.users_id, id2 = k.string_id) { + if (!hash_lookup(users, id1)) + sq_save_unique_data(sq1, id1); + if (!string_check(id2)) + sq_save_unique_data(sq2, id2); +## } + generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1); + generic_delete(sq2, show_krb_str, "krbmap", "string_id", 1); + dprintf("Checking capacls...\n"); ## retrieve (id1 = capacls.list_id, name = capacls.tag) { if (!hash_lookup(lists, id1)) {