Skip to content

Commit 8869cc1

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

@@ -44,9 +44,6 @@
4444
#endif
4545

4646

47-
int allow_bad_names = false;
48-
49-
5047
size_t
5148
login_name_max_size(void)
5249
{
@@ -66,19 +63,13 @@ is_valid_name(const char *name)
6663
if (streq(name, "")
6764
|| streq(name, ".")
6865
|| streq(name, "..")
69-
|| strpbrk(name, ",: /")
7066
|| strprefix(name, "-")
71-
|| strchriscntrl(name)
7267
|| strisdigit(name))
7368
{
7469
errno = EINVAL;
7570
return false;
7671
}
7772

78-
if (allow_bad_names) {
79-
return true;
80-
}
81-
8273
/*
8374
* User/group names must match BRE regex:
8475
* [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 (int *errors, bool *changed);
7777
static void check_spw_file (int *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 (int *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 += 1;
486470
}
487471

src/useradd.c

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

153-
extern int allow_bad_names;
154153

155154
static bool
156155
bflg = false, /* new default root of home directory */
@@ -893,7 +892,6 @@ static void usage (int status)
893892
"\n"
894893
"Options:\n"),
895894
Prog, Prog, Prog);
896-
(void) fputs (_(" --badname do not check for bad names\n"), usageout);
897895
(void) fputs (_(" -b, --base-dir BASE_DIR base directory for the home directory of the\n"
898896
" new account\n"), usageout);
899897
#ifdef WITH_BTRFS
@@ -1180,7 +1178,6 @@ static void process_flags (int argc, char **argv)
11801178
#ifdef WITH_BTRFS
11811179
{"btrfs-subvolume-home", no_argument, NULL, 200},
11821180
#endif
1183-
{"badname", no_argument, NULL, 201},
11841181
{"comment", required_argument, NULL, 'c'},
11851182
{"home-dir", required_argument, NULL, 'd'},
11861183
{"defaults", no_argument, NULL, 'D'},
@@ -1237,9 +1234,6 @@ static void process_flags (int argc, char **argv)
12371234
case 200:
12381235
subvolflg = true;
12391236
break;
1240-
case 201:
1241-
allow_bad_names = true;
1242-
break;
12431237
case 'c':
12441238
if (!VALID (optarg)) {
12451239
fprintf (stderr,
@@ -1534,15 +1528,9 @@ static void process_flags (int argc, char **argv)
15341528

15351529
user_name = argv[optind];
15361530
if (!is_valid_user_name(user_name)) {
1537-
if (errno == EILSEQ) {
1538-
fprintf(stderr,
1539-
_("%s: invalid user name '%s': use --badname to ignore\n"),
1540-
Prog, user_name);
1541-
} else {
1542-
fprintf(stderr,
1543-
_("%s: invalid user name '%s'\n"),
1544-
Prog, user_name);
1545-
}
1531+
fprintf(stderr,
1532+
_("%s: invalid user name '%s'\n"),
1533+
Prog, user_name);
15461534
#ifdef WITH_AUDIT
15471535
audit_logger (AUDIT_ADD_USER, Prog,
15481536
"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)