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);
92 range++; /* number that can be printed */
94 fprintf(stderr, "Only %d ids to be checked.\n", range);
98 printf("Checking for %d %sused ids starting at %d.\n", number,
99 (unused ? "un" : ""), startId);
101 lids.idlist_val = (afs_int32 *) malloc(sizeof(afs_int32) * NUM);
102 lnames.namelist_len = 0;
103 lnames.namelist_val = 0;
109 for (j = 0; j < i; j++) {
110 lids.idlist_val[j] = startId;
117 code = pr_IdToName(&lids, &lnames);
119 afs_com_err(whoami, code, "converting id to name");
122 for (j = 0; j < lnames.namelist_len; j++) {
123 if (lids.idlist_val[j] == atoi(lnames.namelist_val[j])) {
125 printf("%s is free\n", lnames.namelist_val[j]);
128 printf("%s is id %d\n", lnames.namelist_val[j],
135 free(lids.idlist_val);
136 if (lnames.namelist_val)
137 free(lnames.namelist_val);
141 /* TestManyMembers - called with a number N. Try creating N users and N groups
142 * and put all the users on one of the groups and one of the users on all the
143 * groups. Also put many users on many groups.
145 * To keep track of this create an NxN matrix of membership and fill it in with
146 * a function that looks like a quarter of a circle. That makes the first
147 * group contain every user and the first user be a member of every group. */
150 char callerName[PR_MAXNAMELEN];
152 afs_int32 lastGroup; /* id of last group created */
153 afs_int32 ownerUser; /* first created user */
154 char ownerUserName[PR_MAXNAMELEN]; /* " " " name */
155 int steepDropOff; /* precentage decreate in GroupLimit */
156 char *createPrefix; /* prefix for naming users&groups */
157 extern struct ubik_client *pruclient; /* initialized by pr_Initialize */
159 /* These variables form the state if this test */
160 int number; /* max number of members */
161 char *population; /* matrix of memberships */
162 afs_int32 *users; /* ids of users */
163 afs_int32 *groups; /* ids of groups */
164 afs_int32 *groupOwners; /* ids of owners of groups */
167 int nUsers, nGroups, nAdds, nRems, nUDels, nGDels;
170 IdCmp(const void *a, const void *b)
172 if (*(afs_int32 *)a > *(afs_int32 *)b) {
174 } else if (*(afs_int32 *)a == *(afs_int32 *)b) {
176 } else /* (*a < *b) */ {
188 GetGroupLimit(int N, int x)
192 if ((x >= N) || (x < 0)) {
193 printf("GetGroupLimit: input value out of range %d (%d)\n", x, N);
196 if (steepDropOff) { /* Use exponential decrease */
199 for (i = 0; i < x; i++) {
200 y = (y * steepDropOff) / 100; /* parameter is a percentage */
202 y = 1; /* with a floor of 1 */
206 } else { /* Use a circle's third quadrant */
207 y = sqr(N - 1) - sqr(N - 1 - x);
208 y = (int)(sqrt((double)y) + 0.5); /* round off */
211 if ((y > N) || (y < 1)) {
212 printf("filling value out of range: %d (%d) => %d\n", x, N, y);
225 sprintf(name, "%s%d", createPrefix, u);
227 code = pr_CreateUser(name, &id);
229 if (code == PREXIST) {
230 code = pr_Delete(name);
233 code = pr_CreateUser(name, &id);
241 afs_com_err(whoami, code, "couldn't create %s", name);
246 printf("Creating user %s (%di)\n", name, id);
250 if (ownerUser == 0) {
252 strcpy(ownerUserName, name);
263 char *ownerName = NULL;
264 int ownerType; /* type of ownership */
265 static char *lastGroupPrefix; /* prefix used for type==2 */
267 /* At least 50 groups should be owned by another group to test long owner
268 * chains during deletion. Also let's create some long owners of owners
270 ownerType = random() % 3;
279 ownerName = callerName;
283 ownerName = ownerUserName;
287 ownerName = lastGroupPrefix;
291 sprintf(name, "%s:%s%d", ownerName, createPrefix, g);
292 code = ubik_PR_NewEntry(pruclient, 0, name, PRGRP, owner, &id);
294 if (code == PREXIST) {
295 code = pr_Delete(name);
299 ubik_PR_NewEntry(pruclient, 0, name, PRGRP, owner,
308 afs_com_err(whoami, code, "couldn't create %s w/ owner=%d", name, owner);
313 printf("Creating group %s (%di)\n", name, id);
315 groupOwners[g] = owner;
317 if (!lastGroup || (ownerType == 2)) {
319 lastGroupPrefix = ownerName;
324 DeleteRandomId(afs_int32 *list)
331 k = random(); /* random starting point */
332 for (j = 0; j < number; j++) { /* find an undeleted id */
333 m = (k + j) % number;
334 if ((id = list[m])) {
335 code = ubik_PR_Delete(pruclient, 0, id);
337 afs_com_err(whoami, code, "Couldn't delete %di", id);
348 return -1; /* none left */
352 AddUser(int u, int g)
357 if (users[u] == 0) /* create if necessary */
359 if (groups[g] == 0) /* create group if necessary */
363 code = ubik_PR_AddToGroup(pruclient, 0, ui, gi);
365 afs_com_err(whoami, code, "couldn't add %d to %d", ui, gi);
369 printf("Adding user (%di) to group (%di)\n", ui, gi);
370 population[u * number + g]++;
375 RemUser(int u, int g)
382 code = ubik_PR_RemoveFromGroup(pruclient, 0, ui, gi);
384 afs_com_err(whoami, code, "couldn't remove %d from %d", ui, gi);
388 printf("Removing user (%di) from group (%di)\n", ui, gi);
389 population[u * number + g]--;
394 TestManyMembers(struct cmd_syndesc *as, void *arock)
396 char *filled; /* users filled up */
397 char *cleaned; /* users cleaned up */
399 int nFilled, nCleaned;
401 int seed; /* random number generator seed */
403 afs_int32 *glist; /* membership list */
407 code = pr_Initialize(1, conf_dir, NULL);
409 afs_com_err(whoami, code, "initializing pruser");
412 /* get name of person running command */
414 struct ktc_principal afs, user;
415 struct ktc_token token;
417 strcpy(afs.name, "afs");
418 strcpy(afs.instance, "");
419 code = afsconf_GetLocalCell(conf, afs.cell, sizeof(afs.cell));
422 code = ktc_GetToken(&afs, &token, sizeof(token), &user);
424 afs_com_err(whoami, code, "getting afs tokens");
427 if (strlen(user.instance) > 0) {
428 fprintf(stderr, "can't handle non-null instance %s.%s\n",
429 user.name, user.cell);
432 if (strncmp(user.name, "AFS ID ", 7) == 0) {
433 callerId = atoi(user.name + 7);
434 code = pr_SIdToName(callerId, callerName);
436 afs_com_err(whoami, code, "call get name for id %d", callerId);
440 strcpy(callerName, user.name);
441 code = pr_SNameToId(callerName, &callerId);
442 if ((code == 0) && (callerId == ANONYMOUSID))
445 #if 0 /* don't create user */
446 if (code == PRNOENT) {
448 code = pr_CreateUser(callerName, &callerId);
450 afs_com_err(whoami, code, "can't create caller %s", callerName);
453 printf("Creating caller %s (%di)\n", callerName, callerId);
458 afs_com_err(whoami, code, "can't find caller %s", callerName);
461 printf("Assuming caller is %s (%di)\n", callerName, callerId);
464 /* Parse arguments */
465 if (as->parms[0].items)
466 number = atoi(as->parms[0].items->data);
467 if (as->parms[1].items) {
468 steepDropOff = atoi(as->parms[1].items->data);
469 if ((steepDropOff < 0) || (steepDropOff > 100)) {
471 "Illegal value for dropoff: %d, must be between 0 and 100, inclusive.\n",
476 steepDropOff = 0; /* use quadratic dropoff */
477 if (as->parms[2].items)
478 createPrefix = as->parms[2].items->data;
481 if (as->parms[3].items)
485 if (as->parms[4].items)
486 seed = atoi(as->parms[4].items->data);
492 users = calloc(number, sizeof(afs_int32));
493 groups = calloc(number, sizeof(afs_int32));
494 filled = calloc(number, sizeof(char));
495 cleaned = calloc(number, sizeof(char));
496 population = calloc(sqr(number), sizeof(char));
501 ownerUser = lastGroup = 0;
502 groupOwners = (afs_int32 *) malloc(number * sizeof(afs_int32));
503 nUsers = nGroups = nAdds = nRems = nUDels = nGDels = 0;
505 while ((nFilled < number) || (nCleaned < number)) {
506 /* pick a user at random, using */
507 u = random() % number;
509 n = GetGroupLimit(number, u); /* get group limit for that user */
510 g = random() % (n + 1); /* pick a random group */
511 if (g == n) { /* in a few cases create any user */
512 n = number; /* in the whole range */
515 for (i = 0; i < n; i++) { /* rotate until unused one found */
517 if (!population[u * number + j]) {
518 /* add this user/group membership */
529 if (filled[u]) { /* only clean above GroupLimit */
530 base = GetGroupLimit(number, u);
537 n = number; /* pick a group from the whole range */
538 g = random() % 2 * n; /* at random for removal */
540 goto remed; /* but half the time do nothing */
542 for (i = 0; i < n; i++) { /* rotate until used one found */
543 j = (g + i) % n + base;
544 if (population[u * number + j]) {
545 /* remove this user/group membership */
550 if (filled[u]) { /* track finished ones */
559 /* check the membership list of all users for correctness */
560 printf("Starting check of memberships\n");
561 glist = (afs_int32 *) malloc(number * sizeof(afs_int32));
562 for (u = 0; u < number; u++) {
563 afs_int32 ui = users[u];
566 int ng; /* number groups */
568 int (*proc)(struct ubik_client *, afs_int32, afs_int32, prlist *,
572 alist.prlist_len = 0;
573 alist.prlist_val = 0;
575 proc = ubik_PR_ListElements;
577 proc = ubik_PR_GetCPS;
579 code = (*proc)(pruclient, 0, ui, &alist, &over);
581 afs_com_err(whoami, code,
582 "getting membership list of (%di) using %s", ui,
583 (proc == ubik_PR_ListElements?"ListElements":"GetCPS"));
587 fprintf(stderr, "membership list for id %di too long\n", ui);
590 for (i = 0; i < number; i++)
591 if (population[u * number + i])
592 glist[ng++] = groups[i];
593 qsort(glist, ng, sizeof(afs_int32), IdCmp);
594 if (ng != (alist.prlist_len - ((proc == ubik_PR_GetCPS) ? 3 : 0))) {
596 "Membership list for %di of unexpected length: was %d but expected %d\n",
597 ui, alist.prlist_len, ng);
600 /* all the extra entries for the CPS should be at the end. */
602 for (i = 0; i < ng; i++)
603 if (alist.prlist_val[i] != glist[i]) {
605 "membership for %di not correct: was %di but expected %di\n",
606 ui, alist.prlist_val[i], glist[i]);
611 if (proc == ubik_PR_GetCPS) {
612 if ((alist.prlist_val[i /* =ng */ ] != AUTHUSERID) ||
613 (alist.prlist_val[++i] != ANYUSERID)
614 || (alist.prlist_val[++i] != ui)) {
615 fprintf(stderr, "CPS doesn't have extra entries\n");
619 if (alist.prlist_val)
620 free(alist.prlist_val);
622 /* User 0 is a member of all groups all of which should also be on
623 * the owner list of the caller or the ownerUser, although there
624 * may also be others. Check this. */
628 prlist lastGroupList;
632 fprintf(stderr, "User 0 not a member of all groups\n");
635 #define GETOWNED(xlist,xid) \
636 (xlist).prlist_val = 0; (xlist).prlist_len = 0; \
637 code = ubik_PR_ListOwned(pruclient, 0, (xid), &(xlist), &over); \
639 afs_com_err (whoami, code, "getting owner list of (%di)", (xid)); \
642 { fprintf (stderr, "membership of id %di too long\n", (xid)); }
644 GETOWNED(callerList, callerId);
645 GETOWNED(ownerList, ownerUser);
647 /* look for every entry in glist, in all the owner lists */
648 for (i = j = k = l = 0; i < number; i++) {
649 while ((j < callerList.prlist_len)
650 && (callerList.prlist_val[j] < glist[i]))
652 while ((k < ownerList.prlist_len)
653 && (ownerList.prlist_val[k] < glist[i]))
655 #define PRLISTCMP(l,i) \
656 (((l).prlist_len == 0) || (glist[i] != (l).prlist_val[(i)]))
657 if (PRLISTCMP(callerList, j) && PRLISTCMP(ownerList, k)) {
658 for (l = 0; l < number; l++) {
659 if (groups[l] == glist[i]) {
660 if ((groupOwners[l] != callerId)
661 && (groupOwners[l] != ownerUser)) {
662 GETOWNED(lastGroupList, groupOwners[l]);
663 if ((lastGroupList.prlist_len != 1)
664 || (lastGroupList.prlist_val[0] !=
667 "Group (%di) not on any owner list\n",
675 fprintf(stderr, "unexpected group %di\n", glist[i]);
679 if (callerList.prlist_val)
680 free(callerList.prlist_val);
681 if (ownerList.prlist_val)
682 free(ownerList.prlist_val);
683 if (lastGroupList.prlist_val)
684 free(lastGroupList.prlist_val);
689 /* cleanup by deleting all the users and groups */
690 printf("Starting deletion of users and groups\n");
691 for (i = 0; i < number; i++) {
692 DeleteRandomId(users);
693 DeleteRandomId(groups);
697 ("Created/deleted %d/%d users and %d/%d groups; added %d and removed %d.\n",
698 nUsers, nUDels, nGroups, nGDels, nAdds, nRems);
702 /* from ka_ConvertBytes included here to avoid circularity */
703 /* Converts a byte string to ascii. Return the number of unconverted bytes. */
706 ka_ConvertBytes(char *ascii, /* output buffer */
707 int alen, /* buffer length */
708 char bs[], /* byte string */
709 int bl) /* number of bytes */
714 alen--; /* make room for termination */
715 for (i = 0; i < bl; i++) {
719 if (isalnum(c) || ispunct(c))
720 (*ascii++ = c), alen--;
725 *ascii++ = (c >> 6) + '0';
726 *ascii++ = (c >> 3 & 7) + '0';
727 *ascii++ = (c & 7) + '0';
731 *ascii = 0; /* terminate string */
735 /* This runs various tests on the server. It creates, then deletes, a bunch of
736 * users and groups, so it would be safest to run it on a test database.
738 * These are the things I check for:
739 * User names longer than PR_MAXNAMELEN - strlen(cellname).
740 * Group names longer than PR_MAXNAMELEN.
741 * User names containing all legal 8-bit ascii characters. This excludes
742 * only ':', '@', and '\n'.
743 * Group names as above, but at least one colon is required, and the owner
748 TestPrServ(struct cmd_syndesc *as, void *arock)
751 char name[PR_MAXNAMELEN + 1];
752 char creator[PR_MAXNAMELEN]; /* our name */
753 struct prcheckentry ent;
756 int maxLen = PR_MAXNAMELEN - 1 - strlen(lcell) - 1;
758 code = pr_Initialize(1, conf_dir, NULL);
760 afs_com_err(whoami, code, "initializing pruser");
764 for (i = 0; i < maxLen; i++)
766 name[i] = 'a'; /* too long a name... */
769 code = pr_CreateUser(name, &id);
770 if ((code != RXGEN_CC_MARSHAL) && (code != PRBADNAM)) {
771 afs_com_err(whoami, code, "succeeded creating %s", name);
776 code = pr_CreateUser(name, &id);
777 if (code == PREXIST) {
778 fprintf(stderr, "group already exists, skipping\n");
779 pr_SNameToId(name, &id);
781 afs_com_err(whoami, code, "failed creating %s", name);
784 if ((code = pr_ListEntry(id, &ent))
785 || (code = pr_SIdToName(ent.creator, creator))) {
786 afs_com_err(whoami, code, "getting creator's name");
789 code = pr_DeleteByID(id);
791 afs_com_err(whoami, code, "deleting %s", name);
794 /* now make sure the illegal chars are detected */
797 for (illegalChars = "@:\n"; *illegalChars; illegalChars++) {
798 name[10] = *illegalChars;
800 code = pr_CreateUser(name, &id);
801 if (code != PRBADNAM) {
802 afs_com_err(whoami, code, "succeeded creating %s", name);
808 for (i = 1; i <= 255;) { /* for all 8-bit ascii... */
809 j = 0; /* build a new name */
810 while ((j < maxLen) && (i <= 255)) {
811 if (!((i == ':') || (i == '@') || (i == '\n')))
815 name[j] = 0; /* terminate string */
817 code = pr_CreateUser(name, &id);
818 if (code == PREXIST) {
819 fprintf(stderr, "user already exists, skipping\n");
820 pr_SNameToId(name, &id);
823 ka_ConvertBytes(ascii, sizeof(ascii), name, strlen(name));
824 afs_com_err(whoami, code, "failed creating %s", ascii);
827 code = pr_DeleteByID(id);
829 afs_com_err(whoami, code, "deleting %s", name);
834 /* now check group names */
835 strcpy(name, creator);
836 strcat(name, ":abcdefghijklmnopqrstuvwxyz");
837 name[0] = 1; /* bash the owner name */
839 code = pr_CreateGroup(name, creator, &id);
840 if (code != PRNOENT) { /* owner doesn't exist */
841 afs_com_err(whoami, code, "succeeded creating %s", name);
844 name[0] = creator[0]; /* fix owner */
845 /* Make sure the illegal chars are detected */
848 for (illegalChars = ":@\n"; *illegalChars; illegalChars++) {
849 name[strlen(creator) + 10] = *illegalChars;
851 code = pr_CreateGroup(name, creator, &id);
852 if (code != PRBADNAM) {
853 afs_com_err(whoami, code, "succeeded creating %s", name);
858 for (i = 1; i <= 255;) { /* for all 8-bit ascii... */
859 j = strlen(creator) + 1; /* build a new name */
860 while ((j < PR_MAXNAMELEN - 1) && (i <= 255)) {
861 if (!((i == ':') || (i == '@') || (i == '\n')))
865 name[j] = 0; /* terminate string */
867 code = pr_CreateGroup(name, creator, &id);
868 if (code == PREXIST) {
869 fprintf(stderr, "group already exists, skipping\n");
870 pr_SNameToId(name, &id);
873 ka_ConvertBytes(ascii, sizeof(ascii), name, strlen(name));
874 afs_com_err(whoami, code, "failed creating %s", ascii);
877 code = pr_DeleteByID(id);
879 afs_com_err(whoami, code, "deleting %s", name);
888 static char tmp_conf_dir[128] = "";
889 static char tmp_conf_file[128] = "";
890 static char tmp_cell_file[128] = "";
891 static char tmp_noauth_file[128] = "";
894 MyAfterProc(struct cmd_syndesc *as, void *arock)
896 if (strlen(tmp_conf_file))
897 unlink(tmp_conf_file);
898 if (strlen(tmp_cell_file))
899 unlink(tmp_cell_file);
900 if (strlen(tmp_noauth_file))
901 unlink(tmp_noauth_file);
902 if (strlen(tmp_conf_dir))
908 MyBeforeProc(struct cmd_syndesc *as, void *arock)
914 struct cmd_item *serverList = 0;
915 struct afsconf_dir *local_conf = 0; /* so we can default stuff nicely */
916 struct afsconf_cell cellinfo;
918 if (as->parms[12].items) { /* if conf dir specified */
919 cdir = as->parms[12].items->data;
920 if (as->parms[13].items || as->parms[14].items || as->parms[15].items) {
921 printf("Can't specify conf dir and other cell parameters\n");
922 return AFSCONF_SYNTAX;
926 /* if we need to default cell name or cell servers, get local conf info */
928 if (!(local_conf = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH))
929 && !(local_conf = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH))) {
930 printf("** Can't local configuration!\n");
931 return AFSCONF_NOCELL;
934 if (as->parms[13].items) { /* if cell name specified */
935 lcstring(lcell, as->parms[13].items->data, sizeof(lcell));
936 code = afsconf_GetCellInfo(local_conf, lcell, 0, &cellinfo);
938 strncpy(lcell, cellinfo.name, sizeof(lcell));
940 code = afsconf_GetLocalCell(local_conf, lcell, sizeof(lcell));
945 if (as->parms[14].items) { /* noauth flag */
949 if (as->parms[15].items) { /* servers list */
950 serverList = as->parms[15].items;
951 for (i = 0; serverList; i++, serverList = serverList->next) {
953 if (i >= MAXHOSTSPERCELL)
955 strncpy(cellinfo.hostName[i], serverList->data, MAXHOSTCHARS);
956 th = gethostbyname(cellinfo.hostName[i]);
959 memcpy(&cellinfo.hostAddr[i].sin_addr, th->h_addr,
961 cellinfo.hostAddr[i].sin_family = AF_INET;
962 cellinfo.hostAddr[i].sin_port = 0;
963 #ifdef STRUCT_SOCKADDR_HAS_SA_LEN
964 cellinfo.hostAddr[i].sin_len = sizeof(struct sockaddr_in);
967 cellinfo.numServers = i;
968 strcpy(cellinfo.name, lcell);
970 code = afsconf_GetCellInfo(local_conf, lcell, 0, &cellinfo);
976 afsconf_Close(local_conf);
981 sprintf(tmp_conf_dir, "%s/afsconf.%lu", gettmpdir(),
982 (unsigned long)getpid());
983 code = mkdir(tmp_conf_dir, 0777);
984 if ((code < 0) && (errno != EEXIST)) {
985 afs_com_err(whoami, errno, "can't create temporary afsconf dir: %s",
990 strcompose(tmp_conf_file, 128, tmp_conf_dir, "/",
991 AFSDIR_CELLSERVDB_FILE, NULL);
992 f = fopen(tmp_conf_file, "w");
995 afs_com_err(whoami, errno, "can't create conf file %s",
999 fprintf(f, ">%s\n", lcell);
1000 for (i = 0; i < cellinfo.numServers; i++) {
1002 (unsigned char *)&cellinfo.hostAddr[i].sin_addr;
1003 fprintf(f, "%d.%d.%d.%d\t#%s\n", tp[0], tp[1], tp[2], tp[3],
1004 cellinfo.hostName[i]);
1006 if (fclose(f) == EOF) {
1008 afs_com_err(whoami, errno, "can't write to conf file %s",
1013 strcompose(tmp_cell_file, 128, tmp_conf_dir, "/",
1014 AFSDIR_THISCELL_FILE, NULL);
1015 f = fopen(tmp_cell_file, "w");
1018 fprintf(f, "%s", lcell);
1019 if (fclose(f) == EOF)
1022 strcompose(tmp_noauth_file, 128, tmp_conf_dir, "/",
1023 AFSDIR_NOAUTH_FILE, NULL);
1025 code = creat(tmp_noauth_file, 0777);
1026 if (code && (errno != EEXIST))
1028 } else { /* make sure file doesn't exist */
1029 code = unlink(tmp_noauth_file);
1030 if (code && (errno != ENOENT))
1035 strncpy(conf_dir, tmp_conf_dir, sizeof(conf_dir));
1036 conf = afsconf_Open(conf_dir);
1038 return AFSCONF_NOTFOUND;
1043 add_std_args(struct cmd_syndesc *ts)
1046 cmd_AddParm(ts, "-confdir", CMD_SINGLE, CMD_OPTIONAL,
1047 "AFS Conf dir pathname");
1048 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "Cell name");
1049 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "Don't authenticate");
1050 cmd_AddParm(ts, "-servers", CMD_LIST, CMD_OPTIONAL, "Server config");
1056 /* OK, this REALLY sucks bigtime, but I can't tell who is calling
1057 * afsconf_CheckAuth easily, and only *SERVERS* should be calling osi_audit
1058 * anyway. It's gonna give somebody fits to debug, I know, I know.
1063 #include "AFS_component_version_number.c"
1066 main(int argc, char *argv[])
1069 struct cmd_syndesc *ts; /* ptr to parsed command line syntax */
1072 initialize_CMD_error_table();
1073 initialize_ACFG_error_table();
1074 initialize_KTC_error_table();
1075 initialize_U_error_table();
1076 initialize_PT_error_table();
1077 initialize_RXK_error_table();
1080 /* initialize winsock */
1081 if (afs_winsockInit() < 0) {
1082 fprintf(stderr, "%s: couldn't initialize winsock. \n", whoami);
1087 cmd_SetBeforeProc(MyBeforeProc, NULL);
1088 cmd_SetAfterProc(MyAfterProc, NULL);
1090 ts = cmd_CreateSyntax("usedIds", ListUsedIds, NULL,
1091 "Find used (or unused) user (or group) ids");
1092 cmd_AddParm(ts, "-startId", CMD_SINGLE, CMD_OPTIONAL,
1093 "id to start checking");
1094 cmd_AddParm(ts, "-number", CMD_SINGLE, CMD_OPTIONAL,
1095 "number of ids to check");
1096 cmd_AddParm(ts, "-unused", CMD_FLAG, CMD_OPTIONAL, "print unused ids");
1099 ts = cmd_CreateSyntax("initcmd", TestPrServ, NULL, "test the prserver");
1102 ts = cmd_CreateSyntax("testmanymembers", TestManyMembers, NULL,
1103 "test creating users and groups w/ many members");
1104 cmd_AddParm(ts, "-number", CMD_SINGLE, 0,
1105 "number of users/groups to create");
1106 cmd_AddParm(ts, "-dropoff", CMD_SINGLE, CMD_OPTIONAL,
1107 "precentage for exponential dropoff");
1108 cmd_AddParm(ts, "-prefix", CMD_SINGLE, CMD_OPTIONAL, "naming prefix");
1109 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "show progress");
1110 cmd_AddParm(ts, "-seed", CMD_SINGLE, CMD_OPTIONAL, "random number seed");
1112 cmd_CreateAlias(ts, "mm");
1115 code = cmd_Dispatch(argc, argv);
1117 afs_com_err(whoami, code, "calling cmd_Dispatch");