Skip to content

Commit af77c74

Browse files

File tree

9 files changed

+9
-116
lines changed

9 files changed

+9
-116
lines changed

lib/chkname.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* false - bad name
1515
* errors:
1616
* EINVAL Invalid name
17-
* EILSEQ Invalid name character sequence (acceptable with --badname)
17+
* EILSEQ Invalid name character sequence
1818
* EOVERFLOW Name longer than maximum size
1919
*/
2020

@@ -45,9 +45,6 @@
4545
#endif
4646

4747

48-
int allow_bad_names = false;
49-
50-
5148
size_t
5249
login_name_max_size(void)
5350
{
@@ -71,18 +68,12 @@ is_valid_name(const char *name)
7168
|| strcaseeq(name, "all")
7269
|| strcaseeq(name, "except")
7370
|| strprefix(name, "-")
74-
|| strpbrk(name, " !\"#&*+,/:;@|")
75-
|| strchriscntrl(name)
7671
|| strisdigit(name))
7772
{
7873
errno = EINVAL;
7974
return false;
8075
}
8176

82-
if (allow_bad_names) {
83-
return true;
84-
}
85-
8677
/*
8778
* User/group names must match BRE regex:
8879
* [a-zA-Z0-9_.][a-zA-Z0-9_.-]*$\?

man/newusers.8.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -253,18 +253,6 @@
253253
<para>
254254
The options which apply to the <command>newusers</command> command are:
255255
</para>
256-
<variablelist remap='IP'>
257-
<varlistentry>
258-
<term>
259-
<option>--badname</option>&nbsp;
260-
</term>
261-
<listitem>
262-
<para>
263-
Allow names that do not conform to standards.
264-
</para>
265-
</listitem>
266-
</varlistentry>
267-
</variablelist>
268256
<variablelist remap='IP' condition="no_pam">
269257
<varlistentry>
270258
<term><option>-c</option>, <option>--crypt-method</option></term>

man/pwck.8.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,6 @@
159159
The options which apply to the <command>pwck</command> command are:
160160
</para>
161161
<variablelist remap='IP'>
162-
<varlistentry>
163-
<term>
164-
<option>--badname</option>&nbsp;
165-
</term>
166-
<listitem>
167-
<para>
168-
Allow names that do not conform to standards.
169-
</para>
170-
</listitem>
171-
</varlistentry>
172162
<varlistentry>
173163
<term><option>-h</option>, <option>--help</option></term>
174164
<listitem>

man/useradd.8.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,6 @@
103103
<para>The options which apply to the <command>useradd</command> command are:
104104
</para>
105105
<variablelist remap='IP'>
106-
<varlistentry>
107-
<term>
108-
<option>--badname</option>&nbsp;
109-
</term>
110-
<listitem>
111-
<para>
112-
Allow names that do not conform to standards.
113-
</para>
114-
</listitem>
115-
</varlistentry>
116106
<varlistentry>
117107
<term>
118108
<option>-b</option>, <option>--base-dir</option>&nbsp;<replaceable>BASE_DIR</replaceable>

man/usermod.8.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,6 @@
8484
</para>
8585
</listitem>
8686
</varlistentry>
87-
<varlistentry>
88-
<term>
89-
<option>-b</option>, <option>--badname</option>
90-
</term>
91-
<listitem>
92-
<para>
93-
Allow names that do not conform to standards.
94-
</para>
95-
</listitem>
96-
</varlistentry>
9787
<varlistentry>
9888
<term>
9989
<option>-c</option>, <option>--comment</option>&nbsp;<replaceable>COMMENT</replaceable>

src/newusers.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ static void check_perms (void);
114114
static void open_files (void);
115115
static void close_files (void);
116116

117-
extern int allow_bad_names;
118117

119118
/*
120119
* usage - display usage message and exit
@@ -127,7 +126,6 @@ static void usage (int status)
127126
"\n"
128127
"Options:\n"),
129128
Prog);
130-
(void) fputs (_(" -b, --badname allow bad names\n"), usageout);
131129
#ifndef USE_PAM
132130
(void) fprintf (usageout,
133131
_(" -c, --crypt-method METHOD the crypt method (one of %s)\n"),
@@ -388,17 +386,8 @@ static int add_user (const char *name, uid_t uid, gid_t gid)
388386
{
389387
struct passwd pwent;
390388

391-
/* Check if this is a valid user name */
392389
if (!is_valid_user_name(name)) {
393-
if (errno == EILSEQ) {
394-
fprintf(stderr,
395-
_("%s: invalid user name '%s': use --badname to ignore\n"),
396-
Prog, name);
397-
} else {
398-
fprintf(stderr,
399-
_("%s: invalid user name '%s'\n"),
400-
Prog, name);
401-
}
390+
fprintf(stderr, _("%s: invalid user name '%s'\n"), Prog, name);
402391
return -1;
403392
}
404393

