3 * (c) Copyright 1988 by the Massachusetts Institute of Technology.
4 * For copying and distribution information, please see the file
8 #include <mit-copyright.h>
12 static char phase1_qc_rcsid[] = "$Header$";
18 printf("User %s (%s, status %d) has duplicate ID\n",
19 u->login, u->fullname, u->status);
23 handle_duplicate_logins(sq)
24 struct save_queue *sq;
26 struct user *u, *uu, *tmp;
28 uu = (struct user *)0;
29 while (sq_get_data(sq, &u)) {
30 if (!strcmp(u->login, uu->login)) {
31 if (uu->status == 1 || u->status == 0) {
36 printf("User %s (%s, status %d) and\n",
37 u->login, u->fullname, u->status);
38 printf("User %s (%s, status %d) have duplicate logins\n",
39 uu->login, uu->fullname, uu->status);
40 if (!strcmp(u->fullname, uu->fullname) &&
41 single_fix("Delete the second one")) {
42 single_delete("users", "users_id", uu->users_id);
43 } else if (single_fix("Unregister the second one"))
45 ## int id = uu->users_id, rowcount;
47 ## replace users (login = "#"+text(users.uid), status = 0)
48 ## where users.users_id = id
49 ## inquire_equel(rowcount = "rowcount")
51 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
53 printf("Not fixed\n");
65 u->users_id = generic_fix_id("users", "users_id", "login",
66 u->users_id, u->login);
73 printf("Sorry, don't know how to fix that\n");
79 printf("Machine %s has duplicate ID %d\n", m->name, m->mach_id);
86 printf("Machine %s (%d) has duplicate name\n", m->name, m->mach_id);
93 m->mach_id = generic_fix_id("machine", "mach_id", "name",
100 printf("Cluster %s has duplicate ID %d\n", c->name, c->clu_id);
107 printf("Cluster %s (%d) has duplicate name\n", c->name, c->clu_id);
114 c->clu_id = generic_fix_id("cluster", "clu_id", "name", c->clu_id, c->name);
120 printf("List %s has duplicate ID %d\n", l->name, l->list_id);
127 printf("List %s (%d) has duplicate name\n", l->name, l->list_id);
134 l->list_id = generic_fix_id("list", "list_id", "name", l->list_id, l->name);
140 printf("Filesys %s has duplicate ID %d\n", f->name, f->filsys_id);
147 f->filsys_id = generic_fix_id("filesys", "filsys_id", "label",
148 f->filsys_id, f->name);
155 printf("NfsPhys %s:%s has duplicate ID %d\n",
156 ((struct machine *)hash_lookup(machines, n->mach_id))->name,
157 n->dir, n->nfsphys_id);
164 n->nfsphys_id = generic_fix_id("nfsphys", "nfsphys_id", "dir",
165 n->nfsphys_id, n->dir);
171 printf("String %s has duplicate ID %d\n", s->name, s->string_id);
178 ## char name[81], name1[81], last[17], first[17], buf[257];
179 ## int id, id2, id3, aid, aid2, status, sid, sid2, sid3, sid4, sid5;
180 struct save_queue *sq;
189 printf("Phase 1 - Looking for duplicates\n");
191 dprintf("Loading strings...\n");
193 strings = create_hash(5000);
194 ## range of s is strings
195 ## retrieve (id = s.string_id, buf = s.string) {
196 s = (struct string *) malloc(sizeof(struct string));
198 out_of_mem("storing strings");
199 s->name = strsave(strtrim(buf));
202 if (hash_store(strings, id, s)) {
203 sq_save_data(sq, hash_lookup(strings, id));
207 generic_delete(sq, show_str_id, "strings", "string_id", 0);
210 dprintf("Loading users...\n");
212 users = create_hash(10000);
213 ## range of u is users
214 ## retrieve (id = u.users_id, name = u.login, last = u.#last,
215 ## first = u.#first, status = u.#status, buf = u.potype,
216 ## id2 = u.pop_id, id3 = u.box_id, sid = u.modby, sid2 = u.fmodby,
217 ## sid3 = u.pmodby, sid4 = u.comment, sid5 = u.sigwho) {
218 u = (struct user *) malloc(sizeof(struct user));
220 out_of_mem("storing users");
221 strcpy(u->login, strtrim(name));
223 sprintf(buf, "%s, %s", strtrim(last), strtrim(first));
224 u->fullname = strsave(buf);
237 if (hash_store(users, id, u)) {
238 sq_save_data(sq, hash_lookup(users, id));
252 generic_fix(sq, show_user_id, "Change ID", fix_user_id, 0);
256 ## retrieve (id = u.users_id)
257 ## where u.login = users.login and u.tid != users.tid {
258 sq_save_data(sq, hash_lookup(users, id));
260 handle_duplicate_logins(sq);
263 dprintf("Loading machines...\n");
264 machines = create_hash(1000);
266 ## range of m is machine
267 ## retrieve (id = m.mach_id, name = m.#name, sid = m.modby) {
268 m = (struct machine *) malloc(sizeof(struct machine));
270 out_of_mem("storing machines");
271 strcpy(m->name, strtrim(name));
274 if (hash_store(machines, id, m)) {
275 sq_save_data(sq, hash_lookup(machines, id));
281 generic_fix(sq, show_mach_id, "Change ID", fix_mach_id, 0);
285 ## retrieve (id = m.mach_id)
286 ## where m.#name = machine.#name and m.tid != machine.tid {
287 sq_save_data(sq, hash_lookup(machines, id));
289 generic_fix(sq, show_mach_name, "Change name", cant_fix, 0);
292 dprintf("Loading clusters...\n");
294 clusters = create_hash(100);
295 ## range of c is cluster
296 ## retrieve (id = c.clu_id, name = c.#name, sid = c.modby) {
297 c = (struct cluster *) malloc(sizeof(struct cluster));
299 out_of_mem("storing clusters");
300 strcpy(c->name, strtrim(name));
302 if (hash_store(clusters, id, c)) {
303 sq_save_data(sq, hash_lookup(clusters, id));
309 generic_fix(sq, show_clu_id, "Change ID", fix_clu_id, 0);
313 ## retrieve (id = c.clu_id)
314 ## where c.#name = cluster.#name and c.tid != cluster.tid {
315 sq_save_data(sq, hash_lookup(clusters, id));
317 generic_fix(sq, show_clu_name, "Change name", cant_fix, 0);
320 dprintf("Loading lists...\n");
322 lists = create_hash(10000);
323 ## range of l is list
324 ## retrieve (id = l.list_id, name = l.#name,
325 ## aid = l.acl_id, buf = l.acl_type, sid = l.modby) {
326 l = (struct list *) malloc(sizeof(struct list));
328 out_of_mem("storing lists");
329 strcpy(l->name, strtrim(name));
330 l->acl_type = buf[0];
334 if (hash_store(lists, id, l)) {
335 sq_save_data(sq, hash_lookup(lists, id));
341 generic_fix(sq, show_list_id, "Change ID", fix_list_id, 0);
345 ## retrieve (id = l.list_id)
346 ## where l.#name = list.#name and l.tid != list.tid {
347 sq_save_data(sq, hash_lookup(lists, id));
349 generic_fix(sq, show_list_name, "Change name", cant_fix, 0);
352 dprintf("Loading filesys...\n");
354 filesys = create_hash(10000);
355 ## retrieve (id = filesys.filsys_id, name = filesys.label, aid = filesys.owner,
356 ## aid2 = filesys.owners, id2 = filesys.phys_id,
357 ## id3 = filesys.mach_id, buf = filesys.type,
358 ## name1 = filesys.#name, sid = filesys.modby) {
359 f = (struct filesys *) malloc(sizeof(struct filesys));
361 out_of_mem("storing filesystems");
362 strcpy(f->name, strtrim(name));
363 strcpy(f->dir, strtrim(name1));
370 if (hash_store(filesys, id, f)) {
371 sq_save_data(sq, hash_lookup(filesys, id));
377 generic_fix(sq, show_fs_id, "Change ID", fix_fs_id, 0);
379 dprintf("Loading nfsphys...\n");
381 nfsphys = create_hash(500);
382 ## retrieve (id = nfsphys.nfsphys_id, name = nfsphys.dir,
383 ## id2 = nfsphys.mach_id, id3 = nfsphys.allocated,
384 ## sid = nfsphys.modby) {
385 n = (struct nfsphys *) malloc(sizeof(struct nfsphys));
387 out_of_mem("storing nfsphys");
388 strcpy(n->dir, strtrim(name));
393 if (hash_store(nfsphys, id, n)) {
394 sq_save_data(sq, hash_lookup(nfsphys, id));
400 generic_fix(sq, show_np_id, "Change ID", fix_np_id, 0);
403 ## range of s is strings
404 ## retrieve (id = s.string_id, buf = s.string)
405 ## where s.string = strings.string and s.tid != strings.tid {
406 printf("String %s(%d) is a duplicate!\n", strtrim(buf), id);
407 printf("Not fixing this error\n");
412 dprintf("Scanning krbmap...\n");
413 ## range of k is krbmap
414 ## retrieve (id = k.users_id)
415 ## where k.users_id = krbmap.users_id and k.tid != krbmap.tid {
416 printf("User %d is in the krbmap more than once!\n", id);
417 printf("Not fixing this error\n");
419 ## retrieve (id = k.string_id)
420 ## where k.string_id = krbmap.string_id and k.tid != krbmap.tid {
421 printf("Principal %d is in the krbmap more than once!\n", id);
422 printf("Not fixing this error\n");