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 ---------------------
17 #include <afsconfig.h>
18 #include <afs/param.h>
22 #include <afs/cmd.h> /*Command line parsing */
23 #include <afs/cellconfig.h> /*Cell config defs */
24 #include <afs/kautils.h> /*MAXKTCREALMLEN & MAXKTCNAMELEN */
25 #include <afs/pterror.h>
26 #include <afs/vlserver.h>
29 #include "uss_common.h" /*Common uss definitions, globals */
30 #include "uss_procs.h" /*Main uss operations */
31 #include "uss_kauth.h" /*AuthServer routines */
32 #include "uss_fs.h" /*CacheManager ops */
33 #include "uss_ptserver.h"
37 extern int yylex(void);
38 extern int yyparse (void);
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 *uss_yyin
, *uss_yyout
; /*YACC input & output files */
101 int uss_BulkExpires
= 0;
104 static int DoAdd(void);
106 /*-----------------------------------------------------------------------
110 * Read in the command line arguments common to all uss operations.
113 * a_as : Ptr to the command line syntax descriptor.
119 * May exit the program if trouble is encountered determining the
120 * cell name. Set up as the command line parser's BeforeProc().
124 *------------------------------------------------------------------------*/
127 GetCommon(struct cmd_syndesc
*a_as
, void *arock
)
130 int code
; /*Result of ka_LocalCell */
132 if (strcmp(a_as
->name
, "help") == 0)
134 if (a_as
->parms
[AUSS_TEMPLATE
].items
)
135 strcpy(Template
, a_as
->parms
[AUSS_TEMPLATE
].items
->data
);
136 if (a_as
->parms
[AUSS_VERBOSE
].items
)
141 code
= ka_CellConfig(AFSDIR_CLIENT_ETC_DIRPATH
);
143 fprintf(stderr
, "%s: ** Call to ka_CellConfig() failed (code=%d)\n",
146 if (a_as
->parms
[AUSS_CELL
].items
) {
147 char local_cell
[MAXKTCREALMLEN
];
149 (a_as
->parms
[AUSS_CELL
].items
->data
, uss_Cell
, 0 /*local */ )) {
150 fprintf(stderr
, "%s: ** Unknown or ambiguous cell name: %s\n",
151 uss_whoami
, a_as
->parms
[AUSS_CELL
].items
->data
);
155 * Get the local cell name
157 if (ka_ExpandCell((char *)0, local_cell
, 0 /*local */ )) {
158 fprintf(stderr
, "Can't get local cellname\n");
161 if (strcmp(uss_Cell
, local_cell
)) {
163 * Not the same; not a local cell
169 * Get the local cell name
171 if (ka_ExpandCell((char *)0, uss_Cell
, 0 /*local */ )) {
172 fprintf(stderr
, "Can't get local cellname\n");
176 fprintf(stderr
, "No cell specified; assuming '%s'.\n", uss_Cell
);
184 /*-----------------------------------------------------------------------
185 * static SaveRestoreInfo
188 * Save all the information required to restore the currently
189 * parsed user account.
195 * 0 if everything went well,
196 * 1 if something went wrong in the function, or
197 * Lower-level error code if something went wrong below us.
200 * We need to determine and store the following new pieces of
203 * Name of user's volume
204 * FileServer & partition hosting the volume
208 *------------------------------------------------------------------------*/
211 SaveRestoreInfo(void)
212 { /*SaveRestoreInfo */
214 static char rn
[] = "uss:SaveRestoreInfo"; /*Routine name */
216 afs_int32 code
; /*Return code */
217 afs_int32 deletedUid
; /*Uid to be nuked */
220 * Translate the user name to the user ID.
222 code
= uss_ptserver_XlateUser(uss_User
, &deletedUid
);
226 printf("%s: User '%s' translated to uid %d\n", rn
, uss_User
, deletedUid
);
228 sprintf(uss_Uid
, "%d", deletedUid
);
231 * Pull out the name of the volume at the given mountpoint, along
232 * with the name of the FileServer and partition hosting it. This
233 * also sets up all the numerical info for the above.
235 code
= uss_vol_GetVolInfoFromMountPoint(uss_MountPoint
);
240 * Report back that we did fine.
244 } /*SaveRestoreInfo */
247 /*-----------------------------------------------------------------------
251 * With everything properly inserted into the common variables,
252 * delete the specified user account.
258 * 0 if everything went well,
259 * 1 if something went wrong in the function, or
260 * Lower-level error code if something went wrong below us.
263 * Nothing interesting.
267 *------------------------------------------------------------------------*/
273 int code
; /*Return code */
276 * Make sure the user name is a lega one.
278 code
= uss_kauth_CheckUserName();
283 * Store all the info about the account before actually doing
286 code
= SaveRestoreInfo();
290 if ((uss_VolumeID
!= 0) && (uss_MountPoint
[0] != '\0')) {
292 * Unmount the user's volume from the file system.
296 "Unmounting volume '%s' (ID %u) mounted at '%s'\n",
297 uss_Volume
, uss_VolumeID
, uss_MountPoint
);
300 code
= uss_fs_RmMountPoint(uss_MountPoint
);
303 fprintf(stderr
, "%s: Can't remove mountpoint '%s'\n",
304 uss_whoami
, uss_MountPoint
);
305 return (code
); /* Must return - we may have incorrect volume */
310 * If our caller has elected to delete the user's volume now,
313 if (!uss_SaveVolume
&& (uss_VolumeID
!= 0)) {
315 fprintf(stderr
, "Deleting volume '%s' (ID %u)\n", uss_Volume
,
320 uss_vol_DeleteVol(uss_Volume
, uss_VolumeID
, uss_Server
,
321 uss_ServerID
, uss_Partition
, uss_PartitionID
);
324 fprintf(stderr
, "%s: Can't delete volume '%s' (ID %u)\n",
325 uss_whoami
, uss_Volume
, uss_VolumeID
);
328 } else if (uss_verbose
&& (uss_MountPoint
[0] != '\0'))
329 printf("%s: Warning: Not attempting to delete volume at '%s'\n",
330 uss_whoami
, uss_MountPoint
);
333 * Get rid of the user's authentication entry.
335 code
= uss_kauth_DelUser(uss_User
);
340 * Finally, remove the user's AFS ID from the Protection DB and
341 * return that result.
343 code
= uss_ptserver_DelUser(uss_User
);
349 /*-----------------------------------------------------------------------
353 * Process the given (non-bulk) delete command.
356 * a_as : Ptr to the command line syntax descriptor.
357 * a_rock : Ptr to the rock passed in.
360 * 0 if everything went well,
361 * 1 if something went wrong in the function, or
362 * Lower-level error code if something went wrong below us.
365 * Nothing interesting.
369 *------------------------------------------------------------------------*/
372 DelUser(struct cmd_syndesc
*a_as
, void *a_rock
)
378 * Before we do anything else, make sure we initialize the
379 * global field settings.
384 * Pull out the fields as passed in by the caller on the command
387 strcpy(uss_User
, a_as
->parms
[DUP_USER
].items
->data
);
388 if (a_as
->parms
[DUP_MNTPT
].items
)
389 strcpy(uss_MountPoint
, a_as
->parms
[DUP_MNTPT
].items
->data
);
390 #if USS_FUTURE_FEATURES
391 #if USS_DONT_HIDE_SOME_FEATURES
392 strcpy(uss_RestoreDir
, a_as
->parms
[DUP_RESTOREDIR
].items
->data
);
393 #endif /* USS_DONT_HIDE_SOME_FEATURES */
394 #endif /* USS_FUTURE_FEATURES */
397 if (a_as->parms[DUP_SAVEVOLUME].items)
401 if (a_as
->parms
[2].items
) {
404 #if USS_FUTURE_FEATURES
405 #if USS_DONT_HIDE_SOME_FEATURES
406 if (a_as
->parms
[DUP_PWDPATH
].items
)
407 strcpy(uss_PwdPath
, a_as
->parms
[DUP_PWDPATH
].items
->data
);
408 if (a_as
->parms
[DUP_PWDFORMAT
].items
)
409 strcpy(uss_PwdFormat
, a_as
->parms
[DUP_PWDFORMAT
].items
->data
);
410 #endif /* USS_DONT_HIDE_SOME_FEATURES */
411 #endif /* USS_FUTURE_FEATURES */
413 if (a_as
->parms
[AUSS_DRYRUN
].items
)
415 if (a_as
->parms
[AUSS_SKIPAUTH
].items
)
416 uss_SkipKaserver
= 1;
417 if (a_as
->parms
[AUSS_ADMIN
].items
) {
418 strcpy(uss_Administrator
, a_as
->parms
[AUSS_ADMIN
].items
->data
);
419 /* fprintf(stderr, "debugging: uss_Administrator set to '%s'\n",
420 * uss_Administrator); */
422 /* fprintf(stderr, "debugging: No administrator value given\n"); */
423 uss_Administrator
[0] = '\0';
427 * Initialize uss_AccountCreator().
429 code
= uss_kauth_InitAccountCreator();
434 * Now that the command line arguments are parsed and properly stored,
442 #if USS_FUTURE_FEATURES
443 #if USS_DONT_HIDE_SOME_FEATURES
444 /*-----------------------------------------------------------------------
445 * static PurgeVolumes
448 * Purge the given volume(s).
451 * a_as : Ptr to the command line syntax descriptor.
452 * a_rock : Ptr to the rock passed in.
455 * 0 if everything went well,
456 * 1 if something went wrong in the function, or
457 * Lower-level error code if something went wrong below us.
460 * Nothing interesting.
464 *------------------------------------------------------------------------*/
467 PurgeVolumes(struct cmd_syndesc
*a_as
, void *a_rock
)
470 fprintf(stderr
, "Sorry, purgevolumes has not yet been implemented.\n");
476 /*-----------------------------------------------------------------------
480 * Process the given delete command.
483 * a_as : Ptr to the command line syntax descriptor.
484 * a_rock : Ptr to the rock passed in.
487 * 0 if everything went well,
488 * 1 if something went wrong in the function, or
489 * Lower-level error code if something went wrong below us.
492 * Nothing interesting.
496 *------------------------------------------------------------------------*/
499 RestoreUser(struct cmd_syndesc
*a_as
, void *a_rock
)
502 fprintf(stderr
, "Sorry, restoreuser has not yet been implemented.\n");
510 /*-----------------------------------------------------------------------
511 * static DoBulkAddLine
514 * Process the given bulk add command.
517 * a_buf : Ptr to the buffer holding the bulk add command.
518 * a_tp : Ptr to the first char past the opcode.
521 * 0 if everything went well,
522 * -1 if something went wrong in the function, or
523 * Lower-level error code if something went wrong below us.
526 * The required fields are:
531 *------------------------------------------------------------------------*/
534 DoBulkAddLine(char *a_buf
, char *a_tp
)
537 int i
; /*Loop variable */
539 static char rn
[] = "DoBulkAddLine"; /*Routine name */
541 int overflow
; /*Overflow in field copy? */
544 printf("%s: Command buffer left to parse: '%s'\n", rn
, a_tp
);
546 uss_Expires
= uss_BulkExpires
;
549 * Pull out all the fields.
551 a_tp
= uss_common_FieldCp(uss_User
, a_tp
, ':', uss_UserLen
, &overflow
);
554 "%s: * User field in add cmd too long (max is %d chars; truncated value is '%s')\n",
555 uss_whoami
, uss_UserLen
, uss_User
);
558 if ((*a_tp
== '\0') || (*a_tp
== '\n')) {
560 "%s: * The user field must appear in a bulk add command.\n",
566 uss_common_FieldCp(uss_RealName
, a_tp
, ':', uss_RealNameLen
,
570 "%s: * Real name field in add cmd too long (max is %d chars; truncated value is '%s')\n",
571 uss_whoami
, uss_RealNameLen
, uss_RealName
);
574 if (uss_RealName
[0] == '\0') {
576 * The user's real name has not been supplied. As a
577 * default, we use the account name.
579 sprintf(uss_RealName
, "%s", uss_User
);
581 fprintf(stderr
, "%s: Using default real name, '%s'\n", uss_whoami
,
584 /*Use default full name */
585 a_tp
= uss_common_FieldCp(uss_Pwd
, a_tp
, ':', uss_PwdLen
, &overflow
);
588 "%s: * Password field in add cmd too long (max is %d chars; truncated value is '%s')\n",
589 uss_whoami
, uss_PwdLen
, uss_Pwd
);
592 if (uss_Pwd
[0] == '\0') {
594 * The user's password has not been provided. Use
597 sprintf(uss_Pwd
, "%s", uss_DEFAULT_PASSWORD
);
599 fprintf(stderr
, "%s: Using default password, '%s'\n", uss_whoami
,
601 } /*Use default password */
602 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
603 goto DoBulkAddLine_ParsingDone
;
608 a_tp
= uss_common_FieldCp(temp
, a_tp
, ':', 9, &overflow
);
611 "%s: * Password expiration time is longer than %d characters, ignoring...\n",
614 if (temp
[0] == '\0') {
615 /* Expiration time not specified. Use default */
617 fprintf(stderr
, "%s: Using default expiration time, '%d'\n",
618 uss_whoami
, uss_Expires
);
622 if (te
< 0 || te
> 254) {
624 "%s: * Password Expiration must be in [0..254] days, using default %d\n",
625 uss_whoami
, uss_Expires
);
630 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
631 goto DoBulkAddLine_ParsingDone
;
636 uss_common_FieldCp(uss_Server
, a_tp
, ':', uss_ServerLen
, &overflow
);
639 "%s: * Server field in add cmd too long (max is %d chars; truncated value is '%s')\n",
640 uss_whoami
, uss_ServerLen
, uss_Server
);
643 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
644 goto DoBulkAddLine_ParsingDone
;
647 uss_common_FieldCp(uss_Partition
, a_tp
, ':', uss_PartitionLen
,
651 "%s: * Partition field in add cmd too long (max is %d chars; truncated value is '%s')\n",
652 uss_whoami
, uss_PartitionLen
, uss_Partition
);
655 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
656 goto DoBulkAddLine_ParsingDone
;
659 uss_common_FieldCp(uss_MountPoint
, a_tp
, ':', uss_MountPointLen
,
663 "%s: * Mountpoint field in add cmd too long (max is %d chars; truncated value is '%s')\n",
664 uss_whoami
, uss_MountPointLen
, uss_MountPoint
);
667 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
668 goto DoBulkAddLine_ParsingDone
;
670 a_tp
= uss_common_FieldCp(uss_Uid
, a_tp
, ':', uss_UidLen
, &overflow
);
673 "%s: * UID field in add cmd too long (max is %d chars; truncated value is '%s')\n",
674 uss_whoami
, uss_UidLen
, uss_Uid
);
677 uss_DesiredUID
= atoi(uss_Uid
);
678 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
679 goto DoBulkAddLine_ParsingDone
;
681 for (uss_VarMax
= 1; uss_VarMax
< 10; uss_VarMax
++) {
683 uss_common_FieldCp(uss_Var
[uss_VarMax
], a_tp
, ':',
684 uss_MAX_ARG_SIZE
, &overflow
);
687 "%s: * Variable %d field in add cmd too long (max is %d chars; truncated value is '%s')\n",
688 uss_whoami
, uss_VarMax
, uss_MAX_ARG_SIZE
,
689 uss_Var
[uss_VarMax
]);
692 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
693 goto DoBulkAddLine_ParsingDone
;
696 DoBulkAddLine_ParsingDone
:
698 * If there's anything left on the line, we ignore it. Announce
699 * the bulk add parameters we've parsed or filled in if we're
700 * being verbose, then go for it.
704 "\nAdding user '%s' ('%s'), password='%s' on server '%s', partition '%s', home directory='%s'",
705 uss_User
, uss_RealName
, uss_Pwd
,
706 (uss_Server
[0] != '\0' ? uss_Server
: "<default>"),
707 (uss_Partition
[0] != '\0' ? uss_Partition
: "<default>"),
708 (uss_MountPoint
[0] != '\0' ? uss_MountPoint
: "<default>"));
710 fprintf(stderr
, ", uid preset to %d\n", uss_DesiredUID
);
712 fprintf(stderr
, ", no preset uid\n");
713 for (i
= 1; i
<= uss_VarMax
; i
++) {
714 if (uss_Var
[i
][0] != '\0')
715 fprintf(stderr
, "$%1d='%s' ", i
, uss_Var
[i
]);
718 fprintf(stderr
, "\n");
721 /*Verbose status of add command */
723 * Now do the real work.
730 /*-----------------------------------------------------------------------
731 * static DoBulkDeleteLine
734 * Process the given bulk delete command.
737 * a_buf : Ptr to the buffer holding the bulk delete command.
738 * a_tp : Ptr to the first char past the opcode.
741 * 0 if everything went well,
742 * -1 if something went wrong in the function, or
743 * Lower-level error code if something went wrong below us.
746 * The required fields are:
747 * -user, -mountpoint, -restoredir
751 *------------------------------------------------------------------------*/
754 DoBulkDeleteLine(char *a_buf
, char *a_tp
)
755 { /*DoBulkDeleteLine */
757 char volField
[32]; /*Value of optional vol disposition field */
758 int overflow
; /*Was there an overflow in field copying? */
761 * Pull out all the fields.
763 a_tp
= uss_common_FieldCp(uss_User
, a_tp
, ':', uss_UserLen
, &overflow
);
766 "%s: * User field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
767 uss_whoami
, uss_UserLen
, uss_User
);
770 if ((uss_User
[0] == '\0') || (*a_tp
== '\0') || (*a_tp
== '\n'))
771 goto Delete_MissingRequiredParam
;
774 uss_common_FieldCp(uss_MountPoint
, a_tp
, ':', uss_MountPointLen
,
778 "%s: * Mountpoint field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
779 uss_whoami
, uss_MountPointLen
, uss_MountPoint
);
782 #if USS_FUTURE_FEATURES
783 #if USS_DONT_HIDE_SOME_FEATURES
784 if ((uss_MountPoint
[0] == '\0') || (*a_tp
== '\0') || (*a_tp
== '\n'))
785 goto Delete_MissingRequiredParam
;
786 #endif /* USS_DONT_HIDE_SOME_FEATURES */
788 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
789 goto Delete_ParsingDone
;
790 #endif /* USS_FUTURE_FEATURES */
792 #if USS_FUTURE_FEATURES
793 #if USS_DONT_HIDE_SOME_FEATURES
795 uss_common_FieldCp(uss_RestoreDir
, a_tp
, ':', uss_RestoreDirLen
,
799 "%s: * RestoreDir field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
800 uss_whoami
, uss_RestoreDirLen
, uss_RestoreDir
);
803 if (uss_RestoreDir
[0] == '\0')
804 goto Delete_MissingRequiredParam
;
805 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
806 goto Delete_ParsingDone
;
809 uss_common_FieldCp(uss_PwdPath
, a_tp
, ':', uss_PwdPathLen
, &overflow
);
812 "%s: * Password path field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
813 uss_whoami
, uss_PwdPathLen
, uss_PwdPath
);
816 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
817 goto Delete_ParsingDone
;
820 uss_common_FieldCp(uss_PwdFormat
, a_tp
, ':', uss_PwdFormatLen
,
824 "%s: * Password format field in delete cmd too long (max is %d chars; truncated value is '%s')\n",
825 uss_whoami
, uss_PwdFormatLen
, uss_PwdFormat
);
828 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
829 goto Delete_ParsingDone
;
830 #endif /* USS_DONT_HIDE_SOME_FEATURES */
831 #endif /* USS_FUTURE_FEATURES */
833 a_tp
= uss_common_FieldCp(volField
, a_tp
, ':', 32, &overflow
);
836 "%s: * Volume save/del field in delete cmd too long (max is 32 chars; truncated value is '%s')\n",
837 uss_whoami
, volField
);
840 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
841 goto Delete_ParsingDone
;
843 if (strcmp(volField
, "delvolume") == 0)
850 * If there's anything left on the line, we ignore it. Announce
851 * the bulk delete parameters we've parsed if we're being verbose,
855 #if USS_FUTURE_FEATURES
856 #if USS_DONT_HIDE_SOME_FEATURES
858 "\nDeleting user '%s' mounted at '%s', restoredir='%s', pwd path='%s', pwd format='%s'",
859 uss_User
, uss_MountPoint
, uss_RestoreDir
, uss_PwdPath
,
861 #endif /* USS_DONT_HIDE_SOME_FEATURES */
863 fprintf(stderr
, "\nDeleting user '%s' mounted at '%s'", uss_User
,
865 #endif /* USS_FUTURE_FEATURES */
867 fprintf(stderr
, ", saving user's volume\n");
869 fprintf(stderr
, ", deleting user's volume\n");
872 /*Verbose status of delete command */
874 * Now do the real work.
878 Delete_MissingRequiredParam
:
880 "%s: * All of the user, mountpoint, and restoredir fields must appear in a bulk delete command line.\n",
884 } /*DoBulkDeleteLine */
886 #if USS_FUTURE_FEATURES
887 #if USS_DONT_HIDE_SOME_FEATURES
888 /*-----------------------------------------------------------------------
889 * static DoBulkPurgeVolumeLine
892 * Process the given bulk add command.
895 * a_buf : Ptr to the buffer holding the bulk add command.
896 * a_tp : Ptr to the first char past the opcode.
899 * 0 if everything went well,
900 * -1 if something went wrong in the function, or
901 * Lower-level error code if something went wrong below us.
904 * Nothing interesting.
908 *------------------------------------------------------------------------*/
911 DoBulkPurgeVolumeLine(char *a_buf
, char *a_tp
)
912 { /*DoBulkPurgeVolumeLine */
914 int i
; /*Loop variable */
915 int overflow
; /*Did a field copy overflow happen? */
918 * Pull out all the fields.
920 a_tp
= uss_common_FieldCp(uss_User
, a_tp
, ':', uss_UserLen
, &overflow
);
923 "%s: * User field in purgevolume cmd too long (max is %d chars; truncated value is '%s')\n",
924 uss_whoami
, uss_UserLen
, uss_User
);
927 if ((*a_tp
== '\0') || (*a_tp
== '\n')) {
929 "%s: * The user field must appear in a bulk add command.\n",
935 uss_common_FieldCp(uss_RealName
, a_tp
, ':', uss_RealNameLen
,
939 "%s: * Real name field in purgevolume cmd too long (max is %d chars; truncated value is '%s')\n",
940 uss_whoami
, uss_RealNameLen
, uss_RealName
);
943 if (uss_RealName
[0] == '\0') {
945 * The user's real name has not been supplied. As a
946 * default, we use the account name.
948 sprintf(uss_RealName
, "%s", uss_User
);
950 fprintf(stderr
, "%s: Using default real name, '%s'\n", uss_whoami
,
953 /*Use default full name */
954 a_tp
= uss_common_FieldCp(uss_Pwd
, a_tp
, ':', uss_PwdLen
, &overflow
);
957 "%s: * Password field in purgevolume cmd too long (max is %d chars; truncated value is '%s')\n",
958 uss_whoami
, uss_PwdLen
, uss_Pwd
);
961 if (uss_Pwd
[0] == '\0') {
963 * The user's password has not been provided. Use
966 sprintf(uss_Pwd
, "%s", uss_DEFAULT_PASSWORD
);
968 fprintf(stderr
, "%s: Using default password, '%s'\n", uss_whoami
,
970 } /*Use default password */
971 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
975 uss_common_FieldCp(uss_Server
, a_tp
, ':', uss_ServerLen
, &overflow
);
977 fprintf(stderr
, "%s: * Server field too long (max is %d chars)\n",
978 uss_whoami
, uss_ServerLen
);
981 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
985 uss_common_FieldCp(uss_Partition
, a_tp
, ':', uss_PartitionLen
,
988 fprintf(stderr
, "%s: * Partition field too long (max is %d chars)\n",
989 uss_whoami
, uss_PartitionLen
);
992 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
996 uss_common_FieldCp(uss_MountPoint
, a_tp
, ':', uss_MountPointLen
,
999 fprintf(stderr
, "%s: * Mountpoint field too long (max is %d chars)\n",
1000 uss_whoami
, uss_MountPointLen
);
1003 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
1006 a_tp
= uss_common_FieldCp(uss_Uid
, a_tp
, ':', uss_UidLen
, &overflow
);
1008 fprintf(stderr
, "%s: * UID field too long (max is %d chars)\n",
1009 uss_whoami
, uss_UidLen
);
1012 uss_DesiredUID
= atoi(uss_Uid
);
1013 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
1016 for (uss_VarMax
= 1; uss_VarMax
< 10; uss_VarMax
++) {
1018 uss_common_FieldCp(uss_Var
[uss_VarMax
], a_tp
, ':',
1019 uss_MAX_ARG_SIZE
, &overflow
);
1022 "%s: * Variable %d field too long (max is %d chars)\n",
1023 uss_whoami
, uss_VarMax
, uss_MAX_ARG_SIZE
);
1026 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
1031 * If there's anything left on the line, we ignore it. Announce
1032 * the bulk add parameters we've parsed or filled in if we're
1033 * being verbose, then go for it.
1037 "\nAdding user '%s' ('%s'), password='%s' on server '%s', partition '%s', home directory='%s'",
1038 uss_User
, uss_RealName
, uss_Pwd
,
1039 (uss_Server
[0] != '\0' ? uss_Server
: "<default>"),
1040 (uss_Partition
[0] != '\0' ? uss_Partition
: "<default>"),
1041 (uss_MountPoint
[0] != '\0' ? uss_MountPoint
: "<default>"));
1043 fprintf(stderr
, ", uid preset to %d\n", uss_DesiredUID
);
1045 fprintf(stderr
, ", no preset uid\n");
1046 for (i
= 1; i
<= uss_VarMax
; i
++) {
1047 if (uss_Var
[i
][0] != '\0')
1048 fprintf(stderr
, "$%1d='%s' ", i
, uss_Var
[i
]);
1051 fprintf(stderr
, "\n");
1054 /*Verbose status of add command */
1056 * Now do the real work.
1060 } /*DoBulkPurgeVolumeLine */
1061 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1062 #endif /* USS_FUTURE_FEATURES */
1064 #if USS_FUTURE_FEATURES
1065 #if USS_DONT_HIDE_SOME_FEATURES
1066 /*-----------------------------------------------------------------------
1067 * static DoBulkRestoreLine
1070 * Process the given bulk add command.
1073 * a_buf : Ptr to the buffer holding the bulk add command.
1074 * a_tp : Ptr to the first char past the opcode.
1077 * 0 if everything went well,
1078 * -1 if something went wrong in the function, or
1079 * Lower-level error code if something went wrong below us.
1082 * Nothing interesting.
1086 *------------------------------------------------------------------------*/
1089 DoBulkRestoreLine(char *a_buf
, char *a_tp
)
1090 { /*DoBulkRestoreLine */
1092 int i
; /*Loop variable */
1093 int overflow
; /*Overflow occur on field copy? */
1096 * Pull out all the fields.
1098 a_tp
= uss_common_FieldCp(uss_User
, a_tp
, ':', uss_UserLen
, &overflow
);
1100 fprintf(stderr
, "%s: * User field too long (max is %d chars)\n",
1101 uss_whoami
, uss_UserLen
);
1104 if ((*a_tp
== '\0') || (*a_tp
== '\n')) {
1106 "%s: * The user field must appear in a bulk add command.\n",
1112 uss_common_FieldCp(uss_RealName
, a_tp
, ':', uss_RealNameLen
,
1115 fprintf(stderr
, "%s: * Real name field too long (max is %d chars)\n",
1116 uss_whoami
, uss_RealNameLen
);
1119 if (uss_RealName
[0] == '\0') {
1121 * The user's real name has not been supplied. As a
1122 * default, we use the account name.
1124 sprintf(uss_RealName
, "%s", uss_User
);
1126 fprintf(stderr
, "%s: Using default real name, '%s'\n", uss_whoami
,
1129 /*Use default full name */
1130 a_tp
= uss_common_FieldCp(uss_Pwd
, a_tp
, ':', uss_PwdLen
, &overflow
);
1132 fprintf(stderr
, "%s: * Password field too long (max is %d chars)\n",
1133 uss_whoami
, uss_PwdLen
);
1136 if (uss_Pwd
[0] == '\0') {
1138 * The user's password has not been provided. Use
1141 sprintf(uss_Pwd
, "%s", uss_DEFAULT_PASSWORD
);
1143 fprintf(stderr
, "%s: Using default password, '%s'\n", uss_whoami
,
1145 } /*Use default password */
1146 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
1150 uss_common_FieldCp(uss_Server
, a_tp
, ':', uss_ServerLen
, &overflow
);
1152 fprintf(stderr
, "%s: * Server field too long (max is %d chars)\n",
1153 uss_whoami
, uss_ServerLen
);
1156 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
1160 uss_common_FieldCp(uss_Partition
, a_tp
, ':', uss_PartitionLen
,
1163 fprintf(stderr
, "%s: * Partition field too long (max is %d chars)\n",
1164 uss_whoami
, uss_PartitionLen
);
1167 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
1171 uss_common_FieldCp(uss_MountPoint
, a_tp
, ':', uss_MountPointLen
,
1174 fprintf(stderr
, "%s: * mountpoint field too long (max is %d chars)\n",
1175 uss_whoami
, uss_MountPointLen
);
1178 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
1181 a_tp
= uss_common_FieldCp(uss_Uid
, a_tp
, ':', uss_UidLen
, &overflow
);
1183 fprintf(stderr
, "%s: * UID field too long (max is %d chars)\n",
1184 uss_whoami
, uss_UidLen
);
1187 uss_DesiredUID
= atoi(uss_Uid
);
1188 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
1191 for (uss_VarMax
= 1; uss_VarMax
< 10; uss_VarMax
++) {
1193 uss_common_FieldCp(uss_Var
[uss_VarMax
], a_tp
, ':',
1194 uss_MAX_ARG_SIZE
, &overflow
);
1197 "%s: * Variable %d field too long (max is %d chars)\n",
1198 uss_whoami
, uss_VarMax
, uss_MAX_ARG_SIZE
);
1201 if ((*a_tp
== '\0') || (*a_tp
== '\n'))
1206 * If there's anything left on the line, we ignore it. Announce
1207 * the bulk add parameters we've parsed or filled in if we're
1208 * being verbose, then go for it.
1212 "\nAdding user '%s' ('%s'), password='%s' on server '%s', partition '%s', home directory='%s'",
1213 uss_User
, uss_RealName
, uss_Pwd
,
1214 (uss_Server
[0] != '\0' ? uss_Server
: "<default>"),
1215 (uss_Partition
[0] != '\0' ? uss_Partition
: "<default>"),
1216 (uss_MountPoint
[0] != '\0' ? uss_MountPoint
: "<default>"));
1218 fprintf(stderr
, ", uid preset to %d\n", uss_DesiredUID
);
1220 fprintf(stderr
, ", no preset uid\n");
1221 for (i
= 1; i
<= uss_VarMax
; i
++) {
1222 if (uss_Var
[i
][0] != '\0')
1223 fprintf(stderr
, "$%1d='%s' ", i
, uss_Var
[i
]);
1226 fprintf(stderr
, "\n");
1229 /*Verbose status of add command */
1231 * Now do the real work.
1233 return (DoRestore());
1235 } /*DoBulkRestoreLine */
1236 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1237 #endif /* USS_FUTURE_FEATURES */
1240 /*-----------------------------------------------------------------------
1241 * static DoBulkExecLine
1244 * Process the given bulk exec command.
1247 * a_buf : Ptr to the buffer holding the bulk exec command.
1248 * a_tp : Ptr to the first char past the opcode.
1251 * 0 if everything went well,
1252 * -1 if something went wrong in the function, or
1253 * Lower-level error code if something went wrong below us.
1256 * Nothing interesting.
1260 *------------------------------------------------------------------------*/
1263 DoBulkExecLine(char *a_buf
, char *a_tp
)
1264 { /*DoBulkExecLine */
1266 afs_int32 code
; /*Return code */
1269 * Really, uss_procs_Exec does all the work for us!
1271 code
= uss_procs_Exec(a_tp
);
1274 } /*DoBulkExecLine */
1277 /*-----------------------------------------------------------------------
1281 * Process the given bulk command.
1284 * a_as : Ptr to the command line syntax descriptor.
1285 * a_rock : Ptr to the rock passed in.
1288 * 0 if everything went well,
1289 * 1 if something went wrong in the function, or
1290 * Lower-level error code if something went wrong below us.
1293 * Nothing interesting.
1297 *------------------------------------------------------------------------*/
1300 HandleBulk(struct cmd_syndesc
*a_as
, void *a_rock
)
1303 #define USS_BULK_CMD_CHARS 128
1304 #define USS_BULK_BUF_CHARS 1024
1306 char cmd
[USS_BULK_CMD_CHARS
], buf
[USS_BULK_BUF_CHARS
];
1314 char tbuf
[USS_BULK_BUF_CHARS
];
1317 * Open up the bulk file, croak if we can't.
1319 if ((infile
= fopen(a_as
->parms
[ABULK_FILE
].items
->data
, "r")) == NULL
) {
1320 fprintf(stderr
, "%s: * Failed to open input file %s\n", uss_whoami
,
1321 a_as
->parms
[ABULK_FILE
].items
->data
);
1326 * Pull out the other fields as passed in by the caller on the
1329 if (a_as
->parms
[AUSS_DRYRUN
].items
)
1331 if (a_as
->parms
[AUSS_SKIPAUTH
].items
)
1332 uss_SkipKaserver
= 1;
1333 if (a_as
->parms
[AUSS_OVERWRITE
].items
)
1335 if (a_as
->parms
[AUSS_PIPE
].items
)
1337 if (a_as
->parms
[AUSS_ADMIN
].items
)
1338 strcpy(uss_Administrator
, a_as
->parms
[AUSS_ADMIN
].items
->data
);
1340 uss_Administrator
[0] = '\0';
1342 if (a_as
->parms
[AUSS_PWEXPIRES
].items
) {
1343 uss_BulkExpires
= atoi(a_as
->parms
[AUSS_PWEXPIRES
].items
->data
);
1344 if (uss_BulkExpires
< 0 || uss_BulkExpires
> 254) {
1346 "%s: Password Expiration must be in [0..255] days\n",
1351 uss_BulkExpires
= 0;
1354 * Initialize uss_AccountCreator().
1356 code
= uss_kauth_InitAccountCreator();
1361 * Process all the lines in the bulk command file.
1363 uss_VarMax
= 0; /*No uss vars picked up yet */
1364 while (fgets(buf
, sizeof(buf
), infile
) != NULL
) {
1366 /* skip blank line */
1371 /* After executing the line, print the line and the result */
1373 if (error
== UNOQUORUM
) {
1379 printf("LINE %d %s %s", line_no
, (error
? "FAIL" : "SUCCESS"),
1385 * Reset the common variables for each command line
1390 strncpy(tbuf
, buf
, USS_BULK_BUF_CHARS
-1);
1393 * First line of file = line 1.
1399 * Get the opcode and act upon it.
1401 tp
= uss_common_FieldCp(cmd
, buf
, ' ', USS_BULK_CMD_CHARS
, &overflow
);
1404 "%s: * Bulk opcode field too long (max is %d chars)\n",
1405 uss_whoami
, USS_BULK_CMD_CHARS
);
1413 if (strcmp(cmd
, "add") == 0) {
1414 error
= DoBulkAddLine(buf
, tp
);
1417 if (strcmp(cmd
, "delete") == 0) {
1418 error
= DoBulkDeleteLine(buf
, tp
);
1421 if (strcmp(cmd
, "delvolume") == 0) {
1426 #if USS_FUTURE_FEATURES
1427 #if USS_DONT_HIDE_SOME_FEATURES
1428 if (strcmp(cmd
, "purgevolume") == 0) {
1429 error
= DoBulkPurgeVolumeLine(buf
, tp
);
1432 if (strcmp(cmd
, "pwdformat") == 0) {
1433 /*Set the password format here */
1436 if (strcmp(cmd
, "pwdpath") == 0) {
1437 /*Set the password path here */
1440 if (strcmp(cmd
, "restore") == 0) {
1441 error
= DoBulkRestoreLine(buf
, tp
);
1444 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1445 #endif /* USS_FUTURE_FEATURES */
1446 if (strcmp(cmd
, "savevolume") == 0) {
1447 /*Set the savevolume flag here */
1450 if (strcmp(cmd
, "exec") == 0) {
1451 error
= DoBulkExecLine(buf
, tp
);
1456 * If none of the valid opcodes match, see if the line is either
1457 * a comment of a blank. If so, just ignore it. Otherwise, we
1460 if ((cmd
[0] != '#') && (cmd
[0] != '\0')) {
1462 "%s: ** Unrecognized command ('%s') in bulk file\n",
1471 } /*Bad bulk line */
1472 } /*Process a line in the bulk file */
1478 printf("LINE %d %s %s", line_no
, (error
? "FAIL" : "SUCCESS"), tbuf
);
1486 /*-----------------------------------------------------------------------
1490 * Process the given (non-bulk) add command.
1493 * a_as : Ptr to the command line syntax descriptor.
1494 * a_rock : Ptr to the rock passed in.
1497 * 0 if everything went well,
1498 * 1 if something went wrong in the function, or
1499 * Lower-level error code if something went wrong below us.
1502 * Nothing interesting.
1506 *------------------------------------------------------------------------*/
1509 AddUser(struct cmd_syndesc
*a_as
, void *a_rock
)
1513 struct cmd_item
*ti
;
1517 * Before we do anything else, make sure we initialize the
1518 * global field settings.
1523 * Pull out the fields as passed in by the caller on the command
1526 strcpy(uss_User
, a_as
->parms
[AUP_USER
].items
->data
);
1527 if (a_as
->parms
[AUP_REALNAME
].items
)
1528 strcpy(uss_RealName
, a_as
->parms
[AUP_REALNAME
].items
->data
);
1530 strcpy(uss_RealName
, uss_User
);
1531 if (a_as
->parms
[AUP_PASSWD
].items
)
1532 strcpy(uss_Pwd
, a_as
->parms
[AUP_PASSWD
].items
->data
);
1534 strcpy(uss_Pwd
, uss_DEFAULT_PASSWORD
);
1535 if (a_as
->parms
[AUP_SERVER
].items
)
1536 strcpy(uss_Server
, a_as
->parms
[AUP_SERVER
].items
->data
);
1537 if (a_as
->parms
[AUP_PART
].items
)
1538 strcpy(uss_Partition
, a_as
->parms
[AUP_PART
].items
->data
);
1539 if (a_as
->parms
[AUP_MNTPT
].items
)
1540 strcpy(uss_MountPoint
, a_as
->parms
[AUP_MNTPT
].items
->data
);
1541 if (a_as
->parms
[AUP_UID
].items
)
1542 uss_DesiredUID
= atoi(a_as
->parms
[AUP_UID
].items
->data
);
1545 if (a_as
->parms
[AUP_PWEXPIRES
].items
) {
1546 uss_Expires
= atoi(a_as
->parms
[AUP_PWEXPIRES
].items
->data
);
1547 if (uss_Expires
< 0 || uss_Expires
> 254) {
1549 "%s: Password Expiration must be in [0..255] days\n",
1556 if (a_as
->parms
[AUSS_DRYRUN
].items
)
1558 if (a_as
->parms
[AUSS_SKIPAUTH
].items
)
1559 uss_SkipKaserver
= 1;
1560 if (a_as
->parms
[AUSS_OVERWRITE
].items
)
1562 if (a_as
->parms
[AUSS_ADMIN
].items
) {
1563 strcpy(uss_Administrator
, a_as
->parms
[AUSS_ADMIN
].items
->data
);
1564 /* fprintf(stderr, "debugging: uss_Administrator set to '%s'\n",
1565 * uss_Administrator); */
1567 /* fprintf(stderr, "debugging: No administrator value given\n"); */
1568 uss_Administrator
[0] = '\0';
1571 if (a_as
->parms
[AUSS_VAR
].items
) {
1572 for (ti
= a_as
->parms
[AUSS_VAR
].items
; ti
; ti
= ti
->next
) {
1574 if (i
< 0 || i
> 9 || (i
== 0 && *ti
->data
!= '0')) {
1576 "%s: Bad -var format: must be '0 val0 1 val1 ... 9 val9'\n",
1583 "%s: -var values must appear in pairs: 'Num val'\n",
1587 strcpy(uss_Var
[i
], ti
->data
);
1590 } /*Remember each VAR item */
1593 /*VAR items exist */
1595 * Initialize uss_AccountCreator().
1597 code
= uss_kauth_InitAccountCreator();
1602 * Now that the command line arguments are parsed and properly stored,
1610 /*-----------------------------------------------------------------------
1614 * Create the desired user account, having parsed the add command
1615 * from either the command line or a bulk file.
1621 * 0 if everything went well,
1622 * 1 if something went wrong in the function, or
1623 * Lower-level error code if something went wrong below us.
1626 * All values needed have been put in the common variables.
1630 *------------------------------------------------------------------------*/
1636 int code
; /*Return code */
1639 * Make sure the user name is legal.
1641 code
= uss_kauth_CheckUserName();
1646 * This time around, we start off assuming the global value of the
1649 uss_OverwriteThisOne
= uss_Overwrite
;
1652 * Open up the template file before doing any real processing,
1653 * so we can quit early should it not be found.
1655 if (uss_yyin
== NULL
) {
1656 if ((uss_yyin
= uss_procs_FindAndOpen(Template
)) == NULL
) {
1657 fprintf(stderr
, "%s: ** Can't open template file '%s'\n",
1658 uss_whoami
, Template
);
1661 uss_yyout
= fopen("/dev/null", "w");
1666 * Add the new user to the Protection DB.
1668 code
= uss_ptserver_AddUser(uss_User
, uss_Uid
);
1670 fprintf(stderr
, "%s: Failed to add user '%s' to the Protection DB\n",
1671 uss_whoami
, uss_User
);
1676 * Add the new user to the Authentication DB.
1678 code
= uss_kauth_AddUser(uss_User
, uss_Pwd
);
1680 fprintf(stderr
, "%s: Can't add user '%s' to the Authentication DB\n",
1681 uss_whoami
, uss_User
);
1686 * Process the items covered by the template file.
1688 if (yyparse() && (!uss_ignoreFlag
))
1692 * Finally, clean up after ourselves, removing the uss_AccountCreator
1693 * from various of the new user's ACLs.
1695 return (uss_acl_CleanUp());
1700 #if USS_FUTURE_FEATURES
1701 #if USS_DONT_HIDE_SOME_FEATURES
1702 /*-----------------------------------------------------------------------
1706 * Perform the parsed restore command.
1712 * 0 if everything went well,
1713 * 1 if something went wrong in the function, or
1714 * Lower-level error code if something went wrong below us.
1717 * All values needed have been put in the common variables.
1721 *------------------------------------------------------------------------*/
1730 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1731 #endif /* USS_FUTURE_FEATURES */
1734 /*-----------------------------------------------------------------------
1735 * static InitETTables
1738 * Set up the error code tables for the various modules we use.
1747 * Nothing interesting.
1751 *------------------------------------------------------------------------*/
1759 * In order to get error code -> error message translations to work,
1760 * we have to initialize all error tables.
1762 initialize_CMD_error_table();
1763 initialize_RXK_error_table();
1764 initialize_KTC_error_table();
1765 initialize_KA_error_table();
1766 initialize_ACFG_error_table();
1767 initialize_VL_error_table();
1768 initialize_PT_error_table();
1769 initialize_U_error_table();
1777 /* this sucks but it works for now.
1782 #include "AFS_component_version_number.c"
1785 main(int argc
, char *argv
[])
1788 struct cmd_syndesc
*cs
; /*Command line syntax descriptor */
1790 #ifdef AFS_AIX32_ENV
1792 * The following signal action for AIX is necessary so that in case of a
1793 * crash (i.e. core is generated) we can include the user's data section
1794 * in the core dump. Unfortunately, by default, only a partial core is
1795 * generated which, in many cases, isn't too useful.
1797 struct sigaction nsa
;
1799 sigemptyset(&nsa
.sa_mask
);
1800 nsa
.sa_handler
= SIG_DFL
;
1801 nsa
.sa_flags
= SA_FULLDUMP
;
1802 sigaction(SIGABRT
, &nsa
, NULL
);
1803 sigaction(SIGSEGV
, &nsa
, NULL
);
1805 strcpy(uss_whoami
, argv
[0]);
1808 uss_fs_InBuff
= malloc(USS_FS_MAX_SIZE
); /*Cache Manager input buff */
1809 uss_fs_OutBuff
= malloc(USS_FS_MAX_SIZE
); /*Cache Manager output buff */
1810 if (!uss_fs_InBuff
|| !uss_fs_OutBuff
) {
1811 fprintf(stderr
, "%s: Can't malloc in/out buffers\n", uss_whoami
);
1815 /* ----------------------------- add ----------------------------- */
1817 cs
= cmd_CreateSyntax("add", AddUser
, NULL
, 0, "create a new user account");
1818 cmd_AddParm(cs
, "-user", CMD_SINGLE
, 0, "login name");
1819 cmd_AddParm(cs
, "-realname", CMD_SINGLE
, CMD_OPTIONAL
,
1820 "full name in quotes");
1821 cmd_AddParm(cs
, "-pass", CMD_SINGLE
, CMD_OPTIONAL
, "initial password");
1823 cmd_AddParm(cs
, "-pwexpires", CMD_SINGLE
, CMD_OPTIONAL
,
1824 "password expires in [0..254] days (0 => never)");
1825 cmd_AddParm(cs
, "-server", CMD_SINGLE
, CMD_OPTIONAL
,
1826 "FileServer for home volume");
1827 cmd_AddParm(cs
, "-partition", CMD_SINGLE
, CMD_OPTIONAL
,
1828 "FileServer's disk partition for home volume");
1829 cmd_AddParm(cs
, "-mount", CMD_SINGLE
, CMD_OPTIONAL
,
1830 "home directory mount point");
1831 cmd_AddParm(cs
, "-uid", CMD_SINGLE
, CMD_OPTIONAL
,
1832 "uid to assign the user");
1833 cmd_Seek(cs
, AUSS_TEMPLATE
);
1834 cmd_AddParm(cs
, "-template", CMD_SINGLE
, CMD_OPTIONAL
,
1835 "pathname of template file");
1836 cmd_AddParm(cs
, "-verbose", CMD_FLAG
, CMD_OPTIONAL
, "verbose operation");
1837 cmd_AddParm(cs
, "-var", CMD_LIST
, CMD_OPTIONAL
| CMD_EXPANDS
,
1838 "auxiliary argument pairs (Num val)");
1839 cmd_AddParm(cs
, "-cell", CMD_SINGLE
, CMD_OPTIONAL
, "cell name");
1840 cmd_AddParm(cs
, "-admin", CMD_SINGLE
, CMD_OPTIONAL
,
1841 "administrator to authenticate");
1842 cmd_AddParm(cs
, "-dryrun", CMD_FLAG
, CMD_OPTIONAL
,
1843 "list what would be done, don't do it");
1844 cmd_AddParm(cs
, "-skipauth", CMD_FLAG
, CMD_OPTIONAL
,
1845 "ignore all contact with the authentication server (kaserver)");
1846 cmd_AddParm(cs
, "-overwrite", CMD_FLAG
, CMD_OPTIONAL
,
1847 "Overwrite pre-existing files in user home directory tree");
1850 /* ---------------------------- bulk ----------------------------- */
1852 cs
= cmd_CreateSyntax("bulk", HandleBulk
, NULL
, 0, "bulk input mode");
1853 cmd_AddParm(cs
, "-file", CMD_SINGLE
, 0, "bulk input file");
1854 cmd_Seek(cs
, AUSS_TEMPLATE
);
1855 cmd_AddParm(cs
, "-template", CMD_SINGLE
, CMD_OPTIONAL
,
1856 "pathname of template file");
1857 cmd_AddParm(cs
, "-verbose", CMD_FLAG
, CMD_OPTIONAL
, "verbose operation");
1858 cmd_Seek(cs
, AUSS_CELL
);
1859 cmd_AddParm(cs
, "-cell", CMD_SINGLE
, CMD_OPTIONAL
, "cell name");
1860 cmd_AddParm(cs
, "-admin", CMD_SINGLE
, CMD_OPTIONAL
,
1861 "administrator to authenticate");
1862 cmd_AddParm(cs
, "-dryrun", CMD_FLAG
, CMD_OPTIONAL
,
1863 "list what would be done, don't do it");
1864 cmd_AddParm(cs
, "-skipauth", CMD_FLAG
, CMD_OPTIONAL
,
1865 "ignore all contact with the authentication server (kaserver)");
1866 cmd_AddParm(cs
, "-overwrite", CMD_FLAG
, CMD_OPTIONAL
,
1867 "Overwrite pre-existing files in user home directory tree");
1868 cmd_Seek(cs
, AUSS_PWEXPIRES
);
1869 cmd_AddParm(cs
, "-pwexpires", CMD_SINGLE
, CMD_OPTIONAL
,
1870 "password expires in [0..254] days (0 => never)");
1871 cmd_Seek(cs
, AUSS_PIPE
);
1872 cmd_AddParm(cs
, "-pipe", CMD_FLAG
, CMD_OPTIONAL
,
1873 "don't prompt for passwd; get it from standard input");
1875 /* ---------------------------- delete --------------------------- */
1877 cs
= cmd_CreateSyntax("delete", DelUser
, NULL
, 0, "delete a user account");
1878 cmd_AddParm(cs
, "-user", CMD_SINGLE
, 0, "login name");
1879 cmd_AddParm(cs
, "-mountpoint", CMD_SINGLE
, CMD_OPTIONAL
,
1880 "mountpoint for user's volume");
1881 #if USS_FUTURE_FEATURES
1882 #if USS_DONT_HIDE_SOME_FEATURES
1883 cmd_AddParm(cs
, "-restoredir", CMD_SINGLE
, 0,
1884 "directory where restore info is to be placed");
1885 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1886 #endif /* USS_FUTURE_FEATURES */
1887 cmd_AddParm(cs
, "-savevolume", CMD_FLAG
, CMD_OPTIONAL
,
1888 "don't destroy the user's volume");
1889 #if USS_FUTURE_FEATURES
1890 #if USS_DONT_HIDE_SOME_FEATURES
1891 cmd_AddParm(cs
, "-pwdpath", CMD_SINGLE
, CMD_OPTIONAL
,
1892 "pathname to the password file");
1893 cmd_AddParm(cs
, "-pwdformat", CMD_SINGLE
, CMD_OPTIONAL
,
1894 "password entry format");
1895 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1896 #endif /* USS_FUTURE_FEATURES */
1897 cmd_Seek(cs
, AUSS_VERBOSE
);
1898 cmd_AddParm(cs
, "-verbose", CMD_FLAG
, CMD_OPTIONAL
, "verbose operation");
1899 cmd_Seek(cs
, AUSS_CELL
);
1900 cmd_AddParm(cs
, "-cell", CMD_SINGLE
, CMD_OPTIONAL
, "cell name");
1901 cmd_AddParm(cs
, "-admin", CMD_SINGLE
, CMD_OPTIONAL
,
1902 "administrator to authenticate");
1903 cmd_AddParm(cs
, "-dryrun", CMD_FLAG
, CMD_OPTIONAL
,
1904 "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 #if USS_FUTURE_FEATURES
1908 #if USS_DONT_HIDE_SOME_FEATURES
1909 /* ------------------------- purgevolumes ------------------------ */
1911 cs
= cmd_CreateSyntax("purgevolumes", PurgeVolumes
, NULL
, 0,
1912 "destroy a deleted user's volume");
1913 cmd_AddParm(cs
, "-volname", CMD_LIST
, CMD_OPTIONAL
| CMD_EXPANDS
,
1914 "Name(s) of volume(s) to destroy");
1915 cmd_AddParm(cs
, "-volfile", CMD_SINGLE
, CMD_OPTIONAL
,
1916 "pathname to volume purge file");
1917 cmd_Seek(cs
, AUSS_VERBOSE
);
1918 cmd_AddParm(cs
, "-verbose", CMD_FLAG
, CMD_OPTIONAL
, "verbose operation");
1919 cmd_Seek(cs
, AUSS_CELL
);
1920 cmd_AddParm(cs
, "-cell", CMD_SINGLE
, CMD_OPTIONAL
, "cell name");
1921 cmd_AddParm(cs
, "-admin", CMD_SINGLE
, CMD_OPTIONAL
,
1922 "administrator to authenticate");
1923 cmd_AddParm(cs
, "-dryrun", CMD_FLAG
, CMD_OPTIONAL
,
1924 "list what would be done, don't do it");
1925 cmd_AddParm(cs
, "-skipauth", CMD_FLAG
, CMD_OPTIONAL
,
1926 "ignore all contact with the authentication server (kaserver)");
1927 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1928 #endif /* USS_FUTURE_FEATURES */
1930 #if USS_FUTURE_FEATURES
1931 #if USS_DONT_HIDE_SOME_FEATURES
1932 /* ---------------------------- restore -------------------------- */
1934 cs
= cmd_CreateSyntax("restore", RestoreUser
, NULL
, 0,
1935 "restore a deleted user account");
1936 cmd_AddParm(cs
, "-user", CMD_SINGLE
, 0, "login name to restore");
1937 cmd_AddParm(cs
, "-uid", CMD_SINGLE
, 0, "user id number");
1938 cmd_AddParm(cs
, "-mount", CMD_SINGLE
, 0, "mountpoint for user's volume");
1939 cmd_AddParm(cs
, "-volname", CMD_SINGLE
, 0, "name of user's volume");
1940 cmd_AddParm(cs
, "-realname", CMD_SINGLE
, CMD_OPTIONAL
,
1941 "user's full name");
1942 cmd_AddParm(cs
, "-server", CMD_SINGLE
, CMD_OPTIONAL
,
1943 "FileServer to host user's volume");
1944 cmd_AddParm(cs
, "-partition", CMD_SINGLE
, CMD_OPTIONAL
,
1945 "FileServer partition to host user's volume");
1946 cmd_AddParm(cs
, "-pwdpath", CMD_SINGLE
, CMD_OPTIONAL
,
1947 "pathname to the password file");
1948 cmd_AddParm(cs
, "-pwdformat", CMD_SINGLE
, CMD_OPTIONAL
,
1949 "password entry format");
1950 cmd_Seek(cs
, AUSS_VERBOSE
);
1951 cmd_AddParm(cs
, "-verbose", CMD_FLAG
, CMD_OPTIONAL
, "verbose operation");
1952 cmd_Seek(cs
, AUSS_CELL
);
1953 cmd_AddParm(cs
, "-cell", CMD_SINGLE
, CMD_OPTIONAL
, "cell name");
1954 cmd_AddParm(cs
, "-admin", CMD_SINGLE
, CMD_OPTIONAL
,
1955 "administrator to authenticate");
1956 cmd_AddParm(cs
, "-dryrun", CMD_FLAG
, CMD_OPTIONAL
,
1957 "list what would be done, don't do it");
1958 cmd_AddParm(cs
, "-skipauth", CMD_FLAG
, CMD_OPTIONAL
,
1959 "ignore all contact with the authentication server (kaserver)");
1960 #endif /* USS_DONT_HIDE_SOME_FEATURES */
1961 #endif /* USS_FUTURE_FEATURES */
1964 * Set up all the error code translation tables, initialize the
1965 * command variables, and set up to parse the common command line
1970 cmd_SetBeforeProc(GetCommon
, NULL
);
1973 * Execute the parsed command.
1975 cmd_Dispatch(argc
, argv
);
1977 uss_fs_UnlogToken(uss_Cell
);