@@ -631,7 +620,6 @@ static void process_flags (int argc, char **argv)
631620
#endif /* USE_SHA_CRYPT || USE_BCRYPT || USE_YESCRYPT */
632621
#endif /* !USE_PAM */
633622
static struct option long_options[] = {
634-
{"badname", no_argument, NULL, 'b'},
635623
#ifndef USE_PAM
636624
{"crypt-method", required_argument, NULL, 'c'},
637625
#endif /* !USE_PAM */
@@ -658,9 +646,6 @@ static void process_flags (int argc, char **argv)
658646
#endif
659647
long_options, NULL)) != -1) {
660648
switch (c) {
661-
case 'b':
662-
allow_bad_names = true;
663-
break;
664649
#ifndef USE_PAM
665650
case 'c':
666651
crypt_method = optarg;

src/pwck.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ static void close_files (bool changed);
7676
static void check_pw_file (bool *errors, bool *changed);
7777
static void check_spw_file (bool *errors, bool *changed);
7878

79-
extern int allow_bad_names;
8079

8180
/*
8281
* fail_exit - do some cleanup and exit with the given error code
@@ -133,7 +132,6 @@ usage (int status)
133132
"Options:\n"),
134133
Prog);
135134
}
136-
(void) fputs (_(" -b, --badname allow bad names\n"), usageout);
137135
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
138136
(void) fputs (_(" -q, --quiet report errors only\n"), usageout);
139137
(void) fputs (_(" -r, --read-only display errors and warnings\n"
@@ -158,7 +156,6 @@ static void process_flags (int argc, char **argv)
158156
{
159157
int c;
160158
static struct option long_options[] = {
161-
{"badname", no_argument, NULL, 'b'},
162159
{"help", no_argument, NULL, 'h'},
163160
{"quiet", no_argument, NULL, 'q'},
164161
{"read-only", no_argument, NULL, 'r'},
@@ -173,9 +170,6 @@ static void process_flags (int argc, char **argv)
173170
while ((c = getopt_long (argc, argv, "behqrR:s",
174171
long_options, NULL)) != -1) {
175172
switch (c) {
176-
case 'b':
177-
allow_bad_names = true;
178-
break;
179173
case 'h':
180174
usage (E_SUCCESS);
181175
/*@notreached@*/break;
@@ -470,18 +464,8 @@ static void check_pw_file (bool *errors, bool *changed)
470464
}
471465
}
472466

473-
/*
474-
* Check for invalid usernames. --marekm
475-
*/
476-
477467
if (!is_valid_user_name(pwd->pw_name)) {
478-
if (errno == EILSEQ) {
479-
printf(_("invalid user name '%s': use --badname to ignore\n"),
480-
pwd->pw_name);
481-
} else {
482-
printf(_("invalid user name '%s'\n"),
483-
pwd->pw_name);
484-
}
468+
printf(_("invalid user name '%s'\n"), pwd->pw_name);
485469
*errors = true;
486470
}
487471

src/useradd.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ static char **user_groups; /* NULL-terminated list */
151151
static long sys_ngroups;
152152
static bool do_grp_update = false; /* group files need to be updated */
153153

154-
extern int allow_bad_names;
155154

156155
static bool
157156
bflg = false, /* new default root of home directory */
@@ -895,7 +894,6 @@ static void usage (int status)
895894
"\n"
896895
"Options:\n"),
897896
Prog, Prog, Prog);
898-
(void) fputs (_(" --badname do not check for bad names\n"), usageout);
899897
(void) fputs (_(" -b, --base-dir BASE_DIR base directory for the home directory of the\n"
900898
" new account\n"), usageout);
901899
#ifdef WITH_BTRFS
@@ -1182,7 +1180,6 @@ static void process_flags (int argc, char **argv)
11821180
#ifdef WITH_BTRFS
11831181
{"btrfs-subvolume-home", no_argument, NULL, 200},
11841182
#endif
1185-
{"badname", no_argument, NULL, 201},
11861183
{"comment", required_argument, NULL, 'c'},
11871184
{"home-dir", required_argument, NULL, 'd'},
11881185
{"defaults", no_argument, NULL, 'D'},
@@ -1239,9 +1236,6 @@ static void process_flags (int argc, char **argv)
12391236
case 200:
12401237
subvolflg = true;
12411238
break;
1242-
case 201:
1243-
allow_bad_names = true;
1244-
break;
12451239
case 'c':
12461240
if (!VALID (optarg)) {
12471241
fprintf (stderr,
@@ -1536,15 +1530,9 @@ static void process_flags (int argc, char **argv)
15361530

15371531
user_name = argv[optind];
15381532
if (!is_valid_user_name(user_name)) {
1539-
if (errno == EILSEQ) {
1540-
fprintf(stderr,
1541-
_("%s: invalid user name '%s': use --badname to ignore\n"),
1542-
Prog, user_name);
1543-
} else {
1544-
fprintf(stderr,
1545-
_("%s: invalid user name '%s'\n"),
1546-
Prog, user_name);
1547-
}
1533+
fprintf(stderr,
1534+
_("%s: invalid user name '%s'\n"),
1535+
Prog, user_name);
15481536
#ifdef WITH_AUDIT
15491537
audit_logger (AUDIT_ADD_USER, Prog,
15501538
"adding user",

src/usermod.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ static void update_faillog (void);
207207
static void move_mailbox (void);
208208
#endif
209209

210-
extern int allow_bad_names;
211210

212211
/*
213212
* get_groups - convert a list of group names to an array of group IDs
@@ -383,7 +382,6 @@ usage (int status)
383382
(void) fputs (_(" -a, --append append the user to the supplemental GROUPS\n"
384383
" mentioned by the -G option without removing\n"
385384
" the user from other groups\n"), usageout);
386-
(void) fputs (_(" -b, --badname allow bad names\n"), usageout);
387385
(void) fputs (_(" -c, --comment COMMENT new value of the GECOS field\n"), usageout);
388386
(void) fputs (_(" -d, --home HOME_DIR new home directory for the user account\n"), usageout);
389387
(void) fputs (_(" -e, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE\n"), usageout);
@@ -996,8 +994,6 @@ process_flags(int argc, char **argv)
996994
int c;
997995
static struct option long_options[] = {
998996
{"append", no_argument, NULL, 'a'},
999-
{"badname", no_argument, NULL, 'b'},
1000-
{"badnames", no_argument, NULL, 'b'},
1001997
{"comment", required_argument, NULL, 'c'},
1002998
{"home", required_argument, NULL, 'd'},
1003999
{"expiredate", required_argument, NULL, 'e'},
@@ -1041,9 +1037,6 @@ process_flags(int argc, char **argv)
10411037
case 'a':
10421038
aflg = true;
10431039
break;
1044-
case 'b':
1045-
allow_bad_names = true;
1046-
break;
10471040
case 'c':
10481041
if (!VALID (optarg)) {
10491042
fprintf (stderr,
@@ -1118,15 +1111,9 @@ process_flags(int argc, char **argv)
11181111
/*@notreached@*/break;
11191112
case 'l':
11201113
if (!is_valid_user_name(optarg)) {
1121-
if (errno == EILSEQ) {
1122-
fprintf(stderr,
1123-
_("%s: invalid user name '%s': use --badname to ignore\n"),
1124-
Prog, optarg);
1125-
} else {
1126-
fprintf(stderr,
1127-
_("%s: invalid user name '%s'\n"),
1128-
Prog, optarg);
1129-
}
1114+
fprintf(stderr,
1115+
_("%s: invalid user name '%s'\n"),
1116+
Prog, optarg);
11301117
exit (E_BAD_ARG);
11311118
}
11321119
lflg = true;

0 commit comments

Comments
 (0)