Initial IBM OpenAFS 1.0 tree
[openafs.git] / src / libadmin / test / pts.c
1 /* Copyright (C) 1998 Transarc Corporation - All rights reserved.
2  *
3  */
4
5 /*
6  * This file implements the pts related funtions for afscp
7  */
8
9 #include "pts.h"
10
11 /*
12  * Utility functions
13  */
14
15 /*
16  * Generic fuction for converting input string to an integer.  Pass
17  * the error_msg you want displayed if there is an error converting
18  * the string.
19  */
20
21 static int
22 GetIntFromString(const char *int_str, const char *error_msg) {
23     int i;
24     char *bad_char = NULL;
25
26     i = strtoul(int_str, &bad_char, 10);
27     if ((bad_char == NULL) || (*bad_char == 0)) {
28         return i;
29     }
30
31     ERR_EXT(error_msg);
32 }
33
34 /*
35  * Generic fuction for converting input string to an pts_groupAccess_t.  Pass
36  * the error_msg you want displayed if there is an error converting
37  * the string.
38  */
39
40 static pts_groupAccess_t
41 GetGroupAccessFromString(const char *in_str, const char *error_msg) {
42     pts_groupAccess_t access;
43
44     if (!strcasecmp("owner", in_str)) {
45         access = PTS_GROUP_OWNER_ACCESS;
46     } else if (!strcasecmp("group", in_str)) {
47         access = PTS_GROUP_ACCESS;
48     } else if (!strcasecmp("any", in_str)) {
49         access = PTS_GROUP_ANYUSER_ACCESS;
50     } else {
51         ERR_EXT(error_msg);
52     }
53
54     return access;
55 }
56
57 /*
58  * Generic fuction for converting input string to an pts_userAccess_t.  Pass
59  * the error_msg you want displayed if there is an error converting
60  * the string.
61  */
62
63 static pts_userAccess_t
64 GetUserAccessFromString(const char *in_str, const char *error_msg) {
65     pts_userAccess_t access;
66
67     if (!strcasecmp("owner", in_str)) {
68         access = PTS_USER_OWNER_ACCESS;
69     } else if (!strcasecmp("any", in_str)) {
70         access = PTS_USER_ANYUSER_ACCESS;
71     } else {
72         ERR_EXT(error_msg);
73     }
74
75     return access;
76 }
77
78 int
79 DoPtsGroupMemberAdd(struct cmd_syndesc *as, char *arock)
80 {
81     typedef enum {USER, GROUP}
82       DoPtsGroupMemberAdd_parm_t;
83     afs_status_t st = 0;
84     const char *user = as->parms[USER].items->data;
85     const char *group = as->parms[GROUP].items->data;
86
87     if (!pts_GroupMemberAdd(cellHandle, user, group, &st)) {
88         ERR_ST_EXT("pts_GroupMemberAdd", st);
89     }
90
91     return 0;
92 }
93
94 int
95 DoPtsGroupOwnerChange(struct cmd_syndesc *as, char *arock)
96 {
97     typedef enum {OWNER, GROUP}
98       DoPtsGroupOwnerChange_parm_t;
99     afs_status_t st = 0;
100     const char *owner = as->parms[OWNER].items->data;
101     const char *group = as->parms[GROUP].items->data;
102
103     if (!pts_GroupOwnerChange(cellHandle, group, owner, &st)) {
104         ERR_ST_EXT("pts_GroupOwnerChange", st);
105     }
106
107     return 0;
108 }
109
110 int
111 DoPtsGroupCreate(struct cmd_syndesc *as, char *arock)
112 {
113     typedef enum {OWNER, GROUP}
114       DoPtsGroupCreate_parm_t;
115     afs_status_t st = 0;
116     const char *owner = as->parms[OWNER].items->data;
117     const char *group = as->parms[GROUP].items->data;
118     int new_group_id;
119
120     if (!pts_GroupCreate(cellHandle, group, owner, &new_group_id, &st)) {
121         ERR_ST_EXT("pts_GroupMemberAdd", st);
122     }
123
124     printf("Group id %d\n", new_group_id);
125
126     return 0;
127 }
128
129 static void
130 Print_pts_groupAccess_p(pts_groupAccess_p access, const char *prefix)
131 {
132     if (*access == PTS_GROUP_OWNER_ACCESS) {
133         printf("%sPTS_GROUP_OWNER_ACCESS\n", prefix);
134     } else if (*access == PTS_GROUP_ACCESS) {
135         printf("%sPTS_GROUP_ACCESS\n", prefix);
136     } else if (*access == PTS_GROUP_ANYUSER_ACCESS) {
137         printf("%sPTS_GROUP_ANYUSER_ACCESS\n", prefix);
138     }
139 }
140
141 static void
142 Print_pts_GroupEntry_p(pts_GroupEntry_p entry, const char *prefix)
143 {
144     printf("%sName %s Uid %d\n", prefix, entry->name, entry->nameUid);
145     printf("%sOwner %s Uid %d\n", prefix, entry->owner, entry->ownerUid);
146     printf("%sCreator %s Uid %d\n", prefix, entry->creator, entry->creatorUid);
147     printf("%sMembership count %d\n", prefix, entry->membershipCount);
148     printf("%sList status permission:\n", prefix);
149     Print_pts_groupAccess_p(&entry->listStatus, "    ");
150     printf("%sList groups owned permission:\n", prefix);
151     Print_pts_groupAccess_p(&entry->listGroupsOwned, "    ");
152     printf("%sList membership permission:\n", prefix);
153     Print_pts_groupAccess_p(&entry->listMembership, "    ");
154     printf("%sList add permission:\n", prefix);
155     Print_pts_groupAccess_p(&entry->listAdd, "    ");
156     printf("%sList delete permission:\n", prefix);
157     Print_pts_groupAccess_p(&entry->listDelete, "    ");
158 }
159
160 int
161 DoPtsGroupGet(struct cmd_syndesc *as, char *arock)
162 {
163     typedef enum {GROUP}
164       DoPtsGroupGet_parm_t;
165     afs_status_t st = 0;
166     const char *group = as->parms[GROUP].items->data;
167     pts_GroupEntry_t entry;
168
169     if (!pts_GroupGet(cellHandle, group, &entry, &st)) {
170         ERR_ST_EXT("pts_GroupGet", st);
171     }
172
173     Print_pts_GroupEntry_p(&entry, "");
174
175     return 0;
176 }
177
178 int
179 DoPtsGroupDelete(struct cmd_syndesc *as, char *arock)
180 {
181     typedef enum {GROUP}
182       DoPtsGroupDelete_parm_t;
183     afs_status_t st = 0;
184     const char *group = as->parms[GROUP].items->data;
185
186     if (!pts_GroupDelete(cellHandle, group, &st)) {
187         ERR_ST_EXT("pts_GroupDelete", st);
188     }
189
190     return 0;
191 }
192
193 int
194 DoPtsGroupMaxGet(struct cmd_syndesc *as, char *arock)
195 {
196     afs_status_t st = 0;
197     int max_group_id;
198
199     if (!pts_GroupMaxGet(cellHandle, &max_group_id, &st)) {
200         ERR_ST_EXT("pts_GroupMaxGet", st);
201     }
202
203     return 0;
204 }
205
206 int
207 DoPtsGroupMaxSet(struct cmd_syndesc *as, char *arock)
208 {
209     typedef enum {MAX}
210       DoPtsGroupMaxSet_parm_t;
211     afs_status_t st = 0;
212     const char *max = as->parms[MAX].items->data;
213     int max_group_id;
214
215     max_group_id = GetIntFromString(max, "bad group id");
216
217     if (!pts_GroupMaxSet(cellHandle, max_group_id, &st)) {
218         ERR_ST_EXT("pts_GroupMaxSet", st);
219     }
220
221     return 0;
222 }
223
224 int
225 DoPtsGroupMemberList(struct cmd_syndesc *as, char *arock)
226 {
227     typedef enum {GROUP}
228       DoPtsGroupMemberList_parm_t;
229     afs_status_t st = 0;
230     const char *group = as->parms[GROUP].items->data;
231     void *iter;
232     char member[PTS_MAX_NAME_LEN];
233
234     if (!pts_GroupMemberListBegin(cellHandle, group, &iter, &st)) {
235         ERR_ST_EXT("pts_GroupMemberListBegin", st);
236     }
237
238     printf("Listing members of group %s\n", group);
239     while(pts_GroupMemberListNext(iter, member, &st)) {
240         printf("\t%s\n", member);
241     }
242
243     if (st != ADMITERATORDONE) {
244         ERR_ST_EXT("pts_GroupMemberListNext", st);
245     }
246
247     if (!pts_GroupMemberListDone(iter, &st)) {
248         ERR_ST_EXT("pts_GroupMemberListDone", st);
249     }
250
251     return 0;
252 }
253
254 int
255 DoPtsGroupMemberRemove(struct cmd_syndesc *as, char *arock)
256 {
257     typedef enum {USER, GROUP}
258       DoPtsGroupMemberRemove_parm_t;
259     afs_status_t st = 0;
260     const char *user = as->parms[USER].items->data;
261     const char *group = as->parms[GROUP].items->data;
262
263     if (!pts_GroupMemberRemove(cellHandle, user, group, &st)) {
264         ERR_ST_EXT("pts_GroupMemberRemove", st);
265     }
266
267     return 0;
268 }
269
270 int
271 DoPtsGroupRename(struct cmd_syndesc *as, char *arock)
272 {
273     typedef enum {GROUP, NEWNAME}
274       DoPtsGroupRename_parm_t;
275     afs_status_t st = 0;
276     const char *group = as->parms[GROUP].items->data;
277     const char *new_name = as->parms[NEWNAME].items->data;
278
279     if (!pts_GroupRename(cellHandle, group, new_name, &st)) {
280         ERR_ST_EXT("pts_GroupRename", st);
281     }
282
283     return 0;
284 }
285
286 int
287 DoPtsGroupModify(struct cmd_syndesc *as, char *arock)
288 {
289     typedef enum {GROUP, LISTSTATUS, LISTGROUPSOWNED, LISTMEMBERSHIP,
290       LISTADD, LISTDELTE}
291       DoPtsGroupModify_parm_t;
292     afs_status_t st = 0;
293     const char *group = as->parms[GROUP].items->data;
294     pts_GroupUpdateEntry_t entry;
295
296     entry.listStatus = 
297         GetGroupAccessFromString(as->parms[LISTSTATUS].items->data,
298                                  "invalid permission specifier");
299     entry.listGroupsOwned = 
300         GetGroupAccessFromString(as->parms[LISTGROUPSOWNED].items->data,
301                                  "invalid permission specifier");
302     entry.listMembership = 
303         GetGroupAccessFromString(as->parms[LISTMEMBERSHIP].items->data,
304                                  "invalid permission specifier");
305     entry.listAdd = 
306         GetGroupAccessFromString(as->parms[LISTADD].items->data,
307                                  "invalid permission specifier");
308     entry.listDelete = 
309         GetGroupAccessFromString(as->parms[LISTDELTE].items->data,
310                                  "invalid permission specifier");
311
312     if (!pts_GroupModify(cellHandle, group, &entry, &st)) {
313         ERR_ST_EXT("pts_GroupModify", st);
314     }
315
316     return 0;
317 }
318
319 int
320 DoPtsUserCreate(struct cmd_syndesc *as, char *arock)
321 {
322     typedef enum {USER}
323       DoPtsUserCreate_parm_t;
324     afs_status_t st = 0;
325     const char *user = as->parms[USER].items->data;
326     int new_user_id;
327
328     if (!pts_UserCreate(cellHandle, user, &new_user_id, &st)) {
329         ERR_ST_EXT("pts_UserCreate", st);
330     }
331
332     printf("Created user id %d\n", new_user_id);
333
334     return 0;
335 }
336
337 int
338 DoPtsUserDelete(struct cmd_syndesc *as, char *arock)
339 {
340     typedef enum {USER}
341       DoPtsUserDelete_parm_t;
342     afs_status_t st = 0;
343     const char *user = as->parms[USER].items->data;
344
345     if (!pts_UserDelete(cellHandle, user, &st)) {
346         ERR_ST_EXT("pts_UserDelete", st);
347     }
348
349     return 0;
350 }
351
352 static void
353 Print_pts_userAccess_p(pts_userAccess_p access, const char *prefix)
354 {
355     if (*access == PTS_USER_OWNER_ACCESS) {
356         printf("%sPTS_USER_OWNER_ACCESS\n", prefix);
357     } else if (*access == PTS_USER_ANYUSER_ACCESS) {
358         printf("%sPTS_USER_ANYUSER_ACCESS\n", prefix);
359     }
360 }
361
362 static void
363 Print_pts_UserEntry_p(pts_UserEntry_p entry, const char *prefix)
364 {
365     printf("%sName %s Uid %d\n", prefix, entry->name, entry->nameUid);
366     printf("%sOwner %s Uid %d\n", prefix, entry->owner, entry->ownerUid);
367     printf("%sCreator %s Uid %d\n", prefix, entry->creator, entry->creatorUid);
368     printf("%sGroup creation quota %d\n", prefix, entry->groupCreationQuota);
369     printf("%sGroup membership count %d\n",
370            prefix,
371            entry->groupMembershipCount);
372     printf("%sList status permission\n", prefix);
373     Print_pts_userAccess_p(&entry->listStatus, "    ");
374     printf("%sList groups owned permission\n", prefix);
375     Print_pts_userAccess_p(&entry->listGroupsOwned, "    ");
376     printf("%sList membership permission\n", prefix);
377     Print_pts_userAccess_p(&entry->listMembership, "    ");
378     printf("%s\n", prefix);
379 }
380
381 int
382 DoPtsUserGet(struct cmd_syndesc *as, char *arock)
383 {
384     typedef enum {USER}
385       DoPtsUserGet_parm_t;
386     afs_status_t st = 0;
387     const char *user = as->parms[USER].items->data;
388     pts_UserEntry_t entry;
389
390     if (!pts_UserGet(cellHandle, user, &entry, &st)) {
391         ERR_ST_EXT("pts_UserGet", st);
392     }
393
394     Print_pts_UserEntry_p(&entry, "");
395
396     return 0;
397 }
398
399 int
400 DoPtsUserRename(struct cmd_syndesc *as, char *arock)
401 {
402     typedef enum {USER, NEWNAME}
403       DoPtsUserRename_parm_t;
404     afs_status_t st = 0;
405     const char *user = as->parms[USER].items->data;
406     const char *new_name = as->parms[NEWNAME].items->data;
407
408     if (!pts_UserRename(cellHandle, user, new_name, &st)) {
409         ERR_ST_EXT("pts_UserRename", st);
410     }
411
412     return 0;
413 }
414
415 int
416 DoPtsUserModify(struct cmd_syndesc *as, char *arock)
417 {
418     typedef enum {USER, GROUPQUOTA, LISTSTATUS, LISTGROUPSOWNED, LISTMEMBERSHIP}
419       DoPtsUserModify_parm_t;
420     afs_status_t st = 0;
421     const char *user = as->parms[USER].items->data;
422     pts_UserUpdateEntry_t entry;
423     int have_quota = 0;
424     int have_list_status_perm = 0;
425     int have_list_groups_owned_perm = 0;
426     int have_list_membership_perm = 0;
427
428     entry.flag = 0;
429
430     if (as->parms[GROUPQUOTA].items) {
431         entry.groupCreationQuota = 
432             GetIntFromString(as->parms[GROUPQUOTA].items->data, "bad quota");
433         entry.flag = PTS_USER_UPDATE_GROUP_CREATE_QUOTA;
434         have_quota = 1;
435     }
436
437     if (as->parms[LISTSTATUS].items) {
438         entry.listStatus = 
439             GetUserAccessFromString(as->parms[LISTSTATUS].items->data,
440                                     "invalid permission specifier");
441         entry.flag |= PTS_USER_UPDATE_PERMISSIONS;
442         have_list_status_perm = 1;
443     }
444
445     if (as->parms[LISTGROUPSOWNED].items) {
446         entry.listGroupsOwned = 
447             GetUserAccessFromString(as->parms[LISTGROUPSOWNED].items->data,
448                                     "invalid permission specifier");
449         entry.flag |= PTS_USER_UPDATE_PERMISSIONS;
450         have_list_groups_owned_perm = 1;
451     }
452
453     if (as->parms[LISTMEMBERSHIP].items) {
454         entry.listMembership = 
455             GetUserAccessFromString(as->parms[LISTMEMBERSHIP].items->data,
456                                     "invalid permission specifier");
457         entry.flag |= PTS_USER_UPDATE_PERMISSIONS;
458         have_list_membership_perm = 1;
459     }
460
461     if (entry.flag == 0) {
462         ERR_EXT("you must specify either quota or permissions to modify");
463     } else {
464         if (entry.flag & PTS_USER_UPDATE_PERMISSIONS) {
465             if ((have_list_status_perm + have_list_groups_owned_perm +
466                  have_list_membership_perm) != 3) {
467                 ERR_EXT("you must completely specify all permissions "
468                         "when modifying a user");
469             }
470         }
471     }
472
473     if (!pts_UserModify(cellHandle, user, &entry, &st)) {
474         ERR_ST_EXT("pts_UserModify", st);
475     }
476
477     return 0;
478 }
479
480 int
481 DoPtsUserMaxGet(struct cmd_syndesc *as, char *arock)
482 {
483     afs_status_t st = 0;
484     int max_user_id;
485
486     if (!pts_UserMaxGet(cellHandle, &max_user_id, &st)) {
487         ERR_ST_EXT("pts_UserMaxGet", st);
488     }
489
490     return 0;
491 }
492
493 int
494 DoPtsUserMaxSet(struct cmd_syndesc *as, char *arock)
495 {
496     typedef enum {MAX}
497       DoPtsUserMaxSet_parm_t;
498     afs_status_t st = 0;
499     const char *max = as->parms[MAX].items->data;
500     int max_user_id;
501
502     max_user_id = GetIntFromString(max, "bad user id");
503
504     if (!pts_UserMaxSet(cellHandle, max_user_id, &st)) {
505         ERR_ST_EXT("pts_UserMaxSet", st);
506     }
507
508     return 0;
509 }
510
511 int
512 DoPtsUserMemberList(struct cmd_syndesc *as, char *arock)
513 {
514     typedef enum {USER}
515       DoPtsUserMemberList_parm_t;
516     afs_status_t st = 0;
517     const char *user = as->parms[USER].items->data;
518     void *iter;
519     char group[PTS_MAX_NAME_LEN];
520
521     if (!pts_UserMemberListBegin(cellHandle, user, &iter, &st)) {
522         ERR_ST_EXT("pts_UserMemberListBegin", st);
523     }
524
525     printf("Listing group membership for %s\n", user);
526
527     while(pts_UserMemberListNext(iter, group, &st)) {
528         printf("\t%s\n", group);
529     }
530
531     if (st != ADMITERATORDONE) {
532         ERR_ST_EXT("pts_UserMemberListNext", st);
533     }
534
535     if (!pts_UserMemberListDone(iter, &st)) {
536         ERR_ST_EXT("pts_UserMemberListDone", st);
537     }
538
539     return 0;
540 }
541
542 int
543 DoPtsOwnedGroupList(struct cmd_syndesc *as, char *arock)
544 {
545     typedef enum {USER}
546       DoPtsOwnedGroupList_parm_t;
547     afs_status_t st = 0;
548     const char *user = as->parms[USER].items->data;
549     void *iter;
550     char group[PTS_MAX_NAME_LEN];
551
552     if (!pts_OwnedGroupListBegin(cellHandle, user, &iter, &st)) {
553         ERR_ST_EXT("pts_OwnedGroupListBegin", st);
554     }
555
556     printf("Listing groups owned by %s\n", user);
557
558     while(pts_OwnedGroupListNext(iter, group, &st)) {
559         printf("\t%s\n", group);
560     }
561
562     if (st != ADMITERATORDONE) {
563         ERR_ST_EXT("pts_OwnedGroupListNext", st);
564     }
565
566     if (!pts_OwnedGroupListDone(iter, &st)) {
567         ERR_ST_EXT("pts_OwnedGroupListDone", st);
568     }
569
570     return 0;
571 }
572
573 void
574 SetupPtsAdminCmd(void)
575 {
576     struct cmd_syndesc  *ts;
577
578     ts = cmd_CreateSyntax("PtsGroupMemberAdd",
579                           DoPtsGroupMemberAdd, 0,
580                           "add a user to a group");
581     cmd_AddParm(ts,
582                 "-user",
583                 CMD_SINGLE,
584                 CMD_REQUIRED,
585                 "user to add");
586     cmd_AddParm(ts,
587                 "-group",
588                 CMD_SINGLE,
589                 CMD_REQUIRED,
590                 "group to modify");
591     SetupCommonCmdArgs(ts);
592
593     ts = cmd_CreateSyntax("PtsGroupOwnerChange",
594                           DoPtsGroupOwnerChange, 0,
595                           "change the owner of a group");
596     cmd_AddParm(ts,
597                 "-owner",
598                 CMD_SINGLE,
599                 CMD_REQUIRED,
600                 "new owner");
601     cmd_AddParm(ts,
602                 "-group",
603                 CMD_SINGLE,
604                 CMD_REQUIRED,
605                 "group to modify");
606     SetupCommonCmdArgs(ts);
607
608     ts = cmd_CreateSyntax("PtsGroupCreate",
609                           DoPtsGroupCreate, 0,
610                           "create a new group");
611     cmd_AddParm(ts,
612                 "-owner",
613                 CMD_SINGLE,
614                 CMD_REQUIRED,
615                 "owner of group");
616     cmd_AddParm(ts,
617                 "-group",
618                 CMD_SINGLE,
619                 CMD_REQUIRED,
620                 "group to create");
621     SetupCommonCmdArgs(ts);
622
623     ts = cmd_CreateSyntax("PtsGroupGet",
624                           DoPtsGroupGet, 0,
625                           "get information about a group");
626     cmd_AddParm(ts,
627                 "-group",
628                 CMD_SINGLE,
629                 CMD_REQUIRED,
630                 "group to query");
631     SetupCommonCmdArgs(ts);
632
633     ts = cmd_CreateSyntax("PtsGroupDelete",
634                           DoPtsGroupDelete, 0,
635                           "delete a group");
636     cmd_AddParm(ts,
637                 "-group",
638                 CMD_SINGLE,
639                 CMD_REQUIRED,
640                 "group to delete");
641     SetupCommonCmdArgs(ts);
642
643     ts = cmd_CreateSyntax("PtsGroupMaxGet",
644                           DoPtsGroupMaxGet, 0,
645                           "get the maximum group id");
646     SetupCommonCmdArgs(ts);
647
648     ts = cmd_CreateSyntax("PtsGroupMaxSet",
649                           DoPtsGroupMaxSet, 0,
650                           "set the maximum group id");
651     cmd_AddParm(ts,
652                 "-max",
653                 CMD_SINGLE,
654                 CMD_REQUIRED,
655                 "new max group id");
656     SetupCommonCmdArgs(ts);
657
658     ts = cmd_CreateSyntax("PtsGroupMemberList",
659                           DoPtsGroupMemberList, 0,
660                           "list members of a group");
661     cmd_AddParm(ts,
662                 "-group",
663                 CMD_SINGLE,
664                 CMD_REQUIRED,
665                 "group to query");
666     SetupCommonCmdArgs(ts);
667
668     ts = cmd_CreateSyntax("PtsGroupMemberRemove",
669                           DoPtsGroupMemberRemove, 0,
670                           "remove a member from a group");
671     cmd_AddParm(ts,
672                 "-user",
673                 CMD_SINGLE,
674                 CMD_REQUIRED,
675                 "user to remove");
676     cmd_AddParm(ts,
677                 "-group",
678                 CMD_SINGLE,
679                 CMD_REQUIRED,
680                 "group to modify");
681     SetupCommonCmdArgs(ts);
682
683     ts = cmd_CreateSyntax("PtsGroupRename",
684                           DoPtsGroupRename, 0,
685                           "rename a group");
686     cmd_AddParm(ts,
687                 "-group",
688                 CMD_SINGLE,
689                 CMD_REQUIRED,
690                 "group to modify");
691     cmd_AddParm(ts,
692                 "-newname",
693                 CMD_SINGLE,
694                 CMD_REQUIRED,
695                 "new group name");
696     SetupCommonCmdArgs(ts);
697
698     ts = cmd_CreateSyntax("PtsGroupModify",
699                           DoPtsGroupModify, 0,
700                           "modify a group");
701     cmd_AddParm(ts,
702                 "-group",
703                 CMD_SINGLE,
704                 CMD_REQUIRED,
705                 "group to modify");
706     cmd_AddParm(ts,
707                 "-liststatus",
708                 CMD_SINGLE,
709                 CMD_REQUIRED,
710                 "list status permission <owner | group | any>");
711     cmd_AddParm(ts,
712                 "-listgroupsowned",
713                 CMD_SINGLE,
714                 CMD_REQUIRED,
715                 "list groups owned permission <owner | any>");
716     cmd_AddParm(ts,
717                 "-listmembership",
718                 CMD_SINGLE,
719                 CMD_REQUIRED,
720                 "list membership permission <owner | group | any>");
721     cmd_AddParm(ts,
722                 "-listadd",
723                 CMD_SINGLE,
724                 CMD_REQUIRED,
725                 "list add permission <owner | group | any>");
726     cmd_AddParm(ts,
727                 "-listdelete",
728                 CMD_SINGLE,
729                 CMD_REQUIRED,
730                 "list delete permission <owner | group>");
731     SetupCommonCmdArgs(ts);
732
733     ts = cmd_CreateSyntax("PtsUserCreate",
734                           DoPtsUserCreate, 0,
735                           "create a new user");
736     cmd_AddParm(ts,
737                 "-user",
738                 CMD_SINGLE,
739                 CMD_REQUIRED,
740                 "user to create");
741     SetupCommonCmdArgs(ts);
742
743     ts = cmd_CreateSyntax("PtsUserDelete",
744                           DoPtsUserDelete, 0,
745                           "delete a user");
746     cmd_AddParm(ts,
747                 "-user",
748                 CMD_SINGLE,
749                 CMD_REQUIRED,
750                 "user to delete");
751     SetupCommonCmdArgs(ts);
752
753     ts = cmd_CreateSyntax("PtsUserGet",
754                           DoPtsUserGet, 0,
755                           "get information about a user");
756     cmd_AddParm(ts,
757                 "-user",
758                 CMD_SINGLE,
759                 CMD_REQUIRED,
760                 "user to query");
761     SetupCommonCmdArgs(ts);
762
763     ts = cmd_CreateSyntax("PtsUserRename",
764                           DoPtsUserRename, 0,
765                           "rename a user");
766     cmd_AddParm(ts,
767                 "-user",
768                 CMD_SINGLE,
769                 CMD_REQUIRED,
770                 "user to modify");
771     cmd_AddParm(ts,
772                 "-newname",
773                 CMD_SINGLE,
774                 CMD_REQUIRED,
775                 "new user name");
776     SetupCommonCmdArgs(ts);
777
778     ts = cmd_CreateSyntax("PtsUserModify",
779                           DoPtsUserModify, 0,
780                           "change a user");
781     cmd_AddParm(ts,
782                 "-user",
783                 CMD_SINGLE,
784                 CMD_REQUIRED,
785                 "user to modify");
786     cmd_AddParm(ts,
787                 "-groupquota",
788                 CMD_SINGLE,
789                 CMD_OPTIONAL,
790                 "group creation quota");
791     cmd_AddParm(ts,
792                 "-liststatus",
793                 CMD_SINGLE,
794                 CMD_OPTIONAL,
795                 "list status permission <owner | any>");
796     cmd_AddParm(ts,
797                 "-listgroupsowned",
798                 CMD_SINGLE,
799                 CMD_OPTIONAL,
800                 "list groups owned permission <owner | any>");
801     cmd_AddParm(ts,
802                 "-listmembership",
803                 CMD_SINGLE,
804                 CMD_OPTIONAL,
805                 "list membership permission <owner | any>");
806     SetupCommonCmdArgs(ts);
807
808     ts = cmd_CreateSyntax("PtsUserMaxGet",
809                           DoPtsUserMaxGet, 0,
810                           "get the max user id");
811     SetupCommonCmdArgs(ts);
812
813     ts = cmd_CreateSyntax("PtsUserMaxSet",
814                           DoPtsUserMaxSet, 0,
815                           "set the max user id");
816     cmd_AddParm(ts,
817                 "-max",
818                 CMD_SINGLE,
819                 CMD_REQUIRED,
820                 "max user id");
821     SetupCommonCmdArgs(ts);
822
823     ts = cmd_CreateSyntax("PtsUserMemberList",
824                           DoPtsUserMemberList, 0,
825                           "list group membership for a user");
826     cmd_AddParm(ts,
827                 "-user",
828                 CMD_SINGLE,
829                 CMD_REQUIRED,
830                 "user to query");
831     SetupCommonCmdArgs(ts);
832
833     ts = cmd_CreateSyntax("PtsOwnedGroupList",
834                           DoPtsOwnedGroupList, 0,
835                           "list groups owned by a user");
836     cmd_AddParm(ts,
837                 "-user",
838                 CMD_SINGLE,
839                 CMD_REQUIRED,
840                 "user to query");
841     SetupCommonCmdArgs(ts);
842 }