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>
36 #include "uss_common.h" /*Common uss definitions, globals */
37 #include "uss_procs.h" /*Main uss operations */
38 #include "uss_kauth.h" /*AuthServer routines */
39 #include "uss_fs.h" /*CacheManager ops */
40 #include <afs/cmd.h> /*Command line parsing */
41 #include <afs/cellconfig.h> /*Cell config defs */
42 #include <afs/kautils.h> /*MAXKTCREALMLEN & MAXKTCNAMELEN */
46 * Label certain things which will be activated at a later time,
47 * as well as certain semi-implemented features/switches which need
48 * to be hidden for the general AFS 3.2 release.
50 #define USS_FUTURE_FEATURES 1
51 #define USS_DONT_HIDE_SOME_FEATURES 0
54 * ---------------------- Exported variables ----------------------
56 char *uss_fs_InBuff = NULL; /*Cache Manager input buff */
57 char *uss_fs_OutBuff = NULL; /*Cache Manager output buff */
60 * Set up convenient tags for the command line parameter indicies.
65 #define AUP_REALNAME 1
67 #define AUP_PWEXPIRES 3
68 #define AUP_SERVER 4 /* was 3 */
69 #define AUP_PART 5 /* was 4 */
70 #define AUP_MNTPT 6 /* was 5 */
71 #define AUP_UID 7 /* was 6 */
80 #define DUP_RESTOREDIR 2
81 #define DUP_SAVEVOLUME 3
83 #define DUP_PWDFORMAT 5
90 #define AUSS_TEMPLATE 10 /* was 7 */
91 #define AUSS_VERBOSE 11 /* was 8 */
92 #define AUSS_VAR 12 /* was 9 */
93 #define AUSS_CELL 13 /* was 10 */
94 #define AUSS_ADMIN 14 /* was 11 */
95 #define AUSS_DRYRUN 15 /* was 12 */
96 #define AUSS_SKIPAUTH 16 /* was 13 */
97 #define AUSS_OVERWRITE 17 /* was 14 */
98 #define AUSS_PWEXPIRES 18 /* was 15 */
99 #define AUSS_PIPE 19 /* was 16 */
103 static char Template[300] = "uss.template"; /*Default name */
105 extern FILE *yyin, *yyout; /*YACC input & output files */
107 int uss_BulkExpires = 0;
112 /*-----------------------------------------------------------------------
116 * Read in the command line arguments common to all uss operations.
119 * a_as : Ptr to the command line syntax descriptor.
125 * May exit the program if trouble is encountered determining the
126 * cell name. Set up as the command line parser's BeforeProc().
130 *------------------------------------------------------------------------*/
134 register struct cmd_syndesc *a_as;
138 int code; /*Result of ka_LocalCell */
140 if (strcmp(a_as->name, "help") == 0)
142 if (a_as->parms[AUSS_TEMPLATE].items)
143 strcpy(Template, a_as->parms[AUSS_TEMPLATE].items->data);
144 if (a_as->parms[AUSS_VERBOSE].items)
149 code = ka_CellConfig(AFSDIR_CLIENT_ETC_DIRPATH);
151 fprintf(stderr, "%s: ** Call to ka_CellConfig() failed (code=%d)\n",
154 if (a_as->parms[AUSS_CELL].items) {
155 char local_cell[MAXKTCREALMLEN];
157 (a_as->parms[AUSS_CELL].items->data, uss_Cell, 0 /*local */ )) {
158 fprintf(stderr, "%s: ** Unknown or ambiguous cell name: %s\n",
159 uss_whoami, a_as->parms[AUSS_CELL].items->data);
163 * Get the local cell name
165 if (ka_ExpandCell((char *)0, local_cell, 0 /*local */ )) {
166 fprintf(stderr, "Can't get local cellname\n");
169 if (strcmp(uss_Cell, local_cell)) {
171 * Not the same; not a local cell
177 * Get the local cell name
179 if (ka_ExpandCell((char *)0, uss_Cell, 0 /*local */ )) {
180 fprintf(stderr, "Can't get local cellname\n");
184 fprintf(stderr, "No cell specified; assuming '%s'.\n", uss_Cell);
192 /*-----------------------------------------------------------------------
193 * static SaveRestoreInfo
196 * Save all the information required to restore the currently
197 * parsed user account.
203 * 0 if everything went well,
204 * 1 if something went wrong in the function, or
205 * Lower-level error code if something went wrong below us.
208 * We need to determine and store the following new pieces of
211 * Name of user's volume
212 * FileServer & partition hosting the volume
216 *------------------------------------------------------------------------*/
220 { /*SaveRestoreInfo */
222 static char rn[] = "uss:SaveRestoreInfo"; /*Routine name */
223 register afs_int32 code; /*Return code */
224 afs_int32 deletedUid; /*Uid to be nuked */
227 * Translate the user name to the user ID.
229 code = uss_ptserver_XlateUser(uss_User, &deletedUid);
233 printf("%s: User '%s' translated to uid %d\n", rn, uss_User, deletedUid);
235 sprintf(uss_Uid, "%d", deletedUid);
238 * Pull out the name of the volume at the given mountpoint, along
239 * with the name of the FileServer and partition hosting it. This
240 * also sets up all the numerical info for the above.
242 code = uss_vol_GetVolInfoFromMountPoint(uss_MountPoint);
247 * Report back that we did fine.
251 } /*SaveRestoreInfo */
254 /*-----------------------------------------------------------------------
258 * With everything properly inserted into the common variables,
259 * delete the specified user account.
265 * 0 if everything went well,
266 * 1 if something went wrong in the function, or
267 * Lower-level error code if something went wrong below us.
270 * Nothing interesting.
274 *------------------------------------------------------------------------*/
280 int code; /*Return code */
283 * Make sure the user name is a lega one.
285 code = uss_kauth_CheckUserName();
290 * Store all the info about the account before actually doing
293 code = SaveRestoreInfo();
297 if ((uss_VolumeID != 0) && (uss_MountPoint[0] != '\0')) {
299 * Unmount the user's volume from the file system.
303 "Unmounting volume '%s' (ID %u) mounted at '%s'\n",
304 uss_Volume, uss_VolumeID, uss_MountPoint);
307 code = uss_fs_RmMountPoint(uss_MountPoint);
310 fprintf(stderr, "%s: Can't remove mountpoint '%s'\n",
311 uss_whoami, uss_MountPoint);
312 return (code); /* Must return - we may have incorrect volume */
317 * If our caller has elected to delete the user's volume now,
320 if (!uss_SaveVolume && (uss_VolumeID != 0)) {
322 fprintf(stderr, "Deleting volume '%s' (ID %u)\n", uss_Volume,
327 uss_vol_DeleteVol(uss_Volume, uss_VolumeID, uss_Server,
328 uss_ServerID, uss_Partition, uss_PartitionID);
331 fprintf(stderr, "%s: Can't delete volume '%s' (ID %u)\n",
332 uss_whoami, uss_Volume, uss_VolumeID);
335 } else if (uss_verbose && (uss_MountPoint[0] != '\0'))
336 printf("%s: Warning: Not attempting to delete volume at '%s'\n",
337 uss_whoami, uss_MountPoint);
340 * Get rid of the user's authentication entry.
342 code = uss_kauth_DelUser(uss_User);
347 * Finally, remove the user's AFS ID from the Protection DB and
348 * return that result.
350 code = uss_ptserver_DelUser(uss_User);
356 /*-----------------------------------------------------------------------
360 * Process the given (non-bulk) delete command.
363 * a_as : Ptr to the command line syntax descriptor.
364 * a_rock : Ptr to the rock passed in.
367 * 0 if everything went well,
368 * 1 if something went wrong in the function, or
369 * Lower-level error code if something went wrong below us.
372 * Nothing interesting.
376 *------------------------------------------------------------------------*/
379 DelUser(a_as, a_rock)
380 struct cmd_syndesc *a_as;
388 * Before we do anything else, make sure we initialize the
389 * global field settings.
394 * Pull out the fields as passed in by the caller on the command
397 strcpy(uss_User, a_as->parms[DUP_USER].items->data);
398 if (a_as->parms[DUP_MNTPT].items)
399 strcpy(uss_MountPoint, a_as->parms[DUP_MNTPT].items->data);
400 #if USS_FUTURE_FEATURES
401 #if USS_DONT_HIDE_SOME_FEATURES
402 strcpy(uss_RestoreDir, a_as->parms[DUP_RESTOREDIR].items->data);
403 #endif /* USS_DONT_HIDE_SOME_FEATURES */
404 #endif /* USS_FUTURE_FEATURES */
407 if (a_as->parms[DUP_SAVEVOLUME].items)
411 if (a_as->parms[2].items) {
414 #if USS_FUTURE_FEATURES
415 #if USS_DONT_HIDE_SOME_FEATURES
416 if (a_as->parms[DUP_PWDPATH].items)
417 strcpy(uss_PwdPath, a_as->parms[DUP_PWDPATH].items->data);
418 if (a_as->parms[DUP_PWDFORMAT].items)
419 strcpy(uss_PwdFormat, a_as->parms[DUP_PWDFORMAT].items->data);
420 #endif /* USS_DONT_HIDE_SOME_FEATURES */
421 #endif /* USS_FUTURE_FEATURES */
423 if (a_as->parms[AUSS_DRYRUN].items)
425 if (a_as->parms[AUSS_SKIPAUTH].items)
426 uss_SkipKaserver = 1;
427 if (a_as->parms[AUSS_ADMIN].items) {
428 strcpy(uss_Administrator, a_as->parms[AUSS_ADMIN].items->data);
429 /* fprintf(stderr, "debugging: uss_Administrator set to '%s'\n",
430 * uss_Administrator); */
432 /* fprintf(stderr, "debugging: No administrator value given\n"); */
433 uss_Administrator[0] = '\0';
437 * Initialize uss_AccountCreator().
439 code = uss_kauth_InitAccountCreator();
444 * Now that the command line arguments are parsed and properly stored,
453 /*-----------------------------------------------------------------------
454 * static PurgeVolumes
457 * Purge the given volume(s).
460 * a_as : Ptr to the command line syntax descriptor.
461 * a_rock : Ptr to the rock passed in.
464 * 0 if everything went well,
465 * 1 if something went wrong in the function, or
466 * Lower-level error code if something went wrong below us.
469 * Nothing interesting.
473 *------------------------------------------------------------------------*/
476 PurgeVolumes(a_as, a_rock)
477 struct cmd_syndesc *a_as;
482 fprintf(stderr, "Sorry, purgevolumes has not yet been implemented.\n");
488 /*-----------------------------------------------------------------------
492 * Process the given delete command.
495 * a_as : Ptr to the command line syntax descriptor.
496 * a_rock : Ptr to the rock passed in.
499 * 0 if everything went well,
500 * 1 if something went wrong in the function, or
501 * Lower-level error code if something went wrong below us.
504 * Nothing interesting.
508 *------------------------------------------------------------------------*/
511 RestoreUser(a_as, a_rock)
512 struct cmd_syndesc *a_as;
517 fprintf(stderr, "Sorry, restoreuser has not yet been implemented.\n");
523 /*-----------------------------------------------------------------------
524 * static DoBulkAddLine
527 * Process the given bulk add command.
530 * a_buf : Ptr to the buffer holding the bulk add command.
531 * a_tp : Ptr to the first char past the opcode.
534 * 0 if everything went well,
535 * -1 if something went wrong in the function, or
536 * Lower-level error code if something went wrong below us.
539 * The required fields are:
544 *------------------------------------------------------------------------*/
547 DoBulkAddLine(a_buf, a_tp)
553 register int i; /*Loop variable */
554 static char rn[] = "DoBulkAddLine"; /*Routine name */
555 int overflow; /*Overflow in field copy? */
558 printf("%s: Command buffer left to parse: '%s'\n", rn, a_tp);
560 uss_Expires = uss_BulkExpires;
563 * Pull out all the fields.
565 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
568 "%s: * User field in add cmd too long (max is %d chars; truncated value is '%s')\n",
569 uss_whoami, uss_UserLen, uss_User);
572 if ((*a_tp == '\0') || (*a_tp == '\n')) {
574 "%s: * The user field must appear in a bulk add command.\n",
580 uss_common_FieldCp(uss_RealName, a_tp, ':', uss_RealNameLen,
584 "%s: * Real name field in add cmd too long (max is %d chars; truncated value is '%s')\n",
585 uss_whoami, uss_RealNameLen, uss_RealName);
588 if (uss_RealName[0] == '\0') {
590 * The user's real name has not been supplied. As a
591 * default, we use the account name.
593 sprintf(uss_RealName, "%s", uss_User);
595 fprintf(stderr, "%s: Using default real name, '%s'\n", uss_whoami,
598 /*Use default full name */
599 a_tp = uss_common_FieldCp(uss_Pwd, a_tp, ':', uss_PwdLen, &overflow);
602 "%s: * Password field in add cmd too long (max is %d chars; truncated value is '%s')\n",
603 uss_whoami, uss_PwdLen, uss_Pwd);
606 if (uss_Pwd[0] == '\0') {
608 * The user's password has not been provided. Use
611 sprintf(uss_Pwd, "%s", uss_DEFAULT_PASSWORD);
613 fprintf(stderr, "%s: Using default password, '%s'\n", uss_whoami,
615 } /*Use default password */
616 if ((*a_tp == '\0') || (*a_tp == '\n'))
617 goto DoBulkAddLine_ParsingDone;
622 a_tp = uss_common_FieldCp(temp, a_tp, ':', 9, &overflow);
625 "%s: * Password expiration time is longer than %d characters, ignoring...\n",
628 if (temp[0] == '\0') {
629 /* Expiration time not specified. Use default */
631 fprintf(stderr, "%s: Using default expiration time, '%d'\n",
632 uss_whoami, uss_Expires);
636 if (te < 0 || te > 254) {
638 "%s: * Password Expiration must be in [0..254] days, using default %d\n",
639 uss_whoami, uss_Expires);
644 if ((*a_tp == '\0') || (*a_tp == '\n'))
645 goto DoBulkAddLine_ParsingDone;
650 uss_common_FieldCp(uss_Server, a_tp, ':', uss_ServerLen, &overflow);
653 "%s: * Server field in add cmd too long (max is %d chars; truncated value is '%s')\n",
654 uss_whoami, uss_ServerLen, uss_Server);
657 if ((*a_tp == '\0') || (*a_tp == '\n'))
658 goto DoBulkAddLine_ParsingDone;
661 uss_common_FieldCp(uss_Partition, a_tp, ':', uss_PartitionLen,
665 "%s: * Partition field in add cmd too long (max is %d chars; truncated value is '%s')\n",
666 uss_whoami, uss_PartitionLen, uss_Partition);
669 if ((*a_tp == '\0') || (*a_tp == '\n'))
670 goto DoBulkAddLine_ParsingDone;
673 uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
677 "%s: * Mountpoint field in add cmd too long (max is %d chars; truncated value is '%s')\n",
678 uss_whoami, uss_MountPointLen, uss_MountPoint);
681 if ((*a_tp == '\0') || (*a_tp == '\n'))
682 goto DoBulkAddLine_ParsingDone;
684 a_tp = uss_common_FieldCp(uss_Uid, a_tp, ':', uss_UidLen, &overflow);
687 "%s: * UID field in add cmd too long (max is %d chars; truncated value is '%s')\n",
688 uss_whoami, uss_UidLen, uss_Uid);
691 uss_DesiredUID = atoi(uss_Uid);
692 if ((*a_tp == '\0') || (*a_tp == '\n'))
693 goto DoBulkAddLine_ParsingDone;
695 for (uss_VarMax = 1; uss_VarMax < 10; uss_VarMax++) {
697 uss_common_FieldCp(uss_Var[uss_VarMax], a_tp, ':',
698 uss_MAX_ARG_SIZE, &overflow);
701 "%s: * Variable %d field in add cmd too long (max is %d chars; truncated value is '%s')\n",
702 uss_whoami, uss_VarMax, uss_MAX_ARG_SIZE,
703 uss_Var[uss_VarMax]);
706 if ((*a_tp == '\0') || (*a_tp == '\n'))
707 goto DoBulkAddLine_ParsingDone;
710 DoBulkAddLine_ParsingDone:
712 * If there's anything left on the line, we ignore it. Announce
713 * the bulk add parameters we've parsed or filled in if we're
714 * being verbose, then go for it.
718 "\nAdding user '%s' ('%s'), password='%s' on server '%s', partition '%s', home directory='%s'",
719 uss_User, uss_RealName, uss_Pwd,
720 (uss_Server[0] != '\0' ? uss_Server : "<default>"),
721 (uss_Partition[0] != '\0' ? uss_Partition : "<default>"),
722 (uss_MountPoint[0] != '\0' ? uss_MountPoint : "<default>"));
724 fprintf(stderr, ", uid preset to %d\n", uss_DesiredUID);
726 fprintf(stderr, ", no preset uid\n");
727 for (i = 1; i <= uss_VarMax; i++) {
728 if (uss_Var[i][0] != '\0')
729 fprintf(stderr, "$%1d='%s' ", i, uss_Var[i]);
732 fprintf(stderr, "\n");
735 /*Verbose status of add command */
737 * Now do the real work.
744 /*-----------------------------------------------------------------------
745 * static DoBulkDeleteLine
748 * Process the given bulk delete command.
751 * a_buf : Ptr to the buffer holding the bulk delete command.
752 * a_tp : Ptr to the first char past the opcode.
755 * 0 if everything went well,
756 * -1 if something went wrong in the function, or
757 * Lower-level error code if something went wrong below us.
760 * The required fields are:
761 * -user, -mountpoint, -restoredir
765 *------------------------------------------------------------------------*/
768 DoBulkDeleteLine(a_buf, a_tp)
772 { /*DoBulkDeleteLine */
774 char volField[32]; /*Value of optional vol disposition field */
775 int overflow; /*Was there an overflow in field copying? */
778 * Pull out all the fields.
780 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
783 "%s: * User field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
784 uss_whoami, uss_UserLen, uss_User);
787 if ((uss_User[0] == '\0') || (*a_tp == '\0') || (*a_tp == '\n'))
788 goto Delete_MissingRequiredParam;
791 uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
795 "%s: * Mountpoint field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
796 uss_whoami, uss_MountPointLen, uss_MountPoint);
799 #if USS_FUTURE_FEATURES
800 #if USS_DONT_HIDE_SOME_FEATURES
801 if ((uss_MountPoint[0] == '\0') || (*a_tp == '\0') || (*a_tp == '\n'))
802 goto Delete_MissingRequiredParam;
803 #endif /* USS_DONT_HIDE_SOME_FEATURES */
805 if ((*a_tp == '\0') || (*a_tp == '\n'))
806 goto Delete_ParsingDone;
807 #endif /* USS_FUTURE_FEATURES */
809 #if USS_FUTURE_FEATURES
810 #if USS_DONT_HIDE_SOME_FEATURES
812 uss_common_FieldCp(uss_RestoreDir, a_tp, ':', uss_RestoreDirLen,
816 "%s: * RestoreDir field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
817 uss_whoami, uss_RestoreDirLen, uss_RestoreDir);
820 if (uss_RestoreDir[0] == '\0')
821 goto Delete_MissingRequiredParam;
822 if ((*a_tp == '\0') || (*a_tp == '\n'))
823 goto Delete_ParsingDone;
826 uss_common_FieldCp(uss_PwdPath, a_tp, ':', uss_PwdPathLen, &overflow);
829 "%s: * Password path field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
830 uss_whoami, uss_PwdPathLen, uss_PwdPath);
833 if ((*a_tp == '\0') || (*a_tp == '\n'))
834 goto Delete_ParsingDone;
837 uss_common_FieldCp(uss_PwdFormat, a_tp, ':', uss_PwdFormatLen,
841 "%s: * Password format field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
842 uss_whoami, uss_PwdFormatLen, uss_PwdFormat);
845 if ((*a_tp == '\0') || (*a_tp == '\n'))
846 goto Delete_ParsingDone;
847 #endif /* USS_DONT_HIDE_SOME_FEATURES */
848 #endif /* USS_FUTURE_FEATURES */
850 a_tp = uss_common_FieldCp(volField, a_tp, ':', 32, &overflow);
853 "%s: * Volume save/del field in delete cmd too long (max is 32 chars; truncated value is '%s')\n",
854 uss_whoami, volField);
857 if ((*a_tp == '\0') || (*a_tp == '\n'))
858 goto Delete_ParsingDone;
860 if (strcmp(volField, "delvolume") == 0)
867 * If there's anything left on the line, we ignore it. Announce
868 * the bulk delete parameters we've parsed if we're being verbose,
872 #if USS_FUTURE_FEATURES
873 #if USS_DONT_HIDE_SOME_FEATURES
875 "\nDeleting user '%s' mounted at '%s', restoredir='%s', pwd path='%s', pwd format='%s'",
876 uss_User, uss_MountPoint, uss_RestoreDir, uss_PwdPath,
878 #endif /* USS_DONT_HIDE_SOME_FEATURES */
880 fprintf(stderr, "\nDeleting user '%s' mounted at '%s'", uss_User,
882 #endif /* USS_FUTURE_FEATURES */
884 fprintf(stderr, ", saving user's volume\n");
886 fprintf(stderr, ", deleting user's volume\n");
889 /*Verbose status of delete command */
891 * Now do the real work.
895 Delete_MissingRequiredParam:
897 "%s: * All of the user, mountpoint, and restoredir fields must appear in a bulk delete command line.\n",
901 } /*DoBulkDeleteLine */
903 #if USS_FUTURE_FEATURES
904 #if USS_DONT_HIDE_SOME_FEATURES
905 /*-----------------------------------------------------------------------
906 * static DoBulkPurgeVolumeLine
909 * Process the given bulk add command.
912 * a_buf : Ptr to the buffer holding the bulk add command.
913 * a_tp : Ptr to the first char past the opcode.
916 * 0 if everything went well,
917 * -1 if something went wrong in the function, or
918 * Lower-level error code if something went wrong below us.
921 * Nothing interesting.
925 *------------------------------------------------------------------------*/
928 DoBulkPurgeVolumeLine(a_buf, a_tp)
932 { /*DoBulkPurgeVolumeLine */
934 register int i; /*Loop variable */
935 int overflow; /*Did a field copy overflow happen? */
938 * Pull out all the fields.
940 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
943 "%s: * User field in purgevolume cmd too long (max is %d chars; truncated value is '%s')\n",
944 uss_whoami, uss_UserLen, uss_User);
947 if ((*a_tp == '\0') || (*a_tp == '\n')) {
949 "%s: * The user field must appear in a bulk add command.\n",
955 uss_common_FieldCp(uss_RealName, a_tp, ':', uss_RealNameLen,
959 "%s: * Real name field in purgevolume cmd too long (max is %d chars; truncated value is '%s')\n",
960 uss_whoami, uss_RealNameLen, uss_RealName);
963 if (uss_RealName[0] == '\0') {
965 * The user's real name has not been supplied. As a
966 * default, we use the account name.
968 sprintf(uss_RealName, "%s", uss_User);
970 fprintf(stderr, "%s: Using default real name, '%s'\n", uss_whoami,
973 /*Use default full name */
974 a_tp = uss_common_FieldCp(uss_Pwd, a_tp, ':', uss_PwdLen, &overflow);
977 "%s: * Password field in purgevolume cmd too long (max is %d chars; truncated value is '%s')\n",
978 uss_whoami, uss_PwdLen, uss_Pwd);
981 if (uss_Pwd[0] == '\0') {
983 * The user's password has not been provided. Use
986 sprintf(uss_Pwd, "%s", uss_DEFAULT_PASSWORD);
988 fprintf(stderr, "%s: Using default password, '%s'\n", uss_whoami,
990 } /*Use default password */
991 if ((*a_tp == '\0') || (*a_tp == '\n'))
995 uss_common_FieldCp(uss_Server, a_tp, ':', uss_ServerLen, &overflow);
997 fprintf(stderr, "%s: * Server field too long (max is %d chars)\n",
998 uss_whoami, uss_ServerLen);
1001 if ((*a_tp == '\0') || (*a_tp == '\n'))
1005 uss_common_FieldCp(uss_Partition, a_tp, ':', uss_PartitionLen,
1008 fprintf(stderr, "%s: * Partition field too long (max is %d chars)\n",
1009 uss_whoami, uss_PartitionLen);
1012 if ((*a_tp == '\0') || (*a_tp == '\n'))
1016 uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
1019 fprintf(stderr, "%s: * Mountpoint field too long (max is %d chars)\n",
1020 uss_whoami, uss_MountPointLen);
1023 if ((*a_tp == '\0') || (*a_tp == '\n'))
1026 a_tp = uss_common_FieldCp(uss_Uid, a_tp, ':', uss_UidLen, &overflow);
1028 fprintf(stderr, "%s: * UID field too long (max is %d chars)\n",
1029 uss_whoami, uss_UidLen);
1032 uss_DesiredUID = atoi(uss_Uid);
1033 if ((*a_tp == '\0') || (*a_tp == '\n'))
1036 for (uss_VarMax = 1; uss_VarMax < 10; uss_VarMax++) {
1038 uss_common_FieldCp(uss_Var[uss_VarMax], a_tp, ':',
1039 uss_MAX_ARG_SIZE, &overflow);
1042 "%s: * Variable %d field too long (max is %d chars)\n",
1043 uss_whoami, uss_VarMax, uss_MAX_ARG_SIZE);
1046 if ((*a_tp == '\0') || (*a_tp == '\n'))
1051 * If there's anything left on the line, we ignore it. Announce
1052 * the bulk add parameters we've parsed or filled in if we're
1053 * being verbose, then go for it.
1057 "\nAdding user '%s' ('%s'), password='%s' on server '%s', partition '%s', home directory='%s'",
1058 uss_User, uss_RealName, uss_Pwd,
1059 (uss_Server[0] != '\0' ? uss_Server : "<default>"),
1060 (uss_Partition[0] != '\0' ? uss_Partition : "<default>"),
1061 (uss_MountPoint[0] != '\0' ? uss_MountPoint : "<default>"));
1063 fprintf(stderr, ", uid preset to %d\n", uss_DesiredUID);
1065 fprintf(stderr, ", no preset uid\n");
1066 for (i = 1; i <= uss_VarMax; i++) {
1067 if (uss_Var[i][0] != '\0')
1068 fprintf(stderr, "$%1d='%s' ", i, uss_Var[i]);
1071 fprintf(stderr, "\n");
1074 /*Verbose status of add command */
1076 * Now do the real work.
1080 } /*DoBulkPurgeVolumeLine */
1081 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1082 #endif /* USS_FUTURE_FEATURES */
1084 #if USS_FUTURE_FEATURES
1085 #if USS_DONT_HIDE_SOME_FEATURES
1086 /*-----------------------------------------------------------------------
1087 * static DoBulkRestoreLine
1090 * Process the given bulk add command.
1093 * a_buf : Ptr to the buffer holding the bulk add command.
1094 * a_tp : Ptr to the first char past the opcode.
1097 * 0 if everything went well,
1098 * -1 if something went wrong in the function, or
1099 * Lower-level error code if something went wrong below us.
1102 * Nothing interesting.
1106 *------------------------------------------------------------------------*/
1109 DoBulkRestoreLine(a_buf, a_tp)
1113 { /*DoBulkRestoreLine */
1115 register int i; /*Loop variable */
1116 int overflow; /*Overflow occur on field copy? */
1119 * Pull out all the fields.
1121 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
1123 fprintf(stderr, "%s: * User field too long (max is %d chars)\n",
1124 uss_whoami, uss_UserLen);
1127 if ((*a_tp == '\0') || (*a_tp == '\n')) {
1129 "%s: * The user field must appear in a bulk add command.\n",
1135 uss_common_FieldCp(uss_RealName, a_tp, ':', uss_RealNameLen,
1138 fprintf(stderr, "%s: * Real name field too long (max is %d chars)\n",
1139 uss_whoami, uss_RealNameLen);
1142 if (uss_RealName[0] == '\0') {
1144 * The user's real name has not been supplied. As a
1145 * default, we use the account name.
1147 sprintf(uss_RealName, "%s", uss_User);
1149 fprintf(stderr, "%s: Using default real name, '%s'\n", uss_whoami,
1152 /*Use default full name */
1153 a_tp = uss_common_FieldCp(uss_Pwd, a_tp, ':', uss_PwdLen, &overflow);
1155 fprintf(stderr, "%s: * Password field too long (max is %d chars)\n",
1156 uss_whoami, uss_PwdLen);
1159 if (uss_Pwd[0] == '\0') {
1161 * The user's password has not been provided. Use
1164 sprintf(uss_Pwd, "%s", uss_DEFAULT_PASSWORD);
1166 fprintf(stderr, "%s: Using default password, '%s'\n", uss_whoami,
1168 } /*Use default password */
1169 if ((*a_tp == '\0') || (*a_tp == '\n'))
1173 uss_common_FieldCp(uss_Server, a_tp, ':', uss_ServerLen, &overflow);
1175 fprintf(stderr, "%s: * Server field too long (max is %d chars)\n",
1176 uss_whoami, uss_ServerLen);
1179 if ((*a_tp == '\0') || (*a_tp == '\n'))
1183 uss_common_FieldCp(uss_Partition, a_tp, ':', uss_PartitionLen,
1186 fprintf(stderr, "%s: * Partition field too long (max is %d chars)\n",
1187 uss_whoami, uss_PartitionLen);
1190 if ((*a_tp == '\0') || (*a_tp == '\n'))
1194 uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
1197 fprintf(stderr, "%s: * mountpoint field too long (max is %d chars)\n",
1198 uss_whoami, uss_MountPointLen);
1201 if ((*a_tp == '\0') || (*a_tp == '\n'))
1204 a_tp = uss_common_FieldCp(uss_Uid, a_tp, ':', uss_UidLen, &overflow);
1206 fprintf(stderr, "%s: * UID field too long (max is %d chars)\n",
1207 uss_whoami, uss_UidLen);
1210 uss_DesiredUID = atoi(uss_Uid);
1211 if ((*a_tp == '\0') || (*a_tp == '\n'))
1214 for (uss_VarMax = 1; uss_VarMax < 10; uss_VarMax++) {
1216 uss_common_FieldCp(uss_Var[uss_VarMax], a_tp, ':',
1217 uss_MAX_ARG_SIZE, &overflow);
1220 "%s: * Variable %d field too long (max is %d chars)\n",
1221 uss_whoami, uss_VarMax, uss_MAX_ARG_SIZE);
1224 if ((*a_tp == '\0') || (*a_tp == '\n'))
1229 * If there's anything left on the line, we ignore it. Announce
1230 * the bulk add parameters we've parsed or filled in if we're
1231 * being verbose, then go for it.
1235 "\nAdding user '%s' ('%s'), password='%s' on server '%s', partition '%s', home directory='%s'",
1236 uss_User, uss_RealName, uss_Pwd,
1237 (uss_Server[0] != '\0' ? uss_Server : "<default>"),
1238 (uss_Partition[0] != '\0' ? uss_Partition : "<default>"),
1239 (uss_MountPoint[0] != '\0' ? uss_MountPoint : "<default>"));
1241 fprintf(stderr, ", uid preset to %d\n", uss_DesiredUID);
1243 fprintf(stderr, ", no preset uid\n");
1244 for (i = 1; i <= uss_VarMax; i++) {
1245 if (uss_Var[i][0] != '\0')
1246 fprintf(stderr, "$%1d='%s' ", i, uss_Var[i]);
1249 fprintf(stderr, "\n");
1252 /*Verbose status of add command */
1254 * Now do the real work.
1256 return (DoRestore());
1258 } /*DoBulkRestoreLine */
1259 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1260 #endif /* USS_FUTURE_FEATURES */
1263 /*-----------------------------------------------------------------------
1264 * static DoBulkExecLine
1267 * Process the given bulk exec command.
1270 * a_buf : Ptr to the buffer holding the bulk exec command.
1271 * a_tp : Ptr to the first char past the opcode.
1274 * 0 if everything went well,
1275 * -1 if something went wrong in the function, or
1276 * Lower-level error code if something went wrong below us.
1279 * Nothing interesting.
1283 *------------------------------------------------------------------------*/
1286 DoBulkExecLine(a_buf, a_tp)
1290 { /*DoBulkExecLine */
1292 register afs_int32 code; /*Return code */
1295 * Really, uss_procs_Exec does all the work for us!
1297 code = uss_procs_Exec(a_tp);
1300 } /*DoBulkExecLine */
1303 /*-----------------------------------------------------------------------
1307 * Process the given bulk command.
1310 * a_as : Ptr to the command line syntax descriptor.
1311 * a_rock : Ptr to the rock passed in.
1314 * 0 if everything went well,
1315 * 1 if something went wrong in the function, or
1316 * Lower-level error code if something went wrong below us.
1319 * Nothing interesting.
1323 *------------------------------------------------------------------------*/
1326 HandleBulk(a_as, a_rock)
1327 register struct cmd_syndesc *a_as;
1332 #define USS_BULK_CMD_CHARS 128
1333 #define USS_BULK_BUF_CHARS 1024
1335 char cmd[USS_BULK_CMD_CHARS], buf[USS_BULK_BUF_CHARS];
1343 char tbuf[USS_BULK_BUF_CHARS];
1346 * Open up the bulk file, croak if we can't.
1348 if ((infile = fopen(a_as->parms[ABULK_FILE].items->data, "r")) == NULL) {
1349 fprintf(stderr, "%s: * Failed to open input file %s\n", uss_whoami,
1350 a_as->parms[ABULK_FILE].items->data);
1355 * Pull out the other fields as passed in by the caller on the
1358 if (a_as->parms[AUSS_DRYRUN].items)
1360 if (a_as->parms[AUSS_SKIPAUTH].items)
1361 uss_SkipKaserver = 1;
1362 if (a_as->parms[AUSS_OVERWRITE].items)
1364 if (a_as->parms[AUSS_PIPE].items)
1366 if (a_as->parms[AUSS_ADMIN].items)
1367 strcpy(uss_Administrator, a_as->parms[AUSS_ADMIN].items->data);
1369 uss_Administrator[0] = '\0';
1371 if (a_as->parms[AUSS_PWEXPIRES].items) {
1372 uss_BulkExpires = atoi(a_as->parms[AUSS_PWEXPIRES].items->data);
1373 if (uss_BulkExpires < 0 || uss_BulkExpires > 254) {
1375 "%s: Password Expiration must be in [0..255] days\n",
1380 uss_BulkExpires = 0;
1383 * Initialize uss_AccountCreator().
1385 code = uss_kauth_InitAccountCreator();
1390 * Process all the lines in the bulk command file.
1392 uss_VarMax = 0; /*No uss vars picked up yet */
1393 while (fgets(buf, sizeof(buf), infile) != NULL) {
1395 /* skip blank line */
1400 /* After executing the line, print the line and the result */
1402 if (error == UNOQUORUM) {
1408 printf("LINE %d %s %s", line_no, (error ? "FAIL" : "SUCCESS"),
1414 * Reset the common variables for each command line
1419 strncpy(tbuf, buf, USS_BULK_BUF_CHARS-1);
1422 * First line of file = line 1.
1428 * Get the opcode and act upon it.
1430 tp = uss_common_FieldCp(cmd, buf, ' ', USS_BULK_CMD_CHARS, &overflow);
1433 "%s: * Bulk opcode field too long (max is %d chars)\n",
1434 uss_whoami, USS_BULK_CMD_CHARS);
1442 if (strcmp(cmd, "add") == 0) {
1443 error = DoBulkAddLine(buf, tp);
1446 if (strcmp(cmd, "delete") == 0) {
1447 error = DoBulkDeleteLine(buf, tp);
1450 if (strcmp(cmd, "delvolume") == 0) {
1455 #if USS_FUTURE_FEATURES
1456 #if USS_DONT_HIDE_SOME_FEATURES
1457 if (strcmp(cmd, "purgevolume") == 0) {
1458 error = DoBulkPurgeVolumeLine(buf, tp);
1461 if (strcmp(cmd, "pwdformat") == 0) {
1462 /*Set the password format here */
1465 if (strcmp(cmd, "pwdpath") == 0) {
1466 /*Set the password path here */
1469 if (strcmp(cmd, "restore") == 0) {
1470 error = DoBulkRestoreLine(buf, tp);
1473 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1474 #endif /* USS_FUTURE_FEATURES */
1475 if (strcmp(cmd, "savevolume") == 0) {
1476 /*Set the savevolume flag here */
1479 if (strcmp(cmd, "exec") == 0) {
1480 error = DoBulkExecLine(buf, tp);
1485 * If none of the valid opcodes match, see if the line is either
1486 * a comment of a blank. If so, just ignore it. Otherwise, we
1489 if ((cmd[0] != '#') && (cmd[0] != '\0')) {
1491 "%s: ** Unrecognized command ('%s') in bulk file\n",
1500 } /*Bad bulk line */
1501 } /*Process a line in the bulk file */
1507 printf("LINE %d %s %s", line_no, (error ? "FAIL" : "SUCCESS"), tbuf);
1515 /*-----------------------------------------------------------------------
1519 * Process the given (non-bulk) add command.
1522 * a_as : Ptr to the command line syntax descriptor.
1523 * a_rock : Ptr to the rock passed in.
1526 * 0 if everything went well,
1527 * 1 if something went wrong in the function, or
1528 * Lower-level error code if something went wrong below us.
1531 * Nothing interesting.
1535 *------------------------------------------------------------------------*/
1538 AddUser(a_as, a_rock)
1539 register struct cmd_syndesc *a_as;
1545 register struct cmd_item *ti;
1549 * Before we do anything else, make sure we initialize the
1550 * global field settings.
1555 * Pull out the fields as passed in by the caller on the command
1558 strcpy(uss_User, a_as->parms[AUP_USER].items->data);
1559 if (a_as->parms[AUP_REALNAME].items)
1560 strcpy(uss_RealName, a_as->parms[AUP_REALNAME].items->data);
1562 strcpy(uss_RealName, uss_User);
1563 if (a_as->parms[AUP_PASSWD].items)
1564 strcpy(uss_Pwd, a_as->parms[AUP_PASSWD].items->data);
1566 strcpy(uss_Pwd, uss_DEFAULT_PASSWORD);
1567 if (a_as->parms[AUP_SERVER].items)
1568 strcpy(uss_Server, a_as->parms[AUP_SERVER].items->data);
1569 if (a_as->parms[AUP_PART].items)
1570 strcpy(uss_Partition, a_as->parms[AUP_PART].items->data);
1571 if (a_as->parms[AUP_MNTPT].items)
1572 strcpy(uss_MountPoint, a_as->parms[AUP_MNTPT].items->data);
1573 if (a_as->parms[AUP_UID].items)
1574 uss_DesiredUID = atoi(a_as->parms[AUP_UID].items->data);
1577 if (a_as->parms[AUP_PWEXPIRES].items) {
1578 uss_Expires = atoi(a_as->parms[AUP_PWEXPIRES].items->data);
1579 if (uss_Expires < 0 || uss_Expires > 254) {
1581 "%s: Password Expiration must be in [0..255] days\n",
1588 if (a_as->parms[AUSS_DRYRUN].items)
1590 if (a_as->parms[AUSS_SKIPAUTH].items)
1591 uss_SkipKaserver = 1;
1592 if (a_as->parms[AUSS_OVERWRITE].items)
1594 if (a_as->parms[AUSS_ADMIN].items) {
1595 strcpy(uss_Administrator, a_as->parms[AUSS_ADMIN].items->data);
1596 /* fprintf(stderr, "debugging: uss_Administrator set to '%s'\n",
1597 * uss_Administrator); */
1599 /* fprintf(stderr, "debugging: No administrator value given\n"); */
1600 uss_Administrator[0] = '\0';
1603 if (a_as->parms[AUSS_VAR].items) {
1604 for (ti = a_as->parms[AUSS_VAR].items; ti; ti = ti->next) {
1606 if (i < 0 || i > 9 || (i == 0 && *ti->data != '0')) {
1608 "%s: Bad -var format: must be '0 val0 1 val1 ... 9 val9'\n",
1615 "%s: -var values must appear in pairs: 'Num val'\n",
1619 strcpy(uss_Var[i], ti->data);
1622 } /*Remember each VAR item */
1625 /*VAR items exist */
1627 * Initialize uss_AccountCreator().
1629 code = uss_kauth_InitAccountCreator();
1634 * Now that the command line arguments are parsed and properly stored,
1642 /*-----------------------------------------------------------------------
1646 * Create the desired user account, having parsed the add command
1647 * from either the command line or a bulk file.
1653 * 0 if everything went well,
1654 * 1 if something went wrong in the function, or
1655 * Lower-level error code if something went wrong below us.
1658 * All values needed have been put in the common variables.
1662 *------------------------------------------------------------------------*/
1668 int code; /*Return code */
1671 * Make sure the user name is legal.
1673 code = uss_kauth_CheckUserName();
1678 * This time around, we start off assuming the global value of the
1681 uss_OverwriteThisOne = uss_Overwrite;
1684 * Open up the template file before doing any real processing,
1685 * so we can quit early should it not be found.
1688 if ((yyin = uss_procs_FindAndOpen(Template)) == NULL) {
1689 fprintf(stderr, "%s: ** Can't open template file '%s'\n",
1690 uss_whoami, Template);
1693 yyout = fopen("/dev/null", "w");
1698 * Add the new user to the Protection DB.
1700 code = uss_ptserver_AddUser(uss_User, uss_Uid);
1702 fprintf(stderr, "%s: Failed to add user '%s' to the Protection DB\n",
1703 uss_whoami, uss_User);
1708 * Add the new user to the Authentication DB.
1710 code = uss_kauth_AddUser(uss_User, uss_Pwd);
1712 fprintf(stderr, "%s: Can't add user '%s' to the Authentication DB\n",
1713 uss_whoami, uss_User);
1718 * Process the items covered by the template file.
1720 if (yyparse() && (!uss_ignoreFlag))
1724 * Finally, clean up after ourselves, removing the uss_AccountCreator
1725 * from various of the new user's ACLs.
1727 return (uss_acl_CleanUp());
1732 #if USS_FUTURE_FEATURES
1733 #if USS_DONT_HIDE_SOME_FEATURES
1734 /*-----------------------------------------------------------------------
1738 * Perform the parsed restore command.
1744 * 0 if everything went well,
1745 * 1 if something went wrong in the function, or
1746 * Lower-level error code if something went wrong below us.
1749 * All values needed have been put in the common variables.
1753 *------------------------------------------------------------------------*/
1762 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1763 #endif /* USS_FUTURE_FEATURES */
1766 /*-----------------------------------------------------------------------
1767 * static InitETTables
1770 * Set up the error code tables for the various modules we use.
1779 * Nothing interesting.
1783 *------------------------------------------------------------------------*/
1791 * In order to get error code -> error message translations to work,
1792 * we have to initialize all error tables.
1794 initialize_CMD_error_table();
1795 initialize_RXK_error_table();
1796 initialize_KTC_error_table();
1797 initialize_KA_error_table();
1798 initialize_ACFG_error_table();
1799 initialize_VL_error_table();
1800 initialize_PT_error_table();
1801 initialize_U_error_table();
1809 /* this sucks but it works for now.
1814 #include "AFS_component_version_number.c"
1822 register struct cmd_syndesc *cs; /*Command line syntax descriptor */
1823 register afs_int32 code; /*Return code */
1825 #ifdef AFS_AIX32_ENV
1827 * The following signal action for AIX is necessary so that in case of a
1828 * crash (i.e. core is generated) we can include the user's data section
1829 * in the core dump. Unfortunately, by default, only a partial core is
1830 * generated which, in many cases, isn't too useful.
1832 struct sigaction nsa;
1834 sigemptyset(&nsa.sa_mask);
1835 nsa.sa_handler = SIG_DFL;
1836 nsa.sa_flags = SA_FULLDUMP;
1837 sigaction(SIGABRT, &nsa, NULL);
1838 sigaction(SIGSEGV, &nsa, NULL);
1840 strcpy(uss_whoami, argv[0]);
1841 yyin = (FILE *) NULL;
1843 uss_fs_InBuff = (char *)malloc(USS_FS_MAX_SIZE); /*Cache Manager input buff */
1844 uss_fs_OutBuff = (char *)malloc(USS_FS_MAX_SIZE); /*Cache Manager output buff */
1845 if (!uss_fs_InBuff || !uss_fs_OutBuff) {
1846 fprintf(stderr, "%s: Can't malloc in/out buffers\n", uss_whoami);
1850 /* ----------------------------- add ----------------------------- */
1852 cs = cmd_CreateSyntax("add", AddUser, 0, "create a new user account");
1853 cmd_AddParm(cs, "-user", CMD_SINGLE, 0, "login name");
1854 cmd_AddParm(cs, "-realname", CMD_SINGLE, CMD_OPTIONAL,
1855 "full name in quotes");
1856 cmd_AddParm(cs, "-pass", CMD_SINGLE, CMD_OPTIONAL, "initial password");
1858 cmd_AddParm(cs, "-pwexpires", CMD_SINGLE, CMD_OPTIONAL,
1859 "password expires in [0..254] days (0 => never)");
1860 cmd_AddParm(cs, "-server", CMD_SINGLE, CMD_OPTIONAL,
1861 "FileServer for home volume");
1862 cmd_AddParm(cs, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1863 "FileServer's disk partition for home volume");
1864 cmd_AddParm(cs, "-mount", CMD_SINGLE, CMD_OPTIONAL,
1865 "home directory mount point");
1866 cmd_AddParm(cs, "-uid", CMD_SINGLE, CMD_OPTIONAL,
1867 "uid to assign the user");
1868 cmd_Seek(cs, AUSS_TEMPLATE);
1869 cmd_AddParm(cs, "-template", CMD_SINGLE, CMD_OPTIONAL,
1870 "pathname of template file");
1871 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1872 cmd_AddParm(cs, "-var", CMD_LIST, CMD_OPTIONAL | CMD_EXPANDS,
1873 "auxiliary argument pairs (Num val)");
1874 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1875 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1876 "administrator to authenticate");
1877 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1878 "only list what would be done, don't do it");
1879 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1880 "ignore all contact with the authentication server (kaserver)");
1881 cmd_AddParm(cs, "-overwrite", CMD_FLAG, CMD_OPTIONAL,
1882 "Overwrite pre-existing files in user home directory tree");
1885 /* ---------------------------- bulk ----------------------------- */
1887 cs = cmd_CreateSyntax("bulk", HandleBulk, 0, "bulk input mode");
1888 cmd_AddParm(cs, "-file", CMD_SINGLE, 0, "bulk input file");
1889 cmd_Seek(cs, AUSS_TEMPLATE);
1890 cmd_AddParm(cs, "-template", CMD_SINGLE, CMD_OPTIONAL,
1891 "pathname of template file");
1892 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1893 cmd_Seek(cs, AUSS_CELL);
1894 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1895 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1896 "administrator to authenticate");
1897 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1898 "only list what would be done, don't do it");
1899 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1900 "ignore all contact with the authentication server (kaserver)");
1901 cmd_AddParm(cs, "-overwrite", CMD_FLAG, CMD_OPTIONAL,
1902 "Overwrite pre-existing files in user home directory tree");
1903 cmd_Seek(cs, AUSS_PWEXPIRES);
1904 cmd_AddParm(cs, "-pwexpires", CMD_SINGLE, CMD_OPTIONAL,
1905 "password expires in [0..254] days (0 => never)");
1906 cmd_Seek(cs, AUSS_PIPE);
1907 cmd_AddParm(cs, "-pipe", CMD_FLAG, CMD_OPTIONAL,
1908 "don't prompt for passwd; get it from standard input");
1910 /* ---------------------------- delete --------------------------- */
1912 cs = cmd_CreateSyntax("delete", DelUser, 0, "delete a user account");
1913 cmd_AddParm(cs, "-user", CMD_SINGLE, 0, "login name");
1914 cmd_AddParm(cs, "-mountpoint", CMD_SINGLE, CMD_OPTIONAL,
1915 "mountpoint for user's volume");
1916 #if USS_FUTURE_FEATURES
1917 #if USS_DONT_HIDE_SOME_FEATURES
1918 cmd_AddParm(cs, "-restoredir", CMD_SINGLE, 0,
1919 "directory where restore info is to be placed");
1920 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1921 #endif /* USS_FUTURE_FEATURES */
1922 cmd_AddParm(cs, "-savevolume", CMD_FLAG, CMD_OPTIONAL,
1923 "don't destroy the user's volume");
1924 #if USS_FUTURE_FEATURES
1925 #if USS_DONT_HIDE_SOME_FEATURES
1926 cmd_AddParm(cs, "-pwdpath", CMD_SINGLE, CMD_OPTIONAL,
1927 "pathname to the password file");
1928 cmd_AddParm(cs, "-pwdformat", CMD_SINGLE, CMD_OPTIONAL,
1929 "password entry format");
1930 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1931 #endif /* USS_FUTURE_FEATURES */
1932 cmd_Seek(cs, AUSS_VERBOSE);
1933 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1934 cmd_Seek(cs, AUSS_CELL);
1935 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1936 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1937 "administrator to authenticate");
1938 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1939 "only list what would be done, don't do it");
1940 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1941 "ignore all contact with the authentication server (kaserver)");
1942 #if USS_FUTURE_FEATURES
1943 #if USS_DONT_HIDE_SOME_FEATURES
1944 /* ------------------------- purgevolumes ------------------------ */
1946 cs = cmd_CreateSyntax("purgevolumes", PurgeVolumes, 0,
1947 "destroy a deleted user's volume");
1948 cmd_AddParm(cs, "-volname", CMD_LIST, CMD_OPTIONAL | CMD_EXPANDS,
1949 "Name(s) of volume(s) to destroy");
1950 cmd_AddParm(cs, "-volfile", CMD_SINGLE, CMD_OPTIONAL,
1951 "pathname to volume purge file");
1952 cmd_Seek(cs, AUSS_VERBOSE);
1953 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1954 cmd_Seek(cs, AUSS_CELL);
1955 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1956 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1957 "administrator to authenticate");
1958 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1959 "only list what would be done, don't do it");
1960 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1961 "ignore all contact with the authentication server (kaserver)");
1962 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1963 #endif /* USS_FUTURE_FEATURES */
1965 #if USS_FUTURE_FEATURES
1966 #if USS_DONT_HIDE_SOME_FEATURES
1967 /* ---------------------------- restore -------------------------- */
1969 cs = cmd_CreateSyntax("restore", RestoreUser, 0,
1970 "restore a deleted user account");
1971 cmd_AddParm(cs, "-user", CMD_SINGLE, 0, "login name to restore");
1972 cmd_AddParm(cs, "-uid", CMD_SINGLE, 0, "user id number");
1973 cmd_AddParm(cs, "-mount", CMD_SINGLE, 0, "mountpoint for user's volume");
1974 cmd_AddParm(cs, "-volname", CMD_SINGLE, 0, "name of user's volume");
1975 cmd_AddParm(cs, "-realname", CMD_SINGLE, CMD_OPTIONAL,
1976 "user's full name");
1977 cmd_AddParm(cs, "-server", CMD_SINGLE, CMD_OPTIONAL,
1978 "FileServer to host user's volume");
1979 cmd_AddParm(cs, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1980 "FileServer partition to host user's volume");
1981 cmd_AddParm(cs, "-pwdpath", CMD_SINGLE, CMD_OPTIONAL,
1982 "pathname to the password file");
1983 cmd_AddParm(cs, "-pwdformat", CMD_SINGLE, CMD_OPTIONAL,
1984 "password entry format");
1985 cmd_Seek(cs, AUSS_VERBOSE);
1986 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1987 cmd_Seek(cs, AUSS_CELL);
1988 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1989 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1990 "administrator to authenticate");
1991 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1992 "only list what would be done, don't do it");
1993 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1994 "ignore all contact with the authentication server (kaserver)");
1995 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1996 #endif /* USS_FUTURE_FEATURES */
1999 * Set up all the error code translation tables, initialize the
2000 * command variables, and set up to parse the common command line
2005 cmd_SetBeforeProc(GetCommon, NULL);
2008 * Execute the parsed command.
2010 code = cmd_Dispatch(argc, argv);
2013 fprintf(stderr, "%s: Call to cmd_Dispatch() failed; code is %d\n",
2019 code = uss_fs_UnlogToken(uss_Cell);