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>
30 #include "uss_common.h" /*Common uss definitions, globals */
31 #include "uss_procs.h" /*Main uss operations */
32 #include "uss_kauth.h" /*AuthServer routines */
33 #include "uss_fs.h" /*CacheManager ops */
34 #include <afs/cmd.h> /*Command line parsing */
35 #include <afs/cellconfig.h> /*Cell config defs */
36 #include <afs/kautils.h> /*MAXKTCREALMLEN & MAXKTCNAMELEN */
40 * Label certain things which will be activated at a later time,
41 * as well as certain semi-implemented features/switches which need
42 * to be hidden for the general AFS 3.2 release.
44 #define USS_FUTURE_FEATURES 1
45 #define USS_DONT_HIDE_SOME_FEATURES 0
48 * ---------------------- Exported variables ----------------------
50 char *uss_fs_InBuff = NULL; /*Cache Manager input buff */
51 char *uss_fs_OutBuff = NULL; /*Cache Manager output buff */
54 * Set up convenient tags for the command line parameter indicies.
59 #define AUP_REALNAME 1
61 #define AUP_PWEXPIRES 3
62 #define AUP_SERVER 4 /* was 3 */
63 #define AUP_PART 5 /* was 4 */
64 #define AUP_MNTPT 6 /* was 5 */
65 #define AUP_UID 7 /* was 6 */
74 #define DUP_RESTOREDIR 2
75 #define DUP_SAVEVOLUME 3
77 #define DUP_PWDFORMAT 5
84 #define AUSS_TEMPLATE 10 /* was 7 */
85 #define AUSS_VERBOSE 11 /* was 8 */
86 #define AUSS_VAR 12 /* was 9 */
87 #define AUSS_CELL 13 /* was 10 */
88 #define AUSS_ADMIN 14 /* was 11 */
89 #define AUSS_DRYRUN 15 /* was 12 */
90 #define AUSS_SKIPAUTH 16 /* was 13 */
91 #define AUSS_OVERWRITE 17 /* was 14 */
92 #define AUSS_PWEXPIRES 18 /* was 15 */
93 #define AUSS_PIPE 19 /* was 16 */
97 static char Template[300] = "uss.template"; /*Default name */
99 extern FILE *yyin, *yyout; /*YACC input & output files */
101 int uss_BulkExpires = 0;
106 /*-----------------------------------------------------------------------
110 * Read in the command line arguments common to all uss operations.
113 * a_as : Ptr to the command line syntax descriptor.
119 * May exit the program if trouble is encountered determining the
120 * cell name. Set up as the command line parser's BeforeProc().
124 *------------------------------------------------------------------------*/
127 GetCommon(register struct cmd_syndesc *a_as, void *arock)
130 int code; /*Result of ka_LocalCell */
132 if (strcmp(a_as->name, "help") == 0)
134 if (a_as->parms[AUSS_TEMPLATE].items)
135 strcpy(Template, a_as->parms[AUSS_TEMPLATE].items->data);
136 if (a_as->parms[AUSS_VERBOSE].items)
141 code = ka_CellConfig(AFSDIR_CLIENT_ETC_DIRPATH);
143 fprintf(stderr, "%s: ** Call to ka_CellConfig() failed (code=%d)\n",
146 if (a_as->parms[AUSS_CELL].items) {
147 char local_cell[MAXKTCREALMLEN];
149 (a_as->parms[AUSS_CELL].items->data, uss_Cell, 0 /*local */ )) {
150 fprintf(stderr, "%s: ** Unknown or ambiguous cell name: %s\n",
151 uss_whoami, a_as->parms[AUSS_CELL].items->data);
155 * Get the local cell name
157 if (ka_ExpandCell((char *)0, local_cell, 0 /*local */ )) {
158 fprintf(stderr, "Can't get local cellname\n");
161 if (strcmp(uss_Cell, local_cell)) {
163 * Not the same; not a local cell
169 * Get the local cell name
171 if (ka_ExpandCell((char *)0, uss_Cell, 0 /*local */ )) {
172 fprintf(stderr, "Can't get local cellname\n");
176 fprintf(stderr, "No cell specified; assuming '%s'.\n", uss_Cell);
184 /*-----------------------------------------------------------------------
185 * static SaveRestoreInfo
188 * Save all the information required to restore the currently
189 * parsed user account.
195 * 0 if everything went well,
196 * 1 if something went wrong in the function, or
197 * Lower-level error code if something went wrong below us.
200 * We need to determine and store the following new pieces of
203 * Name of user's volume
204 * FileServer & partition hosting the volume
208 *------------------------------------------------------------------------*/
212 { /*SaveRestoreInfo */
214 static char rn[] = "uss:SaveRestoreInfo"; /*Routine name */
215 register afs_int32 code; /*Return code */
216 afs_int32 deletedUid; /*Uid to be nuked */
219 * Translate the user name to the user ID.
221 code = uss_ptserver_XlateUser(uss_User, &deletedUid);
225 printf("%s: User '%s' translated to uid %d\n", rn, uss_User, deletedUid);
227 sprintf(uss_Uid, "%d", deletedUid);
230 * Pull out the name of the volume at the given mountpoint, along
231 * with the name of the FileServer and partition hosting it. This
232 * also sets up all the numerical info for the above.
234 code = uss_vol_GetVolInfoFromMountPoint(uss_MountPoint);
239 * Report back that we did fine.
243 } /*SaveRestoreInfo */
246 /*-----------------------------------------------------------------------
250 * With everything properly inserted into the common variables,
251 * delete the specified user account.
257 * 0 if everything went well,
258 * 1 if something went wrong in the function, or
259 * Lower-level error code if something went wrong below us.
262 * Nothing interesting.
266 *------------------------------------------------------------------------*/
272 int code; /*Return code */
275 * Make sure the user name is a lega one.
277 code = uss_kauth_CheckUserName();
282 * Store all the info about the account before actually doing
285 code = SaveRestoreInfo();
289 if ((uss_VolumeID != 0) && (uss_MountPoint[0] != '\0')) {
291 * Unmount the user's volume from the file system.
295 "Unmounting volume '%s' (ID %u) mounted at '%s'\n",
296 uss_Volume, uss_VolumeID, uss_MountPoint);
299 code = uss_fs_RmMountPoint(uss_MountPoint);
302 fprintf(stderr, "%s: Can't remove mountpoint '%s'\n",
303 uss_whoami, uss_MountPoint);
304 return (code); /* Must return - we may have incorrect volume */
309 * If our caller has elected to delete the user's volume now,
312 if (!uss_SaveVolume && (uss_VolumeID != 0)) {
314 fprintf(stderr, "Deleting volume '%s' (ID %u)\n", uss_Volume,
319 uss_vol_DeleteVol(uss_Volume, uss_VolumeID, uss_Server,
320 uss_ServerID, uss_Partition, uss_PartitionID);
323 fprintf(stderr, "%s: Can't delete volume '%s' (ID %u)\n",
324 uss_whoami, uss_Volume, uss_VolumeID);
327 } else if (uss_verbose && (uss_MountPoint[0] != '\0'))
328 printf("%s: Warning: Not attempting to delete volume at '%s'\n",
329 uss_whoami, uss_MountPoint);
332 * Get rid of the user's authentication entry.
334 code = uss_kauth_DelUser(uss_User);
339 * Finally, remove the user's AFS ID from the Protection DB and
340 * return that result.
342 code = uss_ptserver_DelUser(uss_User);
348 /*-----------------------------------------------------------------------
352 * Process the given (non-bulk) delete command.
355 * a_as : Ptr to the command line syntax descriptor.
356 * a_rock : Ptr to the rock passed in.
359 * 0 if everything went well,
360 * 1 if something went wrong in the function, or
361 * Lower-level error code if something went wrong below us.
364 * Nothing interesting.
368 *------------------------------------------------------------------------*/
371 DelUser(struct cmd_syndesc *a_as, void *a_rock)
377 * Before we do anything else, make sure we initialize the
378 * global field settings.
383 * Pull out the fields as passed in by the caller on the command
386 strcpy(uss_User, a_as->parms[DUP_USER].items->data);
387 if (a_as->parms[DUP_MNTPT].items)
388 strcpy(uss_MountPoint, a_as->parms[DUP_MNTPT].items->data);
389 #if USS_FUTURE_FEATURES
390 #if USS_DONT_HIDE_SOME_FEATURES
391 strcpy(uss_RestoreDir, a_as->parms[DUP_RESTOREDIR].items->data);
392 #endif /* USS_DONT_HIDE_SOME_FEATURES */
393 #endif /* USS_FUTURE_FEATURES */
396 if (a_as->parms[DUP_SAVEVOLUME].items)
400 if (a_as->parms[2].items) {
403 #if USS_FUTURE_FEATURES
404 #if USS_DONT_HIDE_SOME_FEATURES
405 if (a_as->parms[DUP_PWDPATH].items)
406 strcpy(uss_PwdPath, a_as->parms[DUP_PWDPATH].items->data);
407 if (a_as->parms[DUP_PWDFORMAT].items)
408 strcpy(uss_PwdFormat, a_as->parms[DUP_PWDFORMAT].items->data);
409 #endif /* USS_DONT_HIDE_SOME_FEATURES */
410 #endif /* USS_FUTURE_FEATURES */
412 if (a_as->parms[AUSS_DRYRUN].items)
414 if (a_as->parms[AUSS_SKIPAUTH].items)
415 uss_SkipKaserver = 1;
416 if (a_as->parms[AUSS_ADMIN].items) {
417 strcpy(uss_Administrator, a_as->parms[AUSS_ADMIN].items->data);
418 /* fprintf(stderr, "debugging: uss_Administrator set to '%s'\n",
419 * uss_Administrator); */
421 /* fprintf(stderr, "debugging: No administrator value given\n"); */
422 uss_Administrator[0] = '\0';
426 * Initialize uss_AccountCreator().
428 code = uss_kauth_InitAccountCreator();
433 * Now that the command line arguments are parsed and properly stored,
442 /*-----------------------------------------------------------------------
443 * static PurgeVolumes
446 * Purge the given volume(s).
449 * a_as : Ptr to the command line syntax descriptor.
450 * a_rock : Ptr to the rock passed in.
453 * 0 if everything went well,
454 * 1 if something went wrong in the function, or
455 * Lower-level error code if something went wrong below us.
458 * Nothing interesting.
462 *------------------------------------------------------------------------*/
465 PurgeVolumes(struct cmd_syndesc *a_as, void *a_rock)
468 fprintf(stderr, "Sorry, purgevolumes has not yet been implemented.\n");
474 /*-----------------------------------------------------------------------
478 * Process the given delete command.
481 * a_as : Ptr to the command line syntax descriptor.
482 * a_rock : Ptr to the rock passed in.
485 * 0 if everything went well,
486 * 1 if something went wrong in the function, or
487 * Lower-level error code if something went wrong below us.
490 * Nothing interesting.
494 *------------------------------------------------------------------------*/
497 RestoreUser(struct cmd_syndesc *a_as, void *a_rock)
500 fprintf(stderr, "Sorry, restoreuser has not yet been implemented.\n");
506 /*-----------------------------------------------------------------------
507 * static DoBulkAddLine
510 * Process the given bulk add command.
513 * a_buf : Ptr to the buffer holding the bulk add command.
514 * a_tp : Ptr to the first char past the opcode.
517 * 0 if everything went well,
518 * -1 if something went wrong in the function, or
519 * Lower-level error code if something went wrong below us.
522 * The required fields are:
527 *------------------------------------------------------------------------*/
530 DoBulkAddLine(a_buf, a_tp)
536 register int i; /*Loop variable */
537 static char rn[] = "DoBulkAddLine"; /*Routine name */
538 int overflow; /*Overflow in field copy? */
541 printf("%s: Command buffer left to parse: '%s'\n", rn, a_tp);
543 uss_Expires = uss_BulkExpires;
546 * Pull out all the fields.
548 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
551 "%s: * User field in add cmd too long (max is %d chars; truncated value is '%s')\n",
552 uss_whoami, uss_UserLen, uss_User);
555 if ((*a_tp == '\0') || (*a_tp == '\n')) {
557 "%s: * The user field must appear in a bulk add command.\n",
563 uss_common_FieldCp(uss_RealName, a_tp, ':', uss_RealNameLen,
567 "%s: * Real name field in add cmd too long (max is %d chars; truncated value is '%s')\n",
568 uss_whoami, uss_RealNameLen, uss_RealName);
571 if (uss_RealName[0] == '\0') {
573 * The user's real name has not been supplied. As a
574 * default, we use the account name.
576 sprintf(uss_RealName, "%s", uss_User);
578 fprintf(stderr, "%s: Using default real name, '%s'\n", uss_whoami,
581 /*Use default full name */
582 a_tp = uss_common_FieldCp(uss_Pwd, a_tp, ':', uss_PwdLen, &overflow);
585 "%s: * Password field in add cmd too long (max is %d chars; truncated value is '%s')\n",
586 uss_whoami, uss_PwdLen, uss_Pwd);
589 if (uss_Pwd[0] == '\0') {
591 * The user's password has not been provided. Use
594 sprintf(uss_Pwd, "%s", uss_DEFAULT_PASSWORD);
596 fprintf(stderr, "%s: Using default password, '%s'\n", uss_whoami,
598 } /*Use default password */
599 if ((*a_tp == '\0') || (*a_tp == '\n'))
600 goto DoBulkAddLine_ParsingDone;
605 a_tp = uss_common_FieldCp(temp, a_tp, ':', 9, &overflow);
608 "%s: * Password expiration time is longer than %d characters, ignoring...\n",
611 if (temp[0] == '\0') {
612 /* Expiration time not specified. Use default */
614 fprintf(stderr, "%s: Using default expiration time, '%d'\n",
615 uss_whoami, uss_Expires);
619 if (te < 0 || te > 254) {
621 "%s: * Password Expiration must be in [0..254] days, using default %d\n",
622 uss_whoami, uss_Expires);
627 if ((*a_tp == '\0') || (*a_tp == '\n'))
628 goto DoBulkAddLine_ParsingDone;
633 uss_common_FieldCp(uss_Server, a_tp, ':', uss_ServerLen, &overflow);
636 "%s: * Server field in add cmd too long (max is %d chars; truncated value is '%s')\n",
637 uss_whoami, uss_ServerLen, uss_Server);
640 if ((*a_tp == '\0') || (*a_tp == '\n'))
641 goto DoBulkAddLine_ParsingDone;
644 uss_common_FieldCp(uss_Partition, a_tp, ':', uss_PartitionLen,
648 "%s: * Partition field in add cmd too long (max is %d chars; truncated value is '%s')\n",
649 uss_whoami, uss_PartitionLen, uss_Partition);
652 if ((*a_tp == '\0') || (*a_tp == '\n'))
653 goto DoBulkAddLine_ParsingDone;
656 uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
660 "%s: * Mountpoint field in add cmd too long (max is %d chars; truncated value is '%s')\n",
661 uss_whoami, uss_MountPointLen, uss_MountPoint);
664 if ((*a_tp == '\0') || (*a_tp == '\n'))
665 goto DoBulkAddLine_ParsingDone;
667 a_tp = uss_common_FieldCp(uss_Uid, a_tp, ':', uss_UidLen, &overflow);
670 "%s: * UID field in add cmd too long (max is %d chars; truncated value is '%s')\n",
671 uss_whoami, uss_UidLen, uss_Uid);
674 uss_DesiredUID = atoi(uss_Uid);
675 if ((*a_tp == '\0') || (*a_tp == '\n'))
676 goto DoBulkAddLine_ParsingDone;
678 for (uss_VarMax = 1; uss_VarMax < 10; uss_VarMax++) {
680 uss_common_FieldCp(uss_Var[uss_VarMax], a_tp, ':',
681 uss_MAX_ARG_SIZE, &overflow);
684 "%s: * Variable %d field in add cmd too long (max is %d chars; truncated value is '%s')\n",
685 uss_whoami, uss_VarMax, uss_MAX_ARG_SIZE,
686 uss_Var[uss_VarMax]);
689 if ((*a_tp == '\0') || (*a_tp == '\n'))
690 goto DoBulkAddLine_ParsingDone;
693 DoBulkAddLine_ParsingDone:
695 * If there's anything left on the line, we ignore it. Announce
696 * the bulk add parameters we've parsed or filled in if we're
697 * being verbose, then go for it.
701 "\nAdding user '%s' ('%s'), password='%s' on server '%s', partition '%s', home directory='%s'",
702 uss_User, uss_RealName, uss_Pwd,
703 (uss_Server[0] != '\0' ? uss_Server : "<default>"),
704 (uss_Partition[0] != '\0' ? uss_Partition : "<default>"),
705 (uss_MountPoint[0] != '\0' ? uss_MountPoint : "<default>"));
707 fprintf(stderr, ", uid preset to %d\n", uss_DesiredUID);
709 fprintf(stderr, ", no preset uid\n");
710 for (i = 1; i <= uss_VarMax; i++) {
711 if (uss_Var[i][0] != '\0')
712 fprintf(stderr, "$%1d='%s' ", i, uss_Var[i]);
715 fprintf(stderr, "\n");
718 /*Verbose status of add command */
720 * Now do the real work.
727 /*-----------------------------------------------------------------------
728 * static DoBulkDeleteLine
731 * Process the given bulk delete command.
734 * a_buf : Ptr to the buffer holding the bulk delete command.
735 * a_tp : Ptr to the first char past the opcode.
738 * 0 if everything went well,
739 * -1 if something went wrong in the function, or
740 * Lower-level error code if something went wrong below us.
743 * The required fields are:
744 * -user, -mountpoint, -restoredir
748 *------------------------------------------------------------------------*/
751 DoBulkDeleteLine(a_buf, a_tp)
755 { /*DoBulkDeleteLine */
757 char volField[32]; /*Value of optional vol disposition field */
758 int overflow; /*Was there an overflow in field copying? */
761 * Pull out all the fields.
763 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
766 "%s: * User field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
767 uss_whoami, uss_UserLen, uss_User);
770 if ((uss_User[0] == '\0') || (*a_tp == '\0') || (*a_tp == '\n'))
771 goto Delete_MissingRequiredParam;
774 uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
778 "%s: * Mountpoint field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
779 uss_whoami, uss_MountPointLen, uss_MountPoint);
782 #if USS_FUTURE_FEATURES
783 #if USS_DONT_HIDE_SOME_FEATURES
784 if ((uss_MountPoint[0] == '\0') || (*a_tp == '\0') || (*a_tp == '\n'))
785 goto Delete_MissingRequiredParam;
786 #endif /* USS_DONT_HIDE_SOME_FEATURES */
788 if ((*a_tp == '\0') || (*a_tp == '\n'))
789 goto Delete_ParsingDone;
790 #endif /* USS_FUTURE_FEATURES */
792 #if USS_FUTURE_FEATURES
793 #if USS_DONT_HIDE_SOME_FEATURES
795 uss_common_FieldCp(uss_RestoreDir, a_tp, ':', uss_RestoreDirLen,
799 "%s: * RestoreDir field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
800 uss_whoami, uss_RestoreDirLen, uss_RestoreDir);
803 if (uss_RestoreDir[0] == '\0')
804 goto Delete_MissingRequiredParam;
805 if ((*a_tp == '\0') || (*a_tp == '\n'))
806 goto Delete_ParsingDone;
809 uss_common_FieldCp(uss_PwdPath, a_tp, ':', uss_PwdPathLen, &overflow);
812 "%s: * Password path field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
813 uss_whoami, uss_PwdPathLen, uss_PwdPath);
816 if ((*a_tp == '\0') || (*a_tp == '\n'))
817 goto Delete_ParsingDone;
820 uss_common_FieldCp(uss_PwdFormat, a_tp, ':', uss_PwdFormatLen,
824 "%s: * Password format field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
825 uss_whoami, uss_PwdFormatLen, uss_PwdFormat);
828 if ((*a_tp == '\0') || (*a_tp == '\n'))
829 goto Delete_ParsingDone;
830 #endif /* USS_DONT_HIDE_SOME_FEATURES */
831 #endif /* USS_FUTURE_FEATURES */
833 a_tp = uss_common_FieldCp(volField, a_tp, ':', 32, &overflow);
836 "%s: * Volume save/del field in delete cmd too long (max is 32 chars; truncated value is '%s')\n",
837 uss_whoami, volField);
840 if ((*a_tp == '\0') || (*a_tp == '\n'))
841 goto Delete_ParsingDone;
843 if (strcmp(volField, "delvolume") == 0)
850 * If there's anything left on the line, we ignore it. Announce
851 * the bulk delete parameters we've parsed if we're being verbose,
855 #if USS_FUTURE_FEATURES
856 #if USS_DONT_HIDE_SOME_FEATURES
858 "\nDeleting user '%s' mounted at '%s', restoredir='%s', pwd path='%s', pwd format='%s'",
859 uss_User, uss_MountPoint, uss_RestoreDir, uss_PwdPath,
861 #endif /* USS_DONT_HIDE_SOME_FEATURES */
863 fprintf(stderr, "\nDeleting user '%s' mounted at '%s'", uss_User,
865 #endif /* USS_FUTURE_FEATURES */
867 fprintf(stderr, ", saving user's volume\n");
869 fprintf(stderr, ", deleting user's volume\n");
872 /*Verbose status of delete command */
874 * Now do the real work.
878 Delete_MissingRequiredParam:
880 "%s: * All of the user, mountpoint, and restoredir fields must appear in a bulk delete command line.\n",
884 } /*DoBulkDeleteLine */
886 #if USS_FUTURE_FEATURES
887 #if USS_DONT_HIDE_SOME_FEATURES
888 /*-----------------------------------------------------------------------
889 * static DoBulkPurgeVolumeLine
892 * Process the given bulk add command.
895 * a_buf : Ptr to the buffer holding the bulk add command.
896 * a_tp : Ptr to the first char past the opcode.
899 * 0 if everything went well,
900 * -1 if something went wrong in the function, or
901 * Lower-level error code if something went wrong below us.
904 * Nothing interesting.
908 *------------------------------------------------------------------------*/
911 DoBulkPurgeVolumeLine(a_buf, a_tp)
915 { /*DoBulkPurgeVolumeLine */
917 register int i; /*Loop variable */
918 int overflow; /*Did a field copy overflow happen? */
921 * Pull out all the fields.
923 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
926 "%s: * User field in purgevolume cmd too long (max is %d chars; truncated value is '%s')\n",
927 uss_whoami, uss_UserLen, uss_User);
930 if ((*a_tp == '\0') || (*a_tp == '\n')) {
932 "%s: * The user field must appear in a bulk add command.\n",
938 uss_common_FieldCp(uss_RealName, a_tp, ':', uss_RealNameLen,
942 "%s: * Real name field in purgevolume cmd too long (max is %d chars; truncated value is '%s')\n",
943 uss_whoami, uss_RealNameLen, uss_RealName);
946 if (uss_RealName[0] == '\0') {
948 * The user's real name has not been supplied. As a
949 * default, we use the account name.
951 sprintf(uss_RealName, "%s", uss_User);
953 fprintf(stderr, "%s: Using default real name, '%s'\n", uss_whoami,
956 /*Use default full name */
957 a_tp = uss_common_FieldCp(uss_Pwd, a_tp, ':', uss_PwdLen, &overflow);
960 "%s: * Password field in purgevolume cmd too long (max is %d chars; truncated value is '%s')\n",
961 uss_whoami, uss_PwdLen, uss_Pwd);
964 if (uss_Pwd[0] == '\0') {
966 * The user's password has not been provided. Use
969 sprintf(uss_Pwd, "%s", uss_DEFAULT_PASSWORD);
971 fprintf(stderr, "%s: Using default password, '%s'\n", uss_whoami,
973 } /*Use default password */
974 if ((*a_tp == '\0') || (*a_tp == '\n'))
978 uss_common_FieldCp(uss_Server, a_tp, ':', uss_ServerLen, &overflow);
980 fprintf(stderr, "%s: * Server field too long (max is %d chars)\n",
981 uss_whoami, uss_ServerLen);
984 if ((*a_tp == '\0') || (*a_tp == '\n'))
988 uss_common_FieldCp(uss_Partition, a_tp, ':', uss_PartitionLen,
991 fprintf(stderr, "%s: * Partition field too long (max is %d chars)\n",
992 uss_whoami, uss_PartitionLen);
995 if ((*a_tp == '\0') || (*a_tp == '\n'))
999 uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
1002 fprintf(stderr, "%s: * Mountpoint field too long (max is %d chars)\n",
1003 uss_whoami, uss_MountPointLen);
1006 if ((*a_tp == '\0') || (*a_tp == '\n'))
1009 a_tp = uss_common_FieldCp(uss_Uid, a_tp, ':', uss_UidLen, &overflow);
1011 fprintf(stderr, "%s: * UID field too long (max is %d chars)\n",
1012 uss_whoami, uss_UidLen);
1015 uss_DesiredUID = atoi(uss_Uid);
1016 if ((*a_tp == '\0') || (*a_tp == '\n'))
1019 for (uss_VarMax = 1; uss_VarMax < 10; uss_VarMax++) {
1021 uss_common_FieldCp(uss_Var[uss_VarMax], a_tp, ':',
1022 uss_MAX_ARG_SIZE, &overflow);
1025 "%s: * Variable %d field too long (max is %d chars)\n",
1026 uss_whoami, uss_VarMax, uss_MAX_ARG_SIZE);
1029 if ((*a_tp == '\0') || (*a_tp == '\n'))
1034 * If there's anything left on the line, we ignore it. Announce
1035 * the bulk add parameters we've parsed or filled in if we're
1036 * being verbose, then go for it.
1040 "\nAdding user '%s' ('%s'), password='%s' on server '%s', partition '%s', home directory='%s'",
1041 uss_User, uss_RealName, uss_Pwd,
1042 (uss_Server[0] != '\0' ? uss_Server : "<default>"),
1043 (uss_Partition[0] != '\0' ? uss_Partition : "<default>"),
1044 (uss_MountPoint[0] != '\0' ? uss_MountPoint : "<default>"));
1046 fprintf(stderr, ", uid preset to %d\n", uss_DesiredUID);
1048 fprintf(stderr, ", no preset uid\n");
1049 for (i = 1; i <= uss_VarMax; i++) {
1050 if (uss_Var[i][0] != '\0')
1051 fprintf(stderr, "$%1d='%s' ", i, uss_Var[i]);
1054 fprintf(stderr, "\n");
1057 /*Verbose status of add command */
1059 * Now do the real work.
1063 } /*DoBulkPurgeVolumeLine */
1064 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1065 #endif /* USS_FUTURE_FEATURES */
1067 #if USS_FUTURE_FEATURES
1068 #if USS_DONT_HIDE_SOME_FEATURES
1069 /*-----------------------------------------------------------------------
1070 * static DoBulkRestoreLine
1073 * Process the given bulk add command.
1076 * a_buf : Ptr to the buffer holding the bulk add command.
1077 * a_tp : Ptr to the first char past the opcode.
1080 * 0 if everything went well,
1081 * -1 if something went wrong in the function, or
1082 * Lower-level error code if something went wrong below us.
1085 * Nothing interesting.
1089 *------------------------------------------------------------------------*/
1092 DoBulkRestoreLine(a_buf, a_tp)
1096 { /*DoBulkRestoreLine */
1098 register int i; /*Loop variable */
1099 int overflow; /*Overflow occur on field copy? */
1102 * Pull out all the fields.
1104 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
1106 fprintf(stderr, "%s: * User field too long (max is %d chars)\n",
1107 uss_whoami, uss_UserLen);
1110 if ((*a_tp == '\0') || (*a_tp == '\n')) {
1112 "%s: * The user field must appear in a bulk add command.\n",
1118 uss_common_FieldCp(uss_RealName, a_tp, ':', uss_RealNameLen,
1121 fprintf(stderr, "%s: * Real name field too long (max is %d chars)\n",
1122 uss_whoami, uss_RealNameLen);
1125 if (uss_RealName[0] == '\0') {
1127 * The user's real name has not been supplied. As a
1128 * default, we use the account name.
1130 sprintf(uss_RealName, "%s", uss_User);
1132 fprintf(stderr, "%s: Using default real name, '%s'\n", uss_whoami,
1135 /*Use default full name */
1136 a_tp = uss_common_FieldCp(uss_Pwd, a_tp, ':', uss_PwdLen, &overflow);
1138 fprintf(stderr, "%s: * Password field too long (max is %d chars)\n",
1139 uss_whoami, uss_PwdLen);
1142 if (uss_Pwd[0] == '\0') {
1144 * The user's password has not been provided. Use
1147 sprintf(uss_Pwd, "%s", uss_DEFAULT_PASSWORD);
1149 fprintf(stderr, "%s: Using default password, '%s'\n", uss_whoami,
1151 } /*Use default password */
1152 if ((*a_tp == '\0') || (*a_tp == '\n'))
1156 uss_common_FieldCp(uss_Server, a_tp, ':', uss_ServerLen, &overflow);
1158 fprintf(stderr, "%s: * Server field too long (max is %d chars)\n",
1159 uss_whoami, uss_ServerLen);
1162 if ((*a_tp == '\0') || (*a_tp == '\n'))
1166 uss_common_FieldCp(uss_Partition, a_tp, ':', uss_PartitionLen,
1169 fprintf(stderr, "%s: * Partition field too long (max is %d chars)\n",
1170 uss_whoami, uss_PartitionLen);
1173 if ((*a_tp == '\0') || (*a_tp == '\n'))
1177 uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
1180 fprintf(stderr, "%s: * mountpoint field too long (max is %d chars)\n",
1181 uss_whoami, uss_MountPointLen);
1184 if ((*a_tp == '\0') || (*a_tp == '\n'))
1187 a_tp = uss_common_FieldCp(uss_Uid, a_tp, ':', uss_UidLen, &overflow);
1189 fprintf(stderr, "%s: * UID field too long (max is %d chars)\n",
1190 uss_whoami, uss_UidLen);
1193 uss_DesiredUID = atoi(uss_Uid);
1194 if ((*a_tp == '\0') || (*a_tp == '\n'))
1197 for (uss_VarMax = 1; uss_VarMax < 10; uss_VarMax++) {
1199 uss_common_FieldCp(uss_Var[uss_VarMax], a_tp, ':',
1200 uss_MAX_ARG_SIZE, &overflow);
1203 "%s: * Variable %d field too long (max is %d chars)\n",
1204 uss_whoami, uss_VarMax, uss_MAX_ARG_SIZE);
1207 if ((*a_tp == '\0') || (*a_tp == '\n'))
1212 * If there's anything left on the line, we ignore it. Announce
1213 * the bulk add parameters we've parsed or filled in if we're
1214 * being verbose, then go for it.
1218 "\nAdding user '%s' ('%s'), password='%s' on server '%s', partition '%s', home directory='%s'",
1219 uss_User, uss_RealName, uss_Pwd,
1220 (uss_Server[0] != '\0' ? uss_Server : "<default>"),
1221 (uss_Partition[0] != '\0' ? uss_Partition : "<default>"),
1222 (uss_MountPoint[0] != '\0' ? uss_MountPoint : "<default>"));
1224 fprintf(stderr, ", uid preset to %d\n", uss_DesiredUID);
1226 fprintf(stderr, ", no preset uid\n");
1227 for (i = 1; i <= uss_VarMax; i++) {
1228 if (uss_Var[i][0] != '\0')
1229 fprintf(stderr, "$%1d='%s' ", i, uss_Var[i]);
1232 fprintf(stderr, "\n");
1235 /*Verbose status of add command */
1237 * Now do the real work.
1239 return (DoRestore());
1241 } /*DoBulkRestoreLine */
1242 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1243 #endif /* USS_FUTURE_FEATURES */
1246 /*-----------------------------------------------------------------------
1247 * static DoBulkExecLine
1250 * Process the given bulk exec command.
1253 * a_buf : Ptr to the buffer holding the bulk exec command.
1254 * a_tp : Ptr to the first char past the opcode.
1257 * 0 if everything went well,
1258 * -1 if something went wrong in the function, or
1259 * Lower-level error code if something went wrong below us.
1262 * Nothing interesting.
1266 *------------------------------------------------------------------------*/
1269 DoBulkExecLine(a_buf, a_tp)
1273 { /*DoBulkExecLine */
1275 register afs_int32 code; /*Return code */
1278 * Really, uss_procs_Exec does all the work for us!
1280 code = uss_procs_Exec(a_tp);
1283 } /*DoBulkExecLine */
1286 /*-----------------------------------------------------------------------
1290 * Process the given bulk command.
1293 * a_as : Ptr to the command line syntax descriptor.
1294 * a_rock : Ptr to the rock passed in.
1297 * 0 if everything went well,
1298 * 1 if something went wrong in the function, or
1299 * Lower-level error code if something went wrong below us.
1302 * Nothing interesting.
1306 *------------------------------------------------------------------------*/
1309 HandleBulk(register struct cmd_syndesc *a_as, void *a_rock)
1312 #define USS_BULK_CMD_CHARS 128
1313 #define USS_BULK_BUF_CHARS 1024
1315 char cmd[USS_BULK_CMD_CHARS], buf[USS_BULK_BUF_CHARS];
1323 char tbuf[USS_BULK_BUF_CHARS];
1326 * Open up the bulk file, croak if we can't.
1328 if ((infile = fopen(a_as->parms[ABULK_FILE].items->data, "r")) == NULL) {
1329 fprintf(stderr, "%s: * Failed to open input file %s\n", uss_whoami,
1330 a_as->parms[ABULK_FILE].items->data);
1335 * Pull out the other fields as passed in by the caller on the
1338 if (a_as->parms[AUSS_DRYRUN].items)
1340 if (a_as->parms[AUSS_SKIPAUTH].items)
1341 uss_SkipKaserver = 1;
1342 if (a_as->parms[AUSS_OVERWRITE].items)
1344 if (a_as->parms[AUSS_PIPE].items)
1346 if (a_as->parms[AUSS_ADMIN].items)
1347 strcpy(uss_Administrator, a_as->parms[AUSS_ADMIN].items->data);
1349 uss_Administrator[0] = '\0';
1351 if (a_as->parms[AUSS_PWEXPIRES].items) {
1352 uss_BulkExpires = atoi(a_as->parms[AUSS_PWEXPIRES].items->data);
1353 if (uss_BulkExpires < 0 || uss_BulkExpires > 254) {
1355 "%s: Password Expiration must be in [0..255] days\n",
1360 uss_BulkExpires = 0;
1363 * Initialize uss_AccountCreator().
1365 code = uss_kauth_InitAccountCreator();
1370 * Process all the lines in the bulk command file.
1372 uss_VarMax = 0; /*No uss vars picked up yet */
1373 while (fgets(buf, sizeof(buf), infile) != NULL) {
1375 /* skip blank line */
1380 /* After executing the line, print the line and the result */
1382 if (error == UNOQUORUM) {
1388 printf("LINE %d %s %s", line_no, (error ? "FAIL" : "SUCCESS"),
1394 * Reset the common variables for each command line
1399 strncpy(tbuf, buf, USS_BULK_BUF_CHARS-1);
1402 * First line of file = line 1.
1408 * Get the opcode and act upon it.
1410 tp = uss_common_FieldCp(cmd, buf, ' ', USS_BULK_CMD_CHARS, &overflow);
1413 "%s: * Bulk opcode field too long (max is %d chars)\n",
1414 uss_whoami, USS_BULK_CMD_CHARS);
1422 if (strcmp(cmd, "add") == 0) {
1423 error = DoBulkAddLine(buf, tp);
1426 if (strcmp(cmd, "delete") == 0) {
1427 error = DoBulkDeleteLine(buf, tp);
1430 if (strcmp(cmd, "delvolume") == 0) {
1435 #if USS_FUTURE_FEATURES
1436 #if USS_DONT_HIDE_SOME_FEATURES
1437 if (strcmp(cmd, "purgevolume") == 0) {
1438 error = DoBulkPurgeVolumeLine(buf, tp);
1441 if (strcmp(cmd, "pwdformat") == 0) {
1442 /*Set the password format here */
1445 if (strcmp(cmd, "pwdpath") == 0) {
1446 /*Set the password path here */
1449 if (strcmp(cmd, "restore") == 0) {
1450 error = DoBulkRestoreLine(buf, tp);
1453 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1454 #endif /* USS_FUTURE_FEATURES */
1455 if (strcmp(cmd, "savevolume") == 0) {
1456 /*Set the savevolume flag here */
1459 if (strcmp(cmd, "exec") == 0) {
1460 error = DoBulkExecLine(buf, tp);
1465 * If none of the valid opcodes match, see if the line is either
1466 * a comment of a blank. If so, just ignore it. Otherwise, we
1469 if ((cmd[0] != '#') && (cmd[0] != '\0')) {
1471 "%s: ** Unrecognized command ('%s') in bulk file\n",
1480 } /*Bad bulk line */
1481 } /*Process a line in the bulk file */
1487 printf("LINE %d %s %s", line_no, (error ? "FAIL" : "SUCCESS"), tbuf);
1495 /*-----------------------------------------------------------------------
1499 * Process the given (non-bulk) add command.
1502 * a_as : Ptr to the command line syntax descriptor.
1503 * a_rock : Ptr to the rock passed in.
1506 * 0 if everything went well,
1507 * 1 if something went wrong in the function, or
1508 * Lower-level error code if something went wrong below us.
1511 * Nothing interesting.
1515 *------------------------------------------------------------------------*/
1518 AddUser(register struct cmd_syndesc *a_as, void *a_rock)
1522 register struct cmd_item *ti;
1526 * Before we do anything else, make sure we initialize the
1527 * global field settings.
1532 * Pull out the fields as passed in by the caller on the command
1535 strcpy(uss_User, a_as->parms[AUP_USER].items->data);
1536 if (a_as->parms[AUP_REALNAME].items)
1537 strcpy(uss_RealName, a_as->parms[AUP_REALNAME].items->data);
1539 strcpy(uss_RealName, uss_User);
1540 if (a_as->parms[AUP_PASSWD].items)
1541 strcpy(uss_Pwd, a_as->parms[AUP_PASSWD].items->data);
1543 strcpy(uss_Pwd, uss_DEFAULT_PASSWORD);
1544 if (a_as->parms[AUP_SERVER].items)
1545 strcpy(uss_Server, a_as->parms[AUP_SERVER].items->data);
1546 if (a_as->parms[AUP_PART].items)
1547 strcpy(uss_Partition, a_as->parms[AUP_PART].items->data);
1548 if (a_as->parms[AUP_MNTPT].items)
1549 strcpy(uss_MountPoint, a_as->parms[AUP_MNTPT].items->data);
1550 if (a_as->parms[AUP_UID].items)
1551 uss_DesiredUID = atoi(a_as->parms[AUP_UID].items->data);
1554 if (a_as->parms[AUP_PWEXPIRES].items) {
1555 uss_Expires = atoi(a_as->parms[AUP_PWEXPIRES].items->data);
1556 if (uss_Expires < 0 || uss_Expires > 254) {
1558 "%s: Password Expiration must be in [0..255] days\n",
1565 if (a_as->parms[AUSS_DRYRUN].items)
1567 if (a_as->parms[AUSS_SKIPAUTH].items)
1568 uss_SkipKaserver = 1;
1569 if (a_as->parms[AUSS_OVERWRITE].items)
1571 if (a_as->parms[AUSS_ADMIN].items) {
1572 strcpy(uss_Administrator, a_as->parms[AUSS_ADMIN].items->data);
1573 /* fprintf(stderr, "debugging: uss_Administrator set to '%s'\n",
1574 * uss_Administrator); */
1576 /* fprintf(stderr, "debugging: No administrator value given\n"); */
1577 uss_Administrator[0] = '\0';
1580 if (a_as->parms[AUSS_VAR].items) {
1581 for (ti = a_as->parms[AUSS_VAR].items; ti; ti = ti->next) {
1583 if (i < 0 || i > 9 || (i == 0 && *ti->data != '0')) {
1585 "%s: Bad -var format: must be '0 val0 1 val1 ... 9 val9'\n",
1592 "%s: -var values must appear in pairs: 'Num val'\n",
1596 strcpy(uss_Var[i], ti->data);
1599 } /*Remember each VAR item */
1602 /*VAR items exist */
1604 * Initialize uss_AccountCreator().
1606 code = uss_kauth_InitAccountCreator();
1611 * Now that the command line arguments are parsed and properly stored,
1619 /*-----------------------------------------------------------------------
1623 * Create the desired user account, having parsed the add command
1624 * from either the command line or a bulk file.
1630 * 0 if everything went well,
1631 * 1 if something went wrong in the function, or
1632 * Lower-level error code if something went wrong below us.
1635 * All values needed have been put in the common variables.
1639 *------------------------------------------------------------------------*/
1645 int code; /*Return code */
1648 * Make sure the user name is legal.
1650 code = uss_kauth_CheckUserName();
1655 * This time around, we start off assuming the global value of the
1658 uss_OverwriteThisOne = uss_Overwrite;
1661 * Open up the template file before doing any real processing,
1662 * so we can quit early should it not be found.
1665 if ((yyin = uss_procs_FindAndOpen(Template)) == NULL) {
1666 fprintf(stderr, "%s: ** Can't open template file '%s'\n",
1667 uss_whoami, Template);
1670 yyout = fopen("/dev/null", "w");
1675 * Add the new user to the Protection DB.
1677 code = uss_ptserver_AddUser(uss_User, uss_Uid);
1679 fprintf(stderr, "%s: Failed to add user '%s' to the Protection DB\n",
1680 uss_whoami, uss_User);
1685 * Add the new user to the Authentication DB.
1687 code = uss_kauth_AddUser(uss_User, uss_Pwd);
1689 fprintf(stderr, "%s: Can't add user '%s' to the Authentication DB\n",
1690 uss_whoami, uss_User);
1695 * Process the items covered by the template file.
1697 if (yyparse() && (!uss_ignoreFlag))
1701 * Finally, clean up after ourselves, removing the uss_AccountCreator
1702 * from various of the new user's ACLs.
1704 return (uss_acl_CleanUp());
1709 #if USS_FUTURE_FEATURES
1710 #if USS_DONT_HIDE_SOME_FEATURES
1711 /*-----------------------------------------------------------------------
1715 * Perform the parsed restore command.
1721 * 0 if everything went well,
1722 * 1 if something went wrong in the function, or
1723 * Lower-level error code if something went wrong below us.
1726 * All values needed have been put in the common variables.
1730 *------------------------------------------------------------------------*/
1739 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1740 #endif /* USS_FUTURE_FEATURES */
1743 /*-----------------------------------------------------------------------
1744 * static InitETTables
1747 * Set up the error code tables for the various modules we use.
1756 * Nothing interesting.
1760 *------------------------------------------------------------------------*/
1768 * In order to get error code -> error message translations to work,
1769 * we have to initialize all error tables.
1771 initialize_CMD_error_table();
1772 initialize_RXK_error_table();
1773 initialize_KTC_error_table();
1774 initialize_KA_error_table();
1775 initialize_ACFG_error_table();
1776 initialize_VL_error_table();
1777 initialize_PT_error_table();
1778 initialize_U_error_table();
1786 /* this sucks but it works for now.
1791 #include "AFS_component_version_number.c"
1799 register struct cmd_syndesc *cs; /*Command line syntax descriptor */
1800 register afs_int32 code; /*Return code */
1802 #ifdef AFS_AIX32_ENV
1804 * The following signal action for AIX is necessary so that in case of a
1805 * crash (i.e. core is generated) we can include the user's data section
1806 * in the core dump. Unfortunately, by default, only a partial core is
1807 * generated which, in many cases, isn't too useful.
1809 struct sigaction nsa;
1811 sigemptyset(&nsa.sa_mask);
1812 nsa.sa_handler = SIG_DFL;
1813 nsa.sa_flags = SA_FULLDUMP;
1814 sigaction(SIGABRT, &nsa, NULL);
1815 sigaction(SIGSEGV, &nsa, NULL);
1817 strcpy(uss_whoami, argv[0]);
1818 yyin = (FILE *) NULL;
1820 uss_fs_InBuff = (char *)malloc(USS_FS_MAX_SIZE); /*Cache Manager input buff */
1821 uss_fs_OutBuff = (char *)malloc(USS_FS_MAX_SIZE); /*Cache Manager output buff */
1822 if (!uss_fs_InBuff || !uss_fs_OutBuff) {
1823 fprintf(stderr, "%s: Can't malloc in/out buffers\n", uss_whoami);
1827 /* ----------------------------- add ----------------------------- */
1829 cs = cmd_CreateSyntax("add", AddUser, NULL, "create a new user account");
1830 cmd_AddParm(cs, "-user", CMD_SINGLE, 0, "login name");
1831 cmd_AddParm(cs, "-realname", CMD_SINGLE, CMD_OPTIONAL,
1832 "full name in quotes");
1833 cmd_AddParm(cs, "-pass", CMD_SINGLE, CMD_OPTIONAL, "initial password");
1835 cmd_AddParm(cs, "-pwexpires", CMD_SINGLE, CMD_OPTIONAL,
1836 "password expires in [0..254] days (0 => never)");
1837 cmd_AddParm(cs, "-server", CMD_SINGLE, CMD_OPTIONAL,
1838 "FileServer for home volume");
1839 cmd_AddParm(cs, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1840 "FileServer's disk partition for home volume");
1841 cmd_AddParm(cs, "-mount", CMD_SINGLE, CMD_OPTIONAL,
1842 "home directory mount point");
1843 cmd_AddParm(cs, "-uid", CMD_SINGLE, CMD_OPTIONAL,
1844 "uid to assign the user");
1845 cmd_Seek(cs, AUSS_TEMPLATE);
1846 cmd_AddParm(cs, "-template", CMD_SINGLE, CMD_OPTIONAL,
1847 "pathname of template file");
1848 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1849 cmd_AddParm(cs, "-var", CMD_LIST, CMD_OPTIONAL | CMD_EXPANDS,
1850 "auxiliary argument pairs (Num val)");
1851 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1852 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1853 "administrator to authenticate");
1854 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1855 "only list what would be done, don't do it");
1856 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1857 "ignore all contact with the authentication server (kaserver)");
1858 cmd_AddParm(cs, "-overwrite", CMD_FLAG, CMD_OPTIONAL,
1859 "Overwrite pre-existing files in user home directory tree");
1862 /* ---------------------------- bulk ----------------------------- */
1864 cs = cmd_CreateSyntax("bulk", HandleBulk, NULL, "bulk input mode");
1865 cmd_AddParm(cs, "-file", CMD_SINGLE, 0, "bulk input file");
1866 cmd_Seek(cs, AUSS_TEMPLATE);
1867 cmd_AddParm(cs, "-template", CMD_SINGLE, CMD_OPTIONAL,
1868 "pathname of template file");
1869 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1870 cmd_Seek(cs, AUSS_CELL);
1871 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1872 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1873 "administrator to authenticate");
1874 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1875 "only list what would be done, don't do it");
1876 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1877 "ignore all contact with the authentication server (kaserver)");
1878 cmd_AddParm(cs, "-overwrite", CMD_FLAG, CMD_OPTIONAL,
1879 "Overwrite pre-existing files in user home directory tree");
1880 cmd_Seek(cs, AUSS_PWEXPIRES);
1881 cmd_AddParm(cs, "-pwexpires", CMD_SINGLE, CMD_OPTIONAL,
1882 "password expires in [0..254] days (0 => never)");
1883 cmd_Seek(cs, AUSS_PIPE);
1884 cmd_AddParm(cs, "-pipe", CMD_FLAG, CMD_OPTIONAL,
1885 "don't prompt for passwd; get it from standard input");
1887 /* ---------------------------- delete --------------------------- */
1889 cs = cmd_CreateSyntax("delete", DelUser, NULL, "delete a user account");
1890 cmd_AddParm(cs, "-user", CMD_SINGLE, 0, "login name");
1891 cmd_AddParm(cs, "-mountpoint", CMD_SINGLE, CMD_OPTIONAL,
1892 "mountpoint for user's volume");
1893 #if USS_FUTURE_FEATURES
1894 #if USS_DONT_HIDE_SOME_FEATURES
1895 cmd_AddParm(cs, "-restoredir", CMD_SINGLE, 0,
1896 "directory where restore info is to be placed");
1897 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1898 #endif /* USS_FUTURE_FEATURES */
1899 cmd_AddParm(cs, "-savevolume", CMD_FLAG, CMD_OPTIONAL,
1900 "don't destroy the user's volume");
1901 #if USS_FUTURE_FEATURES
1902 #if USS_DONT_HIDE_SOME_FEATURES
1903 cmd_AddParm(cs, "-pwdpath", CMD_SINGLE, CMD_OPTIONAL,
1904 "pathname to the password file");
1905 cmd_AddParm(cs, "-pwdformat", CMD_SINGLE, CMD_OPTIONAL,
1906 "password entry format");
1907 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1908 #endif /* USS_FUTURE_FEATURES */
1909 cmd_Seek(cs, AUSS_VERBOSE);
1910 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1911 cmd_Seek(cs, AUSS_CELL);
1912 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1913 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1914 "administrator to authenticate");
1915 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1916 "only list what would be done, don't do it");
1917 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1918 "ignore all contact with the authentication server (kaserver)");
1919 #if USS_FUTURE_FEATURES
1920 #if USS_DONT_HIDE_SOME_FEATURES
1921 /* ------------------------- purgevolumes ------------------------ */
1923 cs = cmd_CreateSyntax("purgevolumes", PurgeVolumes, NULL,
1924 "destroy a deleted user's volume");
1925 cmd_AddParm(cs, "-volname", CMD_LIST, CMD_OPTIONAL | CMD_EXPANDS,
1926 "Name(s) of volume(s) to destroy");
1927 cmd_AddParm(cs, "-volfile", CMD_SINGLE, CMD_OPTIONAL,
1928 "pathname to volume purge file");
1929 cmd_Seek(cs, AUSS_VERBOSE);
1930 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1931 cmd_Seek(cs, AUSS_CELL);
1932 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1933 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1934 "administrator to authenticate");
1935 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1936 "only list what would be done, don't do it");
1937 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1938 "ignore all contact with the authentication server (kaserver)");
1939 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1940 #endif /* USS_FUTURE_FEATURES */
1942 #if USS_FUTURE_FEATURES
1943 #if USS_DONT_HIDE_SOME_FEATURES
1944 /* ---------------------------- restore -------------------------- */
1946 cs = cmd_CreateSyntax("restore", RestoreUser, NULL,
1947 "restore a deleted user account");
1948 cmd_AddParm(cs, "-user", CMD_SINGLE, 0, "login name to restore");
1949 cmd_AddParm(cs, "-uid", CMD_SINGLE, 0, "user id number");
1950 cmd_AddParm(cs, "-mount", CMD_SINGLE, 0, "mountpoint for user's volume");
1951 cmd_AddParm(cs, "-volname", CMD_SINGLE, 0, "name of user's volume");
1952 cmd_AddParm(cs, "-realname", CMD_SINGLE, CMD_OPTIONAL,
1953 "user's full name");
1954 cmd_AddParm(cs, "-server", CMD_SINGLE, CMD_OPTIONAL,
1955 "FileServer to host user's volume");
1956 cmd_AddParm(cs, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1957 "FileServer partition to host user's volume");
1958 cmd_AddParm(cs, "-pwdpath", CMD_SINGLE, CMD_OPTIONAL,
1959 "pathname to the password file");
1960 cmd_AddParm(cs, "-pwdformat", CMD_SINGLE, CMD_OPTIONAL,
1961 "password entry format");
1962 cmd_Seek(cs, AUSS_VERBOSE);
1963 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1964 cmd_Seek(cs, AUSS_CELL);
1965 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1966 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1967 "administrator to authenticate");
1968 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1969 "only list what would be done, don't do it");
1970 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1971 "ignore all contact with the authentication server (kaserver)");
1972 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1973 #endif /* USS_FUTURE_FEATURES */
1976 * Set up all the error code translation tables, initialize the
1977 * command variables, and set up to parse the common command line
1982 cmd_SetBeforeProc(GetCommon, NULL);
1985 * Execute the parsed command.
1987 code = cmd_Dispatch(argc, argv);
1990 fprintf(stderr, "%s: Call to cmd_Dispatch() failed; code is %d\n",
1996 code = uss_fs_UnlogToken(uss_Cell);