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