diff options
Diffstat (limited to 'src/useradd.c')
-rw-r--r-- | src/useradd.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/useradd.c b/src/useradd.c index bdd7fe8c..4af0f7c6 100644 --- a/src/useradd.c +++ b/src/useradd.c @@ -148,6 +148,8 @@ static char **user_groups; /* NULL-terminated list */ static long sys_ngroups; static bool do_grp_update = false; /* group files need to be updated */ +extern int allow_bad_names; + static bool bflg = false, /* new default root of home directory */ cflg = false, /* comment (GECOS) field for new account */ @@ -821,6 +823,7 @@ static void usage (int status) "\n" "Options:\n"), Prog, Prog, Prog); + (void) fputs (_(" --badnames do not check for bad names\n"), usageout); (void) fputs (_(" -b, --base-dir BASE_DIR base directory for the home directory of the\n" " new account\n"), usageout); #ifdef WITH_BTRFS @@ -1098,6 +1101,7 @@ static void process_flags (int argc, char **argv) const struct group *grp; bool anyflag = false; char *cp; + struct stat st; { /* @@ -1109,6 +1113,7 @@ static void process_flags (int argc, char **argv) #ifdef WITH_BTRFS {"btrfs-subvolume-home", no_argument, NULL, 200}, #endif + {"badnames", no_argument, NULL, 201}, {"comment", required_argument, NULL, 'c'}, {"home-dir", required_argument, NULL, 'd'}, {"defaults", no_argument, NULL, 'D'}, @@ -1158,6 +1163,9 @@ static void process_flags (int argc, char **argv) case 200: subvolflg = true; break; + case 201: + allow_bad_names = true; + break; case 'c': if (!VALID (optarg)) { fprintf (stderr, @@ -1320,7 +1328,10 @@ static void process_flags (int argc, char **argv) if ( ( !VALID (optarg) ) || ( ('\0' != optarg[0]) && ('/' != optarg[0]) - && ('*' != optarg[0]) )) { + && ('*' != optarg[0]) ) + || (stat(optarg, &st) != 0) + || (S_ISDIR(st.st_mode)) + || (access(optarg, X_OK) != 0)) { fprintf (stderr, _("%s: invalid shell '%s'\n"), Prog, optarg); @@ -2449,9 +2460,9 @@ int main (int argc, char **argv) (uid_t)-1, user_id, (gid_t)-1, user_gid); } else { fprintf (stderr, - _("%s: warning: the home directory already exists.\n" - "Not copying any file from skel directory into it.\n"), - Prog); + _("%s: warning: the home directory %s already exists.\n" + "%s: Not copying any file from skel directory into it.\n"), + Prog, user_home, Prog); } } |