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>
18 #include <sys/types.h>
21 #include <WINNT/afsevent.h>
23 #include <sys/socket.h>
25 #include <netinet/in.h>
37 #ifdef HAVE_SYS_STAT_H
40 #ifdef HAVE_SYS_TYPES_H
41 #include <sys/types.h>
45 #include <afs/rxgen_consts.h>
48 #include <afs/cellconfig.h>
51 #include <afs/afsutil.h>
53 extern char *ucstring();
54 extern char *lcstring();
56 static char *whoami = "testpr";
57 static struct afsconf_dir *conf; /* cell info, set by MyBeforeProc */
58 static char conf_dir[100];
59 static char lcell[MAXCELLCHARS];
61 ListUsedIds(as, arock)
62 struct cmd_syndesc *as;
69 int group = 0; /* check groups */
70 int unused = 0; /* print unused */
71 int number = 100; /* check 100 ids */
72 afs_int32 startId = 1;
76 if (as->parms[0].items)
77 startId = atoi(as->parms[0].items->data);
78 if (as->parms[1].items)
79 number = atoi(as->parms[1].items->data);
80 if (as->parms[2].items)
83 code = pr_Initialize(1, conf_dir, NULL);
85 com_err(whoami, code, "initializing pruser");
90 code = pr_ListMaxGroupId(&maxId);
93 com_err(whoami, code, "getting maximum id");
96 if (startId < maxId) {
97 fprintf(stderr, "Max group id is only %d.\n", maxId);
101 code = pr_ListMaxUserId(&maxId);
104 if (startId > maxId) {
105 fprintf(stderr, "Max user id is only %d.\n", maxId);
109 range = abs(startId - maxId);
112 range++; /* number that can be printed */
113 if (range < number) {
114 fprintf(stderr, "Only %d ids to be checked.\n", range);
118 printf("Checking for %d %sused ids starting at %d.\n", number,
119 (unused ? "un" : ""), startId);
121 lids.idlist_val = (afs_int32 *) malloc(sizeof(afs_int32) * NUM);
122 lnames.namelist_len = 0;
123 lnames.namelist_val = 0;
129 for (j = 0; j < i; j++) {
130 lids.idlist_val[j] = startId;
137 code = pr_IdToName(&lids, &lnames);
139 com_err(whoami, code, "converting id to name");
142 for (j = 0; j < lnames.namelist_len; j++) {
143 if (lids.idlist_val[j] == atoi(lnames.namelist_val[j])) {
145 printf("%s is free\n", lnames.namelist_val[j]);
148 printf("%s is id %d\n", lnames.namelist_val[j],
155 free(lids.idlist_val);
156 if (lnames.namelist_val)
157 free(lnames.namelist_val);
161 /* TestManyMembers - called with a number N. Try creating N users and N groups
162 * and put all the users on one of the groups and one of the users on all the
163 * groups. Also put many users on many groups.
165 * To keep track of this create an NxN matrix of membership and fill it in with
166 * a function that looks like a quarter of a circle. That makes the first
167 * group contain every user and the first user be a member of every group. */
170 char callerName[PR_MAXNAMELEN];
172 afs_int32 lastGroup; /* id of last group created */
173 afs_int32 ownerUser; /* first created user */
174 char ownerUserName[PR_MAXNAMELEN]; /* " " " name */
175 int steepDropOff; /* precentage decreate in GroupLimit */
176 char *createPrefix; /* prefix for naming users&groups */
177 extern struct ubik_client *pruclient; /* initialized by pr_Initialize */
179 /* These variables form the state if this test */
180 int number; /* max number of members */
181 char *population; /* matrix of memberships */
182 afs_int32 *users; /* ids of users */
183 afs_int32 *groups; /* ids of groups */
184 afs_int32 *groupOwners; /* ids of owners of groups */
187 int nUsers, nGroups, nAdds, nRems, nUDels, nGDels;
196 } else if (*a == *b) {
198 } else /* (*a < *b) */ {
218 if ((x >= N) || (x < 0)) {
219 printf("GetGroupLimit: input value out of range %d (%d)\n", x, N);
222 if (steepDropOff) { /* Use exponential decrease */
225 for (i = 0; i < x; i++) {
226 y = (y * steepDropOff) / 100; /* parameter is a percentage */
228 y = 1; /* with a floor of 1 */
232 } else { /* Use a circle's third quadrant */
233 y = sqr(N - 1) - sqr(N - 1 - x);
234 y = (int)(sqrt((double)y) + 0.5); /* round off */
237 if ((y > N) || (y < 1)) {
238 printf("filling value out of range: %d (%d) => %d\n", x, N, y);
252 sprintf(name, "%s%d", createPrefix, u);
254 code = pr_CreateUser(name, &id);
256 if (code == PREXIST) {
257 code = pr_Delete(name);
260 code = pr_CreateUser(name, &id);
268 com_err(whoami, code, "couldn't create %s", name);
273 printf("Creating user %s (%di)\n", name, id);
277 if (ownerUser == 0) {
279 strcpy(ownerUserName, name);
290 afs_int32 flags = PRGRP;
293 int ownerType; /* type of ownership */
294 static char *lastGroupPrefix; /* prefix used for type==2 */
296 /* At least 50 groups should be owned by another group to test long owner
297 * chains during deletion. Also let's create some long owners of owners
299 ownerType = random() % 3;
308 ownerName = callerName;
312 ownerName = ownerUserName;
316 ownerName = lastGroupPrefix;
320 sprintf(name, "%s:%s%d", ownerName, createPrefix, g);
321 code = ubik_Call(PR_NewEntry, pruclient, 0, name, PRGRP, owner, &id);
323 if (code == PREXIST) {
324 code = pr_Delete(name);
328 ubik_Call(PR_NewEntry, pruclient, 0, name, PRGRP, owner,
337 com_err(whoami, code, "couldn't create %s w/ owner=%d", name, owner);
342 printf("Creating group %s (%di)\n", name, id);
344 groupOwners[g] = owner;
346 if (!lastGroup || (ownerType == 2)) {
348 lastGroupPrefix = ownerName;
361 k = random(); /* random starting point */
362 for (j = 0; j < number; j++) { /* find an undeleted id */
363 m = (k + j) % number;
365 code = ubik_Call(PR_Delete, pruclient, 0, id);
367 com_err(whoami, code, "Couldn't delete %di", id);
378 return -1; /* none left */
388 if (users[u] == 0) /* create if necessary */
390 if (groups[g] == 0) /* create group if necessary */
394 code = ubik_Call(PR_AddToGroup, pruclient, 0, ui, gi);
396 com_err(whoami, code, "couldn't add %d to %d", ui, gi);
400 printf("Adding user (%di) to group (%di)\n", ui, gi);
401 population[u * number + g]++;
414 code = ubik_Call(PR_RemoveFromGroup, pruclient, 0, ui, gi);
416 com_err(whoami, code, "couldn't remove %d from %d", ui, gi);
420 printf("Removing user (%di) from group (%di)\n", ui, gi);
421 population[u * number + g]--;
425 TestManyMembers(as, arock)
426 struct cmd_syndesc *as;
429 char *filled; /* users filled up */
430 char *cleaned; /* users cleaned up */
432 int nFilled, nCleaned;
434 int seed; /* random number generator seed */
436 afs_int32 *glist; /* membership list */
440 code = pr_Initialize(1, conf_dir, NULL);
442 com_err(whoami, code, "initializing pruser");
445 /* get name of person running command */
447 struct ktc_principal afs, user;
448 struct ktc_token token;
450 strcpy(afs.name, "afs");
451 strcpy(afs.instance, "");
452 code = afsconf_GetLocalCell(conf, afs.cell, sizeof(afs.cell));
455 code = ktc_GetToken(&afs, &token, sizeof(token), &user);
457 com_err(whoami, code, "getting afs tokens");
460 if (strlen(user.instance) > 0) {
461 fprintf(stderr, "can't handle non-null instance %s.%s\n",
462 user.name, user.cell);
465 if (strncmp(user.name, "AFS ID ", 7) == 0) {
466 callerId = atoi(user.name + 7);
467 code = pr_SIdToName(callerId, callerName);
469 com_err(whoami, code, "call get name for id %d", callerId);
473 strcpy(callerName, user.name);
474 code = pr_SNameToId(callerName, &callerId);
475 if ((code == 0) && (callerId == ANONYMOUSID))
478 #if 0 /* don't create user */
479 if (code == PRNOENT) {
481 code = pr_CreateUser(callerName, &callerId);
483 com_err(whoami, code, "can't create caller %s", callerName);
486 printf("Creating caller %s (%di)\n", callerName, callerId);
491 com_err(whoami, code, "can't find caller %s", callerName);
494 printf("Assuming caller is %s (%di)\n", callerName, callerId);
497 /* Parse arguments */
498 if (as->parms[0].items)
499 number = atoi(as->parms[0].items->data);
500 if (as->parms[1].items) {
501 steepDropOff = atoi(as->parms[1].items->data);
502 if ((steepDropOff < 0) || (steepDropOff > 100)) {
504 "Illegal value for dropoff: %d, must be between 0 and 100, inclusive.\n",
509 steepDropOff = 0; /* use quadratic dropoff */
510 if (as->parms[2].items)
511 createPrefix = as->parms[2].items->data;
514 if (as->parms[3].items)
518 if (as->parms[4].items)
519 seed = atoi(as->parms[4].items->data);
525 users = (afs_int32 *) malloc(number * sizeof(afs_int32));
526 groups = (afs_int32 *) malloc(number * sizeof(afs_int32));
527 filled = (char *)malloc(number * sizeof(char));
528 cleaned = (char *)malloc(number * sizeof(char));
529 population = (char *)malloc(sqr(number) * sizeof(char));
532 memset(filled, 0, number);
534 memset(cleaned, 0, number);
535 memset(population, 0, sqr(number));
536 memset(users, 0, number * sizeof(afs_int32));
537 memset(groups, 0, number * sizeof(afs_int32));
539 ownerUser = lastGroup = 0;
540 groupOwners = (afs_int32 *) malloc(number * sizeof(afs_int32));
541 nUsers = nGroups = nAdds = nRems = nUDels = nGDels = 0;
543 while ((nFilled < number) || (nCleaned < number)) {
544 /* pick a user at random, using */
545 u = random() % number;
547 n = GetGroupLimit(number, u); /* get group limit for that user */
548 g = random() % (n + 1); /* pick a random group */
549 if (g == n) { /* in a few cases create any user */
550 n = number; /* in the whole range */
553 for (i = 0; i < n; i++) { /* rotate until unused one found */
555 if (!population[u * number + j]) {
556 /* add this user/group membership */
567 if (filled[u]) { /* only clean above GroupLimit */
568 base = GetGroupLimit(number, u);
575 n = number; /* pick a group from the whole range */
576 g = random() % 2 * n; /* at random for removal */
578 goto remed; /* but half the time do nothing */
580 for (i = 0; i < n; i++) { /* rotate until used one found */
581 j = (g + i) % n + base;
582 if (population[u * number + j]) {
583 /* remove this user/group membership */
588 if (filled[u]) { /* track finished ones */
597 /* check the membership list of all users for correctness */
598 printf("Starting check of memberships\n");
599 glist = (afs_int32 *) malloc(number * sizeof(afs_int32));
600 for (u = 0; u < number; u++) {
601 afs_int32 ui = users[u];
604 int ng; /* number groups */
605 int (*proc) (); /* membership listing procedure */
609 alist.prlist_len = 0;
610 alist.prlist_val = 0;
612 proc = PR_ListElements;
615 code = ubik_Call(proc, pruclient, 0, ui, &alist, &over);
617 com_err(whoami, code,
618 "getting membership list of (%di) using %s", ui,
619 ((proc == PR_GetCPS) ? "GetCPR" : "ListElements"));
623 fprintf(stderr, "membership list for id %di too long\n", ui);
626 for (i = 0; i < number; i++)
627 if (population[u * number + i])
628 glist[ng++] = groups[i];
629 qsort(glist, ng, sizeof(afs_int32), IdCmp);
630 if (ng != (alist.prlist_len - ((proc == PR_GetCPS) ? 3 : 0))) {
632 "Membership list for %di of unexpected length: was %d but expected %d\n",
633 ui, alist.prlist_len, ng);
636 /* all the extra entries for the CPS should be at the end. */
638 for (i = 0; i < ng; i++)
639 if (alist.prlist_val[i] != glist[i]) {
641 "membership for %di not correct: was %di but expected %di\n",
642 ui, alist.prlist_val[i], glist[i]);
647 if (proc == PR_GetCPS) {
648 if ((alist.prlist_val[i /* =ng */ ] != AUTHUSERID) ||
649 (alist.prlist_val[++i] != ANYUSERID)
650 || (alist.prlist_val[++i] != ui)) {
651 fprintf(stderr, "CPS doesn't have extra entries\n");
655 if (alist.prlist_val)
656 free(alist.prlist_val);
658 /* User 0 is a member of all groups all of which should also be on
659 * the owner list of the caller or the ownerUser, although there
660 * may also be others. Check this. */
664 prlist lastGroupList;
668 fprintf(stderr, "User 0 not a member of all groups\n");
671 #define GETOWNED(xlist,xid) \
672 (xlist).prlist_val = 0; (xlist).prlist_len = 0; \
673 code = ubik_Call (PR_ListOwned, pruclient, 0, (xid), &(xlist), &over); \
675 com_err (whoami, code, "getting owner list of (%di)", (xid)); \
678 { fprintf (stderr, "membership of id %di too long\n", (xid)); }
680 GETOWNED(callerList, callerId);
681 GETOWNED(ownerList, ownerUser);
683 /* look for every entry in glist, in all the owner lists */
684 for (i = j = k = l = 0; i < number; i++) {
685 while ((j < callerList.prlist_len)
686 && (callerList.prlist_val[j] < glist[i]))
688 while ((k < ownerList.prlist_len)
689 && (ownerList.prlist_val[k] < glist[i]))
691 #define PRLISTCMP(l,i) \
692 (((l).prlist_len == 0) || (glist[i] != (l).prlist_val[(i)]))
693 if (PRLISTCMP(callerList, j) && PRLISTCMP(ownerList, k)) {
694 for (l = 0; l < number; l++) {
695 if (groups[l] == glist[i]) {
696 if ((groupOwners[l] != callerId)
697 && (groupOwners[l] != ownerUser)) {
698 GETOWNED(lastGroupList, groupOwners[l]);
699 if ((lastGroupList.prlist_len != 1)
700 || (lastGroupList.prlist_val[0] !=
703 "Group (%di) not on any owner list\n",
711 fprintf(stderr, "unexpected group %di\n", glist[i]);
715 if (callerList.prlist_val)
716 free(callerList.prlist_val);
717 if (ownerList.prlist_val)
718 free(ownerList.prlist_val);
719 if (lastGroupList.prlist_val)
720 free(lastGroupList.prlist_val);
725 /* cleanup by deleting all the users and groups */
726 printf("Starting deletion of users and groups\n");
727 for (i = 0; i < number; i++) {
728 DeleteRandomId(users);
729 DeleteRandomId(groups);
733 ("Created/deleted %d/%d users and %d/%d groups; added %d and removed %d.\n",
734 nUsers, nUDels, nGroups, nGDels, nAdds, nRems);
738 /* from ka_ConvertBytes included here to avoid circularity */
739 /* Converts a byte string to ascii. Return the number of unconverted bytes. */
742 ka_ConvertBytes(ascii, alen, bs, bl)
743 char *ascii; /* output buffer */
744 int alen; /* buffer length */
745 char bs[]; /* byte string */
746 int bl; /* number of bytes */
751 alen--; /* make room for termination */
752 for (i = 0; i < bl; i++) {
756 if (isalnum(c) || ispunct(c))
757 (*ascii++ = c), alen--;
762 *ascii++ = (c >> 6) + '0';
763 *ascii++ = (c >> 3 & 7) + '0';
764 *ascii++ = (c & 7) + '0';
768 *ascii = 0; /* terminate string */
772 /* This runs various tests on the server. It creates, then deletes, a bunch of
773 * users and groups, so it would be safest to run it on a test database.
775 * These are the things I check for:
776 * User names longer than PR_MAXNAMELEN - strlen(cellname).
777 * Group names longer than PR_MAXNAMELEN.
778 * User names containing all legal 8-bit ascii characters. This excludes
779 * only ':', '@', and '\n'.
780 * Group names as above, but at least one colon is required, and the owner
784 TestPrServ(as, arock)
785 struct cmd_syndesc *as;
789 char name[PR_MAXNAMELEN + 1];
790 char creator[PR_MAXNAMELEN]; /* our name */
791 struct prcheckentry ent;
794 int maxLen = PR_MAXNAMELEN - 1 - strlen(lcell) - 1;
796 code = pr_Initialize(1, conf_dir, NULL);
798 com_err(whoami, code, "initializing pruser");
802 for (i = 0; i < maxLen; i++)
804 name[i] = 'a'; /* too long a name... */
807 code = pr_CreateUser(name, &id);
808 if ((code != RXGEN_CC_MARSHAL) && (code != PRBADNAM)) {
809 com_err(whoami, code, "succeeded creating %s", name);
814 code = pr_CreateUser(name, &id);
815 if (code == PREXIST) {
816 fprintf(stderr, "group already exists, skipping\n");
817 pr_SNameToId(name, &id);
819 com_err(whoami, code, "failed creating %s", name);
822 if ((code = pr_ListEntry(id, &ent))
823 || (code = pr_SIdToName(ent.creator, creator))) {
824 com_err(whoami, code, "getting creator's name");
827 code = pr_DeleteByID(id);
829 com_err(whoami, code, "deleting %s", name);
832 /* now make sure the illegal chars are detected */
835 for (illegalChars = "@:\n"; *illegalChars; illegalChars++) {
836 name[10] = *illegalChars;
838 code = pr_CreateUser(name, &id);
839 if (code != PRBADNAM) {
840 com_err(whoami, code, "succeeded creating %s", name);
846 for (i = 1; i <= 255;) { /* for all 8-bit ascii... */
847 j = 0; /* build a new name */
848 while ((j < maxLen) && (i <= 255)) {
849 if (!((i == ':') || (i == '@') || (i == '\n')))
853 name[j] = 0; /* terminate string */
855 code = pr_CreateUser(name, &id);
856 if (code == PREXIST) {
857 fprintf(stderr, "user already exists, skipping\n");
858 pr_SNameToId(name, &id);
861 ka_ConvertBytes(ascii, sizeof(ascii), name, strlen(name));
862 com_err(whoami, code, "failed creating %s", ascii);
865 code = pr_DeleteByID(id);
867 com_err(whoami, code, "deleting %s", name);
872 /* now check group names */
873 strcpy(name, creator);
874 strcat(name, ":abcdefghijklmnopqrstuvwxyz");
875 name[0] = 1; /* bash the owner name */
877 code = pr_CreateGroup(name, &id);
878 if (code != PRNOENT) { /* owner doesn't exist */
879 com_err(whoami, code, "succeeded creating %s", name);
882 name[0] = creator[0]; /* fix owner */
883 /* Make sure the illegal chars are detected */
886 for (illegalChars = ":@\n"; *illegalChars; illegalChars++) {
887 name[strlen(creator) + 10] = *illegalChars;
889 code = pr_CreateGroup(name, creator, &id);
890 if (code != PRBADNAM) {
891 com_err(whoami, code, "succeeded creating %s", name);
896 for (i = 1; i <= 255;) { /* for all 8-bit ascii... */
897 j = strlen(creator) + 1; /* build a new name */
898 while ((j < PR_MAXNAMELEN - 1) && (i <= 255)) {
899 if (!((i == ':') || (i == '@') || (i == '\n')))
903 name[j] = 0; /* terminate string */
905 code = pr_CreateGroup(name, creator, &id);
906 if (code == PREXIST) {
907 fprintf(stderr, "group already exists, skipping\n");
908 pr_SNameToId(name, &id);
911 ka_ConvertBytes(ascii, sizeof(ascii), name, strlen(name));
912 com_err(whoami, code, "failed creating %s", ascii);
915 code = pr_DeleteByID(id);
917 com_err(whoami, code, "deleting %s", name);
926 static char tmp_conf_dir[128] = "";
927 static char tmp_conf_file[128] = "";
928 static char tmp_cell_file[128] = "";
929 static char tmp_noauth_file[128] = "";
932 MyAfterProc(as, arock)
933 struct cmd_syndesc *as;
936 if (strlen(tmp_conf_file))
937 unlink(tmp_conf_file);
938 if (strlen(tmp_cell_file))
939 unlink(tmp_cell_file);
940 if (strlen(tmp_noauth_file))
941 unlink(tmp_noauth_file);
942 if (strlen(tmp_conf_dir))
948 MyBeforeProc(as, arock)
949 struct cmd_syndesc *as;
956 struct cmd_item *serverList = 0;
957 struct afsconf_dir *local_conf = 0; /* so we can default stuff nicely */
958 struct afsconf_cell cellinfo;
960 if (as->parms[12].items) { /* if conf dir specified */
961 cdir = as->parms[12].items->data;
962 if (as->parms[13].items || as->parms[14].items || as->parms[15].items) {
963 printf("Can't specify conf dir and other cell parameters\n");
964 return AFSCONF_SYNTAX;
968 /* if we need to default cell name or cell servers, get local conf info */
970 if (!(local_conf = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH))
971 && !(local_conf = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH))) {
972 printf("** Can't local configuration!\n");
973 return AFSCONF_NOCELL;
976 if (as->parms[13].items) { /* if cell name specified */
977 lcstring(lcell, as->parms[13].items->data, sizeof(lcell));
978 code = afsconf_GetCellInfo(local_conf, lcell, 0, &cellinfo);
980 strncpy(lcell, cellinfo.name, sizeof(lcell));
982 code = afsconf_GetLocalCell(local_conf, lcell, sizeof(lcell));
987 if (as->parms[14].items) { /* noauth flag */
991 if (as->parms[15].items) { /* servers list */
992 serverList = as->parms[15].items;
993 for (i = 0; serverList; i++, serverList = serverList->next) {
995 if (i >= MAXHOSTSPERCELL)
997 strncpy(cellinfo.hostName[i], serverList->data, MAXHOSTCHARS);
998 th = gethostbyname(cellinfo.hostName[i]);
1001 memcpy(&cellinfo.hostAddr[i].sin_addr, th->h_addr,
1003 cellinfo.hostAddr[i].sin_family = AF_INET;
1004 cellinfo.hostAddr[i].sin_port = 0;
1005 #ifdef STRUCT_SOCKADDR_HAS_SA_LEN
1006 cellinfo.hostAddr[i].sin_len = sizeof(struct sockaddr_in);
1009 cellinfo.numServers = i;
1010 strcpy(cellinfo.name, lcell);
1012 code = afsconf_GetCellInfo(local_conf, lcell, 0, &cellinfo);
1018 afsconf_Close(local_conf);
1023 sprintf(tmp_conf_dir, "%s/afsconf.%lu", gettmpdir(),
1024 (unsigned long)getpid());
1025 code = mkdir(tmp_conf_dir, 0777);
1026 if ((code < 0) && (errno != EEXIST)) {
1027 com_err(whoami, errno, "can't create temporary afsconf dir: %s",
1032 strcompose(tmp_conf_file, 128, tmp_conf_dir, "/",
1033 AFSDIR_CELLSERVDB_FILE, NULL);
1034 f = fopen(tmp_conf_file, "w");
1037 com_err(whoami, errno, "can't create conf file %s",
1041 fprintf(f, ">%s\n", lcell);
1042 for (i = 0; i < cellinfo.numServers; i++) {
1043 register unsigned char *tp =
1044 (unsigned char *)&cellinfo.hostAddr[i].sin_addr;
1045 fprintf(f, "%d.%d.%d.%d\t#%s\n", tp[0], tp[1], tp[2], tp[3],
1046 cellinfo.hostName[i]);
1048 if (fclose(f) == EOF) {
1050 com_err(whoami, errno, "can't write to conf file %s",
1055 strcompose(tmp_cell_file, 128, tmp_conf_dir, "/",
1056 AFSDIR_THISCELL_FILE, NULL);
1057 f = fopen(tmp_cell_file, "w");
1060 fprintf(f, "%s", lcell);
1061 if (fclose(f) == EOF)
1064 strcompose(tmp_noauth_file, 128, tmp_conf_dir, "/",
1065 AFSDIR_NOAUTH_FILE, NULL);
1067 code = creat(tmp_noauth_file, 0777);
1068 if (code && (errno != EEXIST))
1070 } else { /* make sure file doesn't exist */
1071 code = unlink(tmp_noauth_file);
1072 if (code && (errno != ENOENT))
1077 strncpy(conf_dir, tmp_conf_dir, sizeof(conf_dir));
1078 conf = afsconf_Open(conf_dir);
1080 return AFSCONF_NOTFOUND;
1086 register struct cmd_syndesc *ts;
1089 cmd_AddParm(ts, "-confdir", CMD_SINGLE, CMD_OPTIONAL,
1090 "AFS Conf dir pathname");
1091 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "Cell name");
1092 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "Don't authenticate");
1093 cmd_AddParm(ts, "-servers", CMD_LIST, CMD_OPTIONAL, "Server config");
1099 /* OK, this REALLY sucks bigtime, but I can't tell who is calling
1100 * afsconf_CheckAuth easily, and only *SERVERS* should be calling osi_audit
1101 * anyway. It's gonna give somebody fits to debug, I know, I know.
1106 #include "AFS_component_version_number.c"
1113 struct cmd_syndesc *ts; /* ptr to parsed command line syntax */
1116 initialize_CMD_error_table();
1117 initialize_ACFG_error_table();
1118 initialize_KTC_error_table();
1119 initialize_U_error_table();
1120 initialize_PT_error_table();
1121 initialize_RXK_error_table();
1124 /* initialize winsock */
1125 if (afs_winsockInit() < 0) {
1126 fprintf(stderr, "%s: couldn't initialize winsock. \n", whoami);
1131 cmd_SetBeforeProc(MyBeforeProc, NULL);
1132 cmd_SetAfterProc(MyAfterProc, NULL);
1134 ts = cmd_CreateSyntax("usedIds", ListUsedIds, 0,
1135 "Find used (or unused) user (or group) ids");
1136 cmd_AddParm(ts, "-startId", CMD_SINGLE, CMD_OPTIONAL,
1137 "id to start checking");
1138 cmd_AddParm(ts, "-number", CMD_SINGLE, CMD_OPTIONAL,
1139 "number of ids to check");
1140 cmd_AddParm(ts, "-unused", CMD_FLAG, CMD_OPTIONAL, "print unused ids");
1143 ts = cmd_CreateSyntax("initcmd", TestPrServ, 0, "test the prserver");
1146 ts = cmd_CreateSyntax("testmanymembers", TestManyMembers, 0,
1147 "test creating users and groups w/ many members");
1148 cmd_AddParm(ts, "-number", CMD_SINGLE, 0,
1149 "number of users/groups to create");
1150 cmd_AddParm(ts, "-dropoff", CMD_SINGLE, CMD_OPTIONAL,
1151 "precentage for exponential dropoff");
1152 cmd_AddParm(ts, "-prefix", CMD_SINGLE, CMD_OPTIONAL, "naming prefix");
1153 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "show progress");
1154 cmd_AddParm(ts, "-seed", CMD_SINGLE, CMD_OPTIONAL, "random number seed");
1156 cmd_CreateAlias(ts, "mm");
1159 code = cmd_Dispatch(argc, argv);
1161 com_err(whoami, code, "calling cmd_Dispatch");