2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
17 #include <sys/types.h>
20 #include <WINNT/afsevent.h>
22 #include <sys/socket.h>
24 #include <netinet/in.h>
31 #ifdef HAVE_SYS_STAT_H
34 #ifdef HAVE_SYS_TYPES_H
35 #include <sys/types.h>
39 #include <afs/rxgen_consts.h>
42 #include <afs/cellconfig.h>
46 #include "ptprototypes.h"
47 #include <afs/afsutil.h>
48 #include <afs/com_err.h>
50 static char *whoami = "testpr";
51 static struct afsconf_dir *conf; /* cell info, set by MyBeforeProc */
52 static char conf_dir[100];
53 static char lcell[MAXCELLCHARS];
56 ListUsedIds(struct cmd_syndesc *as, void *arock)
62 int group = 0; /* check groups */
63 int unused = 0; /* print unused */
64 int number = 100; /* check 100 ids */
65 afs_int32 startId = 1;
69 if (as->parms[0].items)
70 startId = atoi(as->parms[0].items->data);
71 if (as->parms[1].items)
72 number = atoi(as->parms[1].items->data);
73 if (as->parms[2].items)
76 code = pr_Initialize(1, conf_dir, NULL);
78 afs_com_err(whoami, code, "initializing pruser");
83 code = pr_ListMaxGroupId(&maxId);
86 afs_com_err(whoami, code, "getting maximum id");
89 if (startId < maxId) {
90 fprintf(stderr, "Max group id is only %d.\n", maxId);
94 code = pr_ListMaxUserId(&maxId);
97 if (startId > maxId) {
98 fprintf(stderr, "Max user id is only %d.\n", maxId);
102 range = abs(startId - maxId);
105 range++; /* number that can be printed */
106 if (range < number) {
107 fprintf(stderr, "Only %d ids to be checked.\n", range);
111 printf("Checking for %d %sused ids starting at %d.\n", number,
112 (unused ? "un" : ""), startId);
114 lids.idlist_val = (afs_int32 *) malloc(sizeof(afs_int32) * NUM);
115 lnames.namelist_len = 0;
116 lnames.namelist_val = 0;
122 for (j = 0; j < i; j++) {
123 lids.idlist_val[j] = startId;
130 code = pr_IdToName(&lids, &lnames);
132 afs_com_err(whoami, code, "converting id to name");
135 for (j = 0; j < lnames.namelist_len; j++) {
136 if (lids.idlist_val[j] == atoi(lnames.namelist_val[j])) {
138 printf("%s is free\n", lnames.namelist_val[j]);
141 printf("%s is id %d\n", lnames.namelist_val[j],
148 free(lids.idlist_val);
149 if (lnames.namelist_val)
150 free(lnames.namelist_val);
154 /* TestManyMembers - called with a number N. Try creating N users and N groups
155 * and put all the users on one of the groups and one of the users on all the
156 * groups. Also put many users on many groups.
158 * To keep track of this create an NxN matrix of membership and fill it in with
159 * a function that looks like a quarter of a circle. That makes the first
160 * group contain every user and the first user be a member of every group. */
163 char callerName[PR_MAXNAMELEN];
165 afs_int32 lastGroup; /* id of last group created */
166 afs_int32 ownerUser; /* first created user */
167 char ownerUserName[PR_MAXNAMELEN]; /* " " " name */
168 int steepDropOff; /* precentage decreate in GroupLimit */
169 char *createPrefix; /* prefix for naming users&groups */
170 extern struct ubik_client *pruclient; /* initialized by pr_Initialize */
172 /* These variables form the state if this test */
173 int number; /* max number of members */
174 char *population; /* matrix of memberships */
175 afs_int32 *users; /* ids of users */
176 afs_int32 *groups; /* ids of groups */
177 afs_int32 *groupOwners; /* ids of owners of groups */
180 int nUsers, nGroups, nAdds, nRems, nUDels, nGDels;
183 IdCmp(const void *a, const void *b)
185 if (*(afs_int32 *)a > *(afs_int32 *)b) {
187 } else if (*(afs_int32 *)a == *(afs_int32 *)b) {
189 } else /* (*a < *b) */ {
201 GetGroupLimit(int N, int x)
205 if ((x >= N) || (x < 0)) {
206 printf("GetGroupLimit: input value out of range %d (%d)\n", x, N);
209 if (steepDropOff) { /* Use exponential decrease */
212 for (i = 0; i < x; i++) {
213 y = (y * steepDropOff) / 100; /* parameter is a percentage */
215 y = 1; /* with a floor of 1 */
219 } else { /* Use a circle's third quadrant */
220 y = sqr(N - 1) - sqr(N - 1 - x);
221 y = (int)(sqrt((double)y) + 0.5); /* round off */
224 if ((y > N) || (y < 1)) {
225 printf("filling value out of range: %d (%d) => %d\n", x, N, y);
238 sprintf(name, "%s%d", createPrefix, u);
240 code = pr_CreateUser(name, &id);
242 if (code == PREXIST) {
243 code = pr_Delete(name);
246 code = pr_CreateUser(name, &id);
254 afs_com_err(whoami, code, "couldn't create %s", name);
259 printf("Creating user %s (%di)\n", name, id);
263 if (ownerUser == 0) {
265 strcpy(ownerUserName, name);
276 char *ownerName = NULL;
277 int ownerType; /* type of ownership */
278 static char *lastGroupPrefix; /* prefix used for type==2 */
280 /* At least 50 groups should be owned by another group to test long owner
281 * chains during deletion. Also let's create some long owners of owners
283 ownerType = random() % 3;
292 ownerName = callerName;
296 ownerName = ownerUserName;
300 ownerName = lastGroupPrefix;
304 sprintf(name, "%s:%s%d", ownerName, createPrefix, g);
305 code = ubik_PR_NewEntry(pruclient, 0, name, PRGRP, owner, &id);
307 if (code == PREXIST) {
308 code = pr_Delete(name);
312 ubik_PR_NewEntry(pruclient, 0, name, PRGRP, owner,
321 afs_com_err(whoami, code, "couldn't create %s w/ owner=%d", name, owner);
326 printf("Creating group %s (%di)\n", name, id);
328 groupOwners[g] = owner;
330 if (!lastGroup || (ownerType == 2)) {
332 lastGroupPrefix = ownerName;
337 DeleteRandomId(afs_int32 *list)
344 k = random(); /* random starting point */
345 for (j = 0; j < number; j++) { /* find an undeleted id */
346 m = (k + j) % number;
347 if ((id = list[m])) {
348 code = ubik_PR_Delete(pruclient, 0, id);
350 afs_com_err(whoami, code, "Couldn't delete %di", id);
361 return -1; /* none left */
365 AddUser(int u, int g)
370 if (users[u] == 0) /* create if necessary */
372 if (groups[g] == 0) /* create group if necessary */
376 code = ubik_PR_AddToGroup(pruclient, 0, ui, gi);
378 afs_com_err(whoami, code, "couldn't add %d to %d", ui, gi);
382 printf("Adding user (%di) to group (%di)\n", ui, gi);
383 population[u * number + g]++;
388 RemUser(int u, int g)
395 code = ubik_PR_RemoveFromGroup(pruclient, 0, ui, gi);
397 afs_com_err(whoami, code, "couldn't remove %d from %d", ui, gi);
401 printf("Removing user (%di) from group (%di)\n", ui, gi);
402 population[u * number + g]--;
407 TestManyMembers(struct cmd_syndesc *as, void *arock)
409 char *filled; /* users filled up */
410 char *cleaned; /* users cleaned up */
412 int nFilled, nCleaned;
414 int seed; /* random number generator seed */
416 afs_int32 *glist; /* membership list */
420 code = pr_Initialize(1, conf_dir, NULL);
422 afs_com_err(whoami, code, "initializing pruser");
425 /* get name of person running command */
427 struct ktc_principal afs, user;
428 struct ktc_token token;
430 strcpy(afs.name, "afs");
431 strcpy(afs.instance, "");
432 code = afsconf_GetLocalCell(conf, afs.cell, sizeof(afs.cell));
435 code = ktc_GetToken(&afs, &token, sizeof(token), &user);
437 afs_com_err(whoami, code, "getting afs tokens");
440 if (strlen(user.instance) > 0) {
441 fprintf(stderr, "can't handle non-null instance %s.%s\n",
442 user.name, user.cell);
445 if (strncmp(user.name, "AFS ID ", 7) == 0) {
446 callerId = atoi(user.name + 7);
447 code = pr_SIdToName(callerId, callerName);
449 afs_com_err(whoami, code, "call get name for id %d", callerId);
453 strcpy(callerName, user.name);
454 code = pr_SNameToId(callerName, &callerId);
455 if ((code == 0) && (callerId == ANONYMOUSID))
458 #if 0 /* don't create user */
459 if (code == PRNOENT) {
461 code = pr_CreateUser(callerName, &callerId);
463 afs_com_err(whoami, code, "can't create caller %s", callerName);
466 printf("Creating caller %s (%di)\n", callerName, callerId);
471 afs_com_err(whoami, code, "can't find caller %s", callerName);
474 printf("Assuming caller is %s (%di)\n", callerName, callerId);
477 /* Parse arguments */
478 if (as->parms[0].items)
479 number = atoi(as->parms[0].items->data);
480 if (as->parms[1].items) {
481 steepDropOff = atoi(as->parms[1].items->data);
482 if ((steepDropOff < 0) || (steepDropOff > 100)) {
484 "Illegal value for dropoff: %d, must be between 0 and 100, inclusive.\n",
489 steepDropOff = 0; /* use quadratic dropoff */
490 if (as->parms[2].items)
491 createPrefix = as->parms[2].items->data;
494 if (as->parms[3].items)
498 if (as->parms[4].items)
499 seed = atoi(as->parms[4].items->data);
505 users = (afs_int32 *) malloc(number * sizeof(afs_int32));
506 groups = (afs_int32 *) malloc(number * sizeof(afs_int32));
507 filled = (char *)malloc(number * sizeof(char));
508 cleaned = (char *)malloc(number * sizeof(char));
509 population = (char *)malloc(sqr(number) * sizeof(char));
512 memset(filled, 0, number);
514 memset(cleaned, 0, number);
515 memset(population, 0, sqr(number));
516 memset(users, 0, number * sizeof(afs_int32));
517 memset(groups, 0, number * sizeof(afs_int32));
519 ownerUser = lastGroup = 0;
520 groupOwners = (afs_int32 *) malloc(number * sizeof(afs_int32));
521 nUsers = nGroups = nAdds = nRems = nUDels = nGDels = 0;
523 while ((nFilled < number) || (nCleaned < number)) {
524 /* pick a user at random, using */
525 u = random() % number;
527 n = GetGroupLimit(number, u); /* get group limit for that user */
528 g = random() % (n + 1); /* pick a random group */
529 if (g == n) { /* in a few cases create any user */
530 n = number; /* in the whole range */
533 for (i = 0; i < n; i++) { /* rotate until unused one found */
535 if (!population[u * number + j]) {
536 /* add this user/group membership */
547 if (filled[u]) { /* only clean above GroupLimit */
548 base = GetGroupLimit(number, u);
555 n = number; /* pick a group from the whole range */
556 g = random() % 2 * n; /* at random for removal */
558 goto remed; /* but half the time do nothing */
560 for (i = 0; i < n; i++) { /* rotate until used one found */
561 j = (g + i) % n + base;
562 if (population[u * number + j]) {
563 /* remove this user/group membership */
568 if (filled[u]) { /* track finished ones */
577 /* check the membership list of all users for correctness */
578 printf("Starting check of memberships\n");
579 glist = (afs_int32 *) malloc(number * sizeof(afs_int32));
580 for (u = 0; u < number; u++) {
581 afs_int32 ui = users[u];
584 int ng; /* number groups */
586 int (*proc)(struct ubik_client *, afs_int32, afs_int32, prlist *,
590 alist.prlist_len = 0;
591 alist.prlist_val = 0;
593 proc = ubik_PR_ListElements;
595 proc = ubik_PR_GetCPS;
597 code = (*proc)(pruclient, 0, ui, &alist, &over);
599 afs_com_err(whoami, code,
600 "getting membership list of (%di) using %s", ui,
601 (proc == ubik_PR_ListElements?"ListElements":"GetCPS"));
605 fprintf(stderr, "membership list for id %di too long\n", ui);
608 for (i = 0; i < number; i++)
609 if (population[u * number + i])
610 glist[ng++] = groups[i];
611 qsort(glist, ng, sizeof(afs_int32), IdCmp);
612 if (ng != (alist.prlist_len - ((proc == ubik_PR_GetCPS) ? 3 : 0))) {
614 "Membership list for %di of unexpected length: was %d but expected %d\n",
615 ui, alist.prlist_len, ng);
618 /* all the extra entries for the CPS should be at the end. */
620 for (i = 0; i < ng; i++)
621 if (alist.prlist_val[i] != glist[i]) {
623 "membership for %di not correct: was %di but expected %di\n",
624 ui, alist.prlist_val[i], glist[i]);
629 if (proc == ubik_PR_GetCPS) {
630 if ((alist.prlist_val[i /* =ng */ ] != AUTHUSERID) ||
631 (alist.prlist_val[++i] != ANYUSERID)
632 || (alist.prlist_val[++i] != ui)) {
633 fprintf(stderr, "CPS doesn't have extra entries\n");
637 if (alist.prlist_val)
638 free(alist.prlist_val);
640 /* User 0 is a member of all groups all of which should also be on
641 * the owner list of the caller or the ownerUser, although there
642 * may also be others. Check this. */
646 prlist lastGroupList;
650 fprintf(stderr, "User 0 not a member of all groups\n");
653 #define GETOWNED(xlist,xid) \
654 (xlist).prlist_val = 0; (xlist).prlist_len = 0; \
655 code = ubik_PR_ListOwned(pruclient, 0, (xid), &(xlist), &over); \
657 afs_com_err (whoami, code, "getting owner list of (%di)", (xid)); \
660 { fprintf (stderr, "membership of id %di too long\n", (xid)); }
662 GETOWNED(callerList, callerId);
663 GETOWNED(ownerList, ownerUser);
665 /* look for every entry in glist, in all the owner lists */
666 for (i = j = k = l = 0; i < number; i++) {
667 while ((j < callerList.prlist_len)
668 && (callerList.prlist_val[j] < glist[i]))
670 while ((k < ownerList.prlist_len)
671 && (ownerList.prlist_val[k] < glist[i]))
673 #define PRLISTCMP(l,i) \
674 (((l).prlist_len == 0) || (glist[i] != (l).prlist_val[(i)]))
675 if (PRLISTCMP(callerList, j) && PRLISTCMP(ownerList, k)) {
676 for (l = 0; l < number; l++) {
677 if (groups[l] == glist[i]) {
678 if ((groupOwners[l] != callerId)
679 && (groupOwners[l] != ownerUser)) {
680 GETOWNED(lastGroupList, groupOwners[l]);
681 if ((lastGroupList.prlist_len != 1)
682 || (lastGroupList.prlist_val[0] !=
685 "Group (%di) not on any owner list\n",
693 fprintf(stderr, "unexpected group %di\n", glist[i]);
697 if (callerList.prlist_val)
698 free(callerList.prlist_val);
699 if (ownerList.prlist_val)
700 free(ownerList.prlist_val);
701 if (lastGroupList.prlist_val)
702 free(lastGroupList.prlist_val);
707 /* cleanup by deleting all the users and groups */
708 printf("Starting deletion of users and groups\n");
709 for (i = 0; i < number; i++) {
710 DeleteRandomId(users);
711 DeleteRandomId(groups);
715 ("Created/deleted %d/%d users and %d/%d groups; added %d and removed %d.\n",
716 nUsers, nUDels, nGroups, nGDels, nAdds, nRems);
720 /* from ka_ConvertBytes included here to avoid circularity */
721 /* Converts a byte string to ascii. Return the number of unconverted bytes. */
724 ka_ConvertBytes(char *ascii, /* output buffer */
725 int alen, /* buffer length */
726 char bs[], /* byte string */
727 int bl) /* number of bytes */
732 alen--; /* make room for termination */
733 for (i = 0; i < bl; i++) {
737 if (isalnum(c) || ispunct(c))
738 (*ascii++ = c), alen--;
743 *ascii++ = (c >> 6) + '0';
744 *ascii++ = (c >> 3 & 7) + '0';
745 *ascii++ = (c & 7) + '0';
749 *ascii = 0; /* terminate string */
753 /* This runs various tests on the server. It creates, then deletes, a bunch of
754 * users and groups, so it would be safest to run it on a test database.
756 * These are the things I check for:
757 * User names longer than PR_MAXNAMELEN - strlen(cellname).
758 * Group names longer than PR_MAXNAMELEN.
759 * User names containing all legal 8-bit ascii characters. This excludes
760 * only ':', '@', and '\n'.
761 * Group names as above, but at least one colon is required, and the owner
766 TestPrServ(struct cmd_syndesc *as, void *arock)
769 char name[PR_MAXNAMELEN + 1];
770 char creator[PR_MAXNAMELEN]; /* our name */
771 struct prcheckentry ent;
774 int maxLen = PR_MAXNAMELEN - 1 - strlen(lcell) - 1;
776 code = pr_Initialize(1, conf_dir, NULL);
778 afs_com_err(whoami, code, "initializing pruser");
782 for (i = 0; i < maxLen; i++)
784 name[i] = 'a'; /* too long a name... */
787 code = pr_CreateUser(name, &id);
788 if ((code != RXGEN_CC_MARSHAL) && (code != PRBADNAM)) {
789 afs_com_err(whoami, code, "succeeded creating %s", name);
794 code = pr_CreateUser(name, &id);
795 if (code == PREXIST) {
796 fprintf(stderr, "group already exists, skipping\n");
797 pr_SNameToId(name, &id);
799 afs_com_err(whoami, code, "failed creating %s", name);
802 if ((code = pr_ListEntry(id, &ent))
803 || (code = pr_SIdToName(ent.creator, creator))) {
804 afs_com_err(whoami, code, "getting creator's name");
807 code = pr_DeleteByID(id);
809 afs_com_err(whoami, code, "deleting %s", name);
812 /* now make sure the illegal chars are detected */
815 for (illegalChars = "@:\n"; *illegalChars; illegalChars++) {
816 name[10] = *illegalChars;
818 code = pr_CreateUser(name, &id);
819 if (code != PRBADNAM) {
820 afs_com_err(whoami, code, "succeeded creating %s", name);
826 for (i = 1; i <= 255;) { /* for all 8-bit ascii... */
827 j = 0; /* build a new name */
828 while ((j < maxLen) && (i <= 255)) {
829 if (!((i == ':') || (i == '@') || (i == '\n')))
833 name[j] = 0; /* terminate string */
835 code = pr_CreateUser(name, &id);
836 if (code == PREXIST) {
837 fprintf(stderr, "user already exists, skipping\n");
838 pr_SNameToId(name, &id);
841 ka_ConvertBytes(ascii, sizeof(ascii), name, strlen(name));
842 afs_com_err(whoami, code, "failed creating %s", ascii);
845 code = pr_DeleteByID(id);
847 afs_com_err(whoami, code, "deleting %s", name);
852 /* now check group names */
853 strcpy(name, creator);
854 strcat(name, ":abcdefghijklmnopqrstuvwxyz");
855 name[0] = 1; /* bash the owner name */
857 code = pr_CreateGroup(name, creator, &id);
858 if (code != PRNOENT) { /* owner doesn't exist */
859 afs_com_err(whoami, code, "succeeded creating %s", name);
862 name[0] = creator[0]; /* fix owner */
863 /* Make sure the illegal chars are detected */
866 for (illegalChars = ":@\n"; *illegalChars; illegalChars++) {
867 name[strlen(creator) + 10] = *illegalChars;
869 code = pr_CreateGroup(name, creator, &id);
870 if (code != PRBADNAM) {
871 afs_com_err(whoami, code, "succeeded creating %s", name);
876 for (i = 1; i <= 255;) { /* for all 8-bit ascii... */
877 j = strlen(creator) + 1; /* build a new name */
878 while ((j < PR_MAXNAMELEN - 1) && (i <= 255)) {
879 if (!((i == ':') || (i == '@') || (i == '\n')))
883 name[j] = 0; /* terminate string */
885 code = pr_CreateGroup(name, creator, &id);
886 if (code == PREXIST) {
887 fprintf(stderr, "group already exists, skipping\n");
888 pr_SNameToId(name, &id);
891 ka_ConvertBytes(ascii, sizeof(ascii), name, strlen(name));
892 afs_com_err(whoami, code, "failed creating %s", ascii);
895 code = pr_DeleteByID(id);
897 afs_com_err(whoami, code, "deleting %s", name);
906 static char tmp_conf_dir[128] = "";
907 static char tmp_conf_file[128] = "";
908 static char tmp_cell_file[128] = "";
909 static char tmp_noauth_file[128] = "";
912 MyAfterProc(struct cmd_syndesc *as, void *arock)
914 if (strlen(tmp_conf_file))
915 unlink(tmp_conf_file);
916 if (strlen(tmp_cell_file))
917 unlink(tmp_cell_file);
918 if (strlen(tmp_noauth_file))
919 unlink(tmp_noauth_file);
920 if (strlen(tmp_conf_dir))
926 MyBeforeProc(struct cmd_syndesc *as, void *arock)
932 struct cmd_item *serverList = 0;
933 struct afsconf_dir *local_conf = 0; /* so we can default stuff nicely */
934 struct afsconf_cell cellinfo;
936 if (as->parms[12].items) { /* if conf dir specified */
937 cdir = as->parms[12].items->data;
938 if (as->parms[13].items || as->parms[14].items || as->parms[15].items) {
939 printf("Can't specify conf dir and other cell parameters\n");
940 return AFSCONF_SYNTAX;
944 /* if we need to default cell name or cell servers, get local conf info */
946 if (!(local_conf = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH))
947 && !(local_conf = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH))) {
948 printf("** Can't local configuration!\n");
949 return AFSCONF_NOCELL;
952 if (as->parms[13].items) { /* if cell name specified */
953 lcstring(lcell, as->parms[13].items->data, sizeof(lcell));
954 code = afsconf_GetCellInfo(local_conf, lcell, 0, &cellinfo);
956 strncpy(lcell, cellinfo.name, sizeof(lcell));
958 code = afsconf_GetLocalCell(local_conf, lcell, sizeof(lcell));
963 if (as->parms[14].items) { /* noauth flag */
967 if (as->parms[15].items) { /* servers list */
968 serverList = as->parms[15].items;
969 for (i = 0; serverList; i++, serverList = serverList->next) {
971 if (i >= MAXHOSTSPERCELL)
973 strncpy(cellinfo.hostName[i], serverList->data, MAXHOSTCHARS);
974 th = gethostbyname(cellinfo.hostName[i]);
977 memcpy(&cellinfo.hostAddr[i].sin_addr, th->h_addr,
979 cellinfo.hostAddr[i].sin_family = AF_INET;
980 cellinfo.hostAddr[i].sin_port = 0;
981 #ifdef STRUCT_SOCKADDR_HAS_SA_LEN
982 cellinfo.hostAddr[i].sin_len = sizeof(struct sockaddr_in);
985 cellinfo.numServers = i;
986 strcpy(cellinfo.name, lcell);
988 code = afsconf_GetCellInfo(local_conf, lcell, 0, &cellinfo);
994 afsconf_Close(local_conf);
999 sprintf(tmp_conf_dir, "%s/afsconf.%lu", gettmpdir(),
1000 (unsigned long)getpid());
1001 code = mkdir(tmp_conf_dir, 0777);
1002 if ((code < 0) && (errno != EEXIST)) {
1003 afs_com_err(whoami, errno, "can't create temporary afsconf dir: %s",
1008 strcompose(tmp_conf_file, 128, tmp_conf_dir, "/",
1009 AFSDIR_CELLSERVDB_FILE, NULL);
1010 f = fopen(tmp_conf_file, "w");
1013 afs_com_err(whoami, errno, "can't create conf file %s",
1017 fprintf(f, ">%s\n", lcell);
1018 for (i = 0; i < cellinfo.numServers; i++) {
1020 (unsigned char *)&cellinfo.hostAddr[i].sin_addr;
1021 fprintf(f, "%d.%d.%d.%d\t#%s\n", tp[0], tp[1], tp[2], tp[3],
1022 cellinfo.hostName[i]);
1024 if (fclose(f) == EOF) {
1026 afs_com_err(whoami, errno, "can't write to conf file %s",
1031 strcompose(tmp_cell_file, 128, tmp_conf_dir, "/",
1032 AFSDIR_THISCELL_FILE, NULL);
1033 f = fopen(tmp_cell_file, "w");
1036 fprintf(f, "%s", lcell);
1037 if (fclose(f) == EOF)
1040 strcompose(tmp_noauth_file, 128, tmp_conf_dir, "/",
1041 AFSDIR_NOAUTH_FILE, NULL);
1043 code = creat(tmp_noauth_file, 0777);
1044 if (code && (errno != EEXIST))
1046 } else { /* make sure file doesn't exist */
1047 code = unlink(tmp_noauth_file);
1048 if (code && (errno != ENOENT))
1053 strncpy(conf_dir, tmp_conf_dir, sizeof(conf_dir));
1054 conf = afsconf_Open(conf_dir);
1056 return AFSCONF_NOTFOUND;
1061 add_std_args(struct cmd_syndesc *ts)
1064 cmd_AddParm(ts, "-confdir", CMD_SINGLE, CMD_OPTIONAL,
1065 "AFS Conf dir pathname");
1066 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "Cell name");
1067 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "Don't authenticate");
1068 cmd_AddParm(ts, "-servers", CMD_LIST, CMD_OPTIONAL, "Server config");
1074 /* OK, this REALLY sucks bigtime, but I can't tell who is calling
1075 * afsconf_CheckAuth easily, and only *SERVERS* should be calling osi_audit
1076 * anyway. It's gonna give somebody fits to debug, I know, I know.
1081 #include "AFS_component_version_number.c"
1084 main(int argc, char *argv[])
1087 struct cmd_syndesc *ts; /* ptr to parsed command line syntax */
1090 initialize_CMD_error_table();
1091 initialize_ACFG_error_table();
1092 initialize_KTC_error_table();
1093 initialize_U_error_table();
1094 initialize_PT_error_table();
1095 initialize_RXK_error_table();
1098 /* initialize winsock */
1099 if (afs_winsockInit() < 0) {
1100 fprintf(stderr, "%s: couldn't initialize winsock. \n", whoami);
1105 cmd_SetBeforeProc(MyBeforeProc, NULL);
1106 cmd_SetAfterProc(MyAfterProc, NULL);
1108 ts = cmd_CreateSyntax("usedIds", ListUsedIds, NULL,
1109 "Find used (or unused) user (or group) ids");
1110 cmd_AddParm(ts, "-startId", CMD_SINGLE, CMD_OPTIONAL,
1111 "id to start checking");
1112 cmd_AddParm(ts, "-number", CMD_SINGLE, CMD_OPTIONAL,
1113 "number of ids to check");
1114 cmd_AddParm(ts, "-unused", CMD_FLAG, CMD_OPTIONAL, "print unused ids");
1117 ts = cmd_CreateSyntax("initcmd", TestPrServ, NULL, "test the prserver");
1120 ts = cmd_CreateSyntax("testmanymembers", TestManyMembers, NULL,
1121 "test creating users and groups w/ many members");
1122 cmd_AddParm(ts, "-number", CMD_SINGLE, 0,
1123 "number of users/groups to create");
1124 cmd_AddParm(ts, "-dropoff", CMD_SINGLE, CMD_OPTIONAL,
1125 "precentage for exponential dropoff");
1126 cmd_AddParm(ts, "-prefix", CMD_SINGLE, CMD_OPTIONAL, "naming prefix");
1127 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "show progress");
1128 cmd_AddParm(ts, "-seed", CMD_SINGLE, CMD_OPTIONAL, "random number seed");
1130 cmd_CreateAlias(ts, "mm");
1133 code = cmd_Dispatch(argc, argv);
1135 afs_com_err(whoami, code, "calling cmd_Dispatch");