2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 * Main module for the AFS user account management tool.
15 * --------------------- Required definitions ---------------------
18 #include <afsconfig.h>
19 #include <afs/param.h>
30 #include "uss_common.h" /*Common uss definitions, globals */
31 #include "uss_procs.h" /*Main uss operations */
32 #include "uss_kauth.h" /*AuthServer routines */
33 #include "uss_fs.h" /*CacheManager ops */
34 #include <afs/cmd.h> /*Command line parsing */
35 #include <afs/cellconfig.h> /*Cell config defs */
36 #include <afs/kautils.h> /*MAXKTCREALMLEN & MAXKTCNAMELEN */
40 * Label certain things which will be activated at a later time,
41 * as well as certain semi-implemented features/switches which need
42 * to be hidden for the general AFS 3.2 release.
44 #define USS_FUTURE_FEATURES 1
45 #define USS_DONT_HIDE_SOME_FEATURES 0
48 * ---------------------- Exported variables ----------------------
50 char *uss_fs_InBuff = NULL; /*Cache Manager input buff */
51 char *uss_fs_OutBuff = NULL; /*Cache Manager output buff */
54 * Set up convenient tags for the command line parameter indicies.
59 #define AUP_REALNAME 1
61 #define AUP_PWEXPIRES 3
62 #define AUP_SERVER 4 /* was 3 */
63 #define AUP_PART 5 /* was 4 */
64 #define AUP_MNTPT 6 /* was 5 */
65 #define AUP_UID 7 /* was 6 */
74 #define DUP_RESTOREDIR 2
75 #define DUP_SAVEVOLUME 3
77 #define DUP_PWDFORMAT 5
84 #define AUSS_TEMPLATE 10 /* was 7 */
85 #define AUSS_VERBOSE 11 /* was 8 */
86 #define AUSS_VAR 12 /* was 9 */
87 #define AUSS_CELL 13 /* was 10 */
88 #define AUSS_ADMIN 14 /* was 11 */
89 #define AUSS_DRYRUN 15 /* was 12 */
90 #define AUSS_SKIPAUTH 16 /* was 13 */
91 #define AUSS_OVERWRITE 17 /* was 14 */
92 #define AUSS_PWEXPIRES 18 /* was 15 */
93 #define AUSS_PIPE 19 /* was 16 */
97 static char Template[300] = "uss.template"; /*Default name */
99 extern FILE *yyin, *yyout; /*YACC input & output files */
101 int uss_BulkExpires = 0;
106 /*-----------------------------------------------------------------------
110 * Read in the command line arguments common to all uss operations.
113 * a_as : Ptr to the command line syntax descriptor.
119 * May exit the program if trouble is encountered determining the
120 * cell name. Set up as the command line parser's BeforeProc().
124 *------------------------------------------------------------------------*/
128 register struct cmd_syndesc *a_as;
132 int code; /*Result of ka_LocalCell */
134 if (strcmp(a_as->name, "help") == 0)
136 if (a_as->parms[AUSS_TEMPLATE].items)
137 strcpy(Template, a_as->parms[AUSS_TEMPLATE].items->data);
138 if (a_as->parms[AUSS_VERBOSE].items)
143 code = ka_CellConfig(AFSDIR_CLIENT_ETC_DIRPATH);
145 fprintf(stderr, "%s: ** Call to ka_CellConfig() failed (code=%d)\n",
148 if (a_as->parms[AUSS_CELL].items) {
149 char local_cell[MAXKTCREALMLEN];
151 (a_as->parms[AUSS_CELL].items->data, uss_Cell, 0 /*local */ )) {
152 fprintf(stderr, "%s: ** Unknown or ambiguous cell name: %s\n",
153 uss_whoami, a_as->parms[AUSS_CELL].items->data);
157 * Get the local cell name
159 if (ka_ExpandCell((char *)0, local_cell, 0 /*local */ )) {
160 fprintf(stderr, "Can't get local cellname\n");
163 if (strcmp(uss_Cell, local_cell)) {
165 * Not the same; not a local cell
171 * Get the local cell name
173 if (ka_ExpandCell((char *)0, uss_Cell, 0 /*local */ )) {
174 fprintf(stderr, "Can't get local cellname\n");
178 fprintf(stderr, "No cell specified; assuming '%s'.\n", uss_Cell);
186 /*-----------------------------------------------------------------------
187 * static SaveRestoreInfo
190 * Save all the information required to restore the currently
191 * parsed user account.
197 * 0 if everything went well,
198 * 1 if something went wrong in the function, or
199 * Lower-level error code if something went wrong below us.
202 * We need to determine and store the following new pieces of
205 * Name of user's volume
206 * FileServer & partition hosting the volume
210 *------------------------------------------------------------------------*/
214 { /*SaveRestoreInfo */
216 static char rn[] = "uss:SaveRestoreInfo"; /*Routine name */
217 register afs_int32 code; /*Return code */
218 afs_int32 deletedUid; /*Uid to be nuked */
221 * Translate the user name to the user ID.
223 code = uss_ptserver_XlateUser(uss_User, &deletedUid);
227 printf("%s: User '%s' translated to uid %d\n", rn, uss_User, deletedUid);
229 sprintf(uss_Uid, "%d", deletedUid);
232 * Pull out the name of the volume at the given mountpoint, along
233 * with the name of the FileServer and partition hosting it. This
234 * also sets up all the numerical info for the above.
236 code = uss_vol_GetVolInfoFromMountPoint(uss_MountPoint);
241 * Report back that we did fine.
245 } /*SaveRestoreInfo */
248 /*-----------------------------------------------------------------------
252 * With everything properly inserted into the common variables,
253 * delete the specified user account.
259 * 0 if everything went well,
260 * 1 if something went wrong in the function, or
261 * Lower-level error code if something went wrong below us.
264 * Nothing interesting.
268 *------------------------------------------------------------------------*/
274 int code; /*Return code */
277 * Make sure the user name is a lega one.
279 code = uss_kauth_CheckUserName();
284 * Store all the info about the account before actually doing
287 code = SaveRestoreInfo();
291 if ((uss_VolumeID != 0) && (uss_MountPoint[0] != '\0')) {
293 * Unmount the user's volume from the file system.
297 "Unmounting volume '%s' (ID %u) mounted at '%s'\n",
298 uss_Volume, uss_VolumeID, uss_MountPoint);
301 code = uss_fs_RmMountPoint(uss_MountPoint);
304 fprintf(stderr, "%s: Can't remove mountpoint '%s'\n",
305 uss_whoami, uss_MountPoint);
306 return (code); /* Must return - we may have incorrect volume */
311 * If our caller has elected to delete the user's volume now,
314 if (!uss_SaveVolume && (uss_VolumeID != 0)) {
316 fprintf(stderr, "Deleting volume '%s' (ID %u)\n", uss_Volume,
321 uss_vol_DeleteVol(uss_Volume, uss_VolumeID, uss_Server,
322 uss_ServerID, uss_Partition, uss_PartitionID);
325 fprintf(stderr, "%s: Can't delete volume '%s' (ID %u)\n",
326 uss_whoami, uss_Volume, uss_VolumeID);
329 } else if (uss_verbose && (uss_MountPoint[0] != '\0'))
330 printf("%s: Warning: Not attempting to delete volume at '%s'\n",
331 uss_whoami, uss_MountPoint);
334 * Get rid of the user's authentication entry.
336 code = uss_kauth_DelUser(uss_User);
341 * Finally, remove the user's AFS ID from the Protection DB and
342 * return that result.
344 code = uss_ptserver_DelUser(uss_User);
350 /*-----------------------------------------------------------------------
354 * Process the given (non-bulk) delete command.
357 * a_as : Ptr to the command line syntax descriptor.
358 * a_rock : Ptr to the rock passed in.
361 * 0 if everything went well,
362 * 1 if something went wrong in the function, or
363 * Lower-level error code if something went wrong below us.
366 * Nothing interesting.
370 *------------------------------------------------------------------------*/
373 DelUser(a_as, a_rock)
374 struct cmd_syndesc *a_as;
382 * Before we do anything else, make sure we initialize the
383 * global field settings.
388 * Pull out the fields as passed in by the caller on the command
391 strcpy(uss_User, a_as->parms[DUP_USER].items->data);
392 if (a_as->parms[DUP_MNTPT].items)
393 strcpy(uss_MountPoint, a_as->parms[DUP_MNTPT].items->data);
394 #if USS_FUTURE_FEATURES
395 #if USS_DONT_HIDE_SOME_FEATURES
396 strcpy(uss_RestoreDir, a_as->parms[DUP_RESTOREDIR].items->data);
397 #endif /* USS_DONT_HIDE_SOME_FEATURES */
398 #endif /* USS_FUTURE_FEATURES */
401 if (a_as->parms[DUP_SAVEVOLUME].items)
405 if (a_as->parms[2].items) {
408 #if USS_FUTURE_FEATURES
409 #if USS_DONT_HIDE_SOME_FEATURES
410 if (a_as->parms[DUP_PWDPATH].items)
411 strcpy(uss_PwdPath, a_as->parms[DUP_PWDPATH].items->data);
412 if (a_as->parms[DUP_PWDFORMAT].items)
413 strcpy(uss_PwdFormat, a_as->parms[DUP_PWDFORMAT].items->data);
414 #endif /* USS_DONT_HIDE_SOME_FEATURES */
415 #endif /* USS_FUTURE_FEATURES */
417 if (a_as->parms[AUSS_DRYRUN].items)
419 if (a_as->parms[AUSS_SKIPAUTH].items)
420 uss_SkipKaserver = 1;
421 if (a_as->parms[AUSS_ADMIN].items) {
422 strcpy(uss_Administrator, a_as->parms[AUSS_ADMIN].items->data);
423 /* fprintf(stderr, "debugging: uss_Administrator set to '%s'\n",
424 * uss_Administrator); */
426 /* fprintf(stderr, "debugging: No administrator value given\n"); */
427 uss_Administrator[0] = '\0';
431 * Initialize uss_AccountCreator().
433 code = uss_kauth_InitAccountCreator();
438 * Now that the command line arguments are parsed and properly stored,
447 /*-----------------------------------------------------------------------
448 * static PurgeVolumes
451 * Purge the given volume(s).
454 * a_as : Ptr to the command line syntax descriptor.
455 * a_rock : Ptr to the rock passed in.
458 * 0 if everything went well,
459 * 1 if something went wrong in the function, or
460 * Lower-level error code if something went wrong below us.
463 * Nothing interesting.
467 *------------------------------------------------------------------------*/
470 PurgeVolumes(a_as, a_rock)
471 struct cmd_syndesc *a_as;
476 fprintf(stderr, "Sorry, purgevolumes has not yet been implemented.\n");
482 /*-----------------------------------------------------------------------
486 * Process the given delete command.
489 * a_as : Ptr to the command line syntax descriptor.
490 * a_rock : Ptr to the rock passed in.
493 * 0 if everything went well,
494 * 1 if something went wrong in the function, or
495 * Lower-level error code if something went wrong below us.
498 * Nothing interesting.
502 *------------------------------------------------------------------------*/
505 RestoreUser(a_as, a_rock)
506 struct cmd_syndesc *a_as;
511 fprintf(stderr, "Sorry, restoreuser has not yet been implemented.\n");
517 /*-----------------------------------------------------------------------
518 * static DoBulkAddLine
521 * Process the given bulk add command.
524 * a_buf : Ptr to the buffer holding the bulk add command.
525 * a_tp : Ptr to the first char past the opcode.
528 * 0 if everything went well,
529 * -1 if something went wrong in the function, or
530 * Lower-level error code if something went wrong below us.
533 * The required fields are:
538 *------------------------------------------------------------------------*/
541 DoBulkAddLine(a_buf, a_tp)
547 register int i; /*Loop variable */
548 static char rn[] = "DoBulkAddLine"; /*Routine name */
549 int overflow; /*Overflow in field copy? */
552 printf("%s: Command buffer left to parse: '%s'\n", rn, a_tp);
554 uss_Expires = uss_BulkExpires;
557 * Pull out all the fields.
559 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
562 "%s: * User field in add cmd too long (max is %d chars; truncated value is '%s')\n",
563 uss_whoami, uss_UserLen, uss_User);
566 if ((*a_tp == '\0') || (*a_tp == '\n')) {
568 "%s: * The user field must appear in a bulk add command.\n",
574 uss_common_FieldCp(uss_RealName, a_tp, ':', uss_RealNameLen,
578 "%s: * Real name field in add cmd too long (max is %d chars; truncated value is '%s')\n",
579 uss_whoami, uss_RealNameLen, uss_RealName);
582 if (uss_RealName[0] == '\0') {
584 * The user's real name has not been supplied. As a
585 * default, we use the account name.
587 sprintf(uss_RealName, "%s", uss_User);
589 fprintf(stderr, "%s: Using default real name, '%s'\n", uss_whoami,
592 /*Use default full name */
593 a_tp = uss_common_FieldCp(uss_Pwd, a_tp, ':', uss_PwdLen, &overflow);
596 "%s: * Password field in add cmd too long (max is %d chars; truncated value is '%s')\n",
597 uss_whoami, uss_PwdLen, uss_Pwd);
600 if (uss_Pwd[0] == '\0') {
602 * The user's password has not been provided. Use
605 sprintf(uss_Pwd, "%s", uss_DEFAULT_PASSWORD);
607 fprintf(stderr, "%s: Using default password, '%s'\n", uss_whoami,
609 } /*Use default password */
610 if ((*a_tp == '\0') || (*a_tp == '\n'))
611 goto DoBulkAddLine_ParsingDone;
616 a_tp = uss_common_FieldCp(temp, a_tp, ':', 9, &overflow);
619 "%s: * Password expiration time is longer than %d characters, ignoring...\n",
622 if (temp[0] == '\0') {
623 /* Expiration time not specified. Use default */
625 fprintf(stderr, "%s: Using default expiration time, '%d'\n",
626 uss_whoami, uss_Expires);
630 if (te < 0 || te > 254) {
632 "%s: * Password Expiration must be in [0..254] days, using default %d\n",
633 uss_whoami, uss_Expires);
638 if ((*a_tp == '\0') || (*a_tp == '\n'))
639 goto DoBulkAddLine_ParsingDone;
644 uss_common_FieldCp(uss_Server, a_tp, ':', uss_ServerLen, &overflow);
647 "%s: * Server field in add cmd too long (max is %d chars; truncated value is '%s')\n",
648 uss_whoami, uss_ServerLen, uss_Server);
651 if ((*a_tp == '\0') || (*a_tp == '\n'))
652 goto DoBulkAddLine_ParsingDone;
655 uss_common_FieldCp(uss_Partition, a_tp, ':', uss_PartitionLen,
659 "%s: * Partition field in add cmd too long (max is %d chars; truncated value is '%s')\n",
660 uss_whoami, uss_PartitionLen, uss_Partition);
663 if ((*a_tp == '\0') || (*a_tp == '\n'))
664 goto DoBulkAddLine_ParsingDone;
667 uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
671 "%s: * Mountpoint field in add cmd too long (max is %d chars; truncated value is '%s')\n",
672 uss_whoami, uss_MountPointLen, uss_MountPoint);
675 if ((*a_tp == '\0') || (*a_tp == '\n'))
676 goto DoBulkAddLine_ParsingDone;
678 a_tp = uss_common_FieldCp(uss_Uid, a_tp, ':', uss_UidLen, &overflow);
681 "%s: * UID field in add cmd too long (max is %d chars; truncated value is '%s')\n",
682 uss_whoami, uss_UidLen, uss_Uid);
685 uss_DesiredUID = atoi(uss_Uid);
686 if ((*a_tp == '\0') || (*a_tp == '\n'))
687 goto DoBulkAddLine_ParsingDone;
689 for (uss_VarMax = 1; uss_VarMax < 10; uss_VarMax++) {
691 uss_common_FieldCp(uss_Var[uss_VarMax], a_tp, ':',
692 uss_MAX_ARG_SIZE, &overflow);
695 "%s: * Variable %d field in add cmd too long (max is %d chars; truncated value is '%s')\n",
696 uss_whoami, uss_VarMax, uss_MAX_ARG_SIZE,
697 uss_Var[uss_VarMax]);
700 if ((*a_tp == '\0') || (*a_tp == '\n'))
701 goto DoBulkAddLine_ParsingDone;
704 DoBulkAddLine_ParsingDone:
706 * If there's anything left on the line, we ignore it. Announce
707 * the bulk add parameters we've parsed or filled in if we're
708 * being verbose, then go for it.
712 "\nAdding user '%s' ('%s'), password='%s' on server '%s', partition '%s', home directory='%s'",
713 uss_User, uss_RealName, uss_Pwd,
714 (uss_Server[0] != '\0' ? uss_Server : "<default>"),
715 (uss_Partition[0] != '\0' ? uss_Partition : "<default>"),
716 (uss_MountPoint[0] != '\0' ? uss_MountPoint : "<default>"));
718 fprintf(stderr, ", uid preset to %d\n", uss_DesiredUID);
720 fprintf(stderr, ", no preset uid\n");
721 for (i = 1; i <= uss_VarMax; i++) {
722 if (uss_Var[i][0] != '\0')
723 fprintf(stderr, "$%1d='%s' ", i, uss_Var[i]);
726 fprintf(stderr, "\n");
729 /*Verbose status of add command */
731 * Now do the real work.
738 /*-----------------------------------------------------------------------
739 * static DoBulkDeleteLine
742 * Process the given bulk delete command.
745 * a_buf : Ptr to the buffer holding the bulk delete command.
746 * a_tp : Ptr to the first char past the opcode.
749 * 0 if everything went well,
750 * -1 if something went wrong in the function, or
751 * Lower-level error code if something went wrong below us.
754 * The required fields are:
755 * -user, -mountpoint, -restoredir
759 *------------------------------------------------------------------------*/
762 DoBulkDeleteLine(a_buf, a_tp)
766 { /*DoBulkDeleteLine */
768 char volField[32]; /*Value of optional vol disposition field */
769 int overflow; /*Was there an overflow in field copying? */
772 * Pull out all the fields.
774 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
777 "%s: * User field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
778 uss_whoami, uss_UserLen, uss_User);
781 if ((uss_User[0] == '\0') || (*a_tp == '\0') || (*a_tp == '\n'))
782 goto Delete_MissingRequiredParam;
785 uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
789 "%s: * Mountpoint field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
790 uss_whoami, uss_MountPointLen, uss_MountPoint);
793 #if USS_FUTURE_FEATURES
794 #if USS_DONT_HIDE_SOME_FEATURES
795 if ((uss_MountPoint[0] == '\0') || (*a_tp == '\0') || (*a_tp == '\n'))
796 goto Delete_MissingRequiredParam;
797 #endif /* USS_DONT_HIDE_SOME_FEATURES */
799 if ((*a_tp == '\0') || (*a_tp == '\n'))
800 goto Delete_ParsingDone;
801 #endif /* USS_FUTURE_FEATURES */
803 #if USS_FUTURE_FEATURES
804 #if USS_DONT_HIDE_SOME_FEATURES
806 uss_common_FieldCp(uss_RestoreDir, a_tp, ':', uss_RestoreDirLen,
810 "%s: * RestoreDir field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
811 uss_whoami, uss_RestoreDirLen, uss_RestoreDir);
814 if (uss_RestoreDir[0] == '\0')
815 goto Delete_MissingRequiredParam;
816 if ((*a_tp == '\0') || (*a_tp == '\n'))
817 goto Delete_ParsingDone;
820 uss_common_FieldCp(uss_PwdPath, a_tp, ':', uss_PwdPathLen, &overflow);
823 "%s: * Password path field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
824 uss_whoami, uss_PwdPathLen, uss_PwdPath);
827 if ((*a_tp == '\0') || (*a_tp == '\n'))
828 goto Delete_ParsingDone;
831 uss_common_FieldCp(uss_PwdFormat, a_tp, ':', uss_PwdFormatLen,
835 "%s: * Password format field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
836 uss_whoami, uss_PwdFormatLen, uss_PwdFormat);
839 if ((*a_tp == '\0') || (*a_tp == '\n'))
840 goto Delete_ParsingDone;
841 #endif /* USS_DONT_HIDE_SOME_FEATURES */
842 #endif /* USS_FUTURE_FEATURES */
844 a_tp = uss_common_FieldCp(volField, a_tp, ':', 32, &overflow);
847 "%s: * Volume save/del field in delete cmd too long (max is 32 chars; truncated value is '%s')\n",
848 uss_whoami, volField);
851 if ((*a_tp == '\0') || (*a_tp == '\n'))
852 goto Delete_ParsingDone;
854 if (strcmp(volField, "delvolume") == 0)
861 * If there's anything left on the line, we ignore it. Announce
862 * the bulk delete parameters we've parsed if we're being verbose,
866 #if USS_FUTURE_FEATURES
867 #if USS_DONT_HIDE_SOME_FEATURES
869 "\nDeleting user '%s' mounted at '%s', restoredir='%s', pwd path='%s', pwd format='%s'",
870 uss_User, uss_MountPoint, uss_RestoreDir, uss_PwdPath,
872 #endif /* USS_DONT_HIDE_SOME_FEATURES */
874 fprintf(stderr, "\nDeleting user '%s' mounted at '%s'", uss_User,
876 #endif /* USS_FUTURE_FEATURES */
878 fprintf(stderr, ", saving user's volume\n");
880 fprintf(stderr, ", deleting user's volume\n");
883 /*Verbose status of delete command */
885 * Now do the real work.
889 Delete_MissingRequiredParam:
891 "%s: * All of the user, mountpoint, and restoredir fields must appear in a bulk delete command line.\n",
895 } /*DoBulkDeleteLine */
897 #if USS_FUTURE_FEATURES
898 #if USS_DONT_HIDE_SOME_FEATURES
899 /*-----------------------------------------------------------------------
900 * static DoBulkPurgeVolumeLine
903 * Process the given bulk add command.
906 * a_buf : Ptr to the buffer holding the bulk add command.
907 * a_tp : Ptr to the first char past the opcode.
910 * 0 if everything went well,
911 * -1 if something went wrong in the function, or
912 * Lower-level error code if something went wrong below us.
915 * Nothing interesting.
919 *------------------------------------------------------------------------*/
922 DoBulkPurgeVolumeLine(a_buf, a_tp)
926 { /*DoBulkPurgeVolumeLine */
928 register int i; /*Loop variable */
929 int overflow; /*Did a field copy overflow happen? */
932 * Pull out all the fields.
934 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
937 "%s: * User field in purgevolume cmd too long (max is %d chars; truncated value is '%s')\n",
938 uss_whoami, uss_UserLen, uss_User);
941 if ((*a_tp == '\0') || (*a_tp == '\n')) {
943 "%s: * The user field must appear in a bulk add command.\n",
949 uss_common_FieldCp(uss_RealName, a_tp, ':', uss_RealNameLen,
953 "%s: * Real name field in purgevolume cmd too long (max is %d chars; truncated value is '%s')\n",
954 uss_whoami, uss_RealNameLen, uss_RealName);
957 if (uss_RealName[0] == '\0') {
959 * The user's real name has not been supplied. As a
960 * default, we use the account name.
962 sprintf(uss_RealName, "%s", uss_User);
964 fprintf(stderr, "%s: Using default real name, '%s'\n", uss_whoami,
967 /*Use default full name */
968 a_tp = uss_common_FieldCp(uss_Pwd, a_tp, ':', uss_PwdLen, &overflow);
971 "%s: * Password field in purgevolume cmd too long (max is %d chars; truncated value is '%s')\n",
972 uss_whoami, uss_PwdLen, uss_Pwd);
975 if (uss_Pwd[0] == '\0') {
977 * The user's password has not been provided. Use
980 sprintf(uss_Pwd, "%s", uss_DEFAULT_PASSWORD);
982 fprintf(stderr, "%s: Using default password, '%s'\n", uss_whoami,
984 } /*Use default password */
985 if ((*a_tp == '\0') || (*a_tp == '\n'))
989 uss_common_FieldCp(uss_Server, a_tp, ':', uss_ServerLen, &overflow);
991 fprintf(stderr, "%s: * Server field too long (max is %d chars)\n",
992 uss_whoami, uss_ServerLen);
995 if ((*a_tp == '\0') || (*a_tp == '\n'))
999 uss_common_FieldCp(uss_Partition, a_tp, ':', uss_PartitionLen,
1002 fprintf(stderr, "%s: * Partition field too long (max is %d chars)\n",
1003 uss_whoami, uss_PartitionLen);
1006 if ((*a_tp == '\0') || (*a_tp == '\n'))
1010 uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
1013 fprintf(stderr, "%s: * Mountpoint field too long (max is %d chars)\n",
1014 uss_whoami, uss_MountPointLen);
1017 if ((*a_tp == '\0') || (*a_tp == '\n'))
1020 a_tp = uss_common_FieldCp(uss_Uid, a_tp, ':', uss_UidLen, &overflow);
1022 fprintf(stderr, "%s: * UID field too long (max is %d chars)\n",
1023 uss_whoami, uss_UidLen);
1026 uss_DesiredUID = atoi(uss_Uid);
1027 if ((*a_tp == '\0') || (*a_tp == '\n'))
1030 for (uss_VarMax = 1; uss_VarMax < 10; uss_VarMax++) {
1032 uss_common_FieldCp(uss_Var[uss_VarMax], a_tp, ':',
1033 uss_MAX_ARG_SIZE, &overflow);
1036 "%s: * Variable %d field too long (max is %d chars)\n",
1037 uss_whoami, uss_VarMax, uss_MAX_ARG_SIZE);
1040 if ((*a_tp == '\0') || (*a_tp == '\n'))
1045 * If there's anything left on the line, we ignore it. Announce
1046 * the bulk add parameters we've parsed or filled in if we're
1047 * being verbose, then go for it.
1051 "\nAdding user '%s' ('%s'), password='%s' on server '%s', partition '%s', home directory='%s'",
1052 uss_User, uss_RealName, uss_Pwd,
1053 (uss_Server[0] != '\0' ? uss_Server : "<default>"),
1054 (uss_Partition[0] != '\0' ? uss_Partition : "<default>"),
1055 (uss_MountPoint[0] != '\0' ? uss_MountPoint : "<default>"));
1057 fprintf(stderr, ", uid preset to %d\n", uss_DesiredUID);
1059 fprintf(stderr, ", no preset uid\n");
1060 for (i = 1; i <= uss_VarMax; i++) {
1061 if (uss_Var[i][0] != '\0')
1062 fprintf(stderr, "$%1d='%s' ", i, uss_Var[i]);
1065 fprintf(stderr, "\n");
1068 /*Verbose status of add command */
1070 * Now do the real work.
1074 } /*DoBulkPurgeVolumeLine */
1075 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1076 #endif /* USS_FUTURE_FEATURES */
1078 #if USS_FUTURE_FEATURES
1079 #if USS_DONT_HIDE_SOME_FEATURES
1080 /*-----------------------------------------------------------------------
1081 * static DoBulkRestoreLine
1084 * Process the given bulk add command.
1087 * a_buf : Ptr to the buffer holding the bulk add command.
1088 * a_tp : Ptr to the first char past the opcode.
1091 * 0 if everything went well,
1092 * -1 if something went wrong in the function, or
1093 * Lower-level error code if something went wrong below us.
1096 * Nothing interesting.
1100 *------------------------------------------------------------------------*/
1103 DoBulkRestoreLine(a_buf, a_tp)
1107 { /*DoBulkRestoreLine */
1109 register int i; /*Loop variable */
1110 int overflow; /*Overflow occur on field copy? */
1113 * Pull out all the fields.
1115 a_tp = uss_common_FieldCp(uss_User, a_tp, ':', uss_UserLen, &overflow);
1117 fprintf(stderr, "%s: * User field too long (max is %d chars)\n",
1118 uss_whoami, uss_UserLen);
1121 if ((*a_tp == '\0') || (*a_tp == '\n')) {
1123 "%s: * The user field must appear in a bulk add command.\n",
1129 uss_common_FieldCp(uss_RealName, a_tp, ':', uss_RealNameLen,
1132 fprintf(stderr, "%s: * Real name field too long (max is %d chars)\n",
1133 uss_whoami, uss_RealNameLen);
1136 if (uss_RealName[0] == '\0') {
1138 * The user's real name has not been supplied. As a
1139 * default, we use the account name.
1141 sprintf(uss_RealName, "%s", uss_User);
1143 fprintf(stderr, "%s: Using default real name, '%s'\n", uss_whoami,
1146 /*Use default full name */
1147 a_tp = uss_common_FieldCp(uss_Pwd, a_tp, ':', uss_PwdLen, &overflow);
1149 fprintf(stderr, "%s: * Password field too long (max is %d chars)\n",
1150 uss_whoami, uss_PwdLen);
1153 if (uss_Pwd[0] == '\0') {
1155 * The user's password has not been provided. Use
1158 sprintf(uss_Pwd, "%s", uss_DEFAULT_PASSWORD);
1160 fprintf(stderr, "%s: Using default password, '%s'\n", uss_whoami,
1162 } /*Use default password */
1163 if ((*a_tp == '\0') || (*a_tp == '\n'))
1167 uss_common_FieldCp(uss_Server, a_tp, ':', uss_ServerLen, &overflow);
1169 fprintf(stderr, "%s: * Server field too long (max is %d chars)\n",
1170 uss_whoami, uss_ServerLen);
1173 if ((*a_tp == '\0') || (*a_tp == '\n'))
1177 uss_common_FieldCp(uss_Partition, a_tp, ':', uss_PartitionLen,
1180 fprintf(stderr, "%s: * Partition field too long (max is %d chars)\n",
1181 uss_whoami, uss_PartitionLen);
1184 if ((*a_tp == '\0') || (*a_tp == '\n'))
1188 uss_common_FieldCp(uss_MountPoint, a_tp, ':', uss_MountPointLen,
1191 fprintf(stderr, "%s: * mountpoint field too long (max is %d chars)\n",
1192 uss_whoami, uss_MountPointLen);
1195 if ((*a_tp == '\0') || (*a_tp == '\n'))
1198 a_tp = uss_common_FieldCp(uss_Uid, a_tp, ':', uss_UidLen, &overflow);
1200 fprintf(stderr, "%s: * UID field too long (max is %d chars)\n",
1201 uss_whoami, uss_UidLen);
1204 uss_DesiredUID = atoi(uss_Uid);
1205 if ((*a_tp == '\0') || (*a_tp == '\n'))
1208 for (uss_VarMax = 1; uss_VarMax < 10; uss_VarMax++) {
1210 uss_common_FieldCp(uss_Var[uss_VarMax], a_tp, ':',
1211 uss_MAX_ARG_SIZE, &overflow);
1214 "%s: * Variable %d field too long (max is %d chars)\n",
1215 uss_whoami, uss_VarMax, uss_MAX_ARG_SIZE);
1218 if ((*a_tp == '\0') || (*a_tp == '\n'))
1223 * If there's anything left on the line, we ignore it. Announce
1224 * the bulk add parameters we've parsed or filled in if we're
1225 * being verbose, then go for it.
1229 "\nAdding user '%s' ('%s'), password='%s' on server '%s', partition '%s', home directory='%s'",
1230 uss_User, uss_RealName, uss_Pwd,
1231 (uss_Server[0] != '\0' ? uss_Server : "<default>"),
1232 (uss_Partition[0] != '\0' ? uss_Partition : "<default>"),
1233 (uss_MountPoint[0] != '\0' ? uss_MountPoint : "<default>"));
1235 fprintf(stderr, ", uid preset to %d\n", uss_DesiredUID);
1237 fprintf(stderr, ", no preset uid\n");
1238 for (i = 1; i <= uss_VarMax; i++) {
1239 if (uss_Var[i][0] != '\0')
1240 fprintf(stderr, "$%1d='%s' ", i, uss_Var[i]);
1243 fprintf(stderr, "\n");
1246 /*Verbose status of add command */
1248 * Now do the real work.
1250 return (DoRestore());
1252 } /*DoBulkRestoreLine */
1253 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1254 #endif /* USS_FUTURE_FEATURES */
1257 /*-----------------------------------------------------------------------
1258 * static DoBulkExecLine
1261 * Process the given bulk exec command.
1264 * a_buf : Ptr to the buffer holding the bulk exec command.
1265 * a_tp : Ptr to the first char past the opcode.
1268 * 0 if everything went well,
1269 * -1 if something went wrong in the function, or
1270 * Lower-level error code if something went wrong below us.
1273 * Nothing interesting.
1277 *------------------------------------------------------------------------*/
1280 DoBulkExecLine(a_buf, a_tp)
1284 { /*DoBulkExecLine */
1286 register afs_int32 code; /*Return code */
1289 * Really, uss_procs_Exec does all the work for us!
1291 code = uss_procs_Exec(a_tp);
1294 } /*DoBulkExecLine */
1297 /*-----------------------------------------------------------------------
1301 * Process the given bulk command.
1304 * a_as : Ptr to the command line syntax descriptor.
1305 * a_rock : Ptr to the rock passed in.
1308 * 0 if everything went well,
1309 * 1 if something went wrong in the function, or
1310 * Lower-level error code if something went wrong below us.
1313 * Nothing interesting.
1317 *------------------------------------------------------------------------*/
1320 HandleBulk(a_as, a_rock)
1321 register struct cmd_syndesc *a_as;
1326 #define USS_BULK_CMD_CHARS 128
1327 #define USS_BULK_BUF_CHARS 1024
1329 char cmd[USS_BULK_CMD_CHARS], buf[USS_BULK_BUF_CHARS];
1337 char tbuf[USS_BULK_BUF_CHARS];
1340 * Open up the bulk file, croak if we can't.
1342 if ((infile = fopen(a_as->parms[ABULK_FILE].items->data, "r")) == NULL) {
1343 fprintf(stderr, "%s: * Failed to open input file %s\n", uss_whoami,
1344 a_as->parms[ABULK_FILE].items->data);
1349 * Pull out the other fields as passed in by the caller on the
1352 if (a_as->parms[AUSS_DRYRUN].items)
1354 if (a_as->parms[AUSS_SKIPAUTH].items)
1355 uss_SkipKaserver = 1;
1356 if (a_as->parms[AUSS_OVERWRITE].items)
1358 if (a_as->parms[AUSS_PIPE].items)
1360 if (a_as->parms[AUSS_ADMIN].items)
1361 strcpy(uss_Administrator, a_as->parms[AUSS_ADMIN].items->data);
1363 uss_Administrator[0] = '\0';
1365 if (a_as->parms[AUSS_PWEXPIRES].items) {
1366 uss_BulkExpires = atoi(a_as->parms[AUSS_PWEXPIRES].items->data);
1367 if (uss_BulkExpires < 0 || uss_BulkExpires > 254) {
1369 "%s: Password Expiration must be in [0..255] days\n",
1374 uss_BulkExpires = 0;
1377 * Initialize uss_AccountCreator().
1379 code = uss_kauth_InitAccountCreator();
1384 * Process all the lines in the bulk command file.
1386 uss_VarMax = 0; /*No uss vars picked up yet */
1387 while (fgets(buf, sizeof(buf), infile) != NULL) {
1389 /* skip blank line */
1394 /* After executing the line, print the line and the result */
1396 if (error == UNOQUORUM) {
1402 printf("LINE %d %s %s", line_no, (error ? "FAIL" : "SUCCESS"),
1408 * Reset the common variables for each command line
1413 strncpy(tbuf, buf, USS_BULK_BUF_CHARS-1);
1416 * First line of file = line 1.
1422 * Get the opcode and act upon it.
1424 tp = uss_common_FieldCp(cmd, buf, ' ', USS_BULK_CMD_CHARS, &overflow);
1427 "%s: * Bulk opcode field too long (max is %d chars)\n",
1428 uss_whoami, USS_BULK_CMD_CHARS);
1436 if (strcmp(cmd, "add") == 0) {
1437 error = DoBulkAddLine(buf, tp);
1440 if (strcmp(cmd, "delete") == 0) {
1441 error = DoBulkDeleteLine(buf, tp);
1444 if (strcmp(cmd, "delvolume") == 0) {
1449 #if USS_FUTURE_FEATURES
1450 #if USS_DONT_HIDE_SOME_FEATURES
1451 if (strcmp(cmd, "purgevolume") == 0) {
1452 error = DoBulkPurgeVolumeLine(buf, tp);
1455 if (strcmp(cmd, "pwdformat") == 0) {
1456 /*Set the password format here */
1459 if (strcmp(cmd, "pwdpath") == 0) {
1460 /*Set the password path here */
1463 if (strcmp(cmd, "restore") == 0) {
1464 error = DoBulkRestoreLine(buf, tp);
1467 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1468 #endif /* USS_FUTURE_FEATURES */
1469 if (strcmp(cmd, "savevolume") == 0) {
1470 /*Set the savevolume flag here */
1473 if (strcmp(cmd, "exec") == 0) {
1474 error = DoBulkExecLine(buf, tp);
1479 * If none of the valid opcodes match, see if the line is either
1480 * a comment of a blank. If so, just ignore it. Otherwise, we
1483 if ((cmd[0] != '#') && (cmd[0] != '\0')) {
1485 "%s: ** Unrecognized command ('%s') in bulk file\n",
1494 } /*Bad bulk line */
1495 } /*Process a line in the bulk file */
1501 printf("LINE %d %s %s", line_no, (error ? "FAIL" : "SUCCESS"), tbuf);
1509 /*-----------------------------------------------------------------------
1513 * Process the given (non-bulk) add command.
1516 * a_as : Ptr to the command line syntax descriptor.
1517 * a_rock : Ptr to the rock passed in.
1520 * 0 if everything went well,
1521 * 1 if something went wrong in the function, or
1522 * Lower-level error code if something went wrong below us.
1525 * Nothing interesting.
1529 *------------------------------------------------------------------------*/
1532 AddUser(a_as, a_rock)
1533 register struct cmd_syndesc *a_as;
1539 register struct cmd_item *ti;
1543 * Before we do anything else, make sure we initialize the
1544 * global field settings.
1549 * Pull out the fields as passed in by the caller on the command
1552 strcpy(uss_User, a_as->parms[AUP_USER].items->data);
1553 if (a_as->parms[AUP_REALNAME].items)
1554 strcpy(uss_RealName, a_as->parms[AUP_REALNAME].items->data);
1556 strcpy(uss_RealName, uss_User);
1557 if (a_as->parms[AUP_PASSWD].items)
1558 strcpy(uss_Pwd, a_as->parms[AUP_PASSWD].items->data);
1560 strcpy(uss_Pwd, uss_DEFAULT_PASSWORD);
1561 if (a_as->parms[AUP_SERVER].items)
1562 strcpy(uss_Server, a_as->parms[AUP_SERVER].items->data);
1563 if (a_as->parms[AUP_PART].items)
1564 strcpy(uss_Partition, a_as->parms[AUP_PART].items->data);
1565 if (a_as->parms[AUP_MNTPT].items)
1566 strcpy(uss_MountPoint, a_as->parms[AUP_MNTPT].items->data);
1567 if (a_as->parms[AUP_UID].items)
1568 uss_DesiredUID = atoi(a_as->parms[AUP_UID].items->data);
1571 if (a_as->parms[AUP_PWEXPIRES].items) {
1572 uss_Expires = atoi(a_as->parms[AUP_PWEXPIRES].items->data);
1573 if (uss_Expires < 0 || uss_Expires > 254) {
1575 "%s: Password Expiration must be in [0..255] days\n",
1582 if (a_as->parms[AUSS_DRYRUN].items)
1584 if (a_as->parms[AUSS_SKIPAUTH].items)
1585 uss_SkipKaserver = 1;
1586 if (a_as->parms[AUSS_OVERWRITE].items)
1588 if (a_as->parms[AUSS_ADMIN].items) {
1589 strcpy(uss_Administrator, a_as->parms[AUSS_ADMIN].items->data);
1590 /* fprintf(stderr, "debugging: uss_Administrator set to '%s'\n",
1591 * uss_Administrator); */
1593 /* fprintf(stderr, "debugging: No administrator value given\n"); */
1594 uss_Administrator[0] = '\0';
1597 if (a_as->parms[AUSS_VAR].items) {
1598 for (ti = a_as->parms[AUSS_VAR].items; ti; ti = ti->next) {
1600 if (i < 0 || i > 9 || (i == 0 && *ti->data != '0')) {
1602 "%s: Bad -var format: must be '0 val0 1 val1 ... 9 val9'\n",
1609 "%s: -var values must appear in pairs: 'Num val'\n",
1613 strcpy(uss_Var[i], ti->data);
1616 } /*Remember each VAR item */
1619 /*VAR items exist */
1621 * Initialize uss_AccountCreator().
1623 code = uss_kauth_InitAccountCreator();
1628 * Now that the command line arguments are parsed and properly stored,
1636 /*-----------------------------------------------------------------------
1640 * Create the desired user account, having parsed the add command
1641 * from either the command line or a bulk file.
1647 * 0 if everything went well,
1648 * 1 if something went wrong in the function, or
1649 * Lower-level error code if something went wrong below us.
1652 * All values needed have been put in the common variables.
1656 *------------------------------------------------------------------------*/
1662 int code; /*Return code */
1665 * Make sure the user name is legal.
1667 code = uss_kauth_CheckUserName();
1672 * This time around, we start off assuming the global value of the
1675 uss_OverwriteThisOne = uss_Overwrite;
1678 * Open up the template file before doing any real processing,
1679 * so we can quit early should it not be found.
1682 if ((yyin = uss_procs_FindAndOpen(Template)) == NULL) {
1683 fprintf(stderr, "%s: ** Can't open template file '%s'\n",
1684 uss_whoami, Template);
1687 yyout = fopen("/dev/null", "w");
1692 * Add the new user to the Protection DB.
1694 code = uss_ptserver_AddUser(uss_User, uss_Uid);
1696 fprintf(stderr, "%s: Failed to add user '%s' to the Protection DB\n",
1697 uss_whoami, uss_User);
1702 * Add the new user to the Authentication DB.
1704 code = uss_kauth_AddUser(uss_User, uss_Pwd);
1706 fprintf(stderr, "%s: Can't add user '%s' to the Authentication DB\n",
1707 uss_whoami, uss_User);
1712 * Process the items covered by the template file.
1714 if (yyparse() && (!uss_ignoreFlag))
1718 * Finally, clean up after ourselves, removing the uss_AccountCreator
1719 * from various of the new user's ACLs.
1721 return (uss_acl_CleanUp());
1726 #if USS_FUTURE_FEATURES
1727 #if USS_DONT_HIDE_SOME_FEATURES
1728 /*-----------------------------------------------------------------------
1732 * Perform the parsed restore command.
1738 * 0 if everything went well,
1739 * 1 if something went wrong in the function, or
1740 * Lower-level error code if something went wrong below us.
1743 * All values needed have been put in the common variables.
1747 *------------------------------------------------------------------------*/
1756 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1757 #endif /* USS_FUTURE_FEATURES */
1760 /*-----------------------------------------------------------------------
1761 * static InitETTables
1764 * Set up the error code tables for the various modules we use.
1773 * Nothing interesting.
1777 *------------------------------------------------------------------------*/
1785 * In order to get error code -> error message translations to work,
1786 * we have to initialize all error tables.
1788 initialize_CMD_error_table();
1789 initialize_RXK_error_table();
1790 initialize_KTC_error_table();
1791 initialize_KA_error_table();
1792 initialize_ACFG_error_table();
1793 initialize_VL_error_table();
1794 initialize_PT_error_table();
1795 initialize_U_error_table();
1803 /* this sucks but it works for now.
1808 #include "AFS_component_version_number.c"
1816 register struct cmd_syndesc *cs; /*Command line syntax descriptor */
1817 register afs_int32 code; /*Return code */
1819 #ifdef AFS_AIX32_ENV
1821 * The following signal action for AIX is necessary so that in case of a
1822 * crash (i.e. core is generated) we can include the user's data section
1823 * in the core dump. Unfortunately, by default, only a partial core is
1824 * generated which, in many cases, isn't too useful.
1826 struct sigaction nsa;
1828 sigemptyset(&nsa.sa_mask);
1829 nsa.sa_handler = SIG_DFL;
1830 nsa.sa_flags = SA_FULLDUMP;
1831 sigaction(SIGABRT, &nsa, NULL);
1832 sigaction(SIGSEGV, &nsa, NULL);
1834 strcpy(uss_whoami, argv[0]);
1835 yyin = (FILE *) NULL;
1837 uss_fs_InBuff = (char *)malloc(USS_FS_MAX_SIZE); /*Cache Manager input buff */
1838 uss_fs_OutBuff = (char *)malloc(USS_FS_MAX_SIZE); /*Cache Manager output buff */
1839 if (!uss_fs_InBuff || !uss_fs_OutBuff) {
1840 fprintf(stderr, "%s: Can't malloc in/out buffers\n", uss_whoami);
1844 /* ----------------------------- add ----------------------------- */
1846 cs = cmd_CreateSyntax("add", AddUser, 0, "create a new user account");
1847 cmd_AddParm(cs, "-user", CMD_SINGLE, 0, "login name");
1848 cmd_AddParm(cs, "-realname", CMD_SINGLE, CMD_OPTIONAL,
1849 "full name in quotes");
1850 cmd_AddParm(cs, "-pass", CMD_SINGLE, CMD_OPTIONAL, "initial password");
1852 cmd_AddParm(cs, "-pwexpires", CMD_SINGLE, CMD_OPTIONAL,
1853 "password expires in [0..254] days (0 => never)");
1854 cmd_AddParm(cs, "-server", CMD_SINGLE, CMD_OPTIONAL,
1855 "FileServer for home volume");
1856 cmd_AddParm(cs, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1857 "FileServer's disk partition for home volume");
1858 cmd_AddParm(cs, "-mount", CMD_SINGLE, CMD_OPTIONAL,
1859 "home directory mount point");
1860 cmd_AddParm(cs, "-uid", CMD_SINGLE, CMD_OPTIONAL,
1861 "uid to assign the user");
1862 cmd_Seek(cs, AUSS_TEMPLATE);
1863 cmd_AddParm(cs, "-template", CMD_SINGLE, CMD_OPTIONAL,
1864 "pathname of template file");
1865 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1866 cmd_AddParm(cs, "-var", CMD_LIST, CMD_OPTIONAL | CMD_EXPANDS,
1867 "auxiliary argument pairs (Num val)");
1868 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1869 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1870 "administrator to authenticate");
1871 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1872 "only list what would be done, don't do it");
1873 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1874 "ignore all contact with the authentication server (kaserver)");
1875 cmd_AddParm(cs, "-overwrite", CMD_FLAG, CMD_OPTIONAL,
1876 "Overwrite pre-existing files in user home directory tree");
1879 /* ---------------------------- bulk ----------------------------- */
1881 cs = cmd_CreateSyntax("bulk", HandleBulk, 0, "bulk input mode");
1882 cmd_AddParm(cs, "-file", CMD_SINGLE, 0, "bulk input file");
1883 cmd_Seek(cs, AUSS_TEMPLATE);
1884 cmd_AddParm(cs, "-template", CMD_SINGLE, CMD_OPTIONAL,
1885 "pathname of template file");
1886 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1887 cmd_Seek(cs, AUSS_CELL);
1888 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1889 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1890 "administrator to authenticate");
1891 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1892 "only list what would be done, don't do it");
1893 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1894 "ignore all contact with the authentication server (kaserver)");
1895 cmd_AddParm(cs, "-overwrite", CMD_FLAG, CMD_OPTIONAL,
1896 "Overwrite pre-existing files in user home directory tree");
1897 cmd_Seek(cs, AUSS_PWEXPIRES);
1898 cmd_AddParm(cs, "-pwexpires", CMD_SINGLE, CMD_OPTIONAL,
1899 "password expires in [0..254] days (0 => never)");
1900 cmd_Seek(cs, AUSS_PIPE);
1901 cmd_AddParm(cs, "-pipe", CMD_FLAG, CMD_OPTIONAL,
1902 "don't prompt for passwd; get it from standard input");
1904 /* ---------------------------- delete --------------------------- */
1906 cs = cmd_CreateSyntax("delete", DelUser, 0, "delete a user account");
1907 cmd_AddParm(cs, "-user", CMD_SINGLE, 0, "login name");
1908 cmd_AddParm(cs, "-mountpoint", CMD_SINGLE, CMD_OPTIONAL,
1909 "mountpoint for user's volume");
1910 #if USS_FUTURE_FEATURES
1911 #if USS_DONT_HIDE_SOME_FEATURES
1912 cmd_AddParm(cs, "-restoredir", CMD_SINGLE, 0,
1913 "directory where restore info is to be placed");
1914 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1915 #endif /* USS_FUTURE_FEATURES */
1916 cmd_AddParm(cs, "-savevolume", CMD_FLAG, CMD_OPTIONAL,
1917 "don't destroy the user's volume");
1918 #if USS_FUTURE_FEATURES
1919 #if USS_DONT_HIDE_SOME_FEATURES
1920 cmd_AddParm(cs, "-pwdpath", CMD_SINGLE, CMD_OPTIONAL,
1921 "pathname to the password file");
1922 cmd_AddParm(cs, "-pwdformat", CMD_SINGLE, CMD_OPTIONAL,
1923 "password entry format");
1924 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1925 #endif /* USS_FUTURE_FEATURES */
1926 cmd_Seek(cs, AUSS_VERBOSE);
1927 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1928 cmd_Seek(cs, AUSS_CELL);
1929 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1930 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1931 "administrator to authenticate");
1932 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1933 "only list what would be done, don't do it");
1934 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1935 "ignore all contact with the authentication server (kaserver)");
1936 #if USS_FUTURE_FEATURES
1937 #if USS_DONT_HIDE_SOME_FEATURES
1938 /* ------------------------- purgevolumes ------------------------ */
1940 cs = cmd_CreateSyntax("purgevolumes", PurgeVolumes, 0,
1941 "destroy a deleted user's volume");
1942 cmd_AddParm(cs, "-volname", CMD_LIST, CMD_OPTIONAL | CMD_EXPANDS,
1943 "Name(s) of volume(s) to destroy");
1944 cmd_AddParm(cs, "-volfile", CMD_SINGLE, CMD_OPTIONAL,
1945 "pathname to volume purge file");
1946 cmd_Seek(cs, AUSS_VERBOSE);
1947 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1948 cmd_Seek(cs, AUSS_CELL);
1949 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1950 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1951 "administrator to authenticate");
1952 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1953 "only list what would be done, don't do it");
1954 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1955 "ignore all contact with the authentication server (kaserver)");
1956 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1957 #endif /* USS_FUTURE_FEATURES */
1959 #if USS_FUTURE_FEATURES
1960 #if USS_DONT_HIDE_SOME_FEATURES
1961 /* ---------------------------- restore -------------------------- */
1963 cs = cmd_CreateSyntax("restore", RestoreUser, 0,
1964 "restore a deleted user account");
1965 cmd_AddParm(cs, "-user", CMD_SINGLE, 0, "login name to restore");
1966 cmd_AddParm(cs, "-uid", CMD_SINGLE, 0, "user id number");
1967 cmd_AddParm(cs, "-mount", CMD_SINGLE, 0, "mountpoint for user's volume");
1968 cmd_AddParm(cs, "-volname", CMD_SINGLE, 0, "name of user's volume");
1969 cmd_AddParm(cs, "-realname", CMD_SINGLE, CMD_OPTIONAL,
1970 "user's full name");
1971 cmd_AddParm(cs, "-server", CMD_SINGLE, CMD_OPTIONAL,
1972 "FileServer to host user's volume");
1973 cmd_AddParm(cs, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1974 "FileServer partition to host user's volume");
1975 cmd_AddParm(cs, "-pwdpath", CMD_SINGLE, CMD_OPTIONAL,
1976 "pathname to the password file");
1977 cmd_AddParm(cs, "-pwdformat", CMD_SINGLE, CMD_OPTIONAL,
1978 "password entry format");
1979 cmd_Seek(cs, AUSS_VERBOSE);
1980 cmd_AddParm(cs, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose operation");
1981 cmd_Seek(cs, AUSS_CELL);
1982 cmd_AddParm(cs, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1983 cmd_AddParm(cs, "-admin", CMD_SINGLE, CMD_OPTIONAL,
1984 "administrator to authenticate");
1985 cmd_AddParm(cs, "-dryrun", CMD_FLAG, CMD_OPTIONAL,
1986 "only list what would be done, don't do it");
1987 cmd_AddParm(cs, "-skipauth", CMD_FLAG, CMD_OPTIONAL,
1988 "ignore all contact with the authentication server (kaserver)");
1989 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1990 #endif /* USS_FUTURE_FEATURES */
1993 * Set up all the error code translation tables, initialize the
1994 * command variables, and set up to parse the common command line
1999 cmd_SetBeforeProc(GetCommon, NULL);
2002 * Execute the parsed command.
2004 code = cmd_Dispatch(argc, argv);
2007 fprintf(stderr, "%s: Call to cmd_Dispatch() failed; code is %d\n",
2013 code = uss_fs_UnlogToken(uss_Cell);