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>
20 #include <WINNT/afsevent.h>
25 #include <afs/rxgen_consts.h>
28 #include <afs/cellconfig.h>
29 #include <afs/afsutil.h>
30 #include <afs/com_err.h>
35 #include "ptprototypes.h"
37 static char *whoami = "testpr";
38 static struct afsconf_dir *conf; /* cell info, set by MyBeforeProc */
39 static char conf_dir[100];
40 static char lcell[MAXCELLCHARS];
43 ListUsedIds(struct cmd_syndesc *as, void *arock)
49 int group = 0; /* check groups */
50 int unused = 0; /* print unused */
51 int number = 100; /* check 100 ids */
52 afs_int32 startId = 1;
56 if (as->parms[0].items)
57 startId = atoi(as->parms[0].items->data);
58 if (as->parms[1].items)
59 number = atoi(as->parms[1].items->data);
60 if (as->parms[2].items)
63 code = pr_Initialize(1, conf_dir, NULL);
65 afs_com_err(whoami, code, "initializing pruser");
70 code = pr_ListMaxGroupId(&maxId);
73 afs_com_err(whoami, code, "getting maximum id");
76 if (startId < maxId) {
77 fprintf(stderr, "Max group id is only %d.\n", maxId);
81 code = pr_ListMaxUserId(&maxId);
84 if (startId > maxId) {
85 fprintf(stderr, "Max user id is only %d.\n", maxId);
89 range = abs(startId - maxId);
90 range++; /* number that can be printed */
92 fprintf(stderr, "Only %d ids to be checked.\n", range);
96 printf("Checking for %d %sused ids starting at %d.\n", number,
97 (unused ? "un" : ""), startId);
99 lids.idlist_val = malloc(sizeof(afs_int32) * NUM);
100 lnames.namelist_len = 0;
101 lnames.namelist_val = 0;
107 for (j = 0; j < i; j++) {
108 lids.idlist_val[j] = startId;
115 code = pr_IdToName(&lids, &lnames);
117 afs_com_err(whoami, code, "converting id to name");
120 for (j = 0; j < lnames.namelist_len; j++) {
121 if (lids.idlist_val[j] == atoi(lnames.namelist_val[j])) {
123 printf("%s is free\n", lnames.namelist_val[j]);
126 printf("%s is id %d\n", lnames.namelist_val[j],
133 free(lids.idlist_val);
134 if (lnames.namelist_val)
135 free(lnames.namelist_val);
139 /* TestManyMembers - called with a number N. Try creating N users and N groups
140 * and put all the users on one of the groups and one of the users on all the
141 * groups. Also put many users on many groups.
143 * To keep track of this create an NxN matrix of membership and fill it in with
144 * a function that looks like a quarter of a circle. That makes the first
145 * group contain every user and the first user be a member of every group. */
148 char callerName[PR_MAXNAMELEN];
150 afs_int32 lastGroup; /* id of last group created */
151 afs_int32 ownerUser; /* first created user */
152 char ownerUserName[PR_MAXNAMELEN]; /* " " " name */
153 int steepDropOff; /* precentage decreate in GroupLimit */
154 char *createPrefix; /* prefix for naming users&groups */
155 extern struct ubik_client *pruclient; /* initialized by pr_Initialize */
157 /* These variables form the state if this test */
158 int number; /* max number of members */
159 char *population; /* matrix of memberships */
160 afs_int32 *users; /* ids of users */
161 afs_int32 *groups; /* ids of groups */
162 afs_int32 *groupOwners; /* ids of owners of groups */
165 int nUsers, nGroups, nAdds, nRems, nUDels, nGDels;
168 IdCmp(const void *a, const void *b)
170 if (*(afs_int32 *)a > *(afs_int32 *)b) {
172 } else if (*(afs_int32 *)a == *(afs_int32 *)b) {
174 } else /* (*a < *b) */ {
186 GetGroupLimit(int N, int x)
190 if ((x >= N) || (x < 0)) {
191 printf("GetGroupLimit: input value out of range %d (%d)\n", x, N);
194 if (steepDropOff) { /* Use exponential decrease */
197 for (i = 0; i < x; i++) {
198 y = (y * steepDropOff) / 100; /* parameter is a percentage */
200 y = 1; /* with a floor of 1 */
204 } else { /* Use a circle's third quadrant */
205 y = sqr(N - 1) - sqr(N - 1 - x);
206 y = (int)(sqrt((double)y) + 0.5); /* round off */
209 if ((y > N) || (y < 1)) {
210 printf("filling value out of range: %d (%d) => %d\n", x, N, y);
223 sprintf(name, "%s%d", createPrefix, u);
225 code = pr_CreateUser(name, &id);
227 if (code == PREXIST) {
228 code = pr_Delete(name);
231 code = pr_CreateUser(name, &id);
239 afs_com_err(whoami, code, "couldn't create %s", name);
244 printf("Creating user %s (%di)\n", name, id);
248 if (ownerUser == 0) {
250 strcpy(ownerUserName, name);
258 char name[PR_MAXNAMELEN + 1];
261 char *ownerName = NULL;
262 int ownerType; /* type of ownership */
263 static char *lastGroupPrefix; /* prefix used for type==2 */
265 /* At least 50 groups should be owned by another group to test long owner
266 * chains during deletion. Also let's create some long owners of owners
268 ownerType = random() % 3;
277 ownerName = callerName;
281 ownerName = ownerUserName;
285 ownerName = lastGroupPrefix;
289 code = snprintf(name, sizeof(name), "%s:%s%d", ownerName, createPrefix, g);
290 if (code >= sizeof(name)) {
291 fprintf(stderr, "%s: generated group name is too long: %s:%s%d\n",
292 whoami, ownerName, createPrefix, g);
295 code = ubik_PR_NewEntry(pruclient, 0, name, PRGRP, owner, &id);
297 if (code == PREXIST) {
298 code = pr_Delete(name);
302 ubik_PR_NewEntry(pruclient, 0, name, PRGRP, owner,
311 afs_com_err(whoami, code, "couldn't create %s w/ owner=%d", name, owner);
316 printf("Creating group %s (%di)\n", name, id);
318 groupOwners[g] = owner;
320 if (!lastGroup || (ownerType == 2)) {
322 lastGroupPrefix = ownerName;
327 DeleteRandomId(afs_int32 *list)
334 k = random(); /* random starting point */
335 for (j = 0; j < number; j++) { /* find an undeleted id */
336 m = (k + j) % number;
337 if ((id = list[m])) {
338 code = ubik_PR_Delete(pruclient, 0, id);
340 afs_com_err(whoami, code, "Couldn't delete %di", id);
351 return -1; /* none left */
355 AddUser(int u, int g)
360 if (users[u] == 0) /* create if necessary */
362 if (groups[g] == 0) /* create group if necessary */
366 code = ubik_PR_AddToGroup(pruclient, 0, ui, gi);
368 afs_com_err(whoami, code, "couldn't add %d to %d", ui, gi);
372 printf("Adding user (%di) to group (%di)\n", ui, gi);
373 population[u * number + g]++;
378 RemUser(int u, int g)
385 code = ubik_PR_RemoveFromGroup(pruclient, 0, ui, gi);
387 afs_com_err(whoami, code, "couldn't remove %d from %d", ui, gi);
391 printf("Removing user (%di) from group (%di)\n", ui, gi);
392 population[u * number + g]--;
397 TestManyMembers(struct cmd_syndesc *as, void *arock)
399 char *filled; /* users filled up */
400 char *cleaned; /* users cleaned up */
402 int nFilled, nCleaned;
404 int seed; /* random number generator seed */
406 afs_int32 *glist; /* membership list */
410 code = pr_Initialize(1, conf_dir, NULL);
412 afs_com_err(whoami, code, "initializing pruser");
415 /* get name of person running command */
417 struct ktc_principal afs, user;
418 struct ktc_token token;
420 strcpy(afs.name, "afs");
421 strcpy(afs.instance, "");
422 code = afsconf_GetLocalCell(conf, afs.cell, sizeof(afs.cell));
425 code = ktc_GetToken(&afs, &token, sizeof(token), &user);
427 afs_com_err(whoami, code, "getting afs tokens");
430 if (strlen(user.instance) > 0) {
431 fprintf(stderr, "can't handle non-null instance %s.%s\n",
432 user.name, user.cell);
435 if (strncmp(user.name, "AFS ID ", 7) == 0) {
436 callerId = atoi(user.name + 7);
437 code = pr_SIdToName(callerId, callerName);
439 afs_com_err(whoami, code, "call get name for id %d", callerId);
443 strcpy(callerName, user.name);
444 code = pr_SNameToId(callerName, &callerId);
445 if ((code == 0) && (callerId == ANONYMOUSID))
449 afs_com_err(whoami, code, "can't find caller %s", callerName);
452 printf("Assuming caller is %s (%di)\n", callerName, callerId);
455 /* Parse arguments */
456 if (as->parms[0].items)
457 number = atoi(as->parms[0].items->data);
458 if (as->parms[1].items) {
459 steepDropOff = atoi(as->parms[1].items->data);
460 if ((steepDropOff < 0) || (steepDropOff > 100)) {
462 "Illegal value for dropoff: %d, must be between 0 and 100, inclusive.\n",
467 steepDropOff = 0; /* use quadratic dropoff */
468 if (as->parms[2].items)
469 createPrefix = as->parms[2].items->data;
472 if (as->parms[3].items)
476 if (as->parms[4].items)
477 seed = atoi(as->parms[4].items->data);
483 users = calloc(number, sizeof(afs_int32));
484 groups = calloc(number, sizeof(afs_int32));
485 filled = calloc(number, sizeof(char));
486 cleaned = calloc(number, sizeof(char));
487 population = calloc(sqr(number), sizeof(char));
492 ownerUser = lastGroup = 0;
493 groupOwners = malloc(number * sizeof(afs_int32));
494 nUsers = nGroups = nAdds = nRems = nUDels = nGDels = 0;
496 while ((nFilled < number) || (nCleaned < number)) {
497 /* pick a user at random, using */
498 u = random() % number;
500 n = GetGroupLimit(number, u); /* get group limit for that user */
501 g = random() % (n + 1); /* pick a random group */
502 if (g == n) { /* in a few cases create any user */
503 n = number; /* in the whole range */
506 for (i = 0; i < n; i++) { /* rotate until unused one found */
508 if (!population[u * number + j]) {
509 /* add this user/group membership */
520 if (filled[u]) { /* only clean above GroupLimit */
521 base = GetGroupLimit(number, u);
528 n = number; /* pick a group from the whole range */
529 g = random() % 2 * n; /* at random for removal */
531 goto remed; /* but half the time do nothing */
533 for (i = 0; i < n; i++) { /* rotate until used one found */
534 j = (g + i) % n + base;
535 if (population[u * number + j]) {
536 /* remove this user/group membership */
541 if (filled[u]) { /* track finished ones */
550 /* check the membership list of all users for correctness */
551 printf("Starting check of memberships\n");
552 glist = malloc(number * sizeof(afs_int32));
553 for (u = 0; u < number; u++) {
554 afs_int32 ui = users[u];
557 int ng; /* number groups */
559 int (*proc)(struct ubik_client *, afs_int32, afs_int32, prlist *,
563 alist.prlist_len = 0;
564 alist.prlist_val = 0;
566 proc = ubik_PR_ListElements;
568 proc = ubik_PR_GetCPS;
570 code = (*proc)(pruclient, 0, ui, &alist, &over);
572 afs_com_err(whoami, code,
573 "getting membership list of (%di) using %s", ui,
574 (proc == ubik_PR_ListElements?"ListElements":"GetCPS"));
578 fprintf(stderr, "membership list for id %di too long\n", ui);
581 for (i = 0; i < number; i++)
582 if (population[u * number + i])
583 glist[ng++] = groups[i];
584 qsort(glist, ng, sizeof(afs_int32), IdCmp);
585 if (ng != (alist.prlist_len - ((proc == ubik_PR_GetCPS) ? 3 : 0))) {
587 "Membership list for %di of unexpected length: was %d but expected %d\n",
588 ui, alist.prlist_len, ng);
591 /* all the extra entries for the CPS should be at the end. */
593 for (i = 0; i < ng; i++)
594 if (alist.prlist_val[i] != glist[i]) {
596 "membership for %di not correct: was %di but expected %di\n",
597 ui, alist.prlist_val[i], glist[i]);
602 if (proc == ubik_PR_GetCPS) {
603 if ((alist.prlist_val[i /* =ng */ ] != AUTHUSERID) ||
604 (alist.prlist_val[++i] != ANYUSERID)
605 || (alist.prlist_val[++i] != ui)) {
606 fprintf(stderr, "CPS doesn't have extra entries\n");
610 if (alist.prlist_val)
611 free(alist.prlist_val);
613 /* User 0 is a member of all groups all of which should also be on
614 * the owner list of the caller or the ownerUser, although there
615 * may also be others. Check this. */
619 prlist lastGroupList;
623 fprintf(stderr, "User 0 not a member of all groups\n");
626 #define GETOWNED(xlist,xid) \
627 (xlist).prlist_val = 0; (xlist).prlist_len = 0; \
628 code = ubik_PR_ListOwned(pruclient, 0, (xid), &(xlist), &over); \
630 afs_com_err (whoami, code, "getting owner list of (%di)", (xid)); \
633 { fprintf (stderr, "membership of id %di too long\n", (xid)); }
635 GETOWNED(callerList, callerId);
636 GETOWNED(ownerList, ownerUser);
638 /* look for every entry in glist, in all the owner lists */
639 for (i = j = k = l = 0; i < number; i++) {
640 while ((j < callerList.prlist_len)
641 && (callerList.prlist_val[j] < glist[i]))
643 while ((k < ownerList.prlist_len)
644 && (ownerList.prlist_val[k] < glist[i]))
646 #define PRLISTCMP(l,i) \
647 (((l).prlist_len == 0) || (glist[i] != (l).prlist_val[(i)]))
648 if (PRLISTCMP(callerList, j) && PRLISTCMP(ownerList, k)) {
649 for (l = 0; l < number; l++) {
650 if (groups[l] == glist[i]) {
651 if ((groupOwners[l] != callerId)
652 && (groupOwners[l] != ownerUser)) {
653 GETOWNED(lastGroupList, groupOwners[l]);
654 if ((lastGroupList.prlist_len != 1)
655 || (lastGroupList.prlist_val[0] !=
658 "Group (%di) not on any owner list\n",
666 fprintf(stderr, "unexpected group %di\n", glist[i]);
670 if (callerList.prlist_val)
671 free(callerList.prlist_val);
672 if (ownerList.prlist_val)
673 free(ownerList.prlist_val);
674 if (lastGroupList.prlist_val)
675 free(lastGroupList.prlist_val);
680 /* cleanup by deleting all the users and groups */
681 printf("Starting deletion of users and groups\n");
682 for (i = 0; i < number; i++) {
683 DeleteRandomId(users);
684 DeleteRandomId(groups);
688 ("Created/deleted %d/%d users and %d/%d groups; added %d and removed %d.\n",
689 nUsers, nUDels, nGroups, nGDels, nAdds, nRems);
693 /* from ka_ConvertBytes included here to avoid circularity */
694 /* Converts a byte string to ascii. Return the number of unconverted bytes. */
697 ka_ConvertBytes(char *ascii, /* output buffer */
698 int alen, /* buffer length */
699 char bs[], /* byte string */
700 int bl) /* number of bytes */
705 alen--; /* make room for termination */
706 for (i = 0; i < bl; i++) {
710 if (isalnum(c) || ispunct(c))
711 (*ascii++ = c), alen--;
716 *ascii++ = (c >> 6) + '0';
717 *ascii++ = (c >> 3 & 7) + '0';
718 *ascii++ = (c & 7) + '0';
722 *ascii = 0; /* terminate string */
726 /* This runs various tests on the server. It creates, then deletes, a bunch of
727 * users and groups, so it would be safest to run it on a test database.
729 * These are the things I check for:
730 * User names longer than PR_MAXNAMELEN - strlen(cellname).
731 * Group names longer than PR_MAXNAMELEN.
732 * User names containing all legal 8-bit ascii characters. This excludes
733 * only ':', '@', and '\n'.
734 * Group names as above, but at least one colon is required, and the owner
739 TestPrServ(struct cmd_syndesc *as, void *arock)
742 char name[PR_MAXNAMELEN + 1];
743 char creator[PR_MAXNAMELEN]; /* our name */
744 struct prcheckentry ent;
747 int maxLen = PR_MAXNAMELEN - 1 - strlen(lcell) - 1;
749 code = pr_Initialize(1, conf_dir, NULL);
751 afs_com_err(whoami, code, "initializing pruser");
755 for (i = 0; i < maxLen; i++)
757 name[i] = 'a'; /* too long a name... */
760 code = pr_CreateUser(name, &id);
761 if ((code != RXGEN_CC_MARSHAL) && (code != PRBADNAM)) {
762 afs_com_err(whoami, code, "succeeded creating %s", name);
767 code = pr_CreateUser(name, &id);
768 if (code == PREXIST) {
769 fprintf(stderr, "group already exists, skipping\n");
770 pr_SNameToId(name, &id);
772 afs_com_err(whoami, code, "failed creating %s", name);
775 if ((code = pr_ListEntry(id, &ent))
776 || (code = pr_SIdToName(ent.creator, creator))) {
777 afs_com_err(whoami, code, "getting creator's name");
780 code = pr_DeleteByID(id);
782 afs_com_err(whoami, code, "deleting %s", name);
785 /* now make sure the illegal chars are detected */
788 for (illegalChars = "@:\n"; *illegalChars; illegalChars++) {
789 name[10] = *illegalChars;
791 code = pr_CreateUser(name, &id);
792 if (code != PRBADNAM) {
793 afs_com_err(whoami, code, "succeeded creating %s", name);
799 for (i = 1; i <= 255;) { /* for all 8-bit ascii... */
800 j = 0; /* build a new name */
801 while ((j < maxLen) && (i <= 255)) {
802 if (!((i == ':') || (i == '@') || (i == '\n')))
806 name[j] = 0; /* terminate string */
808 code = pr_CreateUser(name, &id);
809 if (code == PREXIST) {
810 fprintf(stderr, "user already exists, skipping\n");
811 pr_SNameToId(name, &id);
814 ka_ConvertBytes(ascii, sizeof(ascii), name, strlen(name));
815 afs_com_err(whoami, code, "failed creating %s", ascii);
818 code = pr_DeleteByID(id);
820 afs_com_err(whoami, code, "deleting %s", name);
825 /* now check group names */
826 strcpy(name, creator);
827 strcat(name, ":abcdefghijklmnopqrstuvwxyz");
828 name[0] = 1; /* bash the owner name */
830 code = pr_CreateGroup(name, creator, &id);
831 if (code != PRNOENT) { /* owner doesn't exist */
832 afs_com_err(whoami, code, "succeeded creating %s", name);
835 name[0] = creator[0]; /* fix owner */
836 /* Make sure the illegal chars are detected */
839 for (illegalChars = ":@\n"; *illegalChars; illegalChars++) {
840 name[strlen(creator) + 10] = *illegalChars;
842 code = pr_CreateGroup(name, creator, &id);
843 if (code != PRBADNAM) {
844 afs_com_err(whoami, code, "succeeded creating %s", name);
849 for (i = 1; i <= 255;) { /* for all 8-bit ascii... */
850 j = strlen(creator) + 1; /* build a new name */
851 while ((j < PR_MAXNAMELEN - 1) && (i <= 255)) {
852 if (!((i == ':') || (i == '@') || (i == '\n')))
856 name[j] = 0; /* terminate string */
858 code = pr_CreateGroup(name, creator, &id);
859 if (code == PREXIST) {
860 fprintf(stderr, "group already exists, skipping\n");
861 pr_SNameToId(name, &id);
864 ka_ConvertBytes(ascii, sizeof(ascii), name, strlen(name));
865 afs_com_err(whoami, code, "failed creating %s", ascii);
868 code = pr_DeleteByID(id);
870 afs_com_err(whoami, code, "deleting %s", name);
879 static char tmp_conf_dir[128] = "";
880 static char tmp_conf_file[128] = "";
881 static char tmp_cell_file[128] = "";
882 static char tmp_noauth_file[128] = "";
885 MyAfterProc(struct cmd_syndesc *as, void *arock)
887 if (strlen(tmp_conf_file))
888 unlink(tmp_conf_file);
889 if (strlen(tmp_cell_file))
890 unlink(tmp_cell_file);
891 if (strlen(tmp_noauth_file))
892 unlink(tmp_noauth_file);
893 if (strlen(tmp_conf_dir))
899 MyBeforeProc(struct cmd_syndesc *as, void *arock)
905 struct cmd_item *serverList = 0;
906 struct afsconf_dir *local_conf = 0; /* so we can default stuff nicely */
907 struct afsconf_cell cellinfo;
909 if (as->parms[12].items) { /* if conf dir specified */
910 cdir = as->parms[12].items->data;
911 if (as->parms[13].items || as->parms[14].items || as->parms[15].items) {
912 printf("Can't specify conf dir and other cell parameters\n");
913 return AFSCONF_SYNTAX;
917 /* if we need to default cell name or cell servers, get local conf info */
919 if (!(local_conf = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH))
920 && !(local_conf = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH))) {
921 printf("** Can't local configuration!\n");
922 return AFSCONF_NOCELL;
925 if (as->parms[13].items) { /* if cell name specified */
926 lcstring(lcell, as->parms[13].items->data, sizeof(lcell));
927 code = afsconf_GetCellInfo(local_conf, lcell, 0, &cellinfo);
929 strncpy(lcell, cellinfo.name, sizeof(lcell));
931 code = afsconf_GetLocalCell(local_conf, lcell, sizeof(lcell));
936 if (as->parms[14].items) { /* noauth flag */
940 if (as->parms[15].items) { /* servers list */
941 serverList = as->parms[15].items;
942 for (i = 0; serverList; i++, serverList = serverList->next) {
944 if (i >= MAXHOSTSPERCELL)
946 strncpy(cellinfo.hostName[i], serverList->data, MAXHOSTCHARS);
947 th = gethostbyname(cellinfo.hostName[i]);
950 memcpy(&cellinfo.hostAddr[i].sin_addr, th->h_addr,
952 cellinfo.hostAddr[i].sin_family = AF_INET;
953 cellinfo.hostAddr[i].sin_port = 0;
954 #ifdef STRUCT_SOCKADDR_HAS_SA_LEN
955 cellinfo.hostAddr[i].sin_len = sizeof(struct sockaddr_in);
958 cellinfo.numServers = i;
959 strcpy(cellinfo.name, lcell);
961 code = afsconf_GetCellInfo(local_conf, lcell, 0, &cellinfo);
967 afsconf_Close(local_conf);
972 sprintf(tmp_conf_dir, "%s/afsconf.%lu", gettmpdir(),
973 (unsigned long)getpid());
974 code = mkdir(tmp_conf_dir, 0777);
975 if ((code < 0) && (errno != EEXIST)) {
976 afs_com_err(whoami, errno, "can't create temporary afsconf dir: %s",
981 strcompose(tmp_conf_file, 128, tmp_conf_dir, "/",
982 AFSDIR_CELLSERVDB_FILE, (char *)NULL);
983 f = fopen(tmp_conf_file, "w");
986 afs_com_err(whoami, errno, "can't create conf file %s",
990 fprintf(f, ">%s\n", lcell);
991 for (i = 0; i < cellinfo.numServers; i++) {
993 (unsigned char *)&cellinfo.hostAddr[i].sin_addr;
994 fprintf(f, "%d.%d.%d.%d\t#%s\n", tp[0], tp[1], tp[2], tp[3],
995 cellinfo.hostName[i]);
997 if (fclose(f) == EOF) {
999 afs_com_err(whoami, errno, "can't write to conf file %s",
1004 strcompose(tmp_cell_file, 128, tmp_conf_dir, "/",
1005 AFSDIR_THISCELL_FILE, (char *)NULL);
1006 f = fopen(tmp_cell_file, "w");
1009 fprintf(f, "%s", lcell);
1010 if (fclose(f) == EOF)
1013 strcompose(tmp_noauth_file, 128, tmp_conf_dir, "/",
1014 AFSDIR_NOAUTH_FILE, (char *)NULL);
1016 code = creat(tmp_noauth_file, 0777);
1017 if (code && (errno != EEXIST))
1019 } else { /* make sure file doesn't exist */
1020 code = unlink(tmp_noauth_file);
1021 if (code && (errno != ENOENT))
1026 strncpy(conf_dir, tmp_conf_dir, sizeof(conf_dir));
1027 conf = afsconf_Open(conf_dir);
1029 return AFSCONF_NOTFOUND;
1034 add_std_args(struct cmd_syndesc *ts)
1037 cmd_AddParm(ts, "-confdir", CMD_SINGLE, CMD_OPTIONAL,
1038 "AFS Conf dir pathname");
1039 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "Cell name");
1040 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "Don't authenticate");
1041 cmd_AddParm(ts, "-servers", CMD_LIST, CMD_OPTIONAL, "Server config");
1047 /* OK, this REALLY sucks bigtime, but I can't tell who is calling
1048 * afsconf_CheckAuth easily, and only *SERVERS* should be calling osi_audit
1049 * anyway. It's gonna give somebody fits to debug, I know, I know.
1054 #include "AFS_component_version_number.c"
1057 main(int argc, char *argv[])
1060 struct cmd_syndesc *ts; /* ptr to parsed command line syntax */
1063 initialize_CMD_error_table();
1064 initialize_ACFG_error_table();
1065 initialize_KTC_error_table();
1066 initialize_U_error_table();
1067 initialize_PT_error_table();
1068 initialize_RXK_error_table();
1071 /* initialize winsock */
1072 if (afs_winsockInit() < 0) {
1073 fprintf(stderr, "%s: couldn't initialize winsock. \n", whoami);
1078 cmd_SetBeforeProc(MyBeforeProc, NULL);
1079 cmd_SetAfterProc(MyAfterProc, NULL);
1081 ts = cmd_CreateSyntax("usedIds", ListUsedIds, NULL, 0,
1082 "Find used (or unused) user (or group) ids");
1083 cmd_AddParm(ts, "-startId", CMD_SINGLE, CMD_OPTIONAL,
1084 "id to start checking");
1085 cmd_AddParm(ts, "-number", CMD_SINGLE, CMD_OPTIONAL,
1086 "number of ids to check");
1087 cmd_AddParm(ts, "-unused", CMD_FLAG, CMD_OPTIONAL, "print unused ids");
1090 ts = cmd_CreateSyntax("initcmd", TestPrServ, NULL, 0, "test the prserver");
1093 ts = cmd_CreateSyntax("testmanymembers", TestManyMembers, NULL, 0,
1094 "test creating users and groups w/ many members");
1095 cmd_AddParm(ts, "-number", CMD_SINGLE, 0,
1096 "number of users/groups to create");
1097 cmd_AddParm(ts, "-dropoff", CMD_SINGLE, CMD_OPTIONAL,
1098 "precentage for exponential dropoff");
1099 cmd_AddParm(ts, "-prefix", CMD_SINGLE, CMD_OPTIONAL, "naming prefix");
1100 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "show progress");
1101 cmd_AddParm(ts, "-seed", CMD_SINGLE, CMD_OPTIONAL, "random number seed");
1103 cmd_CreateAlias(ts, "mm");
1106 code = cmd_Dispatch(argc, argv);
1108 afs_com_err(whoami, code, "calling cmd_Dispatch");