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
11 * Main module for the AFS user account management tool.
15 * --------------------- Required definitions ---------------------
18 #include <afsconfig.h>
19 #include <afs/param.h>
28 #include "uss_common.h" /*Common uss definitions, globals */
29 #include "uss_procs.h" /*Main uss operations */
30 #include "uss_kauth.h" /*AuthServer routines */
31 #include "uss_fs.h" /*CacheManager ops */
32 #include "uss_ptserver.h"
35 #include <afs/cmd.h> /*Command line parsing */
36 #include <afs/cellconfig.h> /*Cell config defs */
37 #include <afs/kautils.h> /*MAXKTCREALMLEN & MAXKTCNAMELEN */
38 #include <afs/pterror.h>
39 #include <afs/vlserver.h>
42 extern int yylex(void);
43 extern int yyparse (void);
45 * Label certain things which will be activated at a later time,
46 * as well as certain semi-implemented features/switches which need
47 * to be hidden for the general AFS 3.2 release.
49 #define USS_FUTURE_FEATURES 1
50 #define USS_DONT_HIDE_SOME_FEATURES 0
53 * ---------------------- Exported variables ----------------------
55 char *uss_fs_InBuff = NULL; /*Cache Manager input buff */
56 char *uss_fs_OutBuff = NULL; /*Cache Manager output buff */
59 * Set up convenient tags for the command line parameter indicies.
64 #define AUP_REALNAME 1
66 #define AUP_PWEXPIRES 3
67 #define AUP_SERVER 4 /* was 3 */
68 #define AUP_PART 5 /* was 4 */
69 #define AUP_MNTPT 6 /* was 5 */
70 #define AUP_UID 7 /* was 6 */
79 #define DUP_RESTOREDIR 2
80 #define DUP_SAVEVOLUME 3
82 #define DUP_PWDFORMAT 5
89 #define AUSS_TEMPLATE 10 /* was 7 */
90 #define AUSS_VERBOSE 11 /* was 8 */
91 #define AUSS_VAR 12 /* was 9 */
92 #define AUSS_CELL 13 /* was 10 */
93 #define AUSS_ADMIN 14 /* was 11 */
94 #define AUSS_DRYRUN 15 /* was 12 */
95 #define AUSS_SKIPAUTH 16 /* was 13 */
96 #define AUSS_OVERWRITE 17 /* was 14 */
97 #define AUSS_PWEXPIRES 18 /* was 15 */
98 #define AUSS_PIPE 19 /* was 16 */
102 static char Template[300] = "uss.template"; /*Default name */
104 extern FILE *yyin, *yyout; /*YACC input & output files */
106 int uss_BulkExpires = 0;
109 static int DoAdd(void);
111 /*-----------------------------------------------------------------------
115 * Read in the command line arguments common to all uss operations.
118 * a_as : Ptr to the command line syntax descriptor.
124 * May exit the program if trouble is encountered determining the
125 * cell name. Set up as the command line parser's BeforeProc().
129 *------------------------------------------------------------------------*/
132 GetCommon(struct cmd_syndesc *a_as, void *arock)
135 int code; /*Result of ka_LocalCell */
137 if (strcmp(a_as->name, "help") == 0)
139 if (a_as->parms[AUSS_TEMPLATE].items)
140 strcpy(Template, a_as->parms[AUSS_TEMPLATE].items->data);
141 if (a_as->parms[AUSS_VERBOSE].items)
146 code = ka_CellConfig(AFSDIR_CLIENT_ETC_DIRPATH);
148 fprintf(stderr, "%s: ** Call to ka_CellConfig() failed (code=%d)\n",
151 if (a_as->parms[AUSS_CELL].items) {
152 char local_cell[MAXKTCREALMLEN];
154 (a_as->parms[AUSS_CELL].items->data, uss_Cell, 0 /*local */ )) {
155 fprintf(stderr, "%s: ** Unknown or ambiguous cell name: %s\n",
156 uss_whoami, a_as->parms[AUSS_CELL].items->data);
160 * Get the local cell name
162 if (ka_ExpandCell((char *)0, local_cell, 0 /*local */ )) {
163 fprintf(stderr, "Can't get local cellname\n");
166 if (strcmp(uss_Cell, local_cell)) {
168 * Not the same; not a local cell
174 * Get the local cell name
176 if (ka_ExpandCell((char *)0, uss_Cell, 0 /*local */ )) {
177 fprintf(stderr, "Can't get local cellname\n");
181 fprintf(stderr, "No cell specified; assuming '%s'.\n", uss_Cell);
189 /*-----------------------------------------------------------------------
190 * static SaveRestoreInfo
193 * Save all the information required to restore the currently
194 * parsed user account.
200 * 0 if everything went well,
201 * 1 if something went wrong in the function, or
202 * Lower-level error code if something went wrong below us.
205 * We need to determine and store the following new pieces of
208 * Name of user's volume
209 * FileServer & partition hosting the volume
213 *------------------------------------------------------------------------*/
216 SaveRestoreInfo(void)
217 { /*SaveRestoreInfo */
219 static char rn[] = "uss:SaveRestoreInfo"; /*Routine name */
221 afs_int32 code; /*Return code */
222 afs_int32 deletedUid; /*Uid to be nuked */
225 * Translate the user name to the user ID.
227 code = uss_ptserver_XlateUser(uss_User, &deletedUid);
231 printf("%s: User '%s' translated to uid %d\n", rn, uss_User, deletedUid);
233 sprintf(uss_Uid, "%d", deletedUid);
236 * Pull out the name of the volume at the given mountpoint, along
237 * with the name of the FileServer and partition hosting it. This
238 * also sets up all the numerical info for the above.
240 code = uss_vol_GetVolInfoFromMountPoint(uss_MountPoint);
245 * Report back that we did fine.
249 } /*SaveRestoreInfo */
252 /*-----------------------------------------------------------------------
256 * With everything properly inserted into the common variables,
257 * delete the specified user account.
263 * 0 if everything went well,
264 * 1 if something went wrong in the function, or
265 * Lower-level error code if something went wrong below us.
268 * Nothing interesting.
272 *------------------------------------------------------------------------*/
278 int code; /*Return code */
281 * Make sure the user name is a lega one.
283 code = uss_kauth_CheckUserName();
288 * Store all the info about the account before actually doing
291 code = SaveRestoreInfo();
295 if ((uss_VolumeID != 0) && (uss_MountPoint[0] != '\0')) {
297 * Unmount the user's volume from the file system.
301 "Unmounting volume '%s' (ID %u) mounted at '%s'\n",
302 uss_Volume, uss_VolumeID, uss_MountPoint);
305 code = uss_fs_RmMountPoint(uss_MountPoint);
308 fprintf(stderr, "%s: Can't remove mountpoint '%s'\n",
309 uss_whoami, uss_MountPoint);
310 return (code); /* Must return - we may have incorrect volume */
315 * If our caller has elected to delete the user's volume now,
318 if (!uss_SaveVolume && (uss_VolumeID != 0)) {
320 fprintf(stderr, "Deleting volume '%s' (ID %u)\n", uss_Volume,
325 uss_vol_DeleteVol(uss_Volume, uss_VolumeID, uss_Server,
326 uss_ServerID, uss_Partition, uss_PartitionID);
329 fprintf(stderr, "%s: Can't delete volume '%s' (ID %u)\n",
330 uss_whoami, uss_Volume, uss_VolumeID);
333 } else if (uss_verbose && (uss_MountPoint[0] != '\0'))
334 printf("%s: Warning: Not attempting to delete volume at '%s'\n",
335 uss_whoami, uss_MountPoint);
338 * Get rid of the user's authentication entry.
340 code = uss_kauth_DelUser(uss_User);
345 * Finally, remove the user's AFS ID from the Protection DB and
346 * return that result.
348 code = uss_ptserver_DelUser(uss_User);
354 /*-----------------------------------------------------------------------
358 * Process the given (non-bulk) delete command.
361 * a_as : Ptr to the command line syntax descriptor.
362 * a_rock : Ptr to the rock passed in.
365 * 0 if everything went well,
366 * 1 if something went wrong in the function, or
367 * Lower-level error code if something went wrong below us.
370 * Nothing interesting.
374 *------------------------------------------------------------------------*/
377 DelUser(struct cmd_syndesc *a_as, void *a_rock)
383 * Before we do anything else, make sure we initialize the
384 * global field settings.
389 * Pull out the fields as passed in by the caller on the command
392 strcpy(uss_User, a_as->parms[DUP_USER].items->data);
393 if (a_as->parms[DUP_MNTPT].items)
394 strcpy(uss_MountPoint, a_as->parms[DUP_MNTPT].items->data);
395 #if USS_FUTURE_FEATURES
396 #if USS_DONT_HIDE_SOME_FEATURES
397 strcpy(uss_RestoreDir, a_as->parms[DUP_RESTOREDIR].items->data);
398 #endif /* USS_DONT_HIDE_SOME_FEATURES */
399 #endif /* USS_FUTURE_FEATURES */
402 if (a_as->parms[DUP_SAVEVOLUME].items)
406 if (a_as->parms[2].items) {
409 #if USS_FUTURE_FEATURES
410 #if USS_DONT_HIDE_SOME_FEATURES
411 if (a_as->parms[DUP_PWDPATH].items)
412 strcpy(uss_PwdPath, a_as->parms[DUP_PWDPATH].items->data);
413 if (a_as->parms[DUP_PWDFORMAT].items)
414 strcpy(uss_PwdFormat, a_as->parms[DUP_PWDFORMAT].items->data);
415 #endif /* USS_DONT_HIDE_SOME_FEATURES */
416 #endif /* USS_FUTURE_FEATURES */
418 if (a_as->parms[AUSS_DRYRUN].items)
420 if (a_as->parms[AUSS_SKIPAUTH].items)
421 uss_SkipKaserver = 1;
422 if (a_as->parms[AUSS_ADMIN].items) {
423 strcpy(uss_Administrator, a_as->parms[AUSS_ADMIN].items->data);
424 /* fprintf(stderr, "debugging: uss_Administrator set to '%s'\n",
425 * uss_Administrator); */
427 /* fprintf(stderr, "debugging: No administrator value given\n"); */
428 uss_Administrator[0] = '\0';
432 * Initialize uss_AccountCreator().
434 code = uss_kauth_InitAccountCreator();
439 * Now that the command line arguments are parsed and properly stored,
447 #if USS_FUTURE_FEATURES
448 #if USS_DONT_HIDE_SOME_FEATURES
449 /*-----------------------------------------------------------------------
450 * static PurgeVolumes
453 * Purge the given volume(s).
456 * a_as : Ptr to the command line syntax descriptor.
457 * a_rock : Ptr to the rock passed in.
460 * 0 if everything went well,
461 * 1 if something went wrong in the function, or
462 * Lower-level error code if something went wrong below us.
465 * Nothing interesting.
469 *------------------------------------------------------------------------*/
472 PurgeVolumes(struct cmd_syndesc *a_as, void *a_rock)
475 fprintf(stderr, "Sorry, purgevolumes has not yet been implemented.\n");
481 /*-----------------------------------------------------------------------
485 * Process the given delete command.
488 * a_as : Ptr to the command line syntax descriptor.
489 * a_rock : Ptr to the rock passed in.
492 * 0 if everything went well,
493 * 1 if something went wrong in the function, or
494 * Lower-level error code if something went wrong below us.
497 * Nothing interesting.
501 *------------------------------------------------------------------------*/
504 RestoreUser(struct cmd_syndesc *a_as, void *a_rock)
507 fprintf(stderr, "Sorry, restoreuser has not yet been implemented.\n");
515 /*-----------------------------------------------------------------------
516 * static DoBulkAddLine
519 * Process the given bulk add command.
522 * a_buf : Ptr to the buffer holding the bulk add command.
523 * a_tp : Ptr to the first char past the opcode.
526 * 0 if everything went well,
527 * -1 if something went wrong in the function, or
528 * Lower-level error code if something went wrong below us.
531 * The required fields are:
536 *------------------------------------------------------------------------*/
539 DoBulkAddLine(char *a_buf, char *a_tp)
542 int i; /*Loop variable */
544 static char rn[] = "DoBulkAddLine"; /*Routine name */
546 int overflow; /*Overflow in field copy? */
549 printf("%s: Command buffer left to parse: '%s'\n", rn, a_tp);
551 uss_Expires = uss_BulkExpires;
554 * Pull out all the fields.
556 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
559 "%s: * User field in add cmd too long (max is %d chars; truncated value is '%s')\n",
560 uss_whoami, uss_UserLen, uss_User);
563 if ((*a_tp == '\0') || (*a_tp == '\n')) {
565 "%s: * The user field must appear in a bulk add command.\n",
571 uss_common_FieldCp(uss_RealName, a_tp, ':', uss_RealNameLen,
575 "%s: * Real name field in add cmd too long (max is %d chars; truncated value is '%s')\n",
576 uss_whoami, uss_RealNameLen, uss_RealName);
579 if (uss_RealName[0] == '\0') {
581 * The user's real name has not been supplied. As a
582 * default, we use the account name.
584 sprintf(uss_RealName, "%s", uss_User);
586 fprintf(stderr, "%s: Using default real name, '%s'\n", uss_whoami,
589 /*Use default full name */
590 a_tp = uss_common_FieldCp(uss_Pwd, a_tp, ':', uss_PwdLen, &overflow);
593 "%s: * Password field in add cmd too long (max is %d chars; truncated value is '%s')\n",
594 uss_whoami, uss_PwdLen, uss_Pwd);
597 if (uss_Pwd[0] == '\0') {
599 * The user's password has not been provided. Use
602 sprintf(uss_Pwd, "%s", uss_DEFAULT_PASSWORD);
604 fprintf(stderr, "%s: Using default password, '%s'\n", uss_whoami,
606 } /*Use default password */
607 if ((*a_tp == '\0') || (*a_tp == '\n'))
608 goto DoBulkAddLine_ParsingDone;
613 a_tp = uss_common_FieldCp(temp, a_tp, ':', 9, &overflow);
616 "%s: * Password expiration time is longer than %d characters, ignoring...\n",
619 if (temp[0] == '\0') {
620 /* Expiration time not specified. Use default */
622 fprintf(stderr, "%s: Using default expiration time, '%d'\n",
623 uss_whoami, uss_Expires);
627 if (te < 0 || te > 254) {
629 "%s: * Password Expiration must be in [0..254] days, using default %d\n",
630 uss_whoami, uss_Expires);
635 if ((*a_tp == '\0') || (*a_tp == '\n'))
636 goto DoBulkAddLine_ParsingDone;
641 uss_common_FieldCp(uss_Server, a_tp, ':', uss_ServerLen, &overflow);
644 "%s: * Server field in add cmd too long (max is %d chars; truncated value is '%s')\n",
645 uss_whoami, uss_ServerLen, uss_Server);
648 if ((*a_tp == '\0') || (*a_tp == '\n'))
649 goto DoBulkAddLine_ParsingDone;
652 uss_common_FieldCp(uss_Partition, a_tp, ':', uss_PartitionLen,
656 "%s: * Partition field in add cmd too long (max is %d chars; truncated value is '%s')\n",
657 uss_whoami, uss_PartitionLen, uss_Partition);
660 if ((*a_tp == '\0') || (*a_tp == '\n'))
661 goto DoBulkAddLine_ParsingDone;
664 uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
668 "%s: * Mountpoint field in add cmd too long (max is %d chars; truncated value is '%s')\n",
669 uss_whoami, uss_MountPointLen, uss_MountPoint);
672 if ((*a_tp == '\0') || (*a_tp == '\n'))
673 goto DoBulkAddLine_ParsingDone;
675 a_tp = uss_common_FieldCp(uss_Uid, a_tp, ':', uss_UidLen, &overflow);
678 "%s: * UID field in add cmd too long (max is %d chars; truncated value is '%s')\n",
679 uss_whoami, uss_UidLen, uss_Uid);
682 uss_DesiredUID = atoi(uss_Uid);
683 if ((*a_tp == '\0') || (*a_tp == '\n'))
684 goto DoBulkAddLine_ParsingDone;
686 for (uss_VarMax = 1; uss_VarMax < 10; uss_VarMax++) {
688 uss_common_FieldCp(uss_Var[uss_VarMax], a_tp, ':',
689 uss_MAX_ARG_SIZE, &overflow);
692 "%s: * Variable %d field in add cmd too long (max is %d chars; truncated value is '%s')\n",
693 uss_whoami, uss_VarMax, uss_MAX_ARG_SIZE,
694 uss_Var[uss_VarMax]);
697 if ((*a_tp == '\0') || (*a_tp == '\n'))
698 goto DoBulkAddLine_ParsingDone;
701 DoBulkAddLine_ParsingDone:
703 * If there's anything left on the line, we ignore it. Announce
704 * the bulk add parameters we've parsed or filled in if we're
705 * being verbose, then go for it.
709 "\nAdding user '%s' ('%s'), password='%s' on server '%s', partition '%s', home directory='%s'",
710 uss_User, uss_RealName, uss_Pwd,
711 (uss_Server[0] != '\0' ? uss_Server : "<default>"),
712 (uss_Partition[0] != '\0' ? uss_Partition : "<default>"),
713 (uss_MountPoint[0] != '\0' ? uss_MountPoint : "<default>"));
715 fprintf(stderr, ", uid preset to %d\n", uss_DesiredUID);
717 fprintf(stderr, ", no preset uid\n");
718 for (i = 1; i <= uss_VarMax; i++) {
719 if (uss_Var[i][0] != '\0')
720 fprintf(stderr, "$%1d='%s' ", i, uss_Var[i]);
723 fprintf(stderr, "\n");
726 /*Verbose status of add command */
728 * Now do the real work.
735 /*-----------------------------------------------------------------------
736 * static DoBulkDeleteLine
739 * Process the given bulk delete command.
742 * a_buf : Ptr to the buffer holding the bulk delete command.
743 * a_tp : Ptr to the first char past the opcode.
746 * 0 if everything went well,
747 * -1 if something went wrong in the function, or
748 * Lower-level error code if something went wrong below us.
751 * The required fields are:
752 * -user, -mountpoint, -restoredir
756 *------------------------------------------------------------------------*/
759 DoBulkDeleteLine(char *a_buf, char *a_tp)
760 { /*DoBulkDeleteLine */
762 char volField[32]; /*Value of optional vol disposition field */
763 int overflow; /*Was there an overflow in field copying? */
766 * Pull out all the fields.
768 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
771 "%s: * User field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
772 uss_whoami, uss_UserLen, uss_User);
775 if ((uss_User[0] == '\0') || (*a_tp == '\0') || (*a_tp == '\n'))
776 goto Delete_MissingRequiredParam;
779 uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
783 "%s: * Mountpoint field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
784 uss_whoami, uss_MountPointLen, uss_MountPoint);
787 #if USS_FUTURE_FEATURES
788 #if USS_DONT_HIDE_SOME_FEATURES
789 if ((uss_MountPoint[0] == '\0') || (*a_tp == '\0') || (*a_tp == '\n'))
790 goto Delete_MissingRequiredParam;
791 #endif /* USS_DONT_HIDE_SOME_FEATURES */
793 if ((*a_tp == '\0') || (*a_tp == '\n'))
794 goto Delete_ParsingDone;
795 #endif /* USS_FUTURE_FEATURES */
797 #if USS_FUTURE_FEATURES
798 #if USS_DONT_HIDE_SOME_FEATURES
800 uss_common_FieldCp(uss_RestoreDir, a_tp, ':', uss_RestoreDirLen,
804 "%s: * RestoreDir field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
805 uss_whoami, uss_RestoreDirLen, uss_RestoreDir);
808 if (uss_RestoreDir[0] == '\0')
809 goto Delete_MissingRequiredParam;
810 if ((*a_tp == '\0') || (*a_tp == '\n'))
811 goto Delete_ParsingDone;
814 uss_common_FieldCp(uss_PwdPath, a_tp, ':', uss_PwdPathLen, &overflow);
817 "%s: * Password path field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
818 uss_whoami, uss_PwdPathLen, uss_PwdPath);
821 if ((*a_tp == '\0') || (*a_tp == '\n'))
822 goto Delete_ParsingDone;
825 uss_common_FieldCp(uss_PwdFormat, a_tp, ':', uss_PwdFormatLen,
829 "%s: * Password format field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
830 uss_whoami, uss_PwdFormatLen, uss_PwdFormat);
833 if ((*a_tp == '\0') || (*a_tp == '\n'))
834 goto Delete_ParsingDone;
835 #endif /* USS_DONT_HIDE_SOME_FEATURES */
836 #endif /* USS_FUTURE_FEATURES */
838 a_tp = uss_common_FieldCp(volField, a_tp, ':', 32, &overflow);
841 "%s: * Volume save/del field in delete cmd too long (max is 32 chars; truncated value is '%s')\n",
842 uss_whoami, volField);
845 if ((*a_tp == '\0') || (*a_tp == '\n'))
846 goto Delete_ParsingDone;
848 if (strcmp(volField, "delvolume") == 0)
855 * If there's anything left on the line, we ignore it. Announce
856 * the bulk delete parameters we've parsed if we're being verbose,
860 #if USS_FUTURE_FEATURES
861 #if USS_DONT_HIDE_SOME_FEATURES
863 "\nDeleting user '%s' mounted at '%s', restoredir='%s', pwd path='%s', pwd format='%s'",
864 uss_User, uss_MountPoint, uss_RestoreDir, uss_PwdPath,
866 #endif /* USS_DONT_HIDE_SOME_FEATURES */
868 fprintf(stderr, "\nDeleting user '%s' mounted at '%s'", uss_User,
870 #endif /* USS_FUTURE_FEATURES */
872 fprintf(stderr, ", saving user's volume\n");
874 fprintf(stderr, ", deleting user's volume\n");
877 /*Verbose status of delete command */
879 * Now do the real work.
883 Delete_MissingRequiredParam:
885 "%s: * All of the user, mountpoint, and restoredir fields must appear in a bulk delete command line.\n",
889 } /*DoBulkDeleteLine */
891 #if USS_FUTURE_FEATURES
892 #if USS_DONT_HIDE_SOME_FEATURES
893 /*-----------------------------------------------------------------------
894 * static DoBulkPurgeVolumeLine
897 * Process the given bulk add command.
900 * a_buf : Ptr to the buffer holding the bulk add command.
901 * a_tp : Ptr to the first char past the opcode.
904 * 0 if everything went well,
905 * -1 if something went wrong in the function, or
906 * Lower-level error code if something went wrong below us.
909 * Nothing interesting.
913 *------------------------------------------------------------------------*/
916 DoBulkPurgeVolumeLine(char *a_buf, char *a_tp)
917 { /*DoBulkPurgeVolumeLine */
919 int i; /*Loop variable */
920 int overflow; /*Did a field copy overflow happen? */
923 * Pull out all the fields.
925 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
928 "%s: * User field in purgevolume cmd too long (max is %d chars; truncated value is '%s')\n",
929 uss_whoami, uss_UserLen, uss_User);
932 if ((*a_tp == '\0') || (*a_tp == '\n')) {
934 "%s: * The user field must appear in a bulk add command.\n",
940 uss_common_FieldCp(uss_RealName, a_tp, ':', uss_RealNameLen,
944 "%s: * Real name field in purgevolume cmd too long (max is %d chars; truncated value is '%s')\n",
945 uss_whoami, uss_RealNameLen, uss_RealName);
948 if (uss_RealName[0] == '\0') {
950 * The user's real name has not been supplied. As a
951 * default, we use the account name.
953 sprintf(uss_RealName, "%s", uss_User);
955 fprintf(stderr, "%s: Using default real name, '%s'\n", uss_whoami,
958 /*Use default full name */
959 a_tp = uss_common_FieldCp(uss_Pwd, a_tp, ':', uss_PwdLen, &overflow);
962 "%s: * Password field in purgevolume cmd too long (max is %d chars; truncated value is '%s')\n",
963 uss_whoami, uss_PwdLen, uss_Pwd);
966 if (uss_Pwd[0] == '\0') {
968 * The user's password has not been provided. Use
971 sprintf(uss_Pwd, "%s", uss_DEFAULT_PASSWORD);
973 fprintf(stderr, "%s: Using default password, '%s'\n", uss_whoami,
975 } /*Use default password */
976 if ((*a_tp == '\0') || (*a_tp == '\n'))
980 uss_common_FieldCp(uss_Server, a_tp, ':', uss_ServerLen, &overflow);
982 fprintf(stderr, "%s: * Server field too long (max is %d chars)\n",
983 uss_whoami, uss_ServerLen);
986 if ((*a_tp == '\0') || (*a_tp == '\n'))
990 uss_common_FieldCp(uss_Partition, a_tp, ':', uss_PartitionLen,
993 fprintf(stderr, "%s: * Partition field too long (max is %d chars)\n",
994 uss_whoami, uss_PartitionLen);
997 if ((*a_tp == '\0') || (*a_tp == '\n'))
1001 uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
1004 fprintf(stderr, "%s: * Mountpoint field too long (max is %d chars)\n",
1005 uss_whoami, uss_MountPointLen);
1008 if ((*a_tp == '\0') || (*a_tp == '\n'))
1011 a_tp = uss_common_FieldCp(uss_Uid, a_tp, ':', uss_UidLen, &overflow);
1013 fprintf(stderr, "%s: * UID field too long (max is %d chars)\n",
1014 uss_whoami, uss_UidLen);
1017 uss_DesiredUID = atoi(uss_Uid);
1018 if ((*a_tp == '\0') || (*a_tp == '\n'))
1021 for (uss_VarMax = 1; uss_VarMax < 10; uss_VarMax++) {
1023 uss_common_FieldCp(uss_Var[uss_VarMax], a_tp, ':',
1024 uss_MAX_ARG_SIZE, &overflow);
1027 "%s: * Variable %d field too long (max is %d chars)\n",
1028 uss_whoami, uss_VarMax, uss_MAX_ARG_SIZE);
1031 if ((*a_tp == '\0') || (*a_tp == '\n'))
1036 * If there's anything left on the line, we ignore it. Announce
1037 * the bulk add parameters we've parsed or filled in if we're
1038 * being verbose, then go for it.
1042 "\nAdding user '%s' ('%s'), password='%s' on server '%s', partition '%s', home directory='%s'",
1043 uss_User, uss_RealName, uss_Pwd,
1044 (uss_Server[0] != '\0' ? uss_Server : "<default>"),
1045 (uss_Partition[0] != '\0' ? uss_Partition : "<default>"),
1046 (uss_MountPoint[0] != '\0' ? uss_MountPoint : "<default>"));
1048 fprintf(stderr, ", uid preset to %d\n", uss_DesiredUID);
1050 fprintf(stderr, ", no preset uid\n");
1051 for (i = 1; i <= uss_VarMax; i++) {
1052 if (uss_Var[i][0] != '\0')
1053 fprintf(stderr, "$%1d='%s' ", i, uss_Var[i]);
1056 fprintf(stderr, "\n");
1059 /*Verbose status of add command */
1061 * Now do the real work.
1065 } /*DoBulkPurgeVolumeLine */
1066 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1067 #endif /* USS_FUTURE_FEATURES */
1069 #if USS_FUTURE_FEATURES
1070 #if USS_DONT_HIDE_SOME_FEATURES
1071 /*-----------------------------------------------------------------------
1072 * static DoBulkRestoreLine
1075 * Process the given bulk add command.
1078 * a_buf : Ptr to the buffer holding the bulk add command.
1079 * a_tp : Ptr to the first char past the opcode.
1082 * 0 if everything went well,
1083 * -1 if something went wrong in the function, or
1084 * Lower-level error code if something went wrong below us.
1087 * Nothing interesting.
1091 *------------------------------------------------------------------------*/
1094 DoBulkRestoreLine(char *a_buf, char *a_tp)
1095 { /*DoBulkRestoreLine */
1097 int i; /*Loop variable */
1098 int overflow; /*Overflow occur on field copy? */
1101 * Pull out all the fields.
1103 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
1105 fprintf(stderr, "%s: * User field too long (max is %d chars)\n",
1106 uss_whoami, uss_UserLen);
1109 if ((*a_tp == '\0') || (*a_tp == '\n')) {
1111 "%s: * The user field must appear in a bulk add command.\n",
1117 uss_common_FieldCp(uss_RealName, a_tp, ':', uss_RealNameLen,
1120 fprintf(stderr, "%s: * Real name field too long (max is %d chars)\n",
1121 uss_whoami, uss_RealNameLen);
1124 if (uss_RealName[0] == '\0') {
1126 * The user's real name has not been supplied. As a
1127 * default, we use the account name.
1129 sprintf(uss_RealName, "%s", uss_User);
1131 fprintf(stderr, "%s: Using default real name, '%s'\n", uss_whoami,
1134 /*Use default full name */
1135 a_tp = uss_common_FieldCp(uss_Pwd, a_tp, ':', uss_PwdLen, &overflow);
1137 fprintf(stderr, "%s: * Password field too long (max is %d chars)\n",
1138 uss_whoami, uss_PwdLen);
1141 if (uss_Pwd[0] == '\0') {
1143 * The user's password has not been provided. Use
1146 sprintf(uss_Pwd, "%s", uss_DEFAULT_PASSWORD);
1148 fprintf(stderr, "%s: Using default password, '%s'\n", uss_whoami,
1150 } /*Use default password */
1151 if ((*a_tp == '\0') || (*a_tp == '\n'))
1155 uss_common_FieldCp(uss_Server, a_tp, ':', uss_ServerLen, &overflow);
1157 fprintf(stderr, "%s: * Server field too long (max is %d chars)\n",
1158 uss_whoami, uss_ServerLen);
1161 if ((*a_tp == '\0') || (*a_tp == '\n'))
1165 uss_common_FieldCp(uss_Partition, a_tp, ':', uss_PartitionLen,
1168 fprintf(stderr, "%s: * Partition field too long (max is %d chars)\n",
1169 uss_whoami, uss_PartitionLen);
1172 if ((*a_tp == '\0') || (*a_tp == '\n'))
1176 uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
1179 fprintf(stderr, "%s: * mountpoint field too long (max is %d chars)\n",
1180 uss_whoami, uss_MountPointLen);
1183 if ((*a_tp == '\0') || (*a_tp == '\n'))
1186 a_tp = uss_common_FieldCp(uss_Uid, a_tp, ':', uss_UidLen, &overflow);
1188 fprintf(stderr, "%s: * UID field too long (max is %d chars)\n",
1189 uss_whoami, uss_UidLen);
1192 uss_DesiredUID = atoi(uss_Uid);
1193 if ((*a_tp == '\0') || (*a_tp == '\n'))
1196 for (uss_VarMax = 1; uss_VarMax < 10; uss_VarMax++) {
1198 uss_common_FieldCp(uss_Var[uss_VarMax], a_tp, ':',
1199 uss_MAX_ARG_SIZE, &overflow);
1202 "%s: * Variable %d field too long (max is %d chars)\n",
1203 uss_whoami, uss_VarMax, uss_MAX_ARG_SIZE);
1206 if ((*a_tp == '\0') || (*a_tp == '\n'))
1211 * If there's anything left on the line, we ignore it. Announce
1212 * the bulk add parameters we've parsed or filled in if we're
1213 * being verbose, then go for it.
1217 "\nAdding user '%s' ('%s'), password='%s' on server '%s', partition '%s', home directory='%s'",
1218 uss_User, uss_RealName, uss_Pwd,
1219 (uss_Server[0] != '\0' ? uss_Server : "<default>"),
1220 (uss_Partition[0] != '\0' ? uss_Partition : "<default>"),
1221 (uss_MountPoint[0] != '\0' ? uss_MountPoint : "<default>"));
1223 fprintf(stderr, ", uid preset to %d\n", uss_DesiredUID);
1225 fprintf(stderr, ", no preset uid\n");
1226 for (i = 1; i <= uss_VarMax; i++) {
1227 if (uss_Var[i][0] != '\0')
1228 fprintf(stderr, "$%1d='%s' ", i, uss_Var[i]);
1231 fprintf(stderr, "\n");
1234 /*Verbose status of add command */
1236 * Now do the real work.
1238 return (DoRestore());
1240 } /*DoBulkRestoreLine */
1241 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1242 #endif /* USS_FUTURE_FEATURES */
1245 /*-----------------------------------------------------------------------
1246 * static DoBulkExecLine
1249 * Process the given bulk exec command.
1252 * a_buf : Ptr to the buffer holding the bulk exec command.
1253 * a_tp : Ptr to the first char past the opcode.
1256 * 0 if everything went well,
1257 * -1 if something went wrong in the function, or
1258 * Lower-level error code if something went wrong below us.
1261 * Nothing interesting.
1265 *------------------------------------------------------------------------*/
1268 DoBulkExecLine(char *a_buf, char *a_tp)
1269 { /*DoBulkExecLine */
1271 afs_int32 code; /*Return code */
1274 * Really, uss_procs_Exec does all the work for us!
1276 code = uss_procs_Exec(a_tp);
1279 } /*DoBulkExecLine */
1282 /*-----------------------------------------------------------------------
1286 * Process the given bulk command.
1289 * a_as : Ptr to the command line syntax descriptor.
1290 * a_rock : Ptr to the rock passed in.
1293 * 0 if everything went well,
1294 * 1 if something went wrong in the function, or
1295 * Lower-level error code if something went wrong below us.
1298 * Nothing interesting.
1302 *------------------------------------------------------------------------*/
1305 HandleBulk(struct cmd_syndesc *a_as, void *a_rock)
1308 #define USS_BULK_CMD_CHARS 128
1309 #define USS_BULK_BUF_CHARS 1024
1311 char cmd[USS_BULK_CMD_CHARS], buf[USS_BULK_BUF_CHARS];
1319 char tbuf[USS_BULK_BUF_CHARS];
1322 * Open up the bulk file, croak if we can't.
1324 if ((infile = fopen(a_as->parms[ABULK_FILE].items->data, "r")) == NULL) {
1325 fprintf(stderr, "%s: * Failed to open input file %s\n", uss_whoami,
1326 a_as->parms[ABULK_FILE].items->data);
1331 * Pull out the other fields as passed in by the caller on the
1334 if (a_as->parms[AUSS_DRYRUN].items)
1336 if (a_as->parms[AUSS_SKIPAUTH].items)
1337 uss_SkipKaserver = 1;
1338 if (a_as->parms[AUSS_OVERWRITE].items)
1340 if (a_as->parms[AUSS_PIPE].items)
1342 if (a_as->parms[AUSS_ADMIN].items)
1343 strcpy(uss_Administrator, a_as->parms[AUSS_ADMIN].items->data);
1345 uss_Administrator[0] = '\0';
1347 if (a_as->parms[AUSS_PWEXPIRES].items) {
1348 uss_BulkExpires = atoi(a_as->parms[AUSS_PWEXPIRES].items->data);
1349 if (uss_BulkExpires < 0 || uss_BulkExpires > 254) {
1351 "%s: Password Expiration must be in [0..255] days\n",
1356 uss_BulkExpires = 0;
1359 * Initialize uss_AccountCreator().
1361 code = uss_kauth_InitAccountCreator();
1366 * Process all the lines in the bulk command file.
1368 uss_VarMax = 0; /*No uss vars picked up yet */
1369 while (fgets(buf, sizeof(buf), infile) != NULL) {
1371 /* skip blank line */
1376 /* After executing the line, print the line and the result */
1378 if (error == UNOQUORUM) {
1384 printf("LINE %d %s %s", line_no, (error ? "FAIL" : "SUCCESS"),
1390 * Reset the common variables for each command line
1395 strncpy(tbuf, buf, USS_BULK_BUF_CHARS-1);
1398 * First line of file = line 1.
1404 * Get the opcode and act upon it.
1406 tp = uss_common_FieldCp(cmd, buf, ' ', USS_BULK_CMD_CHARS, &overflow);
1409 "%s: * Bulk opcode field too long (max is %d chars)\n",
1410 uss_whoami, USS_BULK_CMD_CHARS);
1418 if (strcmp(cmd, "add") == 0) {
1419 error = DoBulkAddLine(buf, tp);
1422 if (strcmp(cmd, "delete") == 0) {
1423 error = DoBulkDeleteLine(buf, tp);
1426 if (strcmp(cmd, "delvolume") == 0) {
1431 #if USS_FUTURE_FEATURES
1432 #if USS_DONT_HIDE_SOME_FEATURES
1433 if (strcmp(cmd, "purgevolume") == 0) {
1434 error = DoBulkPurgeVolumeLine(buf, tp);
1437 if (strcmp(cmd, "pwdformat") == 0) {
1438 /*Set the password format here */
1441 if (strcmp(cmd, "pwdpath") == 0) {
1442 /*Set the password path here */
1445 if (strcmp(cmd, "restore") == 0) {
1446 error = DoBulkRestoreLine(buf, tp);
1449 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1450 #endif /* USS_FUTURE_FEATURES */
1451 if (strcmp(cmd, "savevolume") == 0) {
1452 /*Set the savevolume flag here */
1455 if (strcmp(cmd, "exec") == 0) {
1456 error = DoBulkExecLine(buf, tp);
1461 * If none of the valid opcodes match, see if the line is either
1462 * a comment of a blank. If so, just ignore it. Otherwise, we
1465 if ((cmd[0] != '#') && (cmd[0] != '\0')) {
1467 "%s: ** Unrecognized command ('%s') in bulk file\n",
1476 } /*Bad bulk line */
1477 } /*Process a line in the bulk file */
1483 printf("LINE %d %s %s", line_no, (error ? "FAIL" : "SUCCESS"), tbuf);
1491 /*-----------------------------------------------------------------------
1495 * Process the given (non-bulk) add command.
1498 * a_as : Ptr to the command line syntax descriptor.
1499 * a_rock : Ptr to the rock passed in.
1502 * 0 if everything went well,
1503 * 1 if something went wrong in the function, or
1504 * Lower-level error code if something went wrong below us.
1507 * Nothing interesting.
1511 *------------------------------------------------------------------------*/
1514 AddUser(struct cmd_syndesc *a_as, void *a_rock)
1518 struct cmd_item *ti;
1522 * Before we do anything else, make sure we initialize the
1523 * global field settings.
1528 * Pull out the fields as passed in by the caller on the command
1531 strcpy(uss_User, a_as->parms[AUP_USER].items->data);
1532 if (a_as->parms[AUP_REALNAME].items)
1533 strcpy(uss_RealName, a_as->parms[AUP_REALNAME].items->data);
1535 strcpy(uss_RealName, uss_User);
1536 if (a_as->parms[AUP_PASSWD].items)
1537 strcpy(uss_Pwd, a_as->parms[AUP_PASSWD].items->data);
1539 strcpy(uss_Pwd, uss_DEFAULT_PASSWORD);
1540 if (a_as->parms[AUP_SERVER].items)
1541 strcpy(uss_Server, a_as->parms[AUP_SERVER].items->data);
1542 if (a_as->parms[AUP_PART].items)
1543 strcpy(uss_Partition, a_as->parms[AUP_PART].items->data);
1544 if (a_as->parms[AUP_MNTPT].items)
1545 strcpy(uss_MountPoint, a_as->parms[AUP_MNTPT].items->data);
1546 if (a_as->parms[AUP_UID].items)
1547 uss_DesiredUID = atoi(a_as->parms[AUP_UID].items->data);
1550 if (a_as->parms[AUP_PWEXPIRES].items) {
1551 uss_Expires = atoi(a_as->parms[AUP_PWEXPIRES].items->data);
1552 if (uss_Expires < 0 || uss_Expires > 254) {
1554 "%s: Password Expiration must be in [0..255] days\n",
1561 if (a_as->parms[AUSS_DRYRUN].items)
1563 if (a_as->parms[AUSS_SKIPAUTH].items)
1564 uss_SkipKaserver = 1;
1565 if (a_as->parms[AUSS_OVERWRITE].items)
1567 if (a_as->parms[AUSS_ADMIN].items) {
1568 strcpy(uss_Administrator, a_as->parms[AUSS_ADMIN].items->data);
1569 /* fprintf(stderr, "debugging: uss_Administrator set to '%s'\n",
1570 * uss_Administrator); */
1572 /* fprintf(stderr, "debugging: No administrator value given\n"); */
1573 uss_Administrator[0] = '\0';
1576 if (a_as->parms[AUSS_VAR].items) {
1577 for (ti = a_as->parms[AUSS_VAR].items; ti; ti = ti->next) {
1579 if (i < 0 || i > 9 || (i == 0 && *ti->data != '0')) {
1581 "%s: Bad -var format: must be '0 val0 1 val1 ... 9 val9'\n",
1588 "%s: -var values must appear in pairs: 'Num val'\n",
1592 strcpy(uss_Var[i], ti->data);
1595 } /*Remember each VAR item */
1598 /*VAR items exist */
1600 * Initialize uss_AccountCreator().
1602 code = uss_kauth_InitAccountCreator();
1607 * Now that the command line arguments are parsed and properly stored,
1615 /*-----------------------------------------------------------------------
1619 * Create the desired user account, having parsed the add command
1620 * from either the command line or a bulk file.
1626 * 0 if everything went well,
1627 * 1 if something went wrong in the function, or
1628 * Lower-level error code if something went wrong below us.
1631 * All values needed have been put in the common variables.
1635 *------------------------------------------------------------------------*/
1641 int code; /*Return code */
1644 * Make sure the user name is legal.
1646 code = uss_kauth_CheckUserName();
1651 * This time around, we start off assuming the global value of the
1654 uss_OverwriteThisOne = uss_Overwrite;
1657 * Open up the template file before doing any real processing,
1658 * so we can quit early should it not be found.
1661 if ((yyin = uss_procs_FindAndOpen(Template)) == NULL) {
1662 fprintf(stderr, "%s: ** Can't open template file '%s'\n",
1663 uss_whoami, Template);
1666 yyout = fopen("/dev/null", "w");
1671 * Add the new user to the Protection DB.
1673 code = uss_ptserver_AddUser(uss_User, uss_Uid);
1675 fprintf(stderr, "%s: Failed to add user '%s' to the Protection DB\n",
1676 uss_whoami, uss_User);
1681 * Add the new user to the Authentication DB.
1683 code = uss_kauth_AddUser(uss_User, uss_Pwd);
1685 fprintf(stderr, "%s: Can't add user '%s' to the Authentication DB\n",
1686 uss_whoami, uss_User);
1691 * Process the items covered by the template file.
1693 if (yyparse() && (!uss_ignoreFlag))
1697 * Finally, clean up after ourselves, removing the uss_AccountCreator
1698 * from various of the new user's ACLs.
1700 return (uss_acl_CleanUp());
1705 #if USS_FUTURE_FEATURES
1706 #if USS_DONT_HIDE_SOME_FEATURES
1707 /*-----------------------------------------------------------------------
1711 * Perform the parsed restore command.
1717 * 0 if everything went well,
1718 * 1 if something went wrong in the function, or
1719 * Lower-level error code if something went wrong below us.
1722 * All values needed have been put in the common variables.
1726 *------------------------------------------------------------------------*/
1735 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1736 #endif /* USS_FUTURE_FEATURES */
1739 /*-----------------------------------------------------------------------
1740 * static InitETTables
1743 * Set up the error code tables for the various modules we use.
1752 * Nothing interesting.
1756 *------------------------------------------------------------------------*/
1764 * In order to get error code -> error message translations to work,
1765 * we have to initialize all error tables.
1767 initialize_CMD_error_table();
1768 initialize_RXK_error_table();
1769 initialize_KTC_error_table();
1770 initialize_KA_error_table();
1771 initialize_ACFG_error_table();
1772 initialize_VL_error_table();
1773 initialize_PT_error_table();
1774 initialize_U_error_table();
1782 /* this sucks but it works for now.
1787 #include "AFS_component_version_number.c"
1790 main(int argc, char *argv[])
1793 struct cmd_syndesc *cs; /*Command line syntax descriptor */
1794 afs_int32 code; /*Return code */
1796 #ifdef AFS_AIX32_ENV
1798 * The following signal action for AIX is necessary so that in case of a
1799 * crash (i.e. core is generated) we can include the user's data section
1800 * in the core dump. Unfortunately, by default, only a partial core is
1801 * generated which, in many cases, isn't too useful.
1803 struct sigaction nsa;
1805 sigemptyset(&nsa.sa_mask);
1806 nsa.sa_handler = SIG_DFL;
1807 nsa.sa_flags = SA_FULLDUMP;
1808 sigaction(SIGABRT, &nsa, NULL);
1809 sigaction(SIGSEGV, &nsa, NULL);
1811 strcpy(uss_whoami, argv[0]);
1812 yyin = (FILE *) NULL;
1814 uss_fs_InBuff = (char *)malloc(USS_FS_MAX_SIZE); /*Cache Manager input buff */
1815 uss_fs_OutBuff = (char *)malloc(USS_FS_MAX_SIZE); /*Cache Manager output buff */
1816 if (!uss_fs_InBuff || !uss_fs_OutBuff) {
1817 fprintf(stderr, "%s: Can't malloc in/out buffers\n", uss_whoami);
1821 /* ----------------------------- add ----------------------------- */
1823 cs = cmd_CreateSyntax("add", AddUser, NULL, "create a new user account");
1824 cmd_AddParm(cs, "-user", CMD_SINGLE, 0, "login name");
1825 cmd_AddParm(cs, "-realname", CMD_SINGLE, CMD_OPTIONAL,
1826 "full name in quotes");
1827 cmd_AddParm(cs, "-pass", CMD_SINGLE, CMD_OPTIONAL, "initial password");
1829 cmd_AddParm(cs, "-pwexpires", CMD_SINGLE, CMD_OPTIONAL,
1830 "password expires in [0..254] days (0 => never)");
1831 cmd_AddParm(cs, "-server", CMD_SINGLE, CMD_OPTIONAL,
1832 "FileServer for home volume");
1833 cmd_AddParm(cs, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1834 "FileServer's disk partition for home volume");
1835 cmd_AddParm(cs, "-mount", CMD_SINGLE, CMD_OPTIONAL,
1836 "home directory mount point");
1837 cmd_AddParm(cs, "-uid", CMD_SINGLE, CMD_OPTIONAL,
1838 "uid to assign the user");
1839 cmd_Seek(cs, AUSS_TEMPLATE);
1840 cmd_AddParm(cs, "-template", CMD_SINGLE, CMD_OPTIONAL,
1841 "pathname of template file");
1842 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1843 cmd_AddParm(cs, "-var", CMD_LIST, CMD_OPTIONAL | CMD_EXPANDS,
1844 "auxiliary argument pairs (Num val)");
1845 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1846 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1847 "administrator to authenticate");
1848 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1849 "only list what would be done, don't do it");
1850 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1851 "ignore all contact with the authentication server (kaserver)");
1852 cmd_AddParm(cs, "-overwrite", CMD_FLAG, CMD_OPTIONAL,
1853 "Overwrite pre-existing files in user home directory tree");
1856 /* ---------------------------- bulk ----------------------------- */
1858 cs = cmd_CreateSyntax("bulk", HandleBulk, NULL, "bulk input mode");
1859 cmd_AddParm(cs, "-file", CMD_SINGLE, 0, "bulk input file");
1860 cmd_Seek(cs, AUSS_TEMPLATE);
1861 cmd_AddParm(cs, "-template", CMD_SINGLE, CMD_OPTIONAL,
1862 "pathname of template file");
1863 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1864 cmd_Seek(cs, AUSS_CELL);
1865 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1866 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1867 "administrator to authenticate");
1868 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1869 "only list what would be done, don't do it");
1870 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1871 "ignore all contact with the authentication server (kaserver)");
1872 cmd_AddParm(cs, "-overwrite", CMD_FLAG, CMD_OPTIONAL,
1873 "Overwrite pre-existing files in user home directory tree");
1874 cmd_Seek(cs, AUSS_PWEXPIRES);
1875 cmd_AddParm(cs, "-pwexpires", CMD_SINGLE, CMD_OPTIONAL,
1876 "password expires in [0..254] days (0 => never)");
1877 cmd_Seek(cs, AUSS_PIPE);
1878 cmd_AddParm(cs, "-pipe", CMD_FLAG, CMD_OPTIONAL,
1879 "don't prompt for passwd; get it from standard input");
1881 /* ---------------------------- delete --------------------------- */
1883 cs = cmd_CreateSyntax("delete", DelUser, NULL, "delete a user account");
1884 cmd_AddParm(cs, "-user", CMD_SINGLE, 0, "login name");
1885 cmd_AddParm(cs, "-mountpoint", CMD_SINGLE, CMD_OPTIONAL,
1886 "mountpoint for user's volume");
1887 #if USS_FUTURE_FEATURES
1888 #if USS_DONT_HIDE_SOME_FEATURES
1889 cmd_AddParm(cs, "-restoredir", CMD_SINGLE, 0,
1890 "directory where restore info is to be placed");
1891 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1892 #endif /* USS_FUTURE_FEATURES */
1893 cmd_AddParm(cs, "-savevolume", CMD_FLAG, CMD_OPTIONAL,
1894 "don't destroy the user's volume");
1895 #if USS_FUTURE_FEATURES
1896 #if USS_DONT_HIDE_SOME_FEATURES
1897 cmd_AddParm(cs, "-pwdpath", CMD_SINGLE, CMD_OPTIONAL,
1898 "pathname to the password file");
1899 cmd_AddParm(cs, "-pwdformat", CMD_SINGLE, CMD_OPTIONAL,
1900 "password entry format");
1901 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1902 #endif /* USS_FUTURE_FEATURES */
1903 cmd_Seek(cs, AUSS_VERBOSE);
1904 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1905 cmd_Seek(cs, AUSS_CELL);
1906 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1907 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1908 "administrator to authenticate");
1909 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1910 "only list what would be done, don't do it");
1911 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1912 "ignore all contact with the authentication server (kaserver)");
1913 #if USS_FUTURE_FEATURES
1914 #if USS_DONT_HIDE_SOME_FEATURES
1915 /* ------------------------- purgevolumes ------------------------ */
1917 cs = cmd_CreateSyntax("purgevolumes", PurgeVolumes, NULL,
1918 "destroy a deleted user's volume");
1919 cmd_AddParm(cs, "-volname", CMD_LIST, CMD_OPTIONAL | CMD_EXPANDS,
1920 "Name(s) of volume(s) to destroy");
1921 cmd_AddParm(cs, "-volfile", CMD_SINGLE, CMD_OPTIONAL,
1922 "pathname to volume purge file");
1923 cmd_Seek(cs, AUSS_VERBOSE);
1924 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1925 cmd_Seek(cs, AUSS_CELL);
1926 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1927 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1928 "administrator to authenticate");
1929 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1930 "only list what would be done, don't do it");
1931 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1932 "ignore all contact with the authentication server (kaserver)");
1933 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1934 #endif /* USS_FUTURE_FEATURES */
1936 #if USS_FUTURE_FEATURES
1937 #if USS_DONT_HIDE_SOME_FEATURES
1938 /* ---------------------------- restore -------------------------- */
1940 cs = cmd_CreateSyntax("restore", RestoreUser, NULL,
1941 "restore a deleted user account");
1942 cmd_AddParm(cs, "-user", CMD_SINGLE, 0, "login name to restore");
1943 cmd_AddParm(cs, "-uid", CMD_SINGLE, 0, "user id number");
1944 cmd_AddParm(cs, "-mount", CMD_SINGLE, 0, "mountpoint for user's volume");
1945 cmd_AddParm(cs, "-volname", CMD_SINGLE, 0, "name of user's volume");
1946 cmd_AddParm(cs, "-realname", CMD_SINGLE, CMD_OPTIONAL,
1947 "user's full name");
1948 cmd_AddParm(cs, "-server", CMD_SINGLE, CMD_OPTIONAL,
1949 "FileServer to host user's volume");
1950 cmd_AddParm(cs, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1951 "FileServer partition to host user's volume");
1952 cmd_AddParm(cs, "-pwdpath", CMD_SINGLE, CMD_OPTIONAL,
1953 "pathname to the password file");
1954 cmd_AddParm(cs, "-pwdformat", CMD_SINGLE, CMD_OPTIONAL,
1955 "password entry format");
1956 cmd_Seek(cs, AUSS_VERBOSE);
1957 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1958 cmd_Seek(cs, AUSS_CELL);
1959 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1960 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1961 "administrator to authenticate");
1962 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1963 "only list what would be done, don't do it");
1964 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1965 "ignore all contact with the authentication server (kaserver)");
1966 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1967 #endif /* USS_FUTURE_FEATURES */
1970 * Set up all the error code translation tables, initialize the
1971 * command variables, and set up to parse the common command line
1976 cmd_SetBeforeProc(GetCommon, NULL);
1979 * Execute the parsed command.
1981 code = cmd_Dispatch(argc, argv);
1984 fprintf(stderr, "%s: Call to cmd_Dispatch() failed; code is %d\n",
1990 code = uss_fs_UnlogToken(uss_Cell);