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 <WINNT/afsevent.h>
19 #include <WINNT/afsreg.h>
22 #include <afs/cellconfig.h>
23 #include <afs/afsutil.h>
24 #include <afs/com_err.h>
28 #include <rx/rxgk_int.h>
33 #include "ptprototypes.h"
40 extern struct ubik_client *pruclient;
43 struct sourcestack *s_next;
50 char cell[MAXCELLCHARS];
53 static int CleanUp(struct cmd_syndesc *as, void *arock);
56 pts_Interactive(struct cmd_syndesc *as, void *arock)
64 pts_Quit(struct cmd_syndesc *as, void *arock)
71 pts_Source(struct cmd_syndesc *as, void *arock)
74 struct sourcestack *sp;
77 if (!as->parms[0].items) {
78 /* can this happen? */
81 fd = fopen(as->parms[0].items->data, "r");
83 perror(as->parms[0].items->data);
86 sp = malloc(sizeof *sp);
88 return errno ? errno : ENOMEM;
99 pts_Sleep(struct cmd_syndesc *as, void *arock)
102 if (!as->parms[0].items) {
103 /* can this happen? */
106 delay = atoi(as->parms[0].items->data);
107 #ifdef AFS_PTHREAD_ENV
118 struct sourcestack *sp;
132 /* OK, this REALLY sucks bigtime, but I can't tell who is calling
133 * afsconf_CheckAuth easily, and only *SERVERS* should be calling osi_audit
134 * anyway. It's gonna give somebody fits to debug, I know, I know.
141 win32_enableCrypt(void)
148 /* Look up configuration parameters in Registry */
149 code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY,
150 0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &parmKey);
151 if (code != ERROR_SUCCESS) {
152 dummyLen = sizeof(cryptall);
153 RegQueryValueEx(parmKey, "SecurityLevel", NULL, NULL,
154 (BYTE *) &cryptall, &dummyLen);
156 RegCloseKey (parmKey);
160 #endif /* AFS_NT40_ENV */
163 GetGlobals(struct cmd_syndesc *as, void *arock)
165 struct authstate *state = (struct authstate *) arock;
171 RXGK_Level rxgk_level = RXGK_LEVEL_BOGUS;
175 if (!strcmp(as->name, "help"))
183 if (state->confdir == NULL) {
187 if (as->parms[16].items) {
189 cell = as->parms[16].items->data;
191 if (as->parms[17].items) { /* -noauth */
195 if (as->parms[20].items) { /* -localauth */
199 if (as->parms[21].items) { /* -auth */
203 if (as->parms[22].items /* -encrypt */
205 || win32_enableCrypt()
206 #endif /* AFS_NT40_ENV */
211 if (as->parms[18].items || as->parms[20].items) { /* -test, -localauth */
213 confdir = AFSDIR_SERVER_ETC_DIRPATH;
216 confdir = AFSDIR_SERVER_ETC_DIRPATH;
218 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
221 if (as->parms[23].items) { /* -config */
223 confdir = as->parms[23].items->data;
226 if (as->parms[24].items) { /* -rxgk */
227 char *rxgk_seclevel_str = as->parms[24].items->data;
230 if (strcmp(rxgk_seclevel_str, "clear") == 0)
231 rxgk_level = RXGK_LEVEL_CLEAR;
232 else if (strcmp(rxgk_seclevel_str, "auth") == 0)
233 rxgk_level = RXGK_LEVEL_AUTH;
234 else if (strcmp(rxgk_seclevel_str, "crypt") == 0)
235 rxgk_level = RXGK_LEVEL_CRYPT;
237 fprintf(stderr, "Invalid argument to -rxgk: %s\n", rxgk_seclevel_str);
245 code = pr_Initialize2(sec, confdir, cell, rxgk_level);
250 afs_com_err(whoami, code, "while initializing");
254 state->confdir = confdir;
255 if (cell && cell != state->cell)
256 strncpy(state->cell, cell, MAXCELLCHARS-1);
259 if (as->parms[19].items)
266 CleanUp(struct cmd_syndesc *as, void *arock)
268 if (as && !strcmp(as->name, "help"))
271 /* Need to shutdown the ubik_client & other connections */
279 CreateGroup(struct cmd_syndesc *as, void *arock)
284 struct cmd_item *namei;
285 struct cmd_item *idi;
287 namei = as->parms[0].items;
288 idi = as->parms[2].items;
289 if (as->parms[1].items)
290 owner = as->parms[1].items->data;
296 code = util_GetInt32(idi->data, &id);
298 afs_com_err(whoami, code, "because group id was: '%s'",
303 fprintf(stderr, "0 isn't a valid group id; aborting\n");
308 afs_com_err(whoami, code, "because group id %d was not negative",
317 code = pr_CreateGroup(namei->data, owner, &id);
320 afs_com_err(whoami, code,
321 "; unable to create group %s with id %d%s%s%s%s",
322 namei->data, id, owner ? " owned by '" : "",
323 owner ? owner : "", owner ? "'" : "",
324 (force ? " (ignored)" : ""));
326 afs_com_err(whoami, code, "; unable to create group %s %s",
327 namei->data, (force ? "(ignored)" : ""));
331 printf("group %s has id %d\n", namei->data, id);
338 CreateUser(struct cmd_syndesc *as, void *arock)
342 struct cmd_item *namei;
343 struct cmd_item *idi;
345 namei = as->parms[0].items;
346 idi = as->parms[1].items;
350 code = util_GetInt32(idi->data, &id);
352 afs_com_err(whoami, code, "because id was: '%s'", idi->data);
356 fprintf(stderr, "0 isn't a valid user id; aborting\n");
361 afs_com_err(whoami, code, "because user id %d was not positive",
369 code = pr_CreateUser(namei->data, &id);
372 afs_com_err(whoami, code,
373 "; unable to create user %s with id %d %s",
374 namei->data, id, (force ? "(ignored)" : ""));
376 afs_com_err(whoami, code, "; unable to create user %s %s",
377 namei->data, (force ? "(ignored)" : ""));
381 printf("User %s has id %d\n", namei->data, id);
389 GetNameOrId(struct cmd_syndesc *as, struct idlist *lids,
390 struct namelist *lnames)
393 int n = 0, nd = 0, nm = 0, id, x;
395 struct namelist names, tnames; /* local copy, if not ret. names */
396 struct idlist ids, tids; /* local copy, if not ret. ids */
399 /* Initialise our outputs */
400 memset(lids, 0, sizeof(struct idlist));
402 memset(lnames, 0, sizeof(struct namelist));
404 for (i = as->parms[0].items; i; i = i->next)
407 /* Nothing to do, so bail */
411 lids->idlist_val = malloc(n * sizeof(afs_int32));
412 lids->idlist_len = n;
413 ids.idlist_val = malloc(n * sizeof(afs_int32));
415 names.namelist_val = malloc(n * PR_MAXNAMELEN);
416 names.namelist_len = n;
418 lnames->namelist_val = malloc(n * PR_MAXNAMELEN);
419 lnames->namelist_len = 0;
421 for (i = as->parms[0].items; i; i = i->next) {
422 tnames.namelist_val = malloc(PR_MAXNAMELEN);
423 strncpy(tnames.namelist_val[0], i->data, PR_MAXNAMELEN);
424 tnames.namelist_len = 1;
427 code = pr_NameToId(&tnames, &tids);
428 if ((!code && (tids.idlist_val[0] != 32766))
429 || (code = util_GetInt32(i->data, &id))) {
430 /* Assume it's a name instead */
431 strncpy(names.namelist_val[nm++], i->data, PR_MAXNAMELEN);
433 ids.idlist_val[nd++] = id;
435 free(tnames.namelist_val);
437 names.namelist_len = nm;
439 tids.idlist_len = nd = nm = 0;
441 code = pr_NameToId(&names, &tids);
443 afs_com_err(whoami, code, "so couldn't look up names");
445 for (n = 0; n < tids.idlist_len; n++) {
446 if (tids.idlist_val[n] == ANONYMOUSID) {
447 afs_com_err(whoami, PRNOENT, "so couldn't look up id for %s",
448 names.namelist_val[n]);
451 lids->idlist_val[nd] = tids.idlist_val[n];
453 strcpy(lnames->namelist_val[nd], names.namelist_val[n]);
457 for (x = 0; x < ids.idlist_len; x++) {
458 lids->idlist_val[nd + x] = ids.idlist_val[x];
460 lids->idlist_len = nd + x;
461 if (!code && lnames) {
462 tnames.namelist_val = 0;
463 tnames.namelist_len = 0;
464 code = pr_IdToName(&ids, &tnames);
466 afs_com_err(whoami, code, "translating ids");
470 for (x = 0; x < ids.idlist_len; x++)
471 strcpy(lnames->namelist_val[nd + x], tnames.namelist_val[x]);
472 lnames->namelist_len = nd + x;
476 /* treat things as working if any of the lookups worked */
480 if (lids->idlist_val)
481 free(lids->idlist_val);
489 AddToGroup(struct cmd_syndesc *as, void *arock)
492 struct cmd_item *u, *g;
494 for (u = as->parms[0].items; u; u = u->next) {
495 for (g = as->parms[1].items; g; g = g->next) {
496 code = pr_AddToGroup(u->data, g->data);
498 afs_com_err(whoami, code,
499 "; unable to add user %s to group %s %s", u->data,
500 g->data, (force ? "(ignored)" : ""));
510 RemoveFromGroup(struct cmd_syndesc *as, void *arock)
513 struct cmd_item *u, *g;
515 for (u = as->parms[0].items; u; u = u->next) {
516 for (g = as->parms[1].items; g; g = g->next) {
517 code = pr_RemoveUserFromGroup(u->data, g->data);
519 afs_com_err(whoami, code,
520 "; unable to remove user %s from group %s %s",
521 u->data, g->data, (force ? "(ignored)" : ""));
531 ListMembership(struct cmd_syndesc *as, void *arock)
540 if (GetNameOrId(as, &ids, &names))
543 for (i = 0; i < ids.idlist_len; i++) {
544 afs_int32 id = ids.idlist_val[i];
545 char *name = names.namelist_val[i];
547 if (id == ANONYMOUSID)
548 continue; /* bad entry */
550 list.namelist_val = 0;
551 list.namelist_len = 0;
552 if (as->parms[2].items) { /* -expandgroups */
553 code = pr_IDListExpandedMembers(id, &list);
557 code = pr_IDListMembers(id, &list);
560 afs_com_err(whoami, code, "; unable to get membership of %s (id: %d)",
565 printf("Members of %s (id: %d) are:\n", name, id);
567 printf("Groups %s (id: %d) is a member of:\n", name, id);
569 for (j = 0; j < list.namelist_len; j++)
570 printf(" %s\n", list.namelist_val[j]);
571 if (list.namelist_val)
572 free(list.namelist_val);
573 if (as->parms[1].items && id < 0) { /* -supergroups */
574 list.namelist_val = 0;
575 list.namelist_len = 0;
576 code = pr_ListSuperGroups(ids.idlist_val[i], &list);
577 if (code == RXGEN_OPCODE) {
578 continue; /* server does not support supergroups */
579 } else if (code != 0) {
580 afs_com_err(whoami, code,
581 "; unable to get supergroups of %s (id: %d)",
585 printf("Groups %s (id: %d) is a member of:\n", name, id);
586 for (j = 0; j < list.namelist_len; j++)
587 printf(" %s\n", list.namelist_val[j]);
588 if (list.namelist_val)
589 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)
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)
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 = 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);
724 if (lnames.namelist_val)
725 free(lnames.namelist_val);
727 free(lids.idlist_val);
729 free(ids.idlist_val);
735 ListEntries(struct cmd_syndesc *as, void *arock)
738 afs_int32 flag, startindex, nentries, nextstartindex;
739 struct prlistentries *entriesp = 0, *e;
743 if (as->parms[1].items)
745 if (as->parms[0].items)
748 printf("Name ID Owner Creator\n");
749 for (startindex = 0; startindex != -1; startindex = nextstartindex) {
751 pr_ListEntries(flag, startindex, &nentries, &entriesp,
754 afs_com_err(whoami, code, "; unable to list entries");
760 /* Now display each of the entries we read */
761 for (i = 0, e = entriesp; i < nentries; i++, e++) {
762 printf("%-25s %6d %6d %7d \n", e->name, e->id, e->owner,
772 ChownGroup(struct cmd_syndesc *as, void *arock)
778 name = as->parms[0].items->data;
779 owner = as->parms[1].items->data;
780 code = pr_ChangeEntry(name, "", 0, owner);
782 afs_com_err(whoami, code, "; unable to change owner of %s to %s", name,
788 ChangeName(struct cmd_syndesc *as, void *arock)
794 oldname = as->parms[0].items->data;
795 newname = as->parms[1].items->data;
796 code = pr_ChangeEntry(oldname, newname, 0, "");
798 afs_com_err(whoami, code, "; unable to change name of %s to %s", oldname,
804 ListMax(struct cmd_syndesc *as, void *arock)
807 afs_int32 maxUser, maxGroup;
809 code = pr_ListMaxUserId(&maxUser);
811 afs_com_err(whoami, code, "getting maximum user id");
813 code = pr_ListMaxGroupId(&maxGroup);
815 afs_com_err(whoami, code, "getting maximum group id");
817 printf("Max user id is %d and max group id is %d.\n", maxUser,
825 SetMaxCommand(struct cmd_syndesc *as, void *arock)
831 if (as->parms[1].items) {
833 code = util_GetInt32(as->parms[1].items->data, &maxid);
835 afs_com_err(whoami, code, "because id was: '%s'",
836 as->parms[1].items->data);
838 code = pr_SetMaxUserId(maxid);
840 afs_com_err(whoami, code, "so couldn't set Max User Id to %d",
844 if (as->parms[0].items) {
846 code = util_GetInt32(as->parms[0].items->data, &maxid);
848 afs_com_err(whoami, code, "because id was: '%s'",
849 as->parms[0].items->data);
851 code = pr_SetMaxGroupId(maxid);
853 afs_com_err(whoami, code, "so couldn't set Max Group Id to %d",
857 if (!as->parms[0].items && !as->parms[1].items) {
859 fprintf(stderr, "Must specify at least one of group or user.\n");
865 SetFields(struct cmd_syndesc *as, void *arock)
871 afs_int32 mask, flags=0, ngroups, nusers;
873 if (GetNameOrId(as, &ids, &names))
880 if (as->parms[1].items) { /* privacy bits */
881 char *access = as->parms[1].items->data;
884 if (strpbrk(access, "76543210") != 0) { /* all octal digits */
885 sscanf(access, "%lo", (long unsigned int *) &flags);
886 } else { /* interpret flag bit names */
887 if (strlen(access) != 5) {
889 fprintf(stderr, "Access bits must be of the form 'somar', not %s\n",
893 if (strpbrk(access, "somar-") == 0)
896 for (i = 0; i < 5; i++) {
897 if (access[i] == flags_upcase[i])
899 else if (access[i] == flags_dncase[i])
901 else if (access[i] == '-')
905 "Access bits out of order or illegal:\n must be a combination of letters from '%s' or '%s' or hyphen, not %s\n",
906 flags_upcase, flags_dncase, access);
909 flags <<= flags_shift[i];
910 if (flags_shift[i] == 1) {
917 mask |= PR_SF_ALLBITS;
919 if (as->parms[2].items) { /* limitgroups */
920 code = util_GetInt32(as->parms[2].items->data, &ngroups);
922 afs_com_err(whoami, code, "because ngroups was: '%s'",
923 as->parms[2].items->data);
926 mask |= PR_SF_NGROUPS;
929 for (i = 0; i < ids.idlist_len; i++) {
930 afs_int32 id = ids.idlist_val[i];
931 char *name = names.namelist_val[i];
932 if (id == ANONYMOUSID)
934 code = pr_SetFieldsEntry(id, mask, flags, ngroups, nusers);
936 afs_com_err(whoami, code, "; unable to set fields for %s (id: %d)",
942 free(ids.idlist_val);
943 if (names.namelist_val)
944 free(names.namelist_val);
949 ListOwned(struct cmd_syndesc *as, void *arock)
958 if (GetNameOrId(as, &ids, &names))
961 for (i = 0; i < ids.idlist_len; i++) {
962 afs_int32 oid = ids.idlist_val[i];
963 char *name = names.namelist_val[i];
965 if (oid == ANONYMOUSID)
969 printf("Groups owned by %s (id: %d) are:\n", name, oid);
971 printf("Orphaned groups are:\n");
974 list.namelist_val = 0;
975 list.namelist_len = 0;
976 code = pr_ListOwned(oid, &list, &more);
978 afs_com_err(whoami, code,
979 "; unable to get owner list for %s (id: %d)", name,
984 for (j = 0; j < list.namelist_len; j++)
985 printf(" %s\n", list.namelist_val[j]);
986 if (list.namelist_val)
987 free(list.namelist_val);
992 free(ids.idlist_val);
993 if (names.namelist_val)
994 free(names.namelist_val);
999 add_std_args(struct cmd_syndesc *ts)
1003 if (asprintf(&test_help, "use config file in %s",
1004 AFSDIR_SERVER_ETC_DIRPATH) < 0) {
1005 test_help = strdup("use server config file");
1009 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1010 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "run unauthenticated");
1011 cmd_AddParm(ts, "-test", CMD_FLAG, CMD_OPTIONAL | CMD_HIDE, test_help);
1012 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
1013 "Continue oper despite reasonable errors");
1014 cmd_AddParm(ts, "-localauth", CMD_FLAG, CMD_OPTIONAL,
1015 "use local authentication");
1016 cmd_AddParm(ts, "-auth", CMD_FLAG, CMD_OPTIONAL,
1017 "use user's authentication (default)");
1018 cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL,
1019 "encrypt commands");
1020 cmd_AddParm(ts, "-config", CMD_SINGLE, CMD_OPTIONAL, "config location");
1021 cmd_AddParm(ts, "-rxgk", CMD_SINGLE, CMD_OPTIONAL, "rxgk security level to use");
1026 static void add_NameOrId_args (ts)
1027 struct cmd_syndesc *ts;
1029 cmd_AddParm(ts,"-name",CMD_LIST,CMD_OPTIONAL,"user or group name");
1030 cmd_AddParm(ts,"-id",CMD_LIST,CMD_OPTIONAL,"user or group id");
1034 #include "AFS_component_version_number.c"
1037 main(int argc, char **argv)
1040 struct cmd_syndesc *ts;
1045 char *parsev[CMD_MAXPARMS];
1047 struct authstate state;
1054 WSAStartup(0x0101, &WSAjunk);
1057 #ifdef AFS_AIX32_ENV
1059 * The following signal action for AIX is necessary so that in case of a
1060 * crash (i.e. core is generated) we can include the user's data section
1061 * in the core dump. Unfortunately, by default, only a partial core is
1062 * generated which, in many cases, isn't too useful.
1064 struct sigaction nsa;
1066 sigemptyset(&nsa.sa_mask);
1067 nsa.sa_handler = SIG_DFL;
1068 nsa.sa_flags = SA_FULLDUMP;
1069 sigaction(SIGSEGV, &nsa, NULL);
1072 memset(&state, 0, sizeof(state));
1073 state.sec = 1; /* default is auth */
1075 ts = cmd_CreateSyntax("creategroup", CreateGroup, NULL, 0,
1076 "create a new group");
1077 cmd_AddParm(ts, "-name", CMD_LIST, 0, "group name");
1078 cmd_AddParm(ts, "-owner", CMD_SINGLE, CMD_OPTIONAL, "owner of the group");
1079 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL,
1080 "id (negated) for the group");
1082 cmd_CreateAlias(ts, "cg");
1084 ts = cmd_CreateSyntax("createuser", CreateUser, NULL, 0, "create a new user");
1085 cmd_AddParm(ts, "-name", CMD_LIST, 0, "user name");
1086 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL, "user id");
1088 cmd_CreateAlias(ts, "cu");
1090 ts = cmd_CreateSyntax("adduser", AddToGroup, NULL, 0, "add a user to a group");
1091 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user name");
1092 cmd_AddParm(ts, "-group", CMD_LIST, 0, "group name");
1095 ts = cmd_CreateSyntax("removeuser", RemoveFromGroup, NULL, 0,
1096 "remove a user from 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("membership", ListMembership, NULL, 0,
1102 "list membership of a user or group");
1103 cmd_AddParm(ts, "-nameorid", CMD_LIST, 0, "user or group name or id");
1104 cmd_AddParm(ts, "-supergroups", CMD_FLAG, CMD_OPTIONAL, "show supergroups");
1105 cmd_AddParm(ts, "-expandgroups", CMD_FLAG, CMD_OPTIONAL, "expand super and sub group membership");
1107 cmd_CreateAlias(ts, "groups");
1109 ts = cmd_CreateSyntax("delete", Delete, NULL, 0,
1110 "delete a user or group from database");
1111 cmd_AddParm(ts, "-nameorid", CMD_LIST, 0, "user or group name or id");
1114 ts = cmd_CreateSyntax("examine", CheckEntry, NULL, 0, "examine an entry");
1115 cmd_AddParm(ts, "-nameorid", CMD_LIST, 0, "user or group name or id");
1117 cmd_CreateAlias(ts, "check");
1119 ts = cmd_CreateSyntax("chown", ChownGroup, NULL, 0,
1120 "change ownership of a group");
1121 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "group name");
1122 cmd_AddParm(ts, "-owner", CMD_SINGLE, 0, "new owner");
1125 ts = cmd_CreateSyntax("rename", ChangeName, NULL, 0, "rename user or group");
1126 cmd_AddParm(ts, "-oldname", CMD_SINGLE, 0, "old name");
1127 cmd_AddParm(ts, "-newname", CMD_SINGLE, 0, "new name");
1129 cmd_CreateAlias(ts, "chname");
1131 ts = cmd_CreateSyntax("listmax", ListMax, NULL, 0, "list max id");
1134 ts = cmd_CreateSyntax("setmax", SetMaxCommand, NULL, 0, "set max id");
1135 cmd_AddParm(ts, "-group", CMD_SINGLE, CMD_OPTIONAL, "group max");
1136 cmd_AddParm(ts, "-user", CMD_SINGLE, CMD_OPTIONAL, "user max");
1139 ts = cmd_CreateSyntax("setfields", SetFields, NULL, 0,
1140 "set fields for an entry");
1141 cmd_AddParm(ts, "-nameorid", CMD_LIST, 0, "user or group name or id");
1142 cmd_AddParm(ts, "-access", CMD_SINGLE, CMD_OPTIONAL, "set privacy flags");
1143 cmd_AddParm(ts, "-groupquota", CMD_SINGLE, CMD_OPTIONAL,
1144 "set limit on group creation");
1147 ts = cmd_CreateSyntax("listowned", ListOwned, NULL, 0,
1148 "list groups owned by an entry or zero id gets orphaned groups");
1149 cmd_AddParm(ts, "-nameorid", CMD_LIST, 0, "user or group name or id");
1152 ts = cmd_CreateSyntax("listentries", ListEntries, NULL, 0,
1153 "list users/groups in the protection database");
1154 cmd_AddParm(ts, "-users", CMD_FLAG, CMD_OPTIONAL, "list user entries");
1155 cmd_AddParm(ts, "-groups", CMD_FLAG, CMD_OPTIONAL, "list group entries");
1158 ts = cmd_CreateSyntax("interactive", pts_Interactive, NULL, 0,
1159 "enter interactive mode");
1161 cmd_CreateAlias(ts, "in");
1163 ts = cmd_CreateSyntax("quit", pts_Quit, NULL, 0, "exit program");
1166 ts = cmd_CreateSyntax("source", pts_Source, NULL, 0, "read commands from file");
1167 cmd_AddParm(ts, "-file", CMD_SINGLE, 0, "filename");
1170 ts = cmd_CreateSyntax("sleep", pts_Sleep, NULL, 0, "pause for a bit");
1171 cmd_AddParm(ts, "-delay", CMD_SINGLE, 0, "seconds");
1174 cmd_SetBeforeProc(GetGlobals, &state);
1178 if (cmd_Dispatch(argc, argv)) {
1179 CleanUp(NULL, NULL);
1182 while (source && !finished) {
1183 if (isatty(fileno(source)))
1184 fprintf(stderr, "pts> ");
1185 if (!fgets(line, sizeof line, source)) {
1191 for (cp = line; *cp; ++cp)
1201 cmd_ParseLine(line, parsev, &parsec,
1202 sizeof(parsev) / sizeof(*parsev));
1204 afs_com_err(whoami, code, "parsing line: <%s>", line);
1208 parsev[0] = argv[0];
1209 cmd_Dispatch(parsec, parsev);
1211 cmd_FreeArgv(parsev);
1213 CleanUp(NULL, NULL);