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>
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>
45 #include <afs/afsutil.h>
46 #include <afs/com_err.h>
48 static char *whoami = "testpr";
49 static struct afsconf_dir *conf; /* cell info, set by MyBeforeProc */
50 static char conf_dir[100];
51 static char lcell[MAXCELLCHARS];
54 ListUsedIds(struct cmd_syndesc *as, char *arock)
60 int group = 0; /* check groups */
61 int unused = 0; /* print unused */
62 int number = 100; /* check 100 ids */
63 afs_int32 startId = 1;
67 if (as->parms[0].items)
68 startId = atoi(as->parms[0].items->data);
69 if (as->parms[1].items)
70 number = atoi(as->parms[1].items->data);
71 if (as->parms[2].items)
74 code = pr_Initialize(1, conf_dir, NULL);
76 afs_com_err(whoami, code, "initializing pruser");
81 code = pr_ListMaxGroupId(&maxId);
84 afs_com_err(whoami, code, "getting maximum id");
87 if (startId < maxId) {
88 fprintf(stderr, "Max group id is only %d.\n", maxId);
92 code = pr_ListMaxUserId(&maxId);
95 if (startId > maxId) {
96 fprintf(stderr, "Max user id is only %d.\n", maxId);
100 range = abs(startId - maxId);
103 range++; /* number that can be printed */
104 if (range < number) {
105 fprintf(stderr, "Only %d ids to be checked.\n", range);
109 printf("Checking for %d %sused ids starting at %d.\n", number,
110 (unused ? "un" : ""), startId);
112 lids.idlist_val = (afs_int32 *) malloc(sizeof(afs_int32) * NUM);
113 lnames.namelist_len = 0;
114 lnames.namelist_val = 0;
120 for (j = 0; j < i; j++) {
121 lids.idlist_val[j] = startId;
128 code = pr_IdToName(&lids, &lnames);
130 afs_com_err(whoami, code, "converting id to name");
133 for (j = 0; j < lnames.namelist_len; j++) {
134 if (lids.idlist_val[j] == atoi(lnames.namelist_val[j])) {
136 printf("%s is free\n", lnames.namelist_val[j]);
139 printf("%s is id %d\n", lnames.namelist_val[j],
146 free(lids.idlist_val);
147 if (lnames.namelist_val)
148 free(lnames.namelist_val);
152 /* TestManyMembers - called with a number N. Try creating N users and N groups
153 * and put all the users on one of the groups and one of the users on all the
154 * groups. Also put many users on many groups.
156 * To keep track of this create an NxN matrix of membership and fill it in with
157 * a function that looks like a quarter of a circle. That makes the first
158 * group contain every user and the first user be a member of every group. */
161 char callerName[PR_MAXNAMELEN];
163 afs_int32 lastGroup; /* id of last group created */
164 afs_int32 ownerUser; /* first created user */
165 char ownerUserName[PR_MAXNAMELEN]; /* " " " name */
166 int steepDropOff; /* precentage decreate in GroupLimit */
167 char *createPrefix; /* prefix for naming users&groups */
168 extern struct ubik_client *pruclient; /* initialized by pr_Initialize */
170 /* These variables form the state if this test */
171 int number; /* max number of members */
172 char *population; /* matrix of memberships */
173 afs_int32 *users; /* ids of users */
174 afs_int32 *groups; /* ids of groups */
175 afs_int32 *groupOwners; /* ids of owners of groups */
178 int nUsers, nGroups, nAdds, nRems, nUDels, nGDels;
181 IdCmp(afs_int32 *a, afs_int32 *b)
185 } else if (*a == *b) {
187 } else /* (*a < *b) */ {
199 GetGroupLimit(int N, int x)
204 if ((x >= N) || (x < 0)) {
205 printf("GetGroupLimit: input value out of range %d (%d)\n", x, N);
208 if (steepDropOff) { /* Use exponential decrease */
211 for (i = 0; i < x; i++) {
212 y = (y * steepDropOff) / 100; /* parameter is a percentage */
214 y = 1; /* with a floor of 1 */
218 } else { /* Use a circle's third quadrant */
219 y = sqr(N - 1) - sqr(N - 1 - x);
220 y = (int)(sqrt((double)y) + 0.5); /* round off */
223 if ((y > N) || (y < 1)) {
224 printf("filling value out of range: %d (%d) => %d\n", x, N, y);
237 sprintf(name, "%s%d", createPrefix, u);
239 code = pr_CreateUser(name, &id);
241 if (code == PREXIST) {
242 code = pr_Delete(name);
245 code = pr_CreateUser(name, &id);
253 afs_com_err(whoami, code, "couldn't create %s", name);
258 printf("Creating user %s (%di)\n", name, id);
262 if (ownerUser == 0) {
264 strcpy(ownerUserName, name);
274 afs_int32 flags = PRGRP;
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;
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, char *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 */
585 int (*proc) (); /* membership listing procedure */
589 alist.prlist_len = 0;
590 alist.prlist_val = 0;
592 proc = PR_ListElements;
595 code = ubik_Call(proc, pruclient, 0, ui, &alist, &over);
597 afs_com_err(whoami, code,
598 "getting membership list of (%di) using %s", ui,
599 ((proc == PR_GetCPS) ? "GetCPR" : "ListElements"));
603 fprintf(stderr, "membership list for id %di too long\n", ui);
606 for (i = 0; i < number; i++)
607 if (population[u * number + i])
608 glist[ng++] = groups[i];
609 qsort(glist, ng, sizeof(afs_int32), IdCmp);
610 if (ng != (alist.prlist_len - ((proc == PR_GetCPS) ? 3 : 0))) {
612 "Membership list for %di of unexpected length: was %d but expected %d\n",
613 ui, alist.prlist_len, ng);
616 /* all the extra entries for the CPS should be at the end. */
618 for (i = 0; i < ng; i++)
619 if (alist.prlist_val[i] != glist[i]) {
621 "membership for %di not correct: was %di but expected %di\n",
622 ui, alist.prlist_val[i], glist[i]);
627 if (proc == PR_GetCPS) {
628 if ((alist.prlist_val[i /* =ng */ ] != AUTHUSERID) ||
629 (alist.prlist_val[++i] != ANYUSERID)
630 || (alist.prlist_val[++i] != ui)) {
631 fprintf(stderr, "CPS doesn't have extra entries\n");
635 if (alist.prlist_val)
636 free(alist.prlist_val);
638 /* User 0 is a member of all groups all of which should also be on
639 * the owner list of the caller or the ownerUser, although there
640 * may also be others. Check this. */
644 prlist lastGroupList;
648 fprintf(stderr, "User 0 not a member of all groups\n");
651 #define GETOWNED(xlist,xid) \
652 (xlist).prlist_val = 0; (xlist).prlist_len = 0; \
653 code = ubik_PR_ListOwned(pruclient, 0, (xid), &(xlist), &over); \
655 afs_com_err (whoami, code, "getting owner list of (%di)", (xid)); \
658 { fprintf (stderr, "membership of id %di too long\n", (xid)); }
660 GETOWNED(callerList, callerId);
661 GETOWNED(ownerList, ownerUser);
663 /* look for every entry in glist, in all the owner lists */
664 for (i = j = k = l = 0; i < number; i++) {
665 while ((j < callerList.prlist_len)
666 && (callerList.prlist_val[j] < glist[i]))
668 while ((k < ownerList.prlist_len)
669 && (ownerList.prlist_val[k] < glist[i]))
671 #define PRLISTCMP(l,i) \
672 (((l).prlist_len == 0) || (glist[i] != (l).prlist_val[(i)]))
673 if (PRLISTCMP(callerList, j) && PRLISTCMP(ownerList, k)) {
674 for (l = 0; l < number; l++) {
675 if (groups[l] == glist[i]) {
676 if ((groupOwners[l] != callerId)
677 && (groupOwners[l] != ownerUser)) {
678 GETOWNED(lastGroupList, groupOwners[l]);
679 if ((lastGroupList.prlist_len != 1)
680 || (lastGroupList.prlist_val[0] !=
683 "Group (%di) not on any owner list\n",
691 fprintf(stderr, "unexpected group %di\n", glist[i]);
695 if (callerList.prlist_val)
696 free(callerList.prlist_val);
697 if (ownerList.prlist_val)
698 free(ownerList.prlist_val);
699 if (lastGroupList.prlist_val)
700 free(lastGroupList.prlist_val);
705 /* cleanup by deleting all the users and groups */
706 printf("Starting deletion of users and groups\n");
707 for (i = 0; i < number; i++) {
708 DeleteRandomId(users);
709 DeleteRandomId(groups);
713 ("Created/deleted %d/%d users and %d/%d groups; added %d and removed %d.\n",
714 nUsers, nUDels, nGroups, nGDels, nAdds, nRems);
718 /* from ka_ConvertBytes included here to avoid circularity */
719 /* Converts a byte string to ascii. Return the number of unconverted bytes. */
722 ka_ConvertBytes(char *ascii, /* output buffer */
723 int alen, /* buffer length */
724 char bs[], /* byte string */
725 int bl) /* number of bytes */
730 alen--; /* make room for termination */
731 for (i = 0; i < bl; i++) {
735 if (isalnum(c) || ispunct(c))
736 (*ascii++ = c), alen--;
741 *ascii++ = (c >> 6) + '0';
742 *ascii++ = (c >> 3 & 7) + '0';
743 *ascii++ = (c & 7) + '0';
747 *ascii = 0; /* terminate string */
751 /* This runs various tests on the server. It creates, then deletes, a bunch of
752 * users and groups, so it would be safest to run it on a test database.
754 * These are the things I check for:
755 * User names longer than PR_MAXNAMELEN - strlen(cellname).
756 * Group names longer than PR_MAXNAMELEN.
757 * User names containing all legal 8-bit ascii characters. This excludes
758 * only ':', '@', and '\n'.
759 * Group names as above, but at least one colon is required, and the owner
764 TestPrServ(struct cmd_syndesc *as, char *arock)
767 char name[PR_MAXNAMELEN + 1];
768 char creator[PR_MAXNAMELEN]; /* our name */
769 struct prcheckentry ent;
772 int maxLen = PR_MAXNAMELEN - 1 - strlen(lcell) - 1;
774 code = pr_Initialize(1, conf_dir, NULL);
776 afs_com_err(whoami, code, "initializing pruser");
780 for (i = 0; i < maxLen; i++)
782 name[i] = 'a'; /* too long a name... */
785 code = pr_CreateUser(name, &id);
786 if ((code != RXGEN_CC_MARSHAL) && (code != PRBADNAM)) {
787 afs_com_err(whoami, code, "succeeded creating %s", name);
792 code = pr_CreateUser(name, &id);
793 if (code == PREXIST) {
794 fprintf(stderr, "group already exists, skipping\n");
795 pr_SNameToId(name, &id);
797 afs_com_err(whoami, code, "failed creating %s", name);
800 if ((code = pr_ListEntry(id, &ent))
801 || (code = pr_SIdToName(ent.creator, creator))) {
802 afs_com_err(whoami, code, "getting creator's name");
805 code = pr_DeleteByID(id);
807 afs_com_err(whoami, code, "deleting %s", name);
810 /* now make sure the illegal chars are detected */
813 for (illegalChars = "@:\n"; *illegalChars; illegalChars++) {
814 name[10] = *illegalChars;
816 code = pr_CreateUser(name, &id);
817 if (code != PRBADNAM) {
818 afs_com_err(whoami, code, "succeeded creating %s", name);
824 for (i = 1; i <= 255;) { /* for all 8-bit ascii... */
825 j = 0; /* build a new name */
826 while ((j < maxLen) && (i <= 255)) {
827 if (!((i == ':') || (i == '@') || (i == '\n')))
831 name[j] = 0; /* terminate string */
833 code = pr_CreateUser(name, &id);
834 if (code == PREXIST) {
835 fprintf(stderr, "user already exists, skipping\n");
836 pr_SNameToId(name, &id);
839 ka_ConvertBytes(ascii, sizeof(ascii), name, strlen(name));
840 afs_com_err(whoami, code, "failed creating %s", ascii);
843 code = pr_DeleteByID(id);
845 afs_com_err(whoami, code, "deleting %s", name);
850 /* now check group names */
851 strcpy(name, creator);
852 strcat(name, ":abcdefghijklmnopqrstuvwxyz");
853 name[0] = 1; /* bash the owner name */
855 code = pr_CreateGroup(name, &id);
856 if (code != PRNOENT) { /* owner doesn't exist */
857 afs_com_err(whoami, code, "succeeded creating %s", name);
860 name[0] = creator[0]; /* fix owner */
861 /* Make sure the illegal chars are detected */
864 for (illegalChars = ":@\n"; *illegalChars; illegalChars++) {
865 name[strlen(creator) + 10] = *illegalChars;
867 code = pr_CreateGroup(name, creator, &id);
868 if (code != PRBADNAM) {
869 afs_com_err(whoami, code, "succeeded creating %s", name);
874 for (i = 1; i <= 255;) { /* for all 8-bit ascii... */
875 j = strlen(creator) + 1; /* build a new name */
876 while ((j < PR_MAXNAMELEN - 1) && (i <= 255)) {
877 if (!((i == ':') || (i == '@') || (i == '\n')))
881 name[j] = 0; /* terminate string */
883 code = pr_CreateGroup(name, creator, &id);
884 if (code == PREXIST) {
885 fprintf(stderr, "group already exists, skipping\n");
886 pr_SNameToId(name, &id);
889 ka_ConvertBytes(ascii, sizeof(ascii), name, strlen(name));
890 afs_com_err(whoami, code, "failed creating %s", ascii);
893 code = pr_DeleteByID(id);
895 afs_com_err(whoami, code, "deleting %s", name);
904 static char tmp_conf_dir[128] = "";
905 static char tmp_conf_file[128] = "";
906 static char tmp_cell_file[128] = "";
907 static char tmp_noauth_file[128] = "";
910 MyAfterProc(struct cmd_syndesc *as, char *arock)
912 if (strlen(tmp_conf_file))
913 unlink(tmp_conf_file);
914 if (strlen(tmp_cell_file))
915 unlink(tmp_cell_file);
916 if (strlen(tmp_noauth_file))
917 unlink(tmp_noauth_file);
918 if (strlen(tmp_conf_dir))
924 MyBeforeProc(struct cmd_syndesc *as, char *arock)
930 struct cmd_item *serverList = 0;
931 struct afsconf_dir *local_conf = 0; /* so we can default stuff nicely */
932 struct afsconf_cell cellinfo;
934 if (as->parms[12].items) { /* if conf dir specified */
935 cdir = as->parms[12].items->data;
936 if (as->parms[13].items || as->parms[14].items || as->parms[15].items) {
937 printf("Can't specify conf dir and other cell parameters\n");
938 return AFSCONF_SYNTAX;
942 /* if we need to default cell name or cell servers, get local conf info */
944 if (!(local_conf = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH))
945 && !(local_conf = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH))) {
946 printf("** Can't local configuration!\n");
947 return AFSCONF_NOCELL;
950 if (as->parms[13].items) { /* if cell name specified */
951 lcstring(lcell, as->parms[13].items->data, sizeof(lcell));
952 code = afsconf_GetCellInfo(local_conf, lcell, 0, &cellinfo);
954 strncpy(lcell, cellinfo.name, sizeof(lcell));
956 code = afsconf_GetLocalCell(local_conf, lcell, sizeof(lcell));
961 if (as->parms[14].items) { /* noauth flag */
965 if (as->parms[15].items) { /* servers list */
966 serverList = as->parms[15].items;
967 for (i = 0; serverList; i++, serverList = serverList->next) {
969 if (i >= MAXHOSTSPERCELL)
971 strncpy(cellinfo.hostName[i], serverList->data, MAXHOSTCHARS);
972 th = gethostbyname(cellinfo.hostName[i]);
975 memcpy(&cellinfo.hostAddr[i].sin_addr, th->h_addr,
977 cellinfo.hostAddr[i].sin_family = AF_INET;
978 cellinfo.hostAddr[i].sin_port = 0;
979 #ifdef STRUCT_SOCKADDR_HAS_SA_LEN
980 cellinfo.hostAddr[i].sin_len = sizeof(struct sockaddr_in);
983 cellinfo.numServers = i;
984 strcpy(cellinfo.name, lcell);
986 code = afsconf_GetCellInfo(local_conf, lcell, 0, &cellinfo);
992 afsconf_Close(local_conf);
997 sprintf(tmp_conf_dir, "%s/afsconf.%lu", gettmpdir(),
998 (unsigned long)getpid());
999 code = mkdir(tmp_conf_dir, 0777);
1000 if ((code < 0) && (errno != EEXIST)) {
1001 afs_com_err(whoami, errno, "can't create temporary afsconf dir: %s",
1006 strcompose(tmp_conf_file, 128, tmp_conf_dir, "/",
1007 AFSDIR_CELLSERVDB_FILE, NULL);
1008 f = fopen(tmp_conf_file, "w");
1011 afs_com_err(whoami, errno, "can't create conf file %s",
1015 fprintf(f, ">%s\n", lcell);
1016 for (i = 0; i < cellinfo.numServers; i++) {
1017 register unsigned char *tp =
1018 (unsigned char *)&cellinfo.hostAddr[i].sin_addr;
1019 fprintf(f, "%d.%d.%d.%d\t#%s\n", tp[0], tp[1], tp[2], tp[3],
1020 cellinfo.hostName[i]);
1022 if (fclose(f) == EOF) {
1024 afs_com_err(whoami, errno, "can't write to conf file %s",
1029 strcompose(tmp_cell_file, 128, tmp_conf_dir, "/",
1030 AFSDIR_THISCELL_FILE, NULL);
1031 f = fopen(tmp_cell_file, "w");
1034 fprintf(f, "%s", lcell);
1035 if (fclose(f) == EOF)
1038 strcompose(tmp_noauth_file, 128, tmp_conf_dir, "/",
1039 AFSDIR_NOAUTH_FILE, NULL);
1041 code = creat(tmp_noauth_file, 0777);
1042 if (code && (errno != EEXIST))
1044 } else { /* make sure file doesn't exist */
1045 code = unlink(tmp_noauth_file);
1046 if (code && (errno != ENOENT))
1051 strncpy(conf_dir, tmp_conf_dir, sizeof(conf_dir));
1052 conf = afsconf_Open(conf_dir);
1054 return AFSCONF_NOTFOUND;
1059 add_std_args(register struct cmd_syndesc *ts)
1062 cmd_AddParm(ts, "-confdir", CMD_SINGLE, CMD_OPTIONAL,
1063 "AFS Conf dir pathname");
1064 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "Cell name");
1065 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "Don't authenticate");
1066 cmd_AddParm(ts, "-servers", CMD_LIST, CMD_OPTIONAL, "Server config");
1072 /* OK, this REALLY sucks bigtime, but I can't tell who is calling
1073 * afsconf_CheckAuth easily, and only *SERVERS* should be calling osi_audit
1074 * anyway. It's gonna give somebody fits to debug, I know, I know.
1079 #include "AFS_component_version_number.c"
1082 main(int argc, char *argv[])
1085 struct cmd_syndesc *ts; /* ptr to parsed command line syntax */
1088 initialize_CMD_error_table();
1089 initialize_ACFG_error_table();
1090 initialize_KTC_error_table();
1091 initialize_U_error_table();
1092 initialize_PT_error_table();
1093 initialize_RXK_error_table();
1096 /* initialize winsock */
1097 if (afs_winsockInit() < 0) {
1098 fprintf(stderr, "%s: couldn't initialize winsock. \n", whoami);
1103 cmd_SetBeforeProc(MyBeforeProc, NULL);
1104 cmd_SetAfterProc(MyAfterProc, NULL);
1106 ts = cmd_CreateSyntax("usedIds", ListUsedIds, 0,
1107 "Find used (or unused) user (or group) ids");
1108 cmd_AddParm(ts, "-startId", CMD_SINGLE, CMD_OPTIONAL,
1109 "id to start checking");
1110 cmd_AddParm(ts, "-number", CMD_SINGLE, CMD_OPTIONAL,
1111 "number of ids to check");
1112 cmd_AddParm(ts, "-unused", CMD_FLAG, CMD_OPTIONAL, "print unused ids");
1115 ts = cmd_CreateSyntax("initcmd", TestPrServ, 0, "test the prserver");
1118 ts = cmd_CreateSyntax("testmanymembers", TestManyMembers, 0,
1119 "test creating users and groups w/ many members");
1120 cmd_AddParm(ts, "-number", CMD_SINGLE, 0,
1121 "number of users/groups to create");
1122 cmd_AddParm(ts, "-dropoff", CMD_SINGLE, CMD_OPTIONAL,
1123 "precentage for exponential dropoff");
1124 cmd_AddParm(ts, "-prefix", CMD_SINGLE, CMD_OPTIONAL, "naming prefix");
1125 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "show progress");
1126 cmd_AddParm(ts, "-seed", CMD_SINGLE, CMD_OPTIONAL, "random number seed");
1128 cmd_CreateAlias(ts, "mm");
1131 code = cmd_Dispatch(argc, argv);
1133 afs_com_err(whoami, code, "calling cmd_Dispatch");