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>
35 #include "uss_common.h" /*Common uss definitions, globals*/
36 #include "uss_procs.h" /*Main uss operations*/
37 #include "uss_kauth.h" /*AuthServer routines*/
38 #include "uss_fs.h" /*CacheManager ops*/
39 #include <afs/cmd.h> /*Command line parsing*/
40 #include <afs/cellconfig.h> /*Cell config defs*/
41 #include <afs/kautils.h> /*MAXKTCREALMLEN & MAXKTCNAMELEN*/
45 * Label certain things which will be activated at a later time,
46 * as well as certain semi-implemented features/switches which need
47 * to be hidden for the general AFS 3.2 release.
49 #define USS_FUTURE_FEATURES 1
50 #define USS_DONT_HIDE_SOME_FEATURES 0
53 * ---------------------- Exported variables ----------------------
55 char *uss_fs_InBuff = NULL; /*Cache Manager input buff*/
56 char *uss_fs_OutBuff = NULL; /*Cache Manager output buff*/
59 * Set up convenient tags for the command line parameter indicies.
64 #define AUP_REALNAME 1
66 #define AUP_PWEXPIRES 3
67 #define AUP_SERVER 4 /* was 3 */
68 #define AUP_PART 5 /* was 4 */
69 #define AUP_MNTPT 6 /* was 5 */
70 #define AUP_UID 7 /* was 6 */
79 #define DUP_RESTOREDIR 2
80 #define DUP_SAVEVOLUME 3
82 #define DUP_PWDFORMAT 5
89 #define AUSS_TEMPLATE 10 /* was 7 */
90 #define AUSS_VERBOSE 11 /* was 8 */
91 #define AUSS_VAR 12 /* was 9 */
92 #define AUSS_CELL 13 /* was 10 */
93 #define AUSS_ADMIN 14 /* was 11 */
94 #define AUSS_DRYRUN 15 /* was 12 */
95 #define AUSS_SKIPAUTH 16 /* was 13 */
96 #define AUSS_OVERWRITE 17 /* was 14 */
97 #define AUSS_PWEXPIRES 18 /* was 15 */
98 #define AUSS_PIPE 19 /* was 16 */
102 static char Template[300]=
103 "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 *------------------------------------------------------------------------*/
132 static afs_int32 GetCommon(a_as)
133 register struct cmd_syndesc *a_as;
137 int code; /*Result of ka_LocalCell*/
139 if (strcmp(a_as->name, "help") == 0)
141 if (a_as->parms[AUSS_TEMPLATE].items)
142 strcpy(Template, a_as->parms[AUSS_TEMPLATE].items->data);
143 if (a_as->parms[AUSS_VERBOSE].items)
148 code = ka_CellConfig(AFSDIR_CLIENT_ETC_DIRPATH);
150 fprintf(stderr, "%s: ** Call to ka_CellConfig() failed (code=%d)\n",
153 if (a_as->parms[AUSS_CELL].items) {
154 char local_cell[MAXKTCREALMLEN];
155 if (ka_ExpandCell(a_as->parms[AUSS_CELL].items->data,
159 "%s: ** Unknown or ambiguous cell name: %s\n",
160 uss_whoami, a_as->parms[AUSS_CELL].items->data);
164 * Get the local cell name
166 if (ka_ExpandCell((char*)0, local_cell, 0/*local*/)) {
167 fprintf(stderr, "Can't get local cellname\n");
170 if (strcmp(uss_Cell, local_cell)) {
172 * Not the same; not a local cell
179 * Get the local cell name
181 if (ka_ExpandCell((char*)0, uss_Cell, 0/*local*/)) {
182 fprintf(stderr, "Can't get local cellname\n");
186 fprintf(stderr, "No cell specified; assuming '%s'.\n",
195 /*-----------------------------------------------------------------------
196 * static SaveRestoreInfo
199 * Save all the information required to restore the currently
200 * parsed user account.
206 * 0 if everything went well,
207 * 1 if something went wrong in the function, or
208 * Lower-level error code if something went wrong below us.
211 * We need to determine and store the following new pieces of
214 * Name of user's volume
215 * FileServer & partition hosting the volume
219 *------------------------------------------------------------------------*/
221 static int SaveRestoreInfo()
223 { /*SaveRestoreInfo*/
226 "uss:SaveRestoreInfo"; /*Routine name*/
227 register afs_int32 code; /*Return code*/
228 afs_int32 deletedUid; /*Uid to be nuked*/
231 * Translate the user name to the user ID.
233 code = uss_ptserver_XlateUser(uss_User, &deletedUid);
237 printf("%s: User '%s' translated to uid %d\n",
238 rn, uss_User, deletedUid);
240 sprintf(uss_Uid, "%d", deletedUid);
243 * Pull out the name of the volume at the given mountpoint, along
244 * with the name of the FileServer and partition hosting it. This
245 * also sets up all the numerical info for the above.
247 code = uss_vol_GetVolInfoFromMountPoint(uss_MountPoint);
252 * Report back that we did fine.
256 } /*SaveRestoreInfo*/
259 /*-----------------------------------------------------------------------
263 * With everything properly inserted into the common variables,
264 * delete the specified user account.
270 * 0 if everything went well,
271 * 1 if something went wrong in the function, or
272 * Lower-level error code if something went wrong below us.
275 * Nothing interesting.
279 *------------------------------------------------------------------------*/
281 static int DoDelete()
285 int code; /*Return code*/
288 * Make sure the user name is a lega one.
290 code = uss_kauth_CheckUserName();
295 * Store all the info about the account before actually doing
298 code = SaveRestoreInfo();
302 if ((uss_VolumeID != 0) && (uss_MountPoint[0] != '\0')) {
304 * Unmount the user's volume from the file system.
307 fprintf(stderr, "Unmounting volume '%s' (ID %u) mounted at '%s'\n",
308 uss_Volume, uss_VolumeID, uss_MountPoint);
311 code = uss_fs_RmMountPoint(uss_MountPoint);
314 fprintf(stderr, "%s: Can't remove mountpoint '%s'\n",
315 uss_whoami, uss_MountPoint);
316 return(code); /* Must return - we may have incorrect volume */
321 * If our caller has elected to delete the user's volume now,
324 if (!uss_SaveVolume && (uss_VolumeID != 0)) {
326 fprintf(stderr, "Deleting volume '%s' (ID %u)\n",
327 uss_Volume, uss_VolumeID);
330 code = uss_vol_DeleteVol(uss_Volume,
338 fprintf(stderr, "%s: Can't delete volume '%s' (ID %u)\n",
339 uss_whoami, uss_Volume, uss_VolumeID);
344 if (uss_verbose && (uss_MountPoint[0] != '\0'))
345 printf("%s: Warning: Not attempting to delete volume at '%s'\n",
346 uss_whoami, uss_MountPoint);
349 * Get rid of the user's authentication entry.
351 code = uss_kauth_DelUser(uss_User);
356 * Finally, remove the user's AFS ID from the Protection DB and
357 * return that result.
359 code = uss_ptserver_DelUser(uss_User);
365 /*-----------------------------------------------------------------------
369 * Process the given (non-bulk) delete command.
372 * a_as : Ptr to the command line syntax descriptor.
373 * a_rock : Ptr to the rock passed in.
376 * 0 if everything went well,
377 * 1 if something went wrong in the function, or
378 * Lower-level error code if something went wrong below us.
381 * Nothing interesting.
385 *------------------------------------------------------------------------*/
387 static int DelUser(a_as, a_rock)
388 struct cmd_syndesc *a_as;
396 * Before we do anything else, make sure we initialize the
397 * global field settings.
402 * Pull out the fields as passed in by the caller on the command
405 strcpy(uss_User, a_as->parms[DUP_USER].items->data);
406 if (a_as->parms[DUP_MNTPT].items)
407 strcpy(uss_MountPoint, a_as->parms[DUP_MNTPT].items->data);
408 #if USS_FUTURE_FEATURES
409 #if USS_DONT_HIDE_SOME_FEATURES
410 strcpy(uss_RestoreDir, a_as->parms[DUP_RESTOREDIR].items->data);
411 #endif /* USS_DONT_HIDE_SOME_FEATURES */
412 #endif /* USS_FUTURE_FEATURES */
415 if (a_as->parms[DUP_SAVEVOLUME].items)
419 if (a_as->parms[2].items)
424 #if USS_FUTURE_FEATURES
425 #if USS_DONT_HIDE_SOME_FEATURES
426 if (a_as->parms[DUP_PWDPATH].items)
427 strcpy(uss_PwdPath, a_as->parms[DUP_PWDPATH].items->data);
428 if (a_as->parms[DUP_PWDFORMAT].items)
429 strcpy(uss_PwdFormat, a_as->parms[DUP_PWDFORMAT].items->data);
430 #endif /* USS_DONT_HIDE_SOME_FEATURES */
431 #endif /* USS_FUTURE_FEATURES */
433 if (a_as->parms[AUSS_DRYRUN].items)
435 if (a_as->parms[AUSS_SKIPAUTH].items)
436 uss_SkipKaserver = 1;
437 if (a_as->parms[AUSS_ADMIN].items) {
438 strcpy(uss_Administrator, a_as->parms[AUSS_ADMIN].items->data);
439 /* fprintf(stderr, "debugging: uss_Administrator set to '%s'\n",
440 uss_Administrator);*/
443 /* fprintf(stderr, "debugging: No administrator value given\n");*/
444 uss_Administrator[0] = '\0';
448 * Initialize uss_AccountCreator().
450 code = uss_kauth_InitAccountCreator();
455 * Now that the command line arguments are parsed and properly stored,
464 /*-----------------------------------------------------------------------
465 * static PurgeVolumes
468 * Purge the given volume(s).
471 * a_as : Ptr to the command line syntax descriptor.
472 * a_rock : Ptr to the rock passed in.
475 * 0 if everything went well,
476 * 1 if something went wrong in the function, or
477 * Lower-level error code if something went wrong below us.
480 * Nothing interesting.
484 *------------------------------------------------------------------------*/
486 static int PurgeVolumes(a_as, a_rock)
487 struct cmd_syndesc *a_as;
492 fprintf(stderr, "Sorry, purgevolumes has not yet been implemented.\n");
498 /*-----------------------------------------------------------------------
502 * Process the given delete command.
505 * a_as : Ptr to the command line syntax descriptor.
506 * a_rock : Ptr to the rock passed in.
509 * 0 if everything went well,
510 * 1 if something went wrong in the function, or
511 * Lower-level error code if something went wrong below us.
514 * Nothing interesting.
518 *------------------------------------------------------------------------*/
520 static int RestoreUser(a_as, a_rock)
521 struct cmd_syndesc *a_as;
526 fprintf(stderr, "Sorry, restoreuser has not yet been implemented.\n");
532 /*-----------------------------------------------------------------------
533 * static DoBulkAddLine
536 * Process the given bulk add command.
539 * a_buf : Ptr to the buffer holding the bulk add command.
540 * a_tp : Ptr to the first char past the opcode.
543 * 0 if everything went well,
544 * -1 if something went wrong in the function, or
545 * Lower-level error code if something went wrong below us.
548 * The required fields are:
553 *------------------------------------------------------------------------*/
555 static int DoBulkAddLine(a_buf, a_tp)
561 register int i; /*Loop variable*/
562 static char rn[] = "DoBulkAddLine"; /*Routine name*/
563 int overflow; /*Overflow in field copy?*/
566 printf("%s: Command buffer left to parse: '%s'\n",
569 uss_Expires = uss_BulkExpires;
572 * Pull out all the fields.
574 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
577 "%s: * User field in add cmd too long (max is %d chars; truncated value is '%s')\n",
578 uss_whoami, uss_UserLen, uss_User);
581 if ((*a_tp == '\0') || (*a_tp == '\n')) {
583 "%s: * The user field must appear in a bulk add command.\n",
588 a_tp = uss_common_FieldCp(uss_RealName, a_tp, ':', uss_RealNameLen, &overflow);
591 "%s: * Real name field in add cmd too long (max is %d chars; truncated value is '%s')\n",
592 uss_whoami, uss_RealNameLen, uss_RealName);
595 if (uss_RealName[0] == '\0') {
597 * The user's real name has not been supplied. As a
598 * default, we use the account name.
600 sprintf(uss_RealName, "%s", uss_User);
603 "%s: Using default real name, '%s'\n",
604 uss_whoami, uss_User);
605 } /*Use default full name*/
607 a_tp = uss_common_FieldCp(uss_Pwd, a_tp, ':', uss_PwdLen, &overflow);
610 "%s: * Password field in add cmd too long (max is %d chars; truncated value is '%s')\n",
611 uss_whoami, uss_PwdLen, uss_Pwd);
614 if (uss_Pwd[0] == '\0') {
616 * The user's password has not been provided. Use
619 sprintf(uss_Pwd, "%s", uss_DEFAULT_PASSWORD);
622 "%s: Using default password, '%s'\n",
623 uss_whoami, uss_Pwd);
624 } /*Use default password*/
625 if ((*a_tp == '\0') || (*a_tp == '\n'))
626 goto DoBulkAddLine_ParsingDone;
631 a_tp = uss_common_FieldCp(temp, a_tp, ':', 9, &overflow);
634 "%s: * Password expiration time is longer than %d characters, ignoring...\n",
637 if (temp[0] == '\0') {
638 /* Expiration time not specified. Use default */
640 fprintf(stderr, "%s: Using default expiration time, '%d'\n",
641 uss_whoami, uss_Expires);
646 if (te < 0 || te > 254) {
648 "%s: * Password Expiration must be in [0..254] days, using default %d\n",
649 uss_whoami, uss_Expires);
651 else uss_Expires = te;
654 if ((*a_tp == '\0') || (*a_tp == '\n'))
655 goto DoBulkAddLine_ParsingDone;
659 a_tp = uss_common_FieldCp(uss_Server, a_tp, ':', uss_ServerLen, &overflow);
662 "%s: * Server field in add cmd too long (max is %d chars; truncated value is '%s')\n",
663 uss_whoami, uss_ServerLen, uss_Server);
666 if ((*a_tp == '\0') || (*a_tp == '\n'))
667 goto DoBulkAddLine_ParsingDone;
669 a_tp = uss_common_FieldCp(uss_Partition, a_tp, ':', uss_PartitionLen, &overflow);
672 "%s: * Partition field in add cmd too long (max is %d chars; truncated value is '%s')\n",
673 uss_whoami, uss_PartitionLen, uss_Partition);
676 if ((*a_tp == '\0') || (*a_tp == '\n'))
677 goto DoBulkAddLine_ParsingDone;
679 a_tp = uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
683 "%s: * Mountpoint field in add cmd too long (max is %d chars; truncated value is '%s')\n",
684 uss_whoami, uss_MountPointLen, uss_MountPoint);
687 if ((*a_tp == '\0') || (*a_tp == '\n'))
688 goto DoBulkAddLine_ParsingDone;
690 a_tp = uss_common_FieldCp(uss_Uid, a_tp, ':', uss_UidLen, &overflow);
693 "%s: * UID field in add cmd too long (max is %d chars; truncated value is '%s')\n",
694 uss_whoami, uss_UidLen, uss_Uid);
697 uss_DesiredUID = atoi(uss_Uid);
698 if ((*a_tp == '\0') || (*a_tp == '\n'))
699 goto DoBulkAddLine_ParsingDone;
701 for (uss_VarMax = 1; uss_VarMax < 10; uss_VarMax++) {
702 a_tp = uss_common_FieldCp(uss_Var[uss_VarMax],
709 "%s: * Variable %d field in add cmd too long (max is %d chars; truncated value is '%s')\n",
710 uss_whoami, uss_VarMax, uss_MAX_ARG_SIZE, uss_Var[uss_VarMax]);
713 if ((*a_tp == '\0') || (*a_tp == '\n'))
714 goto DoBulkAddLine_ParsingDone;
717 DoBulkAddLine_ParsingDone:
719 * If there's anything left on the line, we ignore it. Announce
720 * the bulk add parameters we've parsed or filled in if we're
721 * being verbose, then go for it.
724 fprintf(stderr, "\nAdding user '%s' ('%s'), password='%s' on server '%s', partition '%s', home directory='%s'",
725 uss_User, uss_RealName, uss_Pwd,
726 (uss_Server[0] != '\0' ? uss_Server : "<default>"),
727 (uss_Partition[0] != '\0' ? uss_Partition : "<default>"),
728 (uss_MountPoint[0] != '\0' ? uss_MountPoint : "<default>"));
730 fprintf(stderr, ", uid preset to %d\n", uss_DesiredUID);
732 fprintf(stderr, ", no preset uid\n");
733 for (i = 1; i <= uss_VarMax; i++) {
734 if (uss_Var[i][0] != '\0')
735 fprintf(stderr, "$%1d='%s' ", i, uss_Var[i]);
738 fprintf(stderr, "\n");
739 } /*Verbose status of add command*/
742 * Now do the real work.
749 /*-----------------------------------------------------------------------
750 * static DoBulkDeleteLine
753 * Process the given bulk delete command.
756 * a_buf : Ptr to the buffer holding the bulk delete command.
757 * a_tp : Ptr to the first char past the opcode.
760 * 0 if everything went well,
761 * -1 if something went wrong in the function, or
762 * Lower-level error code if something went wrong below us.
765 * The required fields are:
766 * -user, -mountpoint, -restoredir
770 *------------------------------------------------------------------------*/
772 static int DoBulkDeleteLine(a_buf, a_tp)
776 { /*DoBulkDeleteLine*/
778 char volField[32]; /*Value of optional vol disposition field*/
779 int overflow; /*Was there an overflow in field copying?*/
782 * Pull out all the fields.
784 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
787 "%s: * User field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
788 uss_whoami, uss_UserLen, uss_User);
791 if ((uss_User[0] == '\0') || (*a_tp == '\0') || (*a_tp == '\n'))
792 goto Delete_MissingRequiredParam;
794 a_tp = uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
798 "%s: * Mountpoint field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
799 uss_whoami, uss_MountPointLen, uss_MountPoint);
802 #if USS_FUTURE_FEATURES
803 #if USS_DONT_HIDE_SOME_FEATURES
804 if ((uss_MountPoint[0] == '\0') || (*a_tp == '\0') || (*a_tp == '\n'))
805 goto Delete_MissingRequiredParam;
806 #endif /* USS_DONT_HIDE_SOME_FEATURES */
808 if ((*a_tp == '\0') || (*a_tp == '\n'))
809 goto Delete_ParsingDone;
810 #endif /* USS_FUTURE_FEATURES */
812 #if USS_FUTURE_FEATURES
813 #if USS_DONT_HIDE_SOME_FEATURES
814 a_tp = uss_common_FieldCp(uss_RestoreDir, a_tp, ':', uss_RestoreDirLen,
818 "%s: * RestoreDir field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
819 uss_whoami, uss_RestoreDirLen, uss_RestoreDir);
822 if (uss_RestoreDir[0] == '\0')
823 goto Delete_MissingRequiredParam;
824 if ((*a_tp == '\0') || (*a_tp == '\n'))
825 goto Delete_ParsingDone;
827 a_tp = uss_common_FieldCp(uss_PwdPath, a_tp, ':', uss_PwdPathLen, &overflow);
830 "%s: * Password path field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
831 uss_whoami, uss_PwdPathLen, uss_PwdPath);
834 if ((*a_tp == '\0') || (*a_tp == '\n'))
835 goto Delete_ParsingDone;
837 a_tp = uss_common_FieldCp(uss_PwdFormat, a_tp, ':', uss_PwdFormatLen, &overflow);
840 "%s: * Password format field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
841 uss_whoami, uss_PwdFormatLen, uss_PwdFormat);
844 if ((*a_tp == '\0') || (*a_tp == '\n'))
845 goto Delete_ParsingDone;
846 #endif /* USS_DONT_HIDE_SOME_FEATURES */
847 #endif /* USS_FUTURE_FEATURES */
849 a_tp = uss_common_FieldCp(volField, a_tp, ':', 32, &overflow);
852 "%s: * Volume save/del field in delete cmd too long (max is 32 chars; truncated value is '%s')\n",
853 uss_whoami, volField);
856 if ((*a_tp == '\0') || (*a_tp == '\n'))
857 goto Delete_ParsingDone;
859 if (strcmp(volField, "delvolume") == 0)
866 * If there's anything left on the line, we ignore it. Announce
867 * the bulk delete parameters we've parsed if we're being verbose,
871 #if USS_FUTURE_FEATURES
872 #if USS_DONT_HIDE_SOME_FEATURES
874 "\nDeleting user '%s' mounted at '%s', restoredir='%s', pwd path='%s', pwd format='%s'",
875 uss_User, uss_MountPoint, uss_RestoreDir, uss_PwdPath,
877 #endif /* USS_DONT_HIDE_SOME_FEATURES */
880 "\nDeleting user '%s' mounted at '%s'",
881 uss_User, uss_MountPoint);
882 #endif /* USS_FUTURE_FEATURES */
884 fprintf(stderr, ", saving user's volume\n");
886 fprintf(stderr, ", deleting user's volume\n");
887 } /*Verbose status of delete command*/
890 * Now do the real work.
894 Delete_MissingRequiredParam:
896 "%s: * All of the user, mountpoint, and restoredir fields must appear in a bulk delete command line.\n",
900 } /*DoBulkDeleteLine*/
902 #if USS_FUTURE_FEATURES
903 #if USS_DONT_HIDE_SOME_FEATURES
904 /*-----------------------------------------------------------------------
905 * static DoBulkPurgeVolumeLine
908 * Process the given bulk add command.
911 * a_buf : Ptr to the buffer holding the bulk add command.
912 * a_tp : Ptr to the first char past the opcode.
915 * 0 if everything went well,
916 * -1 if something went wrong in the function, or
917 * Lower-level error code if something went wrong below us.
920 * Nothing interesting.
924 *------------------------------------------------------------------------*/
926 static int DoBulkPurgeVolumeLine(a_buf, a_tp)
930 { /*DoBulkPurgeVolumeLine*/
932 register int i; /*Loop variable*/
933 int overflow; /*Did a field copy overflow happen?*/
936 * Pull out all the fields.
938 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
941 "%s: * User field in purgevolume cmd too long (max is %d chars; truncated value is '%s')\n",
942 uss_whoami, uss_UserLen, uss_User);
945 if ((*a_tp == '\0') || (*a_tp == '\n')) {
947 "%s: * The user field must appear in a bulk add command.\n",
952 a_tp = uss_common_FieldCp(uss_RealName, a_tp, ':', uss_RealNameLen, &overflow);
955 "%s: * Real name field in purgevolume cmd too long (max is %d chars; truncated value is '%s')\n",
956 uss_whoami, uss_RealNameLen, uss_RealName);
959 if (uss_RealName[0] == '\0') {
961 * The user's real name has not been supplied. As a
962 * default, we use the account name.
964 sprintf(uss_RealName, "%s", uss_User);
967 "%s: Using default real name, '%s'\n",
968 uss_whoami, uss_User);
969 } /*Use default full name*/
971 a_tp = uss_common_FieldCp(uss_Pwd, a_tp, ':', uss_PwdLen, &overflow);
974 "%s: * Password field in purgevolume cmd too long (max is %d chars; truncated value is '%s')\n",
975 uss_whoami, uss_PwdLen, uss_Pwd);
978 if (uss_Pwd[0] == '\0') {
980 * The user's password has not been provided. Use
983 sprintf(uss_Pwd, "%s", uss_DEFAULT_PASSWORD);
986 "%s: Using default password, '%s'\n",
987 uss_whoami, uss_Pwd);
988 } /*Use default password*/
989 if ((*a_tp == '\0') || (*a_tp == '\n'))
992 a_tp = uss_common_FieldCp(uss_Server, a_tp, ':', uss_ServerLen, &overflow);
995 "%s: * Server field too long (max is %d chars)\n",
996 uss_whoami, uss_ServerLen);
999 if ((*a_tp == '\0') || (*a_tp == '\n'))
1002 a_tp = uss_common_FieldCp(uss_Partition, a_tp, ':', uss_PartitionLen, &overflow);
1005 "%s: * Partition field too long (max is %d chars)\n",
1006 uss_whoami, uss_PartitionLen);
1009 if ((*a_tp == '\0') || (*a_tp == '\n'))
1012 a_tp = uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
1016 "%s: * Mountpoint field too long (max is %d chars)\n",
1017 uss_whoami, uss_MountPointLen);
1020 if ((*a_tp == '\0') || (*a_tp == '\n'))
1023 a_tp = uss_common_FieldCp(uss_Uid, a_tp, ':', uss_UidLen, &overflow);
1026 "%s: * UID field too long (max is %d chars)\n",
1027 uss_whoami, uss_UidLen);
1030 uss_DesiredUID = atoi(uss_Uid);
1031 if ((*a_tp == '\0') || (*a_tp == '\n'))
1034 for (uss_VarMax = 1; uss_VarMax < 10; uss_VarMax++) {
1035 a_tp = uss_common_FieldCp(uss_Var[uss_VarMax],
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.
1056 fprintf(stderr, "\nAdding user '%s' ('%s'), password='%s' on server '%s', partition '%s', home directory='%s'",
1057 uss_User, uss_RealName, uss_Pwd,
1058 (uss_Server[0] != '\0' ? uss_Server : "<default>"),
1059 (uss_Partition[0] != '\0' ? uss_Partition : "<default>"),
1060 (uss_MountPoint[0] != '\0' ? uss_MountPoint : "<default>"));
1062 fprintf(stderr, ", uid preset to %d\n", uss_DesiredUID);
1064 fprintf(stderr, ", no preset uid\n");
1065 for (i = 1; i <= uss_VarMax; i++) {
1066 if (uss_Var[i][0] != '\0')
1067 fprintf(stderr, "$%1d='%s' ", i, uss_Var[i]);
1070 fprintf(stderr, "\n");
1071 } /*Verbose status of add command*/
1074 * Now do the real work.
1078 } /*DoBulkPurgeVolumeLine*/
1079 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1080 #endif /* USS_FUTURE_FEATURES */
1082 #if USS_FUTURE_FEATURES
1083 #if USS_DONT_HIDE_SOME_FEATURES
1084 /*-----------------------------------------------------------------------
1085 * static DoBulkRestoreLine
1088 * Process the given bulk add command.
1091 * a_buf : Ptr to the buffer holding the bulk add command.
1092 * a_tp : Ptr to the first char past the opcode.
1095 * 0 if everything went well,
1096 * -1 if something went wrong in the function, or
1097 * Lower-level error code if something went wrong below us.
1100 * Nothing interesting.
1104 *------------------------------------------------------------------------*/
1106 static int DoBulkRestoreLine(a_buf, a_tp)
1110 { /*DoBulkRestoreLine*/
1112 register int i; /*Loop variable*/
1113 int overflow; /*Overflow occur on field copy?*/
1116 * Pull out all the fields.
1118 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
1121 "%s: * User field too long (max is %d chars)\n",
1122 uss_whoami, uss_UserLen);
1125 if ((*a_tp == '\0') || (*a_tp == '\n')) {
1127 "%s: * The user field must appear in a bulk add command.\n",
1132 a_tp = uss_common_FieldCp(uss_RealName, a_tp, ':', uss_RealNameLen, &overflow);
1135 "%s: * Real name field too long (max is %d chars)\n",
1136 uss_whoami, uss_RealNameLen);
1139 if (uss_RealName[0] == '\0') {
1141 * The user's real name has not been supplied. As a
1142 * default, we use the account name.
1144 sprintf(uss_RealName, "%s", uss_User);
1147 "%s: Using default real name, '%s'\n",
1148 uss_whoami, uss_User);
1149 } /*Use default full name*/
1151 a_tp = uss_common_FieldCp(uss_Pwd, a_tp, ':', uss_PwdLen, &overflow);
1154 "%s: * Password field too long (max is %d chars)\n",
1155 uss_whoami, uss_PwdLen);
1158 if (uss_Pwd[0] == '\0') {
1160 * The user's password has not been provided. Use
1163 sprintf(uss_Pwd, "%s", uss_DEFAULT_PASSWORD);
1166 "%s: Using default password, '%s'\n",
1167 uss_whoami, uss_Pwd);
1168 } /*Use default password*/
1169 if ((*a_tp == '\0') || (*a_tp == '\n'))
1172 a_tp = uss_common_FieldCp(uss_Server, a_tp, ':', uss_ServerLen, &overflow);
1175 "%s: * Server field too long (max is %d chars)\n",
1176 uss_whoami, uss_ServerLen);
1179 if ((*a_tp == '\0') || (*a_tp == '\n'))
1182 a_tp = uss_common_FieldCp(uss_Partition, a_tp, ':', uss_PartitionLen,
1186 "%s: * Partition field too long (max is %d chars)\n",
1187 uss_whoami, uss_PartitionLen);
1190 if ((*a_tp == '\0') || (*a_tp == '\n'))
1193 a_tp = uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
1197 "%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);
1207 "%s: * UID field too long (max is %d chars)\n",
1208 uss_whoami, uss_UidLen);
1211 uss_DesiredUID = atoi(uss_Uid);
1212 if ((*a_tp == '\0') || (*a_tp == '\n'))
1215 for (uss_VarMax = 1; uss_VarMax < 10; uss_VarMax++) {
1216 a_tp = uss_common_FieldCp(uss_Var[uss_VarMax],
1223 "%s: * Variable %d field too long (max is %d chars)\n",
1224 uss_whoami, uss_VarMax, uss_MAX_ARG_SIZE);
1227 if ((*a_tp == '\0') || (*a_tp == '\n'))
1232 * If there's anything left on the line, we ignore it. Announce
1233 * the bulk add parameters we've parsed or filled in if we're
1234 * being verbose, then go for it.
1237 fprintf(stderr, "\nAdding user '%s' ('%s'), password='%s' on server '%s', partition '%s', home directory='%s'",
1238 uss_User, uss_RealName, uss_Pwd,
1239 (uss_Server[0] != '\0' ? uss_Server : "<default>"),
1240 (uss_Partition[0] != '\0' ? uss_Partition : "<default>"),
1241 (uss_MountPoint[0] != '\0' ? uss_MountPoint : "<default>"));
1243 fprintf(stderr, ", uid preset to %d\n", uss_DesiredUID);
1245 fprintf(stderr, ", no preset uid\n");
1246 for (i = 1; i <= uss_VarMax; i++) {
1247 if (uss_Var[i][0] != '\0')
1248 fprintf(stderr, "$%1d='%s' ", i, uss_Var[i]);
1251 fprintf(stderr, "\n");
1252 } /*Verbose status of add command*/
1255 * Now do the real work.
1257 return(DoRestore());
1259 } /*DoBulkRestoreLine*/
1260 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1261 #endif /* USS_FUTURE_FEATURES */
1264 /*-----------------------------------------------------------------------
1265 * static DoBulkExecLine
1268 * Process the given bulk exec command.
1271 * a_buf : Ptr to the buffer holding the bulk exec command.
1272 * a_tp : Ptr to the first char past the opcode.
1275 * 0 if everything went well,
1276 * -1 if something went wrong in the function, or
1277 * Lower-level error code if something went wrong below us.
1280 * Nothing interesting.
1284 *------------------------------------------------------------------------*/
1286 static int 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 *------------------------------------------------------------------------*/
1325 static int HandleBulk(a_as, a_rock)
1326 register struct cmd_syndesc *a_as;
1331 #define USS_BULK_CMD_CHARS 128
1332 #define USS_BULK_BUF_CHARS 1024
1334 char cmd[USS_BULK_CMD_CHARS], buf[USS_BULK_BUF_CHARS];
1342 char tbuf[USS_BULK_BUF_CHARS];
1345 * Open up the bulk file, croak if we can't.
1347 if ((infile = fopen(a_as->parms[ABULK_FILE].items->data, "r")) == NULL) {
1349 "%s: * Failed to open input file %s\n",
1350 uss_whoami, 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) {
1374 fprintf(stderr,"%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) {
1406 if (!error) error = uss_perr;
1407 printf("LINE %d %s %s", line_no, (error?"FAIL":"SUCCESS"), tbuf);
1412 * Reset the common variables for each command line
1417 sprintf(tbuf,"%s",buf);
1420 First line of file = line 1.
1426 * Get the opcode and act upon it.
1428 tp = uss_common_FieldCp(cmd, buf, ' ', USS_BULK_CMD_CHARS, &overflow);
1431 "%s: * Bulk opcode field too long (max is %d chars)\n",
1432 uss_whoami, USS_BULK_CMD_CHARS);
1440 if (strcmp(cmd, "add") == 0) {
1441 error=DoBulkAddLine(buf, tp);
1444 if (strcmp(cmd, "delete") == 0) {
1445 error=DoBulkDeleteLine(buf, tp);
1448 if (strcmp(cmd, "delvolume") == 0) {
1453 #if USS_FUTURE_FEATURES
1454 #if USS_DONT_HIDE_SOME_FEATURES
1455 if (strcmp(cmd, "purgevolume") == 0) {
1456 error=DoBulkPurgeVolumeLine(buf, tp);
1459 if (strcmp(cmd, "pwdformat") == 0) {
1460 /*Set the password format here*/
1463 if (strcmp(cmd, "pwdpath") == 0) {
1464 /*Set the password path here*/
1467 if (strcmp(cmd, "restore") == 0) {
1468 error=DoBulkRestoreLine(buf, tp);
1471 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1472 #endif /* USS_FUTURE_FEATURES */
1473 if (strcmp(cmd, "savevolume") == 0) {
1474 /*Set the savevolume flag here*/
1477 if (strcmp(cmd, "exec") == 0) {
1478 error=DoBulkExecLine(buf, tp);
1483 * If none of the valid opcodes match, see if the line is either
1484 * a comment of a blank. If so, just ignore it. Otherwise, we
1487 if ((cmd[0] != '#') && (cmd[0] != '\0')) {
1489 "%s: ** Unrecognized command ('%s') in bulk file\n",
1499 } /*Process a line in the bulk file*/
1503 if (!error) error = uss_perr;
1504 printf("LINE %d %s %s", line_no, (error?"FAIL":"SUCCESS"), tbuf);
1512 /*-----------------------------------------------------------------------
1516 * Process the given (non-bulk) add command.
1519 * a_as : Ptr to the command line syntax descriptor.
1520 * a_rock : Ptr to the rock passed in.
1523 * 0 if everything went well,
1524 * 1 if something went wrong in the function, or
1525 * Lower-level error code if something went wrong below us.
1528 * Nothing interesting.
1532 *------------------------------------------------------------------------*/
1534 static int AddUser(a_as, a_rock)
1535 register struct cmd_syndesc *a_as;
1541 register struct cmd_item *ti;
1545 * Before we do anything else, make sure we initialize the
1546 * global field settings.
1551 * Pull out the fields as passed in by the caller on the command
1554 strcpy(uss_User, a_as->parms[AUP_USER].items->data);
1555 if (a_as->parms[AUP_REALNAME].items)
1556 strcpy(uss_RealName, a_as->parms[AUP_REALNAME].items->data);
1558 strcpy(uss_RealName, uss_User);
1559 if (a_as->parms[AUP_PASSWD].items)
1560 strcpy(uss_Pwd, a_as->parms[AUP_PASSWD].items->data);
1562 strcpy(uss_Pwd, uss_DEFAULT_PASSWORD);
1563 if (a_as->parms[AUP_SERVER].items)
1564 strcpy(uss_Server, a_as->parms[AUP_SERVER].items->data);
1565 if (a_as->parms[AUP_PART].items)
1566 strcpy(uss_Partition, a_as->parms[AUP_PART].items->data);
1567 if (a_as->parms[AUP_MNTPT].items)
1568 strcpy(uss_MountPoint, a_as->parms[AUP_MNTPT].items->data);
1569 if (a_as->parms[AUP_UID].items)
1570 uss_DesiredUID = atoi(a_as->parms[AUP_UID].items->data);
1573 if (a_as->parms[AUP_PWEXPIRES].items) {
1574 uss_Expires = atoi(a_as->parms[AUP_PWEXPIRES].items->data);
1575 if (uss_Expires < 0 || uss_Expires > 254) {
1576 fprintf(stderr,"%s: Password Expiration must be in [0..255] days\n",
1584 if (a_as->parms[AUSS_DRYRUN].items)
1586 if (a_as->parms[AUSS_SKIPAUTH].items)
1587 uss_SkipKaserver = 1;
1588 if (a_as->parms[AUSS_OVERWRITE].items)
1590 if (a_as->parms[AUSS_ADMIN].items) {
1591 strcpy(uss_Administrator, a_as->parms[AUSS_ADMIN].items->data);
1592 /* fprintf(stderr, "debugging: uss_Administrator set to '%s'\n",
1593 uss_Administrator);*/
1596 /* fprintf(stderr, "debugging: No administrator value given\n");*/
1597 uss_Administrator[0] = '\0';
1600 if (a_as->parms[AUSS_VAR].items) {
1601 for (ti = a_as->parms[AUSS_VAR].items; ti; ti = ti->next) {
1603 if (i <0 || i>9 || (i==0 && *ti->data != '0')) {
1605 "%s: Bad -var format: must be '0 val0 1 val1 ... 9 val9'\n",
1612 "%s: -var values must appear in pairs: 'Num val'\n",
1616 strcpy(uss_Var[i], ti->data);
1619 } /*Remember each VAR item*/
1620 } /*VAR items exist*/
1623 * Initialize uss_AccountCreator().
1625 code = uss_kauth_InitAccountCreator();
1630 * Now that the command line arguments are parsed and properly stored,
1638 /*-----------------------------------------------------------------------
1642 * Create the desired user account, having parsed the add command
1643 * from either the command line or a bulk file.
1649 * 0 if everything went well,
1650 * 1 if something went wrong in the function, or
1651 * Lower-level error code if something went wrong below us.
1654 * All values needed have been put in the common variables.
1658 *------------------------------------------------------------------------*/
1664 int code; /*Return code*/
1667 * Make sure the user name is legal.
1669 code = uss_kauth_CheckUserName();
1674 * This time around, we start off assuming the global value of the
1677 uss_OverwriteThisOne = uss_Overwrite;
1680 * Open up the template file before doing any real processing,
1681 * so we can quit early should it not be found.
1684 if ((yyin = uss_procs_FindAndOpen(Template)) == NULL) {
1686 "%s: ** Can't open template file '%s'\n",
1687 uss_whoami, Template);
1690 yyout = fopen("/dev/null", "w");
1696 * Add the new user to the Protection DB.
1698 code = uss_ptserver_AddUser(uss_User, uss_Uid);
1701 "%s: Failed to add user '%s' to the Protection DB\n",
1702 uss_whoami, uss_User);
1707 * Add the new user to the Authentication DB.
1709 code = uss_kauth_AddUser(uss_User, uss_Pwd);
1712 "%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 *------------------------------------------------------------------------*/
1755 static int DoRestore()
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();
1808 /* this sucks but it works for now.
1813 #include "AFS_component_version_number.c"
1821 register struct cmd_syndesc *cs; /*Command line syntax descriptor*/
1822 register afs_int32 code; /*Return code*/
1824 #ifdef AFS_AIX32_ENV
1826 * The following signal action for AIX is necessary so that in case of a
1827 * crash (i.e. core is generated) we can include the user's data section
1828 * in the core dump. Unfortunately, by default, only a partial core is
1829 * generated which, in many cases, isn't too useful.
1831 struct sigaction nsa;
1833 sigemptyset(&nsa.sa_mask);
1834 nsa.sa_handler = SIG_DFL;
1835 nsa.sa_flags = SA_FULLDUMP;
1836 sigaction(SIGABRT, &nsa, NULL);
1837 sigaction(SIGSEGV, &nsa, NULL);
1839 strcpy(uss_whoami, argv[0]);
1840 yyin = (FILE *)NULL;
1842 uss_fs_InBuff = (char*)malloc(USS_FS_MAX_SIZE); /*Cache Manager input buff*/
1843 uss_fs_OutBuff = (char*)malloc(USS_FS_MAX_SIZE); /*Cache Manager output buff*/
1844 if (!uss_fs_InBuff || !uss_fs_OutBuff) {
1845 fprintf(stderr, "%s: Can't malloc in/out buffers\n", uss_whoami);
1849 /* ----------------------------- add -----------------------------*/
1851 cs = cmd_CreateSyntax("add", AddUser, 0, "create a new user account");
1852 cmd_AddParm(cs, "-user", CMD_SINGLE, 0,
1854 cmd_AddParm(cs, "-realname", CMD_SINGLE, CMD_OPTIONAL,
1855 "full name in quotes");
1856 cmd_AddParm(cs, "-pass", CMD_SINGLE, CMD_OPTIONAL,
1857 "initial password");
1859 cmd_AddParm(cs, "-pwexpires", CMD_SINGLE, CMD_OPTIONAL,
1860 "password expires in [0..254] days (0 => never)");
1861 cmd_AddParm(cs, "-server", CMD_SINGLE, CMD_OPTIONAL,
1862 "FileServer for home volume");
1863 cmd_AddParm(cs, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1864 "FileServer's disk partition for home volume");
1865 cmd_AddParm(cs, "-mount", CMD_SINGLE, CMD_OPTIONAL,
1866 "home directory mount point");
1867 cmd_AddParm(cs, "-uid", CMD_SINGLE, CMD_OPTIONAL,
1868 "uid to assign the user");
1869 cmd_Seek(cs, AUSS_TEMPLATE);
1870 cmd_AddParm(cs, "-template", CMD_SINGLE, CMD_OPTIONAL,
1871 "pathname of template file");
1872 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL,
1873 "verbose operation");
1874 cmd_AddParm(cs, "-var", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS,
1875 "auxiliary argument pairs (Num val)");
1876 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL,
1878 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1879 "administrator to authenticate");
1880 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1881 "only list what would be done, don't do it");
1882 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1883 "ignore all contact with the authentication server (kaserver)");
1884 cmd_AddParm(cs, "-overwrite", CMD_FLAG, CMD_OPTIONAL,
1885 "Overwrite pre-existing files in user home directory tree");
1888 /* ---------------------------- bulk -----------------------------*/
1890 cs = cmd_CreateSyntax("bulk", HandleBulk, 0, "bulk input mode");
1891 cmd_AddParm(cs, "-file", CMD_SINGLE, 0,
1893 cmd_Seek(cs, AUSS_TEMPLATE);
1894 cmd_AddParm(cs, "-template", CMD_SINGLE, CMD_OPTIONAL,
1895 "pathname of template file");
1896 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL,
1897 "verbose operation");
1898 cmd_Seek(cs, AUSS_CELL);
1899 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL,
1901 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1902 "administrator to authenticate");
1903 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1904 "only list what would be done, don't do it");
1905 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1906 "ignore all contact with the authentication server (kaserver)");
1907 cmd_AddParm(cs, "-overwrite", CMD_FLAG, CMD_OPTIONAL,
1908 "Overwrite pre-existing files in user home directory tree");
1909 cmd_Seek(cs, AUSS_PWEXPIRES);
1910 cmd_AddParm(cs, "-pwexpires", CMD_SINGLE, CMD_OPTIONAL,
1911 "password expires in [0..254] days (0 => never)");
1912 cmd_Seek(cs, AUSS_PIPE);
1913 cmd_AddParm(cs, "-pipe", CMD_FLAG, CMD_OPTIONAL,
1914 "don't prompt for passwd; get it from standard input");
1916 /* ---------------------------- delete ---------------------------*/
1918 cs = cmd_CreateSyntax("delete", DelUser, 0, "delete a user account");
1919 cmd_AddParm(cs, "-user", CMD_SINGLE, 0,
1921 cmd_AddParm(cs, "-mountpoint", CMD_SINGLE, CMD_OPTIONAL,
1922 "mountpoint for user's volume");
1923 #if USS_FUTURE_FEATURES
1924 #if USS_DONT_HIDE_SOME_FEATURES
1925 cmd_AddParm(cs, "-restoredir", CMD_SINGLE, 0,
1926 "directory where restore info is to be placed");
1927 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1928 #endif /* USS_FUTURE_FEATURES */
1929 cmd_AddParm(cs, "-savevolume", CMD_FLAG, CMD_OPTIONAL,
1930 "don't destroy the user's volume");
1931 #if USS_FUTURE_FEATURES
1932 #if USS_DONT_HIDE_SOME_FEATURES
1933 cmd_AddParm(cs, "-pwdpath", CMD_SINGLE, CMD_OPTIONAL,
1934 "pathname to the password file");
1935 cmd_AddParm(cs, "-pwdformat", CMD_SINGLE, CMD_OPTIONAL,
1936 "password entry format");
1937 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1938 #endif /* USS_FUTURE_FEATURES */
1939 cmd_Seek(cs, AUSS_VERBOSE);
1940 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL,
1941 "verbose operation");
1942 cmd_Seek(cs, AUSS_CELL);
1943 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL,
1945 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1946 "administrator to authenticate");
1947 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1948 "only list what would be done, don't do it");
1949 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1950 "ignore all contact with the authentication server (kaserver)");
1951 #if USS_FUTURE_FEATURES
1952 #if USS_DONT_HIDE_SOME_FEATURES
1953 /* ------------------------- purgevolumes ------------------------*/
1955 cs = cmd_CreateSyntax("purgevolumes", PurgeVolumes, 0,
1956 "destroy a deleted user's volume");
1957 cmd_AddParm(cs, "-volname", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS,
1958 "Name(s) of volume(s) to destroy");
1959 cmd_AddParm(cs, "-volfile", CMD_SINGLE, CMD_OPTIONAL,
1960 "pathname to volume purge file");
1961 cmd_Seek(cs, AUSS_VERBOSE);
1962 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL,
1963 "verbose operation");
1964 cmd_Seek(cs, AUSS_CELL);
1965 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL,
1967 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1968 "administrator to authenticate");
1969 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1970 "only list what would be done, don't do it");
1971 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1972 "ignore all contact with the authentication server (kaserver)");
1973 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1974 #endif /* USS_FUTURE_FEATURES */
1976 #if USS_FUTURE_FEATURES
1977 #if USS_DONT_HIDE_SOME_FEATURES
1978 /* ---------------------------- restore --------------------------*/
1980 cs = cmd_CreateSyntax("restore", RestoreUser, 0,
1981 "restore a deleted user account");
1982 cmd_AddParm(cs, "-user", CMD_SINGLE, 0,
1983 "login name to restore");
1984 cmd_AddParm(cs, "-uid", CMD_SINGLE, 0,
1986 cmd_AddParm(cs, "-mount", CMD_SINGLE, 0,
1987 "mountpoint for user's volume");
1988 cmd_AddParm(cs, "-volname", CMD_SINGLE, 0,
1989 "name of user's volume");
1990 cmd_AddParm(cs, "-realname", CMD_SINGLE, CMD_OPTIONAL,
1991 "user's full name");
1992 cmd_AddParm(cs, "-server", CMD_SINGLE, CMD_OPTIONAL,
1993 "FileServer to host user's volume");
1994 cmd_AddParm(cs, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1995 "FileServer partition to host user's volume");
1996 cmd_AddParm(cs, "-pwdpath", CMD_SINGLE, CMD_OPTIONAL,
1997 "pathname to the password file");
1998 cmd_AddParm(cs, "-pwdformat", CMD_SINGLE, CMD_OPTIONAL,
1999 "password entry format");
2000 cmd_Seek(cs, AUSS_VERBOSE);
2001 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL,
2002 "verbose operation");
2003 cmd_Seek(cs, AUSS_CELL);
2004 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL,
2006 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
2007 "administrator to authenticate");
2008 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
2009 "only list what would be done, don't do it");
2010 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
2011 "ignore all contact with the authentication server (kaserver)");
2012 #endif /* USS_DONT_HIDE_SOME_FEATURES */
2013 #endif /* USS_FUTURE_FEATURES */
2016 * Set up all the error code translation tables, initialize the
2017 * command variables, and set up to parse the common command line
2022 cmd_SetBeforeProc(GetCommon, NULL);
2025 * Execute the parsed command.
2027 code = cmd_Dispatch(argc, argv);
2031 "%s: Call to cmd_Dispatch() failed; code is %d\n",
2037 code = uss_fs_UnlogToken(uss_Cell);