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>
11 static char phase1_qc_rcsid[] = "$Header$";
17 printf("User %s (%s, status %d) has duplicate ID\n",
18 u->login, u->fullname, u->status);
22 handle_duplicate_logins(sq)
23 struct save_queue *sq;
25 struct user *u, *uu, *tmp;
27 uu = (struct user *)0;
28 while (sq_get_data(sq, &u)) {
29 if (!strcmp(u->login, uu->login)) {
30 if (uu->status == 1 || u->status == 0) {
35 printf("User %s (%s, status %d) and\n",
36 u->login, u->fullname, u->status);
37 printf("User %s (%s, status %d) have duplicate logins\n",
38 uu->login, uu->fullname, uu->status);
39 if (!strcmp(u->fullname, uu->fullname) &&
40 single_fix("Delete the second one")) {
41 single_delete("users", "users_id", uu->users_id);
42 } else if (single_fix("Unregister the second one"))
44 ## int id = uu->users_id, rowcount;
46 ## replace users (login = "#"+text(users.uid), status = 0)
47 ## where users.users_id = id
48 ## inquire_equel(rowcount = "rowcount")
50 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
52 printf("Not fixed\n");
64 u->users_id = generic_fix_id("users", "users_id", "login",
65 u->users_id, u->login);
72 printf("Sorry, don't know how to fix that\n");
78 printf("Machine %s has duplicate ID %d\n", m->name, m->mach_id);
85 printf("Machine %s (%d) has duplicate name\n", m->name, m->mach_id);
92 m->mach_id = generic_fix_id("machine", "mach_id", "name",
99 printf("Cluster %s has duplicate ID %d\n", c->name, c->clu_id);
106 printf("Cluster %s (%d) has duplicate name\n", c->name, c->clu_id);
113 c->clu_id = generic_fix_id("cluster", "clu_id", "name", c->clu_id, c->name);
119 printf("List %s has duplicate ID %d\n", l->name, l->list_id);
126 printf("List %s (%d) has duplicate name\n", l->name, l->list_id);
133 l->list_id = generic_fix_id("list", "list_id", "name", l->list_id, l->name);
139 printf("Filesys %s has duplicate ID %d\n", f->name, f->filsys_id);
146 f->filsys_id = generic_fix_id("filesys", "filsys_id", "label",
147 f->filsys_id, f->name);
154 printf("NfsPhys %s:%s has duplicate ID %d\n",
155 ((struct machine *)hash_lookup(machines, n->mach_id))->name,
156 n->dir, n->nfsphys_id);
163 n->nfsphys_id = generic_fix_id("nfsphys", "nfsphys_id", "dir",
164 n->nfsphys_id, n->dir);
170 printf("String %s has duplicate ID %d\n", s->name, s->string_id);
177 ## char name[33], name1[33], last[17], first[17], buf[257];
178 ## int id, id2, id3, aid, aid2, status;
179 struct save_queue *sq;
188 printf("Phase 1 - Looking for duplicates\n");
190 dprintf("Loading users...\n");
192 users = create_hash(10000);
193 ## range of u is users
194 ## retrieve (id = u.users_id, name = u.login, last = u.#last,
195 ## first = u.#first, status = u.#status, buf = u.potype,
196 ## id2 = u.pop_id, id3 = u.box_id) {
197 u = (struct user *) malloc(sizeof(struct user));
198 strcpy(u->login, strtrim(name));
200 sprintf(buf, "%s, %s", strtrim(last), strtrim(first));
201 u->fullname = strsave(buf);
214 if (hash_store(users, id, u)) {
215 sq_save_data(sq, hash_lookup(users, id));
219 generic_fix(sq, show_user_id, "Change ID", fix_user_id, 0);
223 ## retrieve (id = u.users_id)
224 ## where u.login = users.login and u.tid != users.tid {
225 sq_save_data(sq, hash_lookup(users, id));
227 handle_duplicate_logins(sq);
230 dprintf("Loading machines...\n");
231 machines = create_hash(1000);
233 ## range of m is machine
234 ## retrieve (id = m.mach_id, name = m.#name) {
235 m = (struct machine *) malloc(sizeof(struct machine));
236 strcpy(m->name, strtrim(name));
239 if (hash_store(machines, id, m)) {
240 sq_save_data(sq, hash_lookup(machines, id));
244 generic_fix(sq, show_mach_id, "Change ID", fix_mach_id, 0);
248 ## retrieve (id = m.mach_id)
249 ## where m.#name = machine.#name and m.tid != machine.tid {
250 sq_save_data(sq, hash_lookup(machines, id));
252 generic_fix(sq, show_mach_name, "Change name", cant_fix, 0);
255 dprintf("Loading clusters...\n");
257 clusters = create_hash(100);
258 ## range of c is cluster
259 ## retrieve (id = cluster.clu_id, name = cluster.#name) {
260 c = (struct cluster *) malloc(sizeof(struct cluster));
261 strcpy(c->name, strtrim(name));
263 if (hash_store(clusters, id, c)) {
264 sq_save_data(sq, hash_lookup(clusters, id));
268 generic_fix(sq, show_clu_id, "Change ID", fix_clu_id, 0);
272 ## retrieve (id = c.clu_id)
273 ## where c.#name = cluster.#name and c.tid != cluster.tid {
274 sq_save_data(sq, hash_lookup(clusters, id));
276 generic_fix(sq, show_clu_name, "Change name", cant_fix, 0);
279 dprintf("Loading lists...\n");
281 lists = create_hash(10000);
282 ## range of l is list
283 ## retrieve (id = l.list_id, name = l.#name,
284 ## aid = l.acl_id, buf = l.acl_type) {
285 l = (struct list *) malloc(sizeof(struct list));
286 strcpy(l->name, strtrim(name));
287 l->acl_type = buf[0];
291 if (hash_store(lists, id, l)) {
292 sq_save_data(sq, hash_lookup(lists, id));
296 generic_fix(sq, show_list_id, "Change ID", fix_list_id, 0);
300 ## retrieve (id = l.list_id)
301 ## where l.#name = list.#name and l.tid != list.tid {
302 sq_save_data(sq, hash_lookup(lists, id));
304 generic_fix(sq, show_list_name, "Change name", cant_fix, 0);
307 dprintf("Loading filesys...\n");
309 filesys = create_hash(10000);
310 ## retrieve (id = filesys.filsys_id, name = filesys.label, aid = filesys.owner,
311 ## aid2 = filesys.owners, id2 = filesys.phys_id,
312 ## id3 = filesys.mach_id, buf = filesys.type,
313 ## name1 = filesys.#name) {
314 f = (struct filesys *) malloc(sizeof(struct filesys));
315 strcpy(f->name, strtrim(name));
316 strcpy(f->dir, strtrim(name1));
323 if (hash_store(filesys, id, f)) {
324 sq_save_data(sq, hash_lookup(filesys, id));
328 generic_fix(sq, show_fs_id, "Change ID", fix_fs_id, 0);
330 dprintf("Loading nfsphys...\n");
332 nfsphys = create_hash(500);
333 ## retrieve (id = nfsphys.nfsphys_id, name = nfsphys.dir,
334 ## id2 = nfsphys.mach_id, id3 = nfsphys.allocated) {
335 n = (struct nfsphys *) malloc(sizeof(struct nfsphys));
336 strcpy(n->dir, strtrim(name));
341 if (hash_store(nfsphys, id, n)) {
342 sq_save_data(sq, hash_lookup(nfsphys, id));
346 generic_fix(sq, show_np_id, "Change ID", fix_np_id, 0);
348 dprintf("Loading strings...\n");
350 strings = create_hash(5000);
351 ## range of s is strings
352 ## retrieve (id = s.string_id, buf = s.string) {
353 s = (struct string *) malloc(sizeof(struct string));
354 s->name = strsave(strtrim(buf));
357 if (hash_store(strings, id, s)) {
358 sq_save_data(sq, hash_lookup(strings, id));
362 generic_delete(sq, show_str_id, "strings", "string_id", 0);
365 ## retrieve (id = s.string_id, buf = s.string)
366 ## where s.string = strings.string and s.tid != strings.tid {
367 printf("String %s(%d) is a duplicate!\n", strtrim(buf), id);
368 printf("Not fixing this error\n");