1 | /* |
---|
2 | * |
---|
3 | * pt_util: Program to dump the AFS protection server database |
---|
4 | * into an ascii file. |
---|
5 | * |
---|
6 | * Assumptions: We *cheat* here and read the datafile directly, ie. |
---|
7 | * not going through the ubik distributed data manager. |
---|
8 | * therefore the database must be quiescent for the |
---|
9 | * output of this program to be valid. |
---|
10 | */ |
---|
11 | |
---|
12 | #include <sys/types.h> |
---|
13 | #include <sys/time.h> |
---|
14 | #include <stdio.h> |
---|
15 | #include <ctype.h> |
---|
16 | #include <string.h> |
---|
17 | #include <sys/file.h> |
---|
18 | #include <stdlib.h> |
---|
19 | #include <errno.h> |
---|
20 | |
---|
21 | #include <afs/param.h> |
---|
22 | #include <lock.h> |
---|
23 | #include <netinet/in.h> |
---|
24 | #define UBIK_INTERNALS |
---|
25 | #include <ubik.h> |
---|
26 | #include <rx/xdr.h> |
---|
27 | #include <rx/rx.h> |
---|
28 | #include "ptint.h" |
---|
29 | #include "ptserver.h" |
---|
30 | #include "pterror.h" |
---|
31 | #include "vis.h" |
---|
32 | |
---|
33 | #define IDHash(x) (abs(x) % HASHSIZE) |
---|
34 | |
---|
35 | int display_entry(int offset); |
---|
36 | int print_id(int id); |
---|
37 | void add_group(long id); |
---|
38 | void display_groups(void); |
---|
39 | void display_group(int id); |
---|
40 | void fix_pre(struct prentry *pre); |
---|
41 | char *checkin(struct prentry *pre); |
---|
42 | char *check_core(register int id); |
---|
43 | char *id_to_name(int id); |
---|
44 | |
---|
45 | struct hash_entry { |
---|
46 | char h_name[PR_MAXNAMELEN]; |
---|
47 | int h_id; |
---|
48 | struct hash_entry *next; |
---|
49 | }; |
---|
50 | struct hash_entry *hat[HASHSIZE]; |
---|
51 | |
---|
52 | static struct contentry prco; |
---|
53 | static struct prentry pre; |
---|
54 | static struct prheader prh; |
---|
55 | static struct ubik_version uv; |
---|
56 | |
---|
57 | struct grp_list { |
---|
58 | struct grp_list *next; |
---|
59 | long groups[1024]; |
---|
60 | }; |
---|
61 | static struct grp_list *grp_head=0; |
---|
62 | static long grp_count=0; |
---|
63 | |
---|
64 | struct usr_list { |
---|
65 | struct usr_list *next; |
---|
66 | char name[PR_MAXNAMELEN]; |
---|
67 | long uid; |
---|
68 | }; |
---|
69 | static struct usr_list *usr_head=0; |
---|
70 | |
---|
71 | char buffer[1024]; |
---|
72 | int dbase_fd; |
---|
73 | FILE *dfp; |
---|
74 | |
---|
75 | #define FMT_BASE "%-10s %d/%d %d %d %d\n" |
---|
76 | #define FMT_MEM " %-8s %d\n" |
---|
77 | |
---|
78 | #define DO_USR 1 |
---|
79 | #define DO_GRP 2 |
---|
80 | #define DO_MEM 4 |
---|
81 | #define DO_SYS 8 |
---|
82 | #define DO_OTR 16 |
---|
83 | |
---|
84 | int nflag = 0; |
---|
85 | int wflag = 0; |
---|
86 | int flags = 0; |
---|
87 | |
---|
88 | int main(int argc, char **argv) |
---|
89 | { |
---|
90 | register int i; |
---|
91 | register long code; |
---|
92 | long cc, upos, gpos; |
---|
93 | struct prentry uentry, gentry; |
---|
94 | struct ubik_hdr *uh; |
---|
95 | char *dfile = 0; |
---|
96 | char *pfile = "/usr/afs/db/prdb.DB0"; |
---|
97 | char *str; |
---|
98 | |
---|
99 | while ((cc = getopt(argc, argv, "wugmxsnp:d:")) != EOF) { |
---|
100 | switch (cc) { |
---|
101 | case 'p': |
---|
102 | pfile = optarg; |
---|
103 | break; |
---|
104 | case 'd': |
---|
105 | dfile = optarg; |
---|
106 | break; |
---|
107 | case 'n': |
---|
108 | nflag++; |
---|
109 | break; |
---|
110 | case 'w': |
---|
111 | wflag++; |
---|
112 | break; |
---|
113 | case 'u': |
---|
114 | flags |= DO_USR; |
---|
115 | break; |
---|
116 | case 'm': |
---|
117 | flags |= (DO_GRP|DO_MEM); |
---|
118 | break; |
---|
119 | case 'g': |
---|
120 | flags |= DO_GRP; |
---|
121 | break; |
---|
122 | case 's': |
---|
123 | flags |= DO_SYS; |
---|
124 | break; |
---|
125 | case 'x': |
---|
126 | flags |= DO_OTR; |
---|
127 | break; |
---|
128 | default: |
---|
129 | fprintf(stderr, |
---|
130 | "Usage: pt_util [options] [-d data] [-p prdb]\n"); |
---|
131 | fputs(" Options:\n", stderr); |
---|
132 | fputs(" -w Update prdb with contents of data file\n", stderr); |
---|
133 | fputs(" -u Display users\n", stderr); |
---|
134 | fputs(" -g Display groups\n", stderr); |
---|
135 | fputs(" -m Display group members\n", stderr); |
---|
136 | fputs(" -n Follow name hash chains (not id hashes)\n", stderr); |
---|
137 | fputs(" -s Display only system (Moira) data\n", stderr); |
---|
138 | fputs(" -x Display extra users/groups\n", stderr); |
---|
139 | exit(1); |
---|
140 | } |
---|
141 | } |
---|
142 | if ((dbase_fd = open(pfile, wflag ? O_RDWR : O_RDONLY, 0600)) < 0) { |
---|
143 | fprintf(stderr, "pt_util: cannot open %s: %s\n", |
---|
144 | pfile, strerror(errno)); |
---|
145 | exit (1); |
---|
146 | } |
---|
147 | if (read(dbase_fd, buffer, HDRSIZE) < 0) { |
---|
148 | fprintf(stderr, "pt_util: error reading %s: %s\n", |
---|
149 | pfile, strerror(errno)); |
---|
150 | exit (1); |
---|
151 | } |
---|
152 | |
---|
153 | if (dfile) { |
---|
154 | if ((dfp = fopen(dfile, wflag ? "r" : "w")) == 0) { |
---|
155 | fprintf(stderr, "pt_util: error opening %s: %s\n", |
---|
156 | dfile, strerror(errno)); |
---|
157 | exit(1); |
---|
158 | } |
---|
159 | } else |
---|
160 | dfp = (wflag ? stdin : stdout); |
---|
161 | |
---|
162 | uh = (struct ubik_hdr *)buffer; |
---|
163 | if (ntohl(uh->magic) != UBIK_MAGIC) |
---|
164 | fprintf(stderr, "pt_util: %s: Bad UBIK_MAGIC. Is %x should be %x\n", |
---|
165 | pfile, ntohl(uh->magic), UBIK_MAGIC); |
---|
166 | memcpy(&uv, &uh->version, sizeof(struct ubik_version)); |
---|
167 | if (wflag && uv.epoch==0 && uv.counter==0) { |
---|
168 | uv.epoch=2; /* a ubik version of 0 or 1 has special meaning */ |
---|
169 | memcpy(&uh->version, &uv, sizeof(struct ubik_version)); |
---|
170 | lseek(dbase_fd, 0, SEEK_SET); |
---|
171 | if (write(dbase_fd, buffer, HDRSIZE) < 0) { |
---|
172 | fprintf(stderr, "pt_util: error writing ubik version to %s: %s\n", |
---|
173 | pfile, strerror(errno)); |
---|
174 | exit (1); |
---|
175 | } |
---|
176 | } |
---|
177 | fprintf(stderr, "Ubik Version is: %d.%d\n", |
---|
178 | uv.epoch, uv.counter); |
---|
179 | if (read(dbase_fd, &prh, sizeof(struct prheader)) < 0) { |
---|
180 | fprintf(stderr, "pt_util: error reading %s: %s\n", |
---|
181 | pfile, strerror(errno)); |
---|
182 | exit (1); |
---|
183 | } |
---|
184 | |
---|
185 | Initdb(); |
---|
186 | initialize_pt_error_table(); |
---|
187 | |
---|
188 | if (wflag) { |
---|
189 | struct usr_list *u; |
---|
190 | |
---|
191 | while(fgets(buffer, sizeof(buffer), dfp)) { |
---|
192 | int id, oid, cid, flags, quota, uid; |
---|
193 | char name[PR_MAXNAMELEN], mem[PR_MAXNAMELEN]; |
---|
194 | |
---|
195 | if (isspace(*buffer)) { |
---|
196 | sscanf(buffer, "%s %d", mem, &uid); |
---|
197 | |
---|
198 | for (u=usr_head; u; u=u->next) |
---|
199 | if (u->uid && u->uid==uid) break; |
---|
200 | if (u) { |
---|
201 | /* Add user - deferred because it is probably foreign */ |
---|
202 | u->uid = 0; |
---|
203 | if (FindByID(0, uid)) |
---|
204 | code = PRIDEXIST; |
---|
205 | else { |
---|
206 | if (!code && (flags&(PRGRP|PRQUOTA))==(PRGRP|PRQUOTA)){ |
---|
207 | gentry.ngroups++; |
---|
208 | code = pr_WriteEntry(0,0,gpos,&gentry); |
---|
209 | if (code) |
---|
210 | fprintf(stderr, "Error setting group count on %s: %s\n", |
---|
211 | name, error_message(code)); |
---|
212 | } |
---|
213 | code = CreateEntry |
---|
214 | (0, u->name, &uid, 1/*idflag*/, 1/*gflag*/, |
---|
215 | SYSADMINID/*oid*/, SYSADMINID/*cid*/); |
---|
216 | } |
---|
217 | if (code) |
---|
218 | fprintf(stderr, "Error while creating %s: %s\n", |
---|
219 | u->name, error_message(code)); |
---|
220 | continue; |
---|
221 | } |
---|
222 | /* Add user to group */ |
---|
223 | if (id==ANYUSERID || id==AUTHUSERID || uid==ANONYMOUSID) { |
---|
224 | code = PRPERM; |
---|
225 | } else if ((upos=FindByID(0,uid)) && (gpos=FindByID(0,id))) { |
---|
226 | code = pr_ReadEntry(0,0,upos,&uentry); |
---|
227 | if (!code) code = pr_ReadEntry(0,0,gpos,&gentry); |
---|
228 | if (!code) code = AddToEntry (0, &gentry, gpos, uid); |
---|
229 | if (!code) code = AddToEntry (0, &uentry, upos, id); |
---|
230 | } else |
---|
231 | code = PRNOENT; |
---|
232 | |
---|
233 | if (code) |
---|
234 | fprintf(stderr, "Error while adding %s to %s: %s\n", |
---|
235 | mem, name, error_message(code)); |
---|
236 | } else { |
---|
237 | sscanf(buffer, "%s %d/%d %d %d %d", |
---|
238 | name, &flags, "a, &id, &oid, &cid); |
---|
239 | |
---|
240 | str = malloc(strlen(name) + 1); |
---|
241 | if (!str) |
---|
242 | { |
---|
243 | fprintf(stderr, "malloc failed!"); |
---|
244 | exit(1); |
---|
245 | } |
---|
246 | strunvis(str, name); |
---|
247 | strncpy(name, str, PR_MAXNAMELEN); |
---|
248 | name[PR_MAXNAMELEN] = '\0'; |
---|
249 | if (FindByID(0, id)) |
---|
250 | code = PRIDEXIST; |
---|
251 | else |
---|
252 | code = CreateEntry(0, name, &id, 1/*idflag*/, |
---|
253 | flags&PRGRP, oid, cid); |
---|
254 | if (code == PRBADNAM) { |
---|
255 | u = (struct usr_list *)malloc(sizeof(struct usr_list)); |
---|
256 | u->next = usr_head; |
---|
257 | u->uid = id; |
---|
258 | strcpy(u->name, name); |
---|
259 | usr_head = u; |
---|
260 | } else |
---|
261 | if (code) { |
---|
262 | fprintf(stderr, "Error while creating %s: %s\n", |
---|
263 | name, error_message(code)); |
---|
264 | } else if ((flags&PRACCESS) || |
---|
265 | (flags&(PRGRP|PRQUOTA))==(PRGRP|PRQUOTA)) { |
---|
266 | gpos = FindByID(0, id); |
---|
267 | code = pr_ReadEntry(0,0,gpos,&gentry); |
---|
268 | if (!code) { |
---|
269 | gentry.flags = flags; |
---|
270 | gentry.ngroups = quota; |
---|
271 | code = pr_WriteEntry(0,0,gpos,&gentry); |
---|
272 | } |
---|
273 | if (code) |
---|
274 | fprintf(stderr,"Error while setting flags on %s: %s\n", |
---|
275 | name, error_message(code)); |
---|
276 | } |
---|
277 | } |
---|
278 | } |
---|
279 | for (u=usr_head; u; u=u->next) |
---|
280 | if (u->uid) |
---|
281 | fprintf(stderr, "Error while creating %s: %s\n", |
---|
282 | u->name, error_message(PRBADNAM)); |
---|
283 | } else { |
---|
284 | for (i = 0; i < HASHSIZE; i++) { |
---|
285 | upos = nflag ? ntohl(prh.nameHash[i]) : ntohl(prh.idHash[i]); |
---|
286 | while (upos) |
---|
287 | upos = display_entry(upos); |
---|
288 | } |
---|
289 | if (flags & DO_GRP) |
---|
290 | display_groups(); |
---|
291 | } |
---|
292 | |
---|
293 | lseek (dbase_fd, 0, L_SET); /* rewind to beginning of file */ |
---|
294 | if (read(dbase_fd, buffer, HDRSIZE) < 0) { |
---|
295 | fprintf(stderr, "pt_util: error reading %s: %s\n", |
---|
296 | pfile, strerror(errno)); |
---|
297 | exit (1); |
---|
298 | } |
---|
299 | uh = (struct ubik_hdr *)buffer; |
---|
300 | if ((uh->version.epoch != uv.epoch) || |
---|
301 | (uh->version.counter != uv.counter)) { |
---|
302 | fprintf(stderr, "pt_util: Ubik Version number changed during execution.\n"); |
---|
303 | fprintf(stderr, "Old Version = %d.%d, new version = %d.%d\n", |
---|
304 | uv.epoch, uv.counter, uh->version.epoch, |
---|
305 | uh->version.counter); |
---|
306 | } |
---|
307 | close (dbase_fd); |
---|
308 | exit (0); |
---|
309 | } |
---|
310 | |
---|
311 | int display_entry(int offset) |
---|
312 | { |
---|
313 | register int i; |
---|
314 | |
---|
315 | lseek (dbase_fd, offset+HDRSIZE, L_SET); |
---|
316 | read(dbase_fd, &pre, sizeof(struct prentry)); |
---|
317 | |
---|
318 | fix_pre(&pre); |
---|
319 | |
---|
320 | if ((pre.flags & PRFREE) == 0) { |
---|
321 | if (pre.flags & PRGRP) { |
---|
322 | if (flags & DO_GRP) |
---|
323 | add_group(pre.id); |
---|
324 | } else { |
---|
325 | if (print_id(pre.id) && (flags&DO_USR)) |
---|
326 | fprintf(dfp, FMT_BASE, |
---|
327 | pre.name, pre.flags, pre.ngroups, |
---|
328 | pre.id, pre.owner, pre.creator); |
---|
329 | checkin(&pre); |
---|
330 | } |
---|
331 | } |
---|
332 | return(nflag ? pre.nextName: pre.nextID); |
---|
333 | } |
---|
334 | |
---|
335 | void add_group(long id) |
---|
336 | { |
---|
337 | struct grp_list *g; |
---|
338 | register long i; |
---|
339 | |
---|
340 | i = grp_count++ % 1024; |
---|
341 | if (i == 0) { |
---|
342 | g = (struct grp_list *)malloc(sizeof(struct grp_list)); |
---|
343 | g->next = grp_head; |
---|
344 | grp_head = g; |
---|
345 | } |
---|
346 | g = grp_head; |
---|
347 | g->groups[i] = id; |
---|
348 | } |
---|
349 | |
---|
350 | void display_groups(void) |
---|
351 | { |
---|
352 | register int i, id; |
---|
353 | struct grp_list *g; |
---|
354 | |
---|
355 | g = grp_head; |
---|
356 | while (grp_count--) { |
---|
357 | i = grp_count%1024; |
---|
358 | id = g->groups[i]; |
---|
359 | display_group(id); |
---|
360 | if (i==0) { |
---|
361 | grp_head = g->next; |
---|
362 | free(g); |
---|
363 | g = grp_head; |
---|
364 | } |
---|
365 | } |
---|
366 | } |
---|
367 | |
---|
368 | void display_group(int id) |
---|
369 | { |
---|
370 | register int i, offset; |
---|
371 | int print_grp = 0; |
---|
372 | |
---|
373 | offset = ntohl(prh.idHash[IDHash(id)]); |
---|
374 | while (offset) { |
---|
375 | lseek(dbase_fd, offset+HDRSIZE, L_SET); |
---|
376 | if (read(dbase_fd, &pre, sizeof(struct prentry)) < 0) { |
---|
377 | fprintf(stderr, "pt_util: read i/o error: %s\n", |
---|
378 | strerror(errno)); |
---|
379 | exit (1); |
---|
380 | } |
---|
381 | fix_pre(&pre); |
---|
382 | if (pre.id == id) |
---|
383 | break; |
---|
384 | offset = pre.nextID; |
---|
385 | } |
---|
386 | |
---|
387 | if (print_id(id)) { |
---|
388 | fprintf(dfp, FMT_BASE, |
---|
389 | pre.name, pre.flags, pre.ngroups, |
---|
390 | pre.id, pre.owner, pre.creator); |
---|
391 | print_grp = 1; |
---|
392 | } |
---|
393 | |
---|
394 | if ((flags&DO_MEM) == 0) |
---|
395 | return; |
---|
396 | |
---|
397 | for (i=0; i<PRSIZE; i++) { |
---|
398 | if ((id=pre.entries[i]) == 0) |
---|
399 | break; |
---|
400 | if (id==PRBADID) continue; |
---|
401 | if (print_id(id) || print_grp==1) { |
---|
402 | if (print_grp==0) { |
---|
403 | fprintf(dfp, FMT_BASE, |
---|
404 | pre.name, pre.flags, pre.ngroups, |
---|
405 | pre.id, pre.owner, pre.creator); |
---|
406 | print_grp = 2; |
---|
407 | } |
---|
408 | fprintf(dfp, FMT_MEM, id_to_name(id), id); |
---|
409 | } |
---|
410 | } |
---|
411 | if (i == PRSIZE) { |
---|
412 | offset = pre.next; |
---|
413 | while (offset) { |
---|
414 | lseek(dbase_fd, offset+HDRSIZE, L_SET); |
---|
415 | read(dbase_fd, &prco, sizeof(struct contentry)); |
---|
416 | prco.next = ntohl(prco.next); |
---|
417 | for (i = 0; i < COSIZE; i++) { |
---|
418 | prco.entries[i] = ntohl(prco.entries[i]); |
---|
419 | if ((id=prco.entries[i]) == 0) |
---|
420 | break; |
---|
421 | if (id==PRBADID) continue; |
---|
422 | if (print_id(id) || print_grp==1) { |
---|
423 | if (print_grp==0) { |
---|
424 | fprintf(dfp, FMT_BASE, |
---|
425 | pre.name, pre.flags, pre.ngroups, |
---|
426 | pre.id, pre.owner, pre.creator); |
---|
427 | print_grp = 2; |
---|
428 | } |
---|
429 | fprintf(dfp, FMT_MEM, id_to_name(id), id); |
---|
430 | } |
---|
431 | } |
---|
432 | if ((i == COSIZE) && prco.next) |
---|
433 | offset = prco.next; |
---|
434 | else offset = 0; |
---|
435 | } |
---|
436 | } |
---|
437 | } |
---|
438 | |
---|
439 | void fix_pre(struct prentry *pre) |
---|
440 | { |
---|
441 | register int i; |
---|
442 | char *str = malloc(4 * strlen(pre->name) + 1); |
---|
443 | |
---|
444 | if (!str) |
---|
445 | { |
---|
446 | fprintf(stderr, "malloc failed in fix_pre()!"); |
---|
447 | exit(1); |
---|
448 | } |
---|
449 | strvis(str, pre->name, VIS_WHITE); |
---|
450 | if (strlen(str) > PR_MAXNAMELEN) |
---|
451 | { |
---|
452 | fprintf(stderr, "encoding greater than PR_MAXNAMELEN!\n"); |
---|
453 | fprintf(stderr, "groupname %s will not be encoded!\n", pre->name); |
---|
454 | } |
---|
455 | else |
---|
456 | { |
---|
457 | strncpy(pre->name, str, PR_MAXNAMELEN); |
---|
458 | pre->name[PR_MAXNAMELEN] = '\0'; |
---|
459 | } |
---|
460 | pre->flags = ntohl(pre->flags); |
---|
461 | pre->id = ntohl(pre->id); |
---|
462 | pre->cellid = ntohl(pre->cellid); |
---|
463 | pre->next = ntohl(pre->next); |
---|
464 | pre->nextID = ntohl(pre->nextID); |
---|
465 | pre->nextName = ntohl(pre->nextName); |
---|
466 | pre->owner = ntohl(pre->owner); |
---|
467 | pre->creator = ntohl(pre->creator); |
---|
468 | pre->ngroups = ntohl(pre->ngroups); |
---|
469 | pre->nusers = ntohl(pre->nusers); |
---|
470 | pre->count = ntohl(pre->count); |
---|
471 | pre->instance = ntohl(pre->instance); |
---|
472 | pre->owned = ntohl(pre->owned); |
---|
473 | pre->nextOwned = ntohl(pre->nextOwned); |
---|
474 | pre->parent = ntohl(pre->parent); |
---|
475 | pre->sibling = ntohl(pre->sibling); |
---|
476 | pre->child = ntohl(pre->child); |
---|
477 | for (i = 0; i < PRSIZE; i++) { |
---|
478 | pre->entries[i] = ntohl(pre->entries[i]); |
---|
479 | } |
---|
480 | } |
---|
481 | |
---|
482 | char *id_to_name(int id) |
---|
483 | { |
---|
484 | register int offset; |
---|
485 | static struct prentry pre; |
---|
486 | char *name; |
---|
487 | |
---|
488 | name = check_core(id); |
---|
489 | if (name) return(name); |
---|
490 | offset = ntohl(prh.idHash[IDHash(id)]); |
---|
491 | while (offset) { |
---|
492 | lseek(dbase_fd, offset+HDRSIZE, L_SET); |
---|
493 | if (read(dbase_fd, &pre, sizeof(struct prentry)) < 0) { |
---|
494 | fprintf(stderr, "pt_util: read i/o error: %s\n", |
---|
495 | strerror(errno)); |
---|
496 | exit (1); |
---|
497 | } |
---|
498 | pre.id = ntohl(pre.id); |
---|
499 | if (pre.id == id) { |
---|
500 | name = checkin(&pre); |
---|
501 | return(name); |
---|
502 | } |
---|
503 | offset = ntohl(pre.nextID); |
---|
504 | } |
---|
505 | return 0; |
---|
506 | } |
---|
507 | |
---|
508 | char *checkin(struct prentry *pre) |
---|
509 | { |
---|
510 | struct hash_entry *he, *last; |
---|
511 | register int id; |
---|
512 | |
---|
513 | id = pre->id; |
---|
514 | last = (struct hash_entry *)0; |
---|
515 | he = hat[IDHash(id)]; |
---|
516 | while (he) { |
---|
517 | if (id == he->h_id) return(he->h_name); |
---|
518 | last = he; |
---|
519 | he = he->next; |
---|
520 | } |
---|
521 | he = (struct hash_entry *)malloc(sizeof(struct hash_entry)); |
---|
522 | if (he == 0) { |
---|
523 | fprintf(stderr, "pt_util: No Memory for internal hash table.\n"); |
---|
524 | exit (1); |
---|
525 | } |
---|
526 | he->h_id = id; |
---|
527 | he->next = (struct hash_entry *)0; |
---|
528 | strncpy(he->h_name, pre->name, PR_MAXNAMELEN); |
---|
529 | if (last == (struct hash_entry *)0) hat[IDHash(id)] = he; |
---|
530 | else last->next = he; |
---|
531 | return(he->h_name); |
---|
532 | } |
---|
533 | |
---|
534 | char *check_core(register int id) |
---|
535 | { |
---|
536 | struct hash_entry *he; |
---|
537 | he = hat[IDHash(id)]; |
---|
538 | while (he) { |
---|
539 | if (id == he->h_id) return(he->h_name); |
---|
540 | he = he->next; |
---|
541 | } |
---|
542 | return 0; |
---|
543 | } |
---|
544 | |
---|
545 | /* returns 1 if the id value should be printered, otherwise 0 */ |
---|
546 | int print_id(int id) |
---|
547 | { |
---|
548 | /* process system (Moira) users */ |
---|
549 | if (flags & DO_SYS) |
---|
550 | { |
---|
551 | /* hard-coded list of IDs in the system id space that aren't actually |
---|
552 | * system users. Skip them here. Mmm, legacies. |
---|
553 | */ |
---|
554 | switch (id) |
---|
555 | { |
---|
556 | case -65541: |
---|
557 | case -65542: |
---|
558 | case -65544: |
---|
559 | case -65546: |
---|
560 | case -65548: |
---|
561 | case -65549: |
---|
562 | case -65551: |
---|
563 | case -65557: |
---|
564 | case -65563: |
---|
565 | case -65574: |
---|
566 | case -65576: |
---|
567 | case -65578: |
---|
568 | case -65579: |
---|
569 | case -65582: |
---|
570 | case -97536: |
---|
571 | case -97537: |
---|
572 | case -97538: |
---|
573 | case -98766: |
---|
574 | case -98775: |
---|
575 | case -98781: |
---|
576 | case -98782: |
---|
577 | case -98783: |
---|
578 | case -98784: |
---|
579 | case -98785: |
---|
580 | case -98786: |
---|
581 | case -98787: |
---|
582 | case -98788: |
---|
583 | case -98789: |
---|
584 | case -98792: |
---|
585 | case -98813: |
---|
586 | case -98815: |
---|
587 | case -98816: |
---|
588 | case -98818: |
---|
589 | case -98819: |
---|
590 | case -98820: |
---|
591 | case -98821: |
---|
592 | case -98828: |
---|
593 | case -98829: |
---|
594 | case -98830: |
---|
595 | case -98835: |
---|
596 | case -98836: |
---|
597 | case -98837: |
---|
598 | case -98841: |
---|
599 | case -98842: |
---|
600 | case -98844: |
---|
601 | case -98845: |
---|
602 | case -98846: |
---|
603 | case -98847: |
---|
604 | case -98848: |
---|
605 | case -98849: |
---|
606 | case -98851: |
---|
607 | case -98854: |
---|
608 | case -98855: |
---|
609 | case -98856: |
---|
610 | case -98857: |
---|
611 | case -98859: |
---|
612 | case -98867: |
---|
613 | case -98868: |
---|
614 | case -98869: |
---|
615 | case -98870: |
---|
616 | case -98871: |
---|
617 | case -98873: |
---|
618 | case -98878: |
---|
619 | case -98879: |
---|
620 | case -98883: |
---|
621 | case -98884: |
---|
622 | case -98885: |
---|
623 | case -98888: |
---|
624 | case -98891: |
---|
625 | case -98898: |
---|
626 | case -98903: |
---|
627 | case -98905: |
---|
628 | case -98914: |
---|
629 | case -98918: |
---|
630 | case -98919: |
---|
631 | case -98920: |
---|
632 | case -98923: |
---|
633 | case -98927: |
---|
634 | case -98941: |
---|
635 | case -98942: |
---|
636 | case -98945: |
---|
637 | case -98948: |
---|
638 | case -98949: |
---|
639 | case -98951: |
---|
640 | case -98952: |
---|
641 | case -98953: |
---|
642 | case -98956: |
---|
643 | case -98957: |
---|
644 | case -98960: |
---|
645 | case -98961: |
---|
646 | case -98963: |
---|
647 | case -98966: |
---|
648 | case -98994: |
---|
649 | case -98996: |
---|
650 | case -98998: |
---|
651 | case -99000: |
---|
652 | case -99001: |
---|
653 | case -99002: |
---|
654 | case -99003: |
---|
655 | case -99004: |
---|
656 | case -99005: |
---|
657 | case -99006: |
---|
658 | case -99007: |
---|
659 | case -99008: |
---|
660 | case -99009: |
---|
661 | case -99010: |
---|
662 | case -99011: |
---|
663 | case -99012: |
---|
664 | case -99013: |
---|
665 | case -99014: |
---|
666 | case -99015: |
---|
667 | case -99016: |
---|
668 | case -99017: |
---|
669 | case -99018: |
---|
670 | case -99019: |
---|
671 | case -99023: |
---|
672 | case -99029: |
---|
673 | case -99030: |
---|
674 | case -99042: |
---|
675 | case -99048: |
---|
676 | case -99056: |
---|
677 | case -99057: |
---|
678 | case -99058: |
---|
679 | case -99059: |
---|
680 | case -99063: |
---|
681 | case -99064: |
---|
682 | case -99076: |
---|
683 | case -99079: |
---|
684 | case -99090: |
---|
685 | case -99091: |
---|
686 | case -99105: |
---|
687 | case -99106: |
---|
688 | case -99113: |
---|
689 | case -99114: |
---|
690 | case -99115: |
---|
691 | case -99116: |
---|
692 | case -99118: |
---|
693 | case -99120: |
---|
694 | case -99121: |
---|
695 | case -99129: |
---|
696 | case -99130: |
---|
697 | case -99131: |
---|
698 | case -99133: |
---|
699 | case -99146: |
---|
700 | case -99150: |
---|
701 | case -99153: |
---|
702 | case -99154: |
---|
703 | case -99193: |
---|
704 | case -99194: |
---|
705 | case -99200: |
---|
706 | case -99205: |
---|
707 | case -99211: |
---|
708 | case -99214: |
---|
709 | case -99218: |
---|
710 | case -99220: |
---|
711 | case -99223: |
---|
712 | case -99224: |
---|
713 | case -99225: |
---|
714 | case -99233: |
---|
715 | case -99234: |
---|
716 | case -99236: |
---|
717 | case -99237: |
---|
718 | case -99242: |
---|
719 | case -99245: |
---|
720 | case -99250: |
---|
721 | case -99252: |
---|
722 | case -99253: |
---|
723 | case -99254: |
---|
724 | case -99255: |
---|
725 | case -99259: |
---|
726 | case -99260: |
---|
727 | case -99263: |
---|
728 | case -99264: |
---|
729 | case -99267: |
---|
730 | case -99284: |
---|
731 | case -99287: |
---|
732 | case -99289: |
---|
733 | case -99295: |
---|
734 | case -99297: |
---|
735 | case -99307: |
---|
736 | case -99308: |
---|
737 | case -99309: |
---|
738 | case -99310: |
---|
739 | case -99311: |
---|
740 | case -99315: |
---|
741 | case -99317: |
---|
742 | case -99327: |
---|
743 | case -99334: |
---|
744 | case -99344: |
---|
745 | case -99348: |
---|
746 | case -99349: |
---|
747 | case -99354: |
---|
748 | case -99366: |
---|
749 | case -99367: |
---|
750 | case -99370: |
---|
751 | case -99371: |
---|
752 | case -99372: |
---|
753 | case -99373: |
---|
754 | case -99377: |
---|
755 | case -99378: |
---|
756 | case -99379: |
---|
757 | case 65613: |
---|
758 | case 65678: |
---|
759 | case 65770: |
---|
760 | case 65896: |
---|
761 | case 65971: |
---|
762 | case 65987: |
---|
763 | case 66011: |
---|
764 | case 66114: |
---|
765 | case 66142: |
---|
766 | case 67145: |
---|
767 | case 67299: |
---|
768 | case 67393: |
---|
769 | case 67669: |
---|
770 | case 67712: |
---|
771 | case 67903: |
---|
772 | case 68276: |
---|
773 | case 68421: |
---|
774 | case 68467: |
---|
775 | case 69005: |
---|
776 | case 69143: |
---|
777 | case 69234: |
---|
778 | case 69611: |
---|
779 | case 70141: |
---|
780 | case 70481: |
---|
781 | case 71468: |
---|
782 | case 71559: |
---|
783 | case 71689: |
---|
784 | case 72203: |
---|
785 | case 72775: |
---|
786 | case 72799: |
---|
787 | case 73319: |
---|
788 | case 73348: |
---|
789 | case 73578: |
---|
790 | case 73642: |
---|
791 | case 73656: |
---|
792 | case 74424: |
---|
793 | case 74610: |
---|
794 | case 75067: |
---|
795 | case 75169: |
---|
796 | case 75197: |
---|
797 | case 75332: |
---|
798 | case 75717: |
---|
799 | case 76261: |
---|
800 | case 76322: |
---|
801 | case 76341: |
---|
802 | case 76529: |
---|
803 | case 76546: |
---|
804 | case 76747: |
---|
805 | case 76804: |
---|
806 | case 77353: |
---|
807 | case 77409: |
---|
808 | case 77800: |
---|
809 | case 78720: |
---|
810 | case 80148: |
---|
811 | case 80176: |
---|
812 | case 80422: |
---|
813 | case 80533: |
---|
814 | case 80856: |
---|
815 | case 81342: |
---|
816 | case 82058: |
---|
817 | case 82279: |
---|
818 | case 82304: |
---|
819 | case 82605: |
---|
820 | case 82611: |
---|
821 | case 84255: |
---|
822 | case 84476: |
---|
823 | case 85005: |
---|
824 | case 85309: |
---|
825 | case 85426: |
---|
826 | case 85530: |
---|
827 | case 87306: |
---|
828 | case 88377: |
---|
829 | case 89960: |
---|
830 | case 90782: |
---|
831 | case 92388: |
---|
832 | case 92990: |
---|
833 | case 94724: |
---|
834 | case 95044: |
---|
835 | case 95057: |
---|
836 | case 95969: |
---|
837 | case 96863: |
---|
838 | case 97354: |
---|
839 | case 97538: |
---|
840 | case 97540: |
---|
841 | case 97542: |
---|
842 | case 97544: |
---|
843 | case 97545: |
---|
844 | case 97546: |
---|
845 | case 97547: |
---|
846 | case 97556: |
---|
847 | case 97559: |
---|
848 | case 97560: |
---|
849 | case 97570: |
---|
850 | case 99070: |
---|
851 | case 99071: |
---|
852 | case 99072: |
---|
853 | case 101061: |
---|
854 | case 101502: |
---|
855 | case 102042: |
---|
856 | case 103500: |
---|
857 | case 106026: |
---|
858 | case 119873: |
---|
859 | case 127811: |
---|
860 | case 128401: |
---|
861 | case 128906: |
---|
862 | case 130756: |
---|
863 | case 130781: |
---|
864 | return 0; |
---|
865 | break; |
---|
866 | } |
---|
867 | if (id > -131073 && id < 131073) |
---|
868 | return 1; |
---|
869 | else |
---|
870 | return 0; |
---|
871 | } |
---|
872 | /* process non-system (not in Moira) users */ |
---|
873 | else if (flags & DO_OTR) |
---|
874 | { |
---|
875 | /* hard-coded list of IDs in the system id space that aren't actually |
---|
876 | * system users. Print them here. Mmm, legacies. |
---|
877 | */ |
---|
878 | switch (id) |
---|
879 | { |
---|
880 | case -65541: |
---|
881 | case -65542: |
---|
882 | case -65544: |
---|
883 | case -65546: |
---|
884 | case -65548: |
---|
885 | case -65549: |
---|
886 | case -65551: |
---|
887 | case -65557: |
---|
888 | case -65563: |
---|
889 | case -65574: |
---|
890 | case -65576: |
---|
891 | case -65578: |
---|
892 | case -65579: |
---|
893 | case -65582: |
---|
894 | case -97536: |
---|
895 | case -97537: |
---|
896 | case -97538: |
---|
897 | case -98766: |
---|
898 | case -98775: |
---|
899 | case -98781: |
---|
900 | case -98782: |
---|
901 | case -98783: |
---|
902 | case -98784: |
---|
903 | case -98785: |
---|
904 | case -98786: |
---|
905 | case -98787: |
---|
906 | case -98788: |
---|
907 | case -98789: |
---|
908 | case -98792: |
---|
909 | case -98813: |
---|
910 | case -98815: |
---|
911 | case -98816: |
---|
912 | case -98818: |
---|
913 | case -98819: |
---|
914 | case -98820: |
---|
915 | case -98821: |
---|
916 | case -98828: |
---|
917 | case -98829: |
---|
918 | case -98830: |
---|
919 | case -98835: |
---|
920 | case -98836: |
---|
921 | case -98837: |
---|
922 | case -98841: |
---|
923 | case -98842: |
---|
924 | case -98844: |
---|
925 | case -98845: |
---|
926 | case -98846: |
---|
927 | case -98847: |
---|
928 | case -98848: |
---|
929 | case -98849: |
---|
930 | case -98851: |
---|
931 | case -98854: |
---|
932 | case -98855: |
---|
933 | case -98856: |
---|
934 | case -98857: |
---|
935 | case -98859: |
---|
936 | case -98867: |
---|
937 | case -98868: |
---|
938 | case -98869: |
---|
939 | case -98870: |
---|
940 | case -98871: |
---|
941 | case -98873: |
---|
942 | case -98878: |
---|
943 | case -98879: |
---|
944 | case -98883: |
---|
945 | case -98884: |
---|
946 | case -98885: |
---|
947 | case -98888: |
---|
948 | case -98891: |
---|
949 | case -98898: |
---|
950 | case -98903: |
---|
951 | case -98905: |
---|
952 | case -98914: |
---|
953 | case -98918: |
---|
954 | case -98919: |
---|
955 | case -98920: |
---|
956 | case -98923: |
---|
957 | case -98927: |
---|
958 | case -98941: |
---|
959 | case -98942: |
---|
960 | case -98945: |
---|
961 | case -98948: |
---|
962 | case -98949: |
---|
963 | case -98951: |
---|
964 | case -98952: |
---|
965 | case -98953: |
---|
966 | case -98956: |
---|
967 | case -98957: |
---|
968 | case -98960: |
---|
969 | case -98961: |
---|
970 | case -98963: |
---|
971 | case -98966: |
---|
972 | case -98994: |
---|
973 | case -98996: |
---|
974 | case -98998: |
---|
975 | case -99000: |
---|
976 | case -99001: |
---|
977 | case -99002: |
---|
978 | case -99003: |
---|
979 | case -99004: |
---|
980 | case -99005: |
---|
981 | case -99006: |
---|
982 | case -99007: |
---|
983 | case -99008: |
---|
984 | case -99009: |
---|
985 | case -99010: |
---|
986 | case -99011: |
---|
987 | case -99012: |
---|
988 | case -99013: |
---|
989 | case -99014: |
---|
990 | case -99015: |
---|
991 | case -99016: |
---|
992 | case -99017: |
---|
993 | case -99018: |
---|
994 | case -99019: |
---|
995 | case -99023: |
---|
996 | case -99029: |
---|
997 | case -99030: |
---|
998 | case -99042: |
---|
999 | case -99048: |
---|
1000 | case -99056: |
---|
1001 | case -99057: |
---|
1002 | case -99058: |
---|
1003 | case -99059: |
---|
1004 | case -99063: |
---|
1005 | case -99064: |
---|
1006 | case -99076: |
---|
1007 | case -99079: |
---|
1008 | case -99090: |
---|
1009 | case -99091: |
---|
1010 | case -99105: |
---|
1011 | case -99106: |
---|
1012 | case -99113: |
---|
1013 | case -99114: |
---|
1014 | case -99115: |
---|
1015 | case -99116: |
---|
1016 | case -99118: |
---|
1017 | case -99120: |
---|
1018 | case -99121: |
---|
1019 | case -99129: |
---|
1020 | case -99130: |
---|
1021 | case -99131: |
---|
1022 | case -99133: |
---|
1023 | case -99146: |
---|
1024 | case -99150: |
---|
1025 | case -99153: |
---|
1026 | case -99154: |
---|
1027 | case -99193: |
---|
1028 | case -99194: |
---|
1029 | case -99200: |
---|
1030 | case -99205: |
---|
1031 | case -99211: |
---|
1032 | case -99214: |
---|
1033 | case -99218: |
---|
1034 | case -99220: |
---|
1035 | case -99223: |
---|
1036 | case -99224: |
---|
1037 | case -99225: |
---|
1038 | case -99233: |
---|
1039 | case -99234: |
---|
1040 | case -99236: |
---|
1041 | case -99237: |
---|
1042 | case -99242: |
---|
1043 | case -99245: |
---|
1044 | case -99250: |
---|
1045 | case -99252: |
---|
1046 | case -99253: |
---|
1047 | case -99254: |
---|
1048 | case -99255: |
---|
1049 | case -99259: |
---|
1050 | case -99260: |
---|
1051 | case -99263: |
---|
1052 | case -99264: |
---|
1053 | case -99267: |
---|
1054 | case -99284: |
---|
1055 | case -99287: |
---|
1056 | case -99289: |
---|
1057 | case -99295: |
---|
1058 | case -99297: |
---|
1059 | case -99307: |
---|
1060 | case -99308: |
---|
1061 | case -99309: |
---|
1062 | case -99310: |
---|
1063 | case -99311: |
---|
1064 | case -99315: |
---|
1065 | case -99317: |
---|
1066 | case -99327: |
---|
1067 | case -99334: |
---|
1068 | case -99344: |
---|
1069 | case -99348: |
---|
1070 | case -99349: |
---|
1071 | case -99354: |
---|
1072 | case -99366: |
---|
1073 | case -99367: |
---|
1074 | case -99370: |
---|
1075 | case -99371: |
---|
1076 | case -99372: |
---|
1077 | case -99373: |
---|
1078 | case -99377: |
---|
1079 | case -99378: |
---|
1080 | case -99379: |
---|
1081 | case 65613: |
---|
1082 | case 65678: |
---|
1083 | case 65770: |
---|
1084 | case 65896: |
---|
1085 | case 65971: |
---|
1086 | case 65987: |
---|
1087 | case 66011: |
---|
1088 | case 66114: |
---|
1089 | case 66142: |
---|
1090 | case 67145: |
---|
1091 | case 67299: |
---|
1092 | case 67393: |
---|
1093 | case 67669: |
---|
1094 | case 67712: |
---|
1095 | case 67903: |
---|
1096 | case 68276: |
---|
1097 | case 68421: |
---|
1098 | case 68467: |
---|
1099 | case 69005: |
---|
1100 | case 69143: |
---|
1101 | case 69234: |
---|
1102 | case 69611: |
---|
1103 | case 70141: |
---|
1104 | case 70481: |
---|
1105 | case 71468: |
---|
1106 | case 71559: |
---|
1107 | case 71689: |
---|
1108 | case 72203: |
---|
1109 | case 72775: |
---|
1110 | case 72799: |
---|
1111 | case 73319: |
---|
1112 | case 73348: |
---|
1113 | case 73578: |
---|
1114 | case 73642: |
---|
1115 | case 73656: |
---|
1116 | case 74424: |
---|
1117 | case 74610: |
---|
1118 | case 75067: |
---|
1119 | case 75169: |
---|
1120 | case 75197: |
---|
1121 | case 75332: |
---|
1122 | case 75717: |
---|
1123 | case 76261: |
---|
1124 | case 76322: |
---|
1125 | case 76341: |
---|
1126 | case 76529: |
---|
1127 | case 76546: |
---|
1128 | case 76747: |
---|
1129 | case 76804: |
---|
1130 | case 77353: |
---|
1131 | case 77409: |
---|
1132 | case 77800: |
---|
1133 | case 78720: |
---|
1134 | case 80148: |
---|
1135 | case 80176: |
---|
1136 | case 80422: |
---|
1137 | case 80533: |
---|
1138 | case 80856: |
---|
1139 | case 81342: |
---|
1140 | case 82058: |
---|
1141 | case 82279: |
---|
1142 | case 82304: |
---|
1143 | case 82605: |
---|
1144 | case 82611: |
---|
1145 | case 84255: |
---|
1146 | case 84476: |
---|
1147 | case 85005: |
---|
1148 | case 85309: |
---|
1149 | case 85426: |
---|
1150 | case 85530: |
---|
1151 | case 87306: |
---|
1152 | case 88377: |
---|
1153 | case 89960: |
---|
1154 | case 90782: |
---|
1155 | case 92388: |
---|
1156 | case 92990: |
---|
1157 | case 94724: |
---|
1158 | case 95044: |
---|
1159 | case 95057: |
---|
1160 | case 95969: |
---|
1161 | case 96863: |
---|
1162 | case 97354: |
---|
1163 | case 97538: |
---|
1164 | case 97540: |
---|
1165 | case 97542: |
---|
1166 | case 97544: |
---|
1167 | case 97545: |
---|
1168 | case 97546: |
---|
1169 | case 97547: |
---|
1170 | case 97556: |
---|
1171 | case 97559: |
---|
1172 | case 97560: |
---|
1173 | case 97570: |
---|
1174 | case 99070: |
---|
1175 | case 99071: |
---|
1176 | case 99072: |
---|
1177 | case 101061: |
---|
1178 | case 101502: |
---|
1179 | case 102042: |
---|
1180 | case 103500: |
---|
1181 | case 106026: |
---|
1182 | case 119873: |
---|
1183 | case 127811: |
---|
1184 | case 128401: |
---|
1185 | case 128906: |
---|
1186 | case 130756: |
---|
1187 | case 130781: |
---|
1188 | return 1; |
---|
1189 | break; |
---|
1190 | } |
---|
1191 | if (id < -131072 || id > 131072) |
---|
1192 | return 1; |
---|
1193 | else |
---|
1194 | return 0; |
---|
1195 | } |
---|
1196 | /* neither flag set, don't do anything */ |
---|
1197 | else |
---|
1198 | return 0; |
---|
1199 | } |
---|