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 <sys/types.h>
25 #include <WINNT/afsevent.h>
27 #include <netinet/in.h>
29 #include <afs/cellconfig.h>
35 #include "ptprototypes.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];
59 static int CleanUp(struct cmd_syndesc *as, void *arock);
62 pts_Interactive(struct cmd_syndesc *as, void *arock)
70 pts_Quit(struct cmd_syndesc *as, void *arock)
77 pts_Source(struct cmd_syndesc *as, void *arock)
80 struct sourcestack *sp;
83 if (!as->parms[0].items) {
84 /* can this happen? */
87 fd = fopen(as->parms[0].items->data, "r");
89 perror(as->parms[0].items->data);
92 sp = (struct sourcestack *)malloc(sizeof *sp);
94 return errno ? errno : ENOMEM;
105 pts_Sleep(struct cmd_syndesc *as, void *arock)
108 if (!as->parms[0].items) {
109 /* can this happen? */
112 delay = atoi(as->parms[0].items->data);
113 #ifdef AFS_PTHREAD_ENV
124 register struct sourcestack *sp;
138 /* OK, this REALLY sucks bigtime, but I can't tell who is calling
139 * afsconf_CheckAuth easily, and only *SERVERS* should be calling osi_audit
140 * anyway. It's gonna give somebody fits to debug, I know, I know.
146 GetGlobals(struct cmd_syndesc *as, void *arock)
148 struct authstate *state = (struct authstate *) arock;
157 if (!strcmp(as->name, "help"))
165 if (state->confdir == NULL) {
169 if (as->parms[16].items) {
171 cell = as->parms[16].items->data;
173 if (as->parms[17].items) { /* -noauth */
177 if (as->parms[20].items) { /* -localauth */
181 if (as->parms[21].items) { /* -auth */
185 if (as->parms[22].items) { /* -encrypt */
189 if (as->parms[18].items || as->parms[20].items) { /* -test, -localauth */
191 confdir = AFSDIR_SERVER_ETC_DIRPATH;
194 confdir = AFSDIR_SERVER_ETC_DIRPATH;
196 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
200 code = pr_Initialize(sec, confdir, cell);
205 afs_com_err(whoami, code, "while initializing");
209 state->confdir = confdir;
210 if (cell && cell != state->cell)
211 strncpy(state->cell, cell, MAXCELLCHARS-1);
214 if (as->parms[19].items)
221 CleanUp(struct cmd_syndesc *as, void *arock)
223 if (as && !strcmp(as->name, "help"))
226 /* Need to shutdown the ubik_client & other connections */
234 CreateGroup(struct cmd_syndesc *as, void *arock)
236 register afs_int32 code;
239 struct cmd_item *namei;
240 struct cmd_item *idi;
242 namei = as->parms[0].items;
243 idi = as->parms[2].items;
244 if (as->parms[1].items)
245 owner = as->parms[1].items->data;
251 code = util_GetInt32(idi->data, &id);
253 afs_com_err(whoami, code, "because group id was: '%s'",
259 afs_com_err(whoami, code, "because group id %d was not negative",
265 printf("0 isn't a valid user id; aborting\n");
273 code = pr_CreateGroup(namei->data, owner, &id);
276 afs_com_err(whoami, code,
277 "; unable to create group %s with id %d%s%s%s%s",
278 namei->data, id, owner ? " owned by '" : "",
279 owner ? owner : "", owner ? "'" : "",
280 (force ? " (ignored)" : ""));
282 afs_com_err(whoami, code, "; unable to create group %s %s",
283 namei->data, (force ? "(ignored)" : ""));
287 printf("group %s has id %d\n", namei->data, id);
294 CreateUser(struct cmd_syndesc *as, void *arock)
296 register afs_int32 code;
298 struct cmd_item *namei;
299 struct cmd_item *idi;
301 namei = as->parms[0].items;
302 idi = as->parms[1].items;
306 code = util_GetInt32(idi->data, &id);
308 afs_com_err(whoami, code, "because id was: '%s'", idi->data);
312 printf("0 isn't a valid user id; aborting\n");
319 code = pr_CreateUser(namei->data, &id);
322 afs_com_err(whoami, code,
323 "; unable to create user %s with id %d %s",
324 namei->data, id, (force ? "(ignored)" : ""));
326 afs_com_err(whoami, code, "; unable to create user %s %s",
327 namei->data, (force ? "(ignored)" : ""));
331 printf("User %s has id %d\n", namei->data, id);
340 GetNameOrId(struct cmd_syndesc *as, struct idlist *lids, struct namelist *lnames)
342 register afs_int32 code = 0;
347 if (!(as->parms[0].items || as->parms[1].items)) {
348 afs_com_err(whoami, 0, "must specify either a name or an id.");
351 if (as->parms[0].items && as->parms[1].items) {
352 afs_com_err(whoami, 0, "can't specify both a name and id.");
357 lids->idlist_len = 0;
358 lids->idlist_val = 0;
360 if (as->parms[0].items) { /* name */
361 struct namelist names; /* local copy, if not ret. names */
364 names.namelist_val = 0; /* so it gets freed later if needed */
370 n = 0; /* count names */
371 for (i = as->parms[0].items; i; i = i->next)
373 nl->namelist_val = (prname *) malloc(n * PR_MAXNAMELEN);
374 nl->namelist_len = n;
376 for (i = as->parms[0].items; i; i = i->next)
377 strncpy(nl->namelist_val[n++], i->data, PR_MAXNAMELEN);
379 code = pr_NameToId(nl, lids);
381 afs_com_err(whoami, code, "so couldn't look up names");
383 for (n = 0; n < lids->idlist_len; n++) {
384 if ((lids->idlist_val[n] == ANONYMOUSID)) {
385 afs_com_err(whoami, PRNOENT, "so couldn't look up id for %s",
386 nl->namelist_val[n]);
390 /* treat things as working if any of the lookups worked */
395 if (names.namelist_val)
396 free(names.namelist_val);
397 } else if (as->parms[1].items) { /* id */
399 for (i = as->parms[1].items; i; i = i->next)
401 lids->idlist_val = (afs_int32 *) malloc(n * sizeof(afs_int32));
402 lids->idlist_len = n;
404 for (i = as->parms[1].items; i; i = i->next) {
405 code = util_GetInt32(i->data, &lids->idlist_val[n]);
407 afs_com_err(whoami, code =
408 PRNOENT, "because a bogus id '%s' was specified",
412 if (!code && lnames) {
413 lnames->namelist_val = 0;
414 lnames->namelist_len = 0;
415 code = pr_IdToName(lids, lnames);
417 afs_com_err(whoami, code, "translating ids");
421 if (lids->idlist_val)
422 free(lids->idlist_val);
431 GetNameOrId(struct cmd_syndesc *as, struct idlist *lids,
432 struct namelist *lnames)
434 register afs_int32 code = 0;
435 int n = 0, nd = 0, nm = 0, id, x;
437 struct namelist names, tnames; /* local copy, if not ret. names */
438 struct idlist ids, tids; /* local copy, if not ret. ids */
441 for (i = as->parms[0].items; i; i = i->next)
443 lids->idlist_val = (afs_int32 *) malloc(n * sizeof(afs_int32));
444 lids->idlist_len = n;
445 ids.idlist_val = (afs_int32 *) malloc(n * sizeof(afs_int32));
447 names.namelist_val = (prname *) malloc(n * PR_MAXNAMELEN);
448 names.namelist_len = n;
450 lnames->namelist_val = (prname *) malloc(n * PR_MAXNAMELEN);
451 lnames->namelist_len = 0;
453 for (i = as->parms[0].items; i; i = i->next) {
454 tnames.namelist_val = (prname *) malloc(PR_MAXNAMELEN);
455 strncpy(tnames.namelist_val[0], i->data, PR_MAXNAMELEN);
456 tnames.namelist_len = 1;
459 code = pr_NameToId(&tnames, &tids);
460 if ((!code && (tids.idlist_val[0] != 32766))
461 || (code = util_GetInt32(i->data, &id))) {
462 /* Assume it's a name instead */
463 strncpy(names.namelist_val[nm++], i->data, PR_MAXNAMELEN);
465 ids.idlist_val[nd++] = id;
467 free(tnames.namelist_val);
469 names.namelist_len = nm;
471 tids.idlist_len = nd = nm = 0;
473 code = pr_NameToId(&names, &tids);
475 afs_com_err(whoami, code, "so couldn't look up names");
477 for (n = 0; n < tids.idlist_len; n++) {
478 if ((tids.idlist_val[n] == ANONYMOUSID)) {
479 afs_com_err(whoami, PRNOENT, "so couldn't look up id for %s",
480 names.namelist_val[n]);
483 lids->idlist_val[nd] = tids.idlist_val[n];
485 strcpy(lnames->namelist_val[nd], names.namelist_val[n]);
489 for (x = 0; x < ids.idlist_len; x++) {
490 lids->idlist_val[nd + x] = ids.idlist_val[x];
492 lids->idlist_len = nd + x;
493 if (!code && lnames) {
494 tnames.namelist_val = 0;
495 tnames.namelist_len = 0;
496 code = pr_IdToName(&ids, &tnames);
498 afs_com_err(whoami, code, "translating ids");
502 for (x = 0; x < ids.idlist_len; x++)
503 strcpy(lnames->namelist_val[nd + x], tnames.namelist_val[x]);
504 lnames->namelist_len = nd + x;
507 /* treat things as working if any of the lookups worked */
511 if (lids->idlist_val)
512 free(lids->idlist_val);
520 AddToGroup(struct cmd_syndesc *as, void *arock)
522 register afs_int32 code;
523 struct cmd_item *u, *g;
525 for (u = as->parms[0].items; u; u = u->next) {
526 for (g = as->parms[1].items; g; g = g->next) {
527 code = pr_AddToGroup(u->data, g->data);
529 afs_com_err(whoami, code,
530 "; unable to add user %s to group %s %s", u->data,
531 g->data, (force ? "(ignored)" : ""));
541 RemoveFromGroup(struct cmd_syndesc *as, void *arock)
543 register afs_int32 code;
544 struct cmd_item *u, *g;
546 for (u = as->parms[0].items; u; u = u->next) {
547 for (g = as->parms[1].items; g; g = g->next) {
548 code = pr_RemoveUserFromGroup(u->data, g->data);
550 afs_com_err(whoami, code,
551 "; unable to remove user %s from group %s %s",
552 u->data, g->data, (force ? "(ignored)" : ""));
562 ListMembership(struct cmd_syndesc *as, void *arock)
564 register afs_int32 code;
571 if (GetNameOrId(as, &ids, &names))
574 for (i = 0; i < ids.idlist_len; i++) {
575 afs_int32 id = ids.idlist_val[i];
576 char *name = names.namelist_val[i];
578 if (id == ANONYMOUSID)
579 continue; /* bad entry */
581 list.namelist_val = 0;
582 list.namelist_len = 0;
583 code = pr_IDListMembers(ids.idlist_val[i], &list);
585 afs_com_err(whoami, code, "; unable to get membership of %s (id: %d)",
590 printf("Members of %s (id: %d) are:\n", name, id);
592 printf("Groups %s (id: %d) is a member of:\n", name, id);
594 for (j = 0; j < list.namelist_len; j++)
595 printf(" %s\n", list.namelist_val[j]);
596 if (list.namelist_val)
597 free(list.namelist_val);
600 free(ids.idlist_val);
601 if (names.namelist_val)
602 free(names.namelist_val);
607 Delete(struct cmd_syndesc *as, void *arock)
609 register afs_int32 code;
614 if (GetNameOrId(as, &ids, &names))
617 for (i = 0; i < ids.idlist_len; i++) {
618 afs_int32 id = ids.idlist_val[i];
619 char *name = names.namelist_val[i];
621 if (id == ANONYMOUSID)
624 code = pr_DeleteByID(id);
626 afs_com_err(whoami, code, "deleting %s (id: %d) %s", name, id,
627 (force ? "(ignored)" : ""));
633 free(ids.idlist_val);
634 if (names.namelist_val)
635 free(names.namelist_val);
639 /* access bit translation info */
641 char *flags_upcase = "SOMA "; /* legal all access values */
642 char *flags_dncase = "s mar"; /* legal member acces values */
643 int flags_shift[5] = { 2, 1, 2, 2, 1 }; /* bits for each */
646 CheckEntry(struct cmd_syndesc *as, void *arock)
648 register afs_int32 code;
650 int i, flag = 0, admin = 0;
651 namelist lnames, names;
654 struct prcheckentry aentry;
656 if (GetNameOrId(as, &ids, &names))
660 lids.idlist_val = (afs_int32 *) malloc(sizeof(afs_int32) * 2);
661 lnames.namelist_len = 0;
662 lnames.namelist_val = 0;
664 for (i = 0; i < ids.idlist_len; i++) {
665 afs_int32 id = ids.idlist_val[i];
667 if (id == ANONYMOUSID)
671 code = pr_ListEntry(id, &aentry);
674 afs_com_err(whoami, code, "; unable to find entry for (id: %d)", id);
678 lids.idlist_val[0] = aentry.owner;
679 lids.idlist_val[1] = aentry.creator;
680 code = pr_IdToName(&lids, &lnames);
683 afs_com_err(whoami, code,
684 "translating owner (%d) and creator (%d) ids",
685 aentry.owner, aentry.creator);
688 printf("Name: %s, id: %d, owner: %s, creator: %s,\n", aentry.name,
689 aentry.id, lnames.namelist_val[0], lnames.namelist_val[1]);
690 printf(" membership: %d", aentry.count);
693 afs_int32 flags = aentry.flags;
696 access[5] = 0; /* null-terminate the string */
697 for (j = 4; j >= 0; j--) {
716 printf(", flags: %s", access);
718 if (aentry.id == SYSADMINID)
720 else if (!pr_IsAMemberOf(aentry.name, "system:administrators", &flag)) {
725 printf(", group quota: unlimited");
727 printf(", group quota: %d", aentry.ngroups);
729 printf(", foreign user quota=%d", aentry.nusers);
734 if (lnames.namelist_val)
735 free(lnames.namelist_val);
737 free(lids.idlist_val);
739 free(ids.idlist_val);
745 ListEntries(struct cmd_syndesc *as, void *arock)
748 afs_int32 flag, startindex, nentries, nextstartindex;
749 struct prlistentries *entriesp = 0, *e;
753 if (as->parms[1].items)
755 if (as->parms[0].items)
758 printf("Name ID Owner Creator\n");
759 for (startindex = 0; startindex != -1; startindex = nextstartindex) {
761 pr_ListEntries(flag, startindex, &nentries, &entriesp,
764 afs_com_err(whoami, code, "; unable to list entries");
770 /* Now display each of the entries we read */
771 for (i = 0, e = entriesp; i < nentries; i++, e++) {
772 printf("%-25s %6d %6d %7d \n", e->name, e->id, e->owner,
782 ChownGroup(struct cmd_syndesc *as, void *arock)
784 register afs_int32 code;
788 name = as->parms[0].items->data;
789 owner = as->parms[1].items->data;
790 code = pr_ChangeEntry(name, "", 0, owner);
792 afs_com_err(whoami, code, "; unable to change owner of %s to %s", name,
798 ChangeName(struct cmd_syndesc *as, void *arock)
800 register afs_int32 code;
804 oldname = as->parms[0].items->data;
805 newname = as->parms[1].items->data;
806 code = pr_ChangeEntry(oldname, newname, 0, "");
808 afs_com_err(whoami, code, "; unable to change name of %s to %s", oldname,
814 ListMax(struct cmd_syndesc *as, void *arock)
816 register afs_int32 code;
817 afs_int32 maxUser, maxGroup;
819 code = pr_ListMaxUserId(&maxUser);
821 afs_com_err(whoami, code, "getting maximum user id");
823 code = pr_ListMaxGroupId(&maxGroup);
825 afs_com_err(whoami, code, "getting maximum group id");
827 printf("Max user id is %d and max group id is %d.\n", maxUser,
835 SetMaxCommand(struct cmd_syndesc *as, void *arock)
837 register afs_int32 code;
841 if (as->parms[1].items) {
843 code = util_GetInt32(as->parms[1].items->data, &maxid);
845 afs_com_err(whoami, code, "because id was: '%s'",
846 as->parms[1].items->data);
848 code = pr_SetMaxUserId(maxid);
850 afs_com_err(whoami, code, "so couldn't set Max User Id to %d",
854 if (as->parms[0].items) {
856 code = util_GetInt32(as->parms[0].items->data, &maxid);
858 afs_com_err(whoami, code, "because id was: '%s'",
859 as->parms[0].items->data);
861 code = pr_SetMaxGroupId(maxid);
863 afs_com_err(whoami, code, "so couldn't set Max Group Id to %d",
867 if (!as->parms[0].items && !as->parms[1].items) {
869 printf("Must specify at least one of group or user.\n");
875 SetFields(struct cmd_syndesc *as, void *arock)
877 register afs_int32 code;
881 afs_int32 mask, flags=0, ngroups, nusers;
883 if (GetNameOrId(as, &ids, &names))
890 if (as->parms[1].items) { /* privacy bits */
891 char *access = as->parms[1].items->data;
894 if (strpbrk(access, "76543210") != 0) { /* all octal digits */
895 sscanf(access, "%lo", (long unsigned int *) &flags);
896 } else { /* interpret flag bit names */
897 if (strlen(access) != 5) {
899 printf("Access bits must be of the form 'somar', not %s\n",
903 if (strpbrk(access, "somar-") == 0)
906 for (i = 0; i < 5; i++) {
907 if (access[i] == flags_upcase[i])
909 else if (access[i] == flags_dncase[i])
911 else if (access[i] == '-')
915 ("Access bits out of order or illegal:\n must be a combination of letters from '%s' or '%s' or hyphen, not %s\n",
916 flags_upcase, flags_dncase, access);
919 flags <<= flags_shift[i];
920 if (flags_shift[i] == 1) {
927 mask |= PR_SF_ALLBITS;
929 if (as->parms[2].items) { /* limitgroups */
930 code = util_GetInt32(as->parms[2].items->data, &ngroups);
932 afs_com_err(whoami, code, "because ngroups was: '%s'",
933 as->parms[2].items->data);
936 mask |= PR_SF_NGROUPS;
939 if (as->parms[3].items) { /* limitgroups */
940 code = util_GetInt32(as->parms[3].items->data, &nusers);
942 afs_com_err(whoami, code, "because nusers was: '%s'",
943 as->parms[3].items->data);
946 mask |= PR_SF_NUSERS;
950 for (i = 0; i < ids.idlist_len; i++) {
951 afs_int32 id = ids.idlist_val[i];
952 char *name = names.namelist_val[i];
953 if (id == ANONYMOUSID)
955 code = pr_SetFieldsEntry(id, mask, flags, ngroups, nusers);
957 afs_com_err(whoami, code, "; unable to set fields for %s (id: %d)",
963 free(ids.idlist_val);
964 if (names.namelist_val)
965 free(names.namelist_val);
970 ListOwned(struct cmd_syndesc *as, void *arock)
972 register afs_int32 code;
979 if (GetNameOrId(as, &ids, &names))
982 for (i = 0; i < ids.idlist_len; i++) {
983 afs_int32 oid = ids.idlist_val[i];
984 char *name = names.namelist_val[i];
986 if (oid == ANONYMOUSID)
990 printf("Groups owned by %s (id: %d) are:\n", name, oid);
992 printf("Orphaned groups are:\n");
995 list.namelist_val = 0;
996 list.namelist_len = 0;
997 code = pr_ListOwned(oid, &list, &more);
999 afs_com_err(whoami, code,
1000 "; unable to get owner list for %s (id: %d)", name,
1005 for (j = 0; j < list.namelist_len; j++)
1006 printf(" %s\n", list.namelist_val[j]);
1007 if (list.namelist_val)
1008 free(list.namelist_val);
1013 free(ids.idlist_val);
1014 if (names.namelist_val)
1015 free(names.namelist_val);
1020 add_std_args(struct cmd_syndesc *ts)
1022 char test_help[AFSDIR_PATH_MAX];
1024 sprintf(test_help, "use config file in %s", AFSDIR_SERVER_ETC_DIRPATH);
1027 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1028 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "run unauthenticated");
1029 cmd_AddParm(ts, "-test", CMD_FLAG, CMD_OPTIONAL | CMD_HIDE, test_help);
1030 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
1031 "Continue oper despite reasonable errors");
1032 cmd_AddParm(ts, "-localauth", CMD_FLAG, CMD_OPTIONAL,
1033 "use local authentication");
1034 cmd_AddParm(ts, "-auth", CMD_FLAG, CMD_OPTIONAL,
1035 "use user's authentication (default)");
1036 cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL,
1037 "encrypt commands");
1041 static void add_NameOrId_args (ts)
1042 register struct cmd_syndesc *ts;
1044 cmd_AddParm(ts,"-name",CMD_LIST,CMD_OPTIONAL,"user or group name");
1045 cmd_AddParm(ts,"-id",CMD_LIST,CMD_OPTIONAL,"user or group id");
1049 #include "AFS_component_version_number.c"
1052 main(int argc, char **argv)
1054 register afs_int32 code;
1055 register struct cmd_syndesc *ts;
1060 char *parsev[CMD_MAXPARMS];
1062 struct authstate state;
1069 WSAStartup(0x0101, &WSAjunk);
1072 #ifdef AFS_AIX32_ENV
1074 * The following signal action for AIX is necessary so that in case of a
1075 * crash (i.e. core is generated) we can include the user's data section
1076 * in the core dump. Unfortunately, by default, only a partial core is
1077 * generated which, in many cases, isn't too useful.
1079 struct sigaction nsa;
1081 sigemptyset(&nsa.sa_mask);
1082 nsa.sa_handler = SIG_DFL;
1083 nsa.sa_flags = SA_FULLDUMP;
1084 sigaction(SIGSEGV, &nsa, NULL);
1087 memset(&state, 0, sizeof(state));
1088 state.sec = 1; /* default is auth */
1090 ts = cmd_CreateSyntax("creategroup", CreateGroup, NULL,
1091 "create a new group");
1092 cmd_AddParm(ts, "-name", CMD_LIST, 0, "group name");
1093 cmd_AddParm(ts, "-owner", CMD_SINGLE, CMD_OPTIONAL, "owner of the group");
1094 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL,
1095 "id (negated) for the group");
1097 cmd_CreateAlias(ts, "cg");
1099 ts = cmd_CreateSyntax("createuser", CreateUser, NULL, "create a new user");
1100 cmd_AddParm(ts, "-name", CMD_LIST, 0, "user name");
1101 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL, "user id");
1103 cmd_CreateAlias(ts, "cu");
1105 ts = cmd_CreateSyntax("adduser", AddToGroup, NULL, "add a user to a group");
1106 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user name");
1107 cmd_AddParm(ts, "-group", CMD_LIST, 0, "group name");
1110 ts = cmd_CreateSyntax("removeuser", RemoveFromGroup, NULL,
1111 "remove a user from a group");
1112 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user name");
1113 cmd_AddParm(ts, "-group", CMD_LIST, 0, "group name");
1116 ts = cmd_CreateSyntax("membership", ListMembership, NULL,
1117 "list membership of a user or group");
1118 cmd_AddParm(ts, "-nameorid", CMD_LIST, 0, "user or group name or id");
1120 cmd_CreateAlias(ts, "groups");
1122 ts = cmd_CreateSyntax("delete", Delete, NULL,
1123 "delete a user or group from database");
1124 cmd_AddParm(ts, "-nameorid", CMD_LIST, 0, "user or group name or id");
1127 ts = cmd_CreateSyntax("examine", CheckEntry, NULL, "examine an entry");
1128 cmd_AddParm(ts, "-nameorid", CMD_LIST, 0, "user or group name or id");
1130 cmd_CreateAlias(ts, "check");
1132 ts = cmd_CreateSyntax("chown", ChownGroup, NULL,
1133 "change ownership of a group");
1134 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "group name");
1135 cmd_AddParm(ts, "-owner", CMD_SINGLE, 0, "new owner");
1138 ts = cmd_CreateSyntax("rename", ChangeName, NULL, "rename user or group");
1139 cmd_AddParm(ts, "-oldname", CMD_SINGLE, 0, "old name");
1140 cmd_AddParm(ts, "-newname", CMD_SINGLE, 0, "new name");
1142 cmd_CreateAlias(ts, "chname");
1144 ts = cmd_CreateSyntax("listmax", ListMax, NULL, "list max id");
1147 ts = cmd_CreateSyntax("setmax", SetMaxCommand, NULL, "set max id");
1148 cmd_AddParm(ts, "-group", CMD_SINGLE, CMD_OPTIONAL, "group max");
1149 cmd_AddParm(ts, "-user", CMD_SINGLE, CMD_OPTIONAL, "user max");
1152 ts = cmd_CreateSyntax("setfields", SetFields, NULL,
1153 "set fields for an entry");
1154 cmd_AddParm(ts, "-nameorid", CMD_LIST, 0, "user or group name or id");
1155 cmd_AddParm(ts, "-access", CMD_SINGLE, CMD_OPTIONAL, "set privacy flags");
1156 cmd_AddParm(ts, "-groupquota", CMD_SINGLE, CMD_OPTIONAL,
1157 "set limit on group creation");
1159 cmd_AddParm(ts, "-userquota", CMD_SINGLE, CMD_OPTIONAL,
1160 "set limit on foreign user creation");
1164 ts = cmd_CreateSyntax("listowned", ListOwned, NULL,
1165 "list groups owned by an entry or zero id gets orphaned groups");
1166 cmd_AddParm(ts, "-nameorid", CMD_LIST, 0, "user or group name or id");
1169 ts = cmd_CreateSyntax("listentries", ListEntries, NULL,
1170 "list users/groups in the protection database");
1171 cmd_AddParm(ts, "-users", CMD_FLAG, CMD_OPTIONAL, "list user entries");
1172 cmd_AddParm(ts, "-groups", CMD_FLAG, CMD_OPTIONAL, "list group entries");
1175 ts = cmd_CreateSyntax("interactive", pts_Interactive, NULL,
1176 "enter interactive mode");
1178 cmd_CreateAlias(ts, "in");
1180 ts = cmd_CreateSyntax("quit", pts_Quit, NULL, "exit program");
1183 ts = cmd_CreateSyntax("source", pts_Source, NULL, "read commands from file");
1184 cmd_AddParm(ts, "-file", CMD_SINGLE, 0, "filename");
1187 ts = cmd_CreateSyntax("sleep", pts_Sleep, NULL, "pause for a bit");
1188 cmd_AddParm(ts, "-delay", CMD_SINGLE, 0, "seconds");
1191 cmd_SetBeforeProc(GetGlobals, &state);
1195 if ((code = cmd_Dispatch(argc, argv))) {
1196 CleanUp(NULL, NULL);
1199 while (source && !finished) {
1200 if (isatty(fileno(source)))
1201 fprintf(stderr, "pts> ");
1202 if (!fgets(line, sizeof line, source)) {
1208 for (cp = line; *cp; ++cp)
1218 cmd_ParseLine(line, parsev, &parsec,
1219 sizeof(parsev) / sizeof(*parsev));
1221 afs_com_err(whoami, code, "parsing line: <%s>", line);
1225 parsev[0] = argv[0];
1226 code = cmd_Dispatch(parsec, parsev);
1228 cmd_FreeArgv(parsev);
1230 CleanUp(NULL, NULL);