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>
22 #include <sys/types.h>
27 #include <WINNT/afsevent.h>
29 #include <netinet/in.h>
31 #include <afs/cellconfig.h>
36 #include <afs/afsutil.h>
37 #include <afs/com_err.h>
46 extern struct ubik_client *pruclient;
49 struct sourcestack *s_next;
56 char cell[MAXCELLCHARS];
60 pts_Interactive(struct cmd_syndesc *as, void *arock)
68 pts_Quit(struct cmd_syndesc *as, void *arock)
75 pts_Source(struct cmd_syndesc *as, void *arock)
78 struct sourcestack *sp;
81 if (!as->parms[0].items) {
82 /* can this happen? */
85 fd = fopen(as->parms[0].items->data, "r");
87 perror(as->parms[0].items->data);
90 sp = (struct sourcestack *)malloc(sizeof *sp);
92 return errno ? errno : ENOMEM;
103 pts_Sleep(struct cmd_syndesc *as, void *arock)
106 if (!as->parms[0].items) {
107 /* can this happen? */
110 delay = atoi(as->parms[0].items->data);
111 #ifdef AFS_PTHREAD_ENV
122 register struct sourcestack *sp;
136 /* OK, this REALLY sucks bigtime, but I can't tell who is calling
137 * afsconf_CheckAuth easily, and only *SERVERS* should be calling osi_audit
138 * anyway. It's gonna give somebody fits to debug, I know, I know.
144 GetGlobals(struct cmd_syndesc *as, void *arock)
146 struct authstate *state = (struct authstate *) arock;
155 if (!strcmp(as->name, "help"))
163 if (state->confdir == NULL) {
167 if (as->parms[16].items) {
169 cell = as->parms[16].items->data;
171 if (as->parms[17].items) { /* -noauth */
175 if (as->parms[20].items) { /* -localauth */
179 if (as->parms[21].items) { /* -auth */
183 if (as->parms[18].items || as->parms[20].items) { /* -test, -localauth */
185 confdir = AFSDIR_SERVER_ETC_DIRPATH;
188 confdir = AFSDIR_SERVER_ETC_DIRPATH;
190 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
194 code = pr_Initialize(sec, confdir, cell);
199 afs_com_err(whoami, code, "while initializing");
203 state->confdir = confdir;
204 if (cell && cell != state->cell)
205 strncpy(state->cell, cell, MAXCELLCHARS-1);
208 if (as->parms[19].items)
215 CleanUp(struct cmd_syndesc *as, void *arock)
217 if (as && !strcmp(as->name, "help"))
220 /* Need to shutdown the ubik_client & other connections */
228 CreateGroup(struct cmd_syndesc *as, void *arock)
230 register afs_int32 code;
233 struct cmd_item *namei;
234 struct cmd_item *idi;
236 namei = as->parms[0].items;
237 idi = as->parms[2].items;
238 if (as->parms[1].items)
239 owner = as->parms[1].items->data;
245 code = util_GetInt32(idi->data, &id);
247 afs_com_err(whoami, code, "because group id was: '%s'",
253 afs_com_err(whoami, code, "because group id %d was not negative",
259 printf("0 isn't a valid user id; aborting\n");
267 code = pr_CreateGroup(namei->data, owner, &id);
270 afs_com_err(whoami, code,
271 "; unable to create group %s with id %d%s%s%s%s",
272 namei->data, id, owner ? " owned by '" : "",
273 owner ? owner : "", owner ? "'" : "",
274 (force ? " (ignored)" : ""));
276 afs_com_err(whoami, code, "; unable to create group %s %s",
277 namei->data, (force ? "(ignored)" : ""));
281 printf("group %s has id %d\n", namei->data, id);
288 CreateUser(struct cmd_syndesc *as, void *arock)
290 register afs_int32 code;
292 struct cmd_item *namei;
293 struct cmd_item *idi;
295 namei = as->parms[0].items;
296 idi = as->parms[1].items;
300 code = util_GetInt32(idi->data, &id);
302 afs_com_err(whoami, code, "because id was: '%s'", idi->data);
306 printf("0 isn't a valid user id; aborting\n");
313 code = pr_CreateUser(namei->data, &id);
316 afs_com_err(whoami, code,
317 "; unable to create user %s with id %d %s",
318 namei->data, id, (force ? "(ignored)" : ""));
320 afs_com_err(whoami, code, "; unable to create user %s %s",
321 namei->data, (force ? "(ignored)" : ""));
325 printf("User %s has id %d\n", namei->data, id);
334 GetNameOrId(register struct cmd_syndesc *as, struct idlist *lids, struct namelist *lnames)
336 register afs_int32 code = 0;
341 if (!(as->parms[0].items || as->parms[1].items)) {
342 afs_com_err(whoami, 0, "must specify either a name or an id.");
345 if (as->parms[0].items && as->parms[1].items) {
346 afs_com_err(whoami, 0, "can't specify both a name and id.");
351 lids->idlist_len = 0;
352 lids->idlist_val = 0;
354 if (as->parms[0].items) { /* name */
355 struct namelist names; /* local copy, if not ret. names */
358 names.namelist_val = 0; /* so it gets freed later if needed */
364 n = 0; /* count names */
365 for (i = as->parms[0].items; i; i = i->next)
367 nl->namelist_val = (prname *) malloc(n * PR_MAXNAMELEN);
368 nl->namelist_len = n;
370 for (i = as->parms[0].items; i; i = i->next)
371 strncpy(nl->namelist_val[n++], i->data, PR_MAXNAMELEN);
373 code = pr_NameToId(nl, lids);
375 afs_com_err(whoami, code, "so couldn't look up names");
377 for (n = 0; n < lids->idlist_len; n++) {
378 if ((lids->idlist_val[n] == ANONYMOUSID)) {
379 afs_com_err(whoami, PRNOENT, "so couldn't look up id for %s",
380 nl->namelist_val[n]);
384 /* treat things as working if any of the lookups worked */
389 if (names.namelist_val)
390 free(names.namelist_val);
391 } else if (as->parms[1].items) { /* id */
393 for (i = as->parms[1].items; i; i = i->next)
395 lids->idlist_val = (afs_int32 *) malloc(n * sizeof(afs_int32));
396 lids->idlist_len = n;
398 for (i = as->parms[1].items; i; i = i->next) {
399 code = util_GetInt32(i->data, &lids->idlist_val[n]);
401 afs_com_err(whoami, code =
402 PRNOENT, "because a bogus id '%s' was specified",
406 if (!code && lnames) {
407 lnames->namelist_val = 0;
408 lnames->namelist_len = 0;
409 code = pr_IdToName(lids, lnames);
411 afs_com_err(whoami, code, "translating ids");
415 if (lids->idlist_val)
416 free(lids->idlist_val);
425 GetNameOrId(register struct cmd_syndesc *as, struct idlist *lids, struct namelist *lnames)
427 register afs_int32 code = 0;
428 int n = 0, nd = 0, nm = 0, id, x;
430 struct namelist names, tnames; /* local copy, if not ret. names */
431 struct idlist ids, tids; /* local copy, if not ret. ids */
434 for (i = as->parms[0].items; i; i = i->next)
436 lids->idlist_val = (afs_int32 *) malloc(n * sizeof(afs_int32));
437 lids->idlist_len = n;
438 ids.idlist_val = (afs_int32 *) malloc(n * sizeof(afs_int32));
440 names.namelist_val = (prname *) malloc(n * PR_MAXNAMELEN);
441 names.namelist_len = n;
443 lnames->namelist_val = (prname *) malloc(n * PR_MAXNAMELEN);
444 lnames->namelist_len = 0;
446 for (i = as->parms[0].items; i; i = i->next) {
447 tnames.namelist_val = (prname *) malloc(PR_MAXNAMELEN);
448 strncpy(tnames.namelist_val[0], i->data, PR_MAXNAMELEN);
449 tnames.namelist_len = 1;
452 code = pr_NameToId(&tnames, &tids);
453 if ((!code && (tids.idlist_val[0] != 32766))
454 || (code = util_GetInt32(i->data, &id))) {
455 /* Assume it's a name instead */
456 strncpy(names.namelist_val[nm++], i->data, PR_MAXNAMELEN);
458 ids.idlist_val[nd++] = id;
460 free(tnames.namelist_val);
462 names.namelist_len = nm;
464 tids.idlist_len = nd = nm = 0;
466 code = pr_NameToId(&names, &tids);
468 afs_com_err(whoami, code, "so couldn't look up names");
470 for (n = 0; n < tids.idlist_len; n++) {
471 if ((tids.idlist_val[n] == ANONYMOUSID)) {
472 afs_com_err(whoami, PRNOENT, "so couldn't look up id for %s",
473 names.namelist_val[n]);
476 lids->idlist_val[nd] = tids.idlist_val[n];
478 strcpy(lnames->namelist_val[nd], names.namelist_val[n]);
482 for (x = 0; x < ids.idlist_len; x++) {
483 lids->idlist_val[nd + x] = ids.idlist_val[x];
485 lids->idlist_len = nd + x;
486 if (!code && lnames) {
487 tnames.namelist_val = 0;
488 tnames.namelist_len = 0;
489 code = pr_IdToName(&ids, &tnames);
491 afs_com_err(whoami, code, "translating ids");
495 for (x = 0; x < ids.idlist_len; x++)
496 strcpy(lnames->namelist_val[nd + x], tnames.namelist_val[x]);
497 lnames->namelist_len = nd + x;
500 /* treat things as working if any of the lookups worked */
504 if (lids->idlist_val)
505 free(lids->idlist_val);
513 AddToGroup(struct cmd_syndesc *as, void *arock)
515 register afs_int32 code;
516 struct cmd_item *u, *g;
518 for (u = as->parms[0].items; u; u = u->next) {
519 for (g = as->parms[1].items; g; g = g->next) {
520 code = pr_AddToGroup(u->data, g->data);
522 afs_com_err(whoami, code,
523 "; unable to add user %s to group %s %s", u->data,
524 g->data, (force ? "(ignored)" : ""));
534 RemoveFromGroup(struct cmd_syndesc *as, void *arock)
536 register afs_int32 code;
537 struct cmd_item *u, *g;
539 for (u = as->parms[0].items; u; u = u->next) {
540 for (g = as->parms[1].items; g; g = g->next) {
541 code = pr_RemoveUserFromGroup(u->data, g->data);
543 afs_com_err(whoami, code,
544 "; unable to remove user %s from group %s %s",
545 u->data, g->data, (force ? "(ignored)" : ""));
555 ListMembership(struct cmd_syndesc *as, void *arock)
557 register afs_int32 code;
564 if (GetNameOrId(as, &ids, &names))
567 for (i = 0; i < ids.idlist_len; i++) {
568 afs_int32 id = ids.idlist_val[i];
569 char *name = names.namelist_val[i];
571 if (id == ANONYMOUSID)
572 continue; /* bad entry */
574 list.namelist_val = 0;
575 list.namelist_len = 0;
576 code = pr_IDListMembers(ids.idlist_val[i], &list);
578 afs_com_err(whoami, code, "; unable to get membership of %s (id: %d)",
583 printf("Members of %s (id: %d) are:\n", name, id);
585 printf("Groups %s (id: %d) is a member of:\n", name, id);
587 for (j = 0; j < list.namelist_len; j++)
588 printf(" %s\n", list.namelist_val[j]);
589 if (list.namelist_val)
590 free(list.namelist_val);
593 free(ids.idlist_val);
594 if (names.namelist_val)
595 free(names.namelist_val);
600 Delete(struct cmd_syndesc *as, void *arock)
602 register afs_int32 code;
607 if (GetNameOrId(as, &ids, &names))
610 for (i = 0; i < ids.idlist_len; i++) {
611 afs_int32 id = ids.idlist_val[i];
612 char *name = names.namelist_val[i];
614 if (id == ANONYMOUSID)
617 code = pr_DeleteByID(id);
619 afs_com_err(whoami, code, "deleting %s (id: %d) %s", name, id,
620 (force ? "(ignored)" : ""));
626 free(ids.idlist_val);
627 if (names.namelist_val)
628 free(names.namelist_val);
632 /* access bit translation info */
634 char *flags_upcase = "SOMA "; /* legal all access values */
635 char *flags_dncase = "s mar"; /* legal member acces values */
636 int flags_shift[5] = { 2, 1, 2, 2, 1 }; /* bits for each */
639 CheckEntry(struct cmd_syndesc *as, void *arock)
641 register afs_int32 code;
643 int i, flag = 0, admin = 0;
644 namelist lnames, names;
647 struct prcheckentry aentry;
649 if (GetNameOrId(as, &ids, &names))
653 lids.idlist_val = (afs_int32 *) malloc(sizeof(afs_int32) * 2);
654 lnames.namelist_len = 0;
655 lnames.namelist_val = 0;
657 for (i = 0; i < ids.idlist_len; i++) {
658 afs_int32 id = ids.idlist_val[i];
660 if (id == ANONYMOUSID)
664 code = pr_ListEntry(id, &aentry);
667 afs_com_err(whoami, code, "; unable to find entry for (id: %d)", id);
671 lids.idlist_val[0] = aentry.owner;
672 lids.idlist_val[1] = aentry.creator;
673 code = pr_IdToName(&lids, &lnames);
676 afs_com_err(whoami, code,
677 "translating owner (%d) and creator (%d) ids",
678 aentry.owner, aentry.creator);
681 printf("Name: %s, id: %d, owner: %s, creator: %s,\n", aentry.name,
682 aentry.id, lnames.namelist_val[0], lnames.namelist_val[1]);
683 printf(" membership: %d", aentry.count);
686 afs_int32 flags = aentry.flags;
689 access[5] = 0; /* null-terminate the string */
690 for (j = 4; j >= 0; j--) {
709 printf(", flags: %s", access);
711 if (aentry.id == SYSADMINID)
713 else if (!pr_IsAMemberOf(aentry.name, "system:administrators", &flag)) {
718 printf(", group quota: unlimited");
720 printf(", group quota: %d", aentry.ngroups);
722 printf(", foreign user quota=%d", aentry.nusers);
727 if (lnames.namelist_val)
728 free(lnames.namelist_val);
730 free(lids.idlist_val);
732 free(ids.idlist_val);
738 ListEntries(struct cmd_syndesc *as, void *arock)
741 afs_int32 flag, startindex, nentries, nextstartindex;
742 struct prlistentries *entriesp = 0, *e;
746 if (as->parms[1].items)
748 if (as->parms[0].items)
751 printf("Name ID Owner Creator\n");
752 for (startindex = 0; startindex != -1; startindex = nextstartindex) {
754 pr_ListEntries(flag, startindex, &nentries, &entriesp,
757 afs_com_err(whoami, code, "; unable to list entries");
763 /* Now display each of the entries we read */
764 for (i = 0, e = entriesp; i < nentries; i++, e++) {
765 printf("%-25s %6d %6d %7d \n", e->name, e->id, e->owner,
775 ChownGroup(struct cmd_syndesc *as, void *arock)
777 register afs_int32 code;
781 name = as->parms[0].items->data;
782 owner = as->parms[1].items->data;
783 code = pr_ChangeEntry(name, "", 0, owner);
785 afs_com_err(whoami, code, "; unable to change owner of %s to %s", name,
791 ChangeName(struct cmd_syndesc *as, void *arock)
793 register afs_int32 code;
797 oldname = as->parms[0].items->data;
798 newname = as->parms[1].items->data;
799 code = pr_ChangeEntry(oldname, newname, 0, "");
801 afs_com_err(whoami, code, "; unable to change name of %s to %s", oldname,
807 ListMax(struct cmd_syndesc *as, void *arock)
809 register afs_int32 code;
810 afs_int32 maxUser, maxGroup;
812 code = pr_ListMaxUserId(&maxUser);
814 afs_com_err(whoami, code, "getting maximum user id");
816 code = pr_ListMaxGroupId(&maxGroup);
818 afs_com_err(whoami, code, "getting maximum group id");
820 printf("Max user id is %d and max group id is %d.\n", maxUser,
828 SetMax(struct cmd_syndesc *as, void *arock)
830 register afs_int32 code;
834 if (as->parms[1].items) {
836 code = util_GetInt32(as->parms[1].items->data, &maxid);
838 afs_com_err(whoami, code, "because id was: '%s'",
839 as->parms[1].items->data);
841 code = pr_SetMaxUserId(maxid);
843 afs_com_err(whoami, code, "so couldn't set Max User Id to %d",
847 if (as->parms[0].items) {
849 code = util_GetInt32(as->parms[0].items->data, &maxid);
851 afs_com_err(whoami, code, "because id was: '%s'",
852 as->parms[0].items->data);
854 code = pr_SetMaxGroupId(maxid);
856 afs_com_err(whoami, code, "so couldn't set Max Group Id to %d",
860 if (!as->parms[0].items && !as->parms[1].items) {
862 printf("Must specify at least one of group or user.\n");
868 SetFields(struct cmd_syndesc *as, void *arock)
870 register afs_int32 code;
874 afs_int32 mask, flags=0, ngroups, nusers;
876 if (GetNameOrId(as, &ids, &names))
883 if (as->parms[1].items) { /* privacy bits */
884 char *access = as->parms[1].items->data;
887 if (strpbrk(access, "76543210") != 0) { /* all octal digits */
888 sscanf(access, "%lo", &flags);
889 } else { /* interpret flag bit names */
890 if (strlen(access) != 5) {
892 printf("Access bits must be of the form 'somar', not %s\n",
896 if (strpbrk(access, "somar-") == 0)
899 for (i = 0; i < 5; i++) {
900 if (access[i] == flags_upcase[i])
902 else if (access[i] == flags_dncase[i])
904 else if (access[i] == '-')
908 ("Access bits out of order or illegal:\n must be a combination of letters from '%s' or '%s' or hyphen, not %s\n",
909 flags_upcase, flags_dncase, access);
912 flags <<= flags_shift[i];
913 if (flags_shift[i] == 1) {
920 mask |= PR_SF_ALLBITS;
922 if (as->parms[2].items) { /* limitgroups */
923 code = util_GetInt32(as->parms[2].items->data, &ngroups);
925 afs_com_err(whoami, code, "because ngroups was: '%s'",
926 as->parms[2].items->data);
929 mask |= PR_SF_NGROUPS;
932 if (as->parms[3].items) { /* limitgroups */
933 code = util_GetInt32(as->parms[3].items->data, &nusers);
935 afs_com_err(whoami, code, "because nusers was: '%s'",
936 as->parms[3].items->data);
939 mask |= PR_SF_NUSERS;
943 for (i = 0; i < ids.idlist_len; i++) {
944 afs_int32 id = ids.idlist_val[i];
945 char *name = names.namelist_val[i];
946 if (id == ANONYMOUSID)
948 code = pr_SetFieldsEntry(id, mask, flags, ngroups, nusers);
950 afs_com_err(whoami, code, "; unable to set fields for %s (id: %d)",
956 free(ids.idlist_val);
957 if (names.namelist_val)
958 free(names.namelist_val);
963 ListOwned(struct cmd_syndesc *as, void *arock)
965 register afs_int32 code;
972 if (GetNameOrId(as, &ids, &names))
975 for (i = 0; i < ids.idlist_len; i++) {
976 afs_int32 oid = ids.idlist_val[i];
977 char *name = names.namelist_val[i];
979 if (oid == ANONYMOUSID)
983 printf("Groups owned by %s (id: %d) are:\n", name, oid);
985 printf("Orphaned groups are:\n");
988 list.namelist_val = 0;
989 list.namelist_len = 0;
990 code = pr_ListOwned(oid, &list, &more);
992 afs_com_err(whoami, code,
993 "; unable to get owner list for %s (id: %d)", name,
998 for (j = 0; j < list.namelist_len; j++)
999 printf(" %s\n", list.namelist_val[j]);
1000 if (list.namelist_val)
1001 free(list.namelist_val);
1006 free(ids.idlist_val);
1007 if (names.namelist_val)
1008 free(names.namelist_val);
1013 add_std_args(register struct cmd_syndesc *ts)
1015 char test_help[AFSDIR_PATH_MAX];
1017 sprintf(test_help, "use config file in %s", AFSDIR_SERVER_ETC_DIRPATH);
1020 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1021 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "run unauthenticated");
1022 cmd_AddParm(ts, "-test", CMD_FLAG, CMD_OPTIONAL | CMD_HIDE, test_help);
1023 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
1024 "Continue oper despite reasonable errors");
1025 cmd_AddParm(ts, "-localauth", CMD_FLAG, CMD_OPTIONAL,
1026 "use local authentication");
1027 cmd_AddParm(ts, "-auth", CMD_FLAG, CMD_OPTIONAL,
1028 "use user's authentication (default)");
1032 static void add_NameOrId_args (ts)
1033 register struct cmd_syndesc *ts;
1035 cmd_AddParm(ts,"-name",CMD_LIST,CMD_OPTIONAL,"user or group name");
1036 cmd_AddParm(ts,"-id",CMD_LIST,CMD_OPTIONAL,"user or group id");
1040 #include "AFS_component_version_number.c"
1043 main(int argc, char **argv)
1045 register afs_int32 code;
1046 register struct cmd_syndesc *ts;
1051 char *parsev[CMD_MAXPARMS];
1053 struct authstate state;
1060 WSAStartup(0x0101, &WSAjunk);
1063 #ifdef AFS_AIX32_ENV
1065 * The following signal action for AIX is necessary so that in case of a
1066 * crash (i.e. core is generated) we can include the user's data section
1067 * in the core dump. Unfortunately, by default, only a partial core is
1068 * generated which, in many cases, isn't too useful.
1070 struct sigaction nsa;
1072 sigemptyset(&nsa.sa_mask);
1073 nsa.sa_handler = SIG_DFL;
1074 nsa.sa_flags = SA_FULLDUMP;
1075 sigaction(SIGSEGV, &nsa, NULL);
1078 memset(&state, 0, sizeof(state));
1079 state.sec = 1; /* default is auth */
1081 ts = cmd_CreateSyntax("creategroup", CreateGroup, NULL,
1082 "create a new group");
1083 cmd_AddParm(ts, "-name", CMD_LIST, 0, "group name");
1084 cmd_AddParm(ts, "-owner", CMD_SINGLE, CMD_OPTIONAL, "owner of the group");
1085 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL,
1086 "id (negated) for the group");
1088 cmd_CreateAlias(ts, "cg");
1090 ts = cmd_CreateSyntax("createuser", CreateUser, NULL, "create a new user");
1091 cmd_AddParm(ts, "-name", CMD_LIST, 0, "user name");
1092 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL, "user id");
1094 cmd_CreateAlias(ts, "cu");
1096 ts = cmd_CreateSyntax("adduser", AddToGroup, NULL, "add a user to a group");
1097 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user name");
1098 cmd_AddParm(ts, "-group", CMD_LIST, 0, "group name");
1101 ts = cmd_CreateSyntax("removeuser", RemoveFromGroup, NULL,
1102 "remove a user from a group");
1103 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user name");
1104 cmd_AddParm(ts, "-group", CMD_LIST, 0, "group name");
1107 ts = cmd_CreateSyntax("membership", ListMembership, NULL,
1108 "list membership of a user or group");
1109 cmd_AddParm(ts, "-nameorid", CMD_LIST, 0, "user or group name or id");
1111 cmd_CreateAlias(ts, "groups");
1113 ts = cmd_CreateSyntax("delete", Delete, NULL,
1114 "delete a user or group from database");
1115 cmd_AddParm(ts, "-nameorid", CMD_LIST, 0, "user or group name or id");
1118 ts = cmd_CreateSyntax("examine", CheckEntry, NULL, "examine an entry");
1119 cmd_AddParm(ts, "-nameorid", CMD_LIST, 0, "user or group name or id");
1121 cmd_CreateAlias(ts, "check");
1123 ts = cmd_CreateSyntax("chown", ChownGroup, NULL,
1124 "change ownership of a group");
1125 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "group name");
1126 cmd_AddParm(ts, "-owner", CMD_SINGLE, 0, "new owner");
1129 ts = cmd_CreateSyntax("rename", ChangeName, NULL, "rename user or group");
1130 cmd_AddParm(ts, "-oldname", CMD_SINGLE, 0, "old name");
1131 cmd_AddParm(ts, "-newname", CMD_SINGLE, 0, "new name");
1133 cmd_CreateAlias(ts, "chname");
1135 ts = cmd_CreateSyntax("listmax", ListMax, NULL, "list max id");
1138 ts = cmd_CreateSyntax("setmax", SetMax, NULL, "set max id");
1139 cmd_AddParm(ts, "-group", CMD_SINGLE, CMD_OPTIONAL, "group max");
1140 cmd_AddParm(ts, "-user", CMD_SINGLE, CMD_OPTIONAL, "user max");
1143 ts = cmd_CreateSyntax("setfields", SetFields, NULL,
1144 "set fields for an entry");
1145 cmd_AddParm(ts, "-nameorid", CMD_LIST, 0, "user or group name or id");
1146 cmd_AddParm(ts, "-access", CMD_SINGLE, CMD_OPTIONAL, "set privacy flags");
1147 cmd_AddParm(ts, "-groupquota", CMD_SINGLE, CMD_OPTIONAL,
1148 "set limit on group creation");
1150 cmd_AddParm(ts, "-userquota", CMD_SINGLE, CMD_OPTIONAL,
1151 "set limit on foreign user creation");
1155 ts = cmd_CreateSyntax("listowned", ListOwned, NULL,
1156 "list groups owned by an entry or zero id gets orphaned groups");
1157 cmd_AddParm(ts, "-nameorid", CMD_LIST, 0, "user or group name or id");
1160 ts = cmd_CreateSyntax("listentries", ListEntries, NULL,
1161 "list users/groups in the protection database");
1162 cmd_AddParm(ts, "-users", CMD_FLAG, CMD_OPTIONAL, "list user entries");
1163 cmd_AddParm(ts, "-groups", CMD_FLAG, CMD_OPTIONAL, "list group entries");
1166 ts = cmd_CreateSyntax("interactive", pts_Interactive, NULL,
1167 "enter interactive mode");
1169 cmd_CreateAlias(ts, "in");
1171 ts = cmd_CreateSyntax("quit", pts_Quit, NULL, "exit program");
1174 ts = cmd_CreateSyntax("source", pts_Source, NULL, "read commands from file");
1175 cmd_AddParm(ts, "-file", CMD_SINGLE, 0, "filename");
1178 ts = cmd_CreateSyntax("sleep", pts_Sleep, NULL, "pause for a bit");
1179 cmd_AddParm(ts, "-delay", CMD_SINGLE, 0, "seconds");
1182 cmd_SetBeforeProc(GetGlobals, &state);
1186 if (code = cmd_Dispatch(argc, argv)) {
1187 CleanUp(NULL, NULL);
1190 while (source && !finished) {
1191 if (isatty(fileno(source)))
1192 fprintf(stderr, "pts> ");
1193 if (!fgets(line, sizeof line, source)) {
1199 for (cp = line; *cp; ++cp)
1209 cmd_ParseLine(line, parsev, &parsec,
1210 sizeof(parsev) / sizeof(*parsev));
1212 afs_com_err(whoami, code, "parsing line: <%s>", line);
1216 parsev[0] = argv[0];
1217 code = cmd_Dispatch(parsec, parsev);
1219 cmd_FreeArgv(parsev);
1221 CleanUp(NULL, NULL);