Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
DescriptionAbdul Rehman Quadri
2022-04-10 05:46:06 UTC
Description of problem:
1. The useradd command now allows names that do not conform to standards using the option "--badnames".
2. Now if the option --bad is used then also it allows the user to be created with bad names. The below options are being resulted in successful user account creation by useradd:
2.1: --bad
2.2: --badn
2.3: --badna
2.4: --badnam
2.5: --badname
2.6: --badnames
Version-Release number of selected component (if applicable):
shadow-utils-4.9-3.el9.x86_64
How reproducible:
Always
Steps to Reproduce:
1. log in as a privileged/root user
2. useradd --bad @user1
3. useradd --badn @user2
4. useradd --badna @user3
5. useradd --badnam @user4
6. useradd --badname @user5
7. useradd --badnames @user6
Actual results:
All the users from user1 to user6 get added successfully
Expected results:
Steps 2-6 should be failed I think and it should throw warning message and only the 7th step should get succeeded i.e the useradd command should only allow adding a user with badname with a single option "--badnames"
Additional info:
As mentioned in https://bugzilla.redhat.com/show_bug.cgi?id=2069680#c1 the good option is "badnames", so the other ones shouldn't work.
As you are playing around, can you try "--ba" and "--badnamesblablabla" options?
Comment 3Abdul Rehman Quadri
2022-04-11 09:17:32 UTC
(In reply to Iker Pedrosa from comment #2)
> As mentioned in https://bugzilla.redhat.com/show_bug.cgi?id=2069680#c1 the
> good option is "badnames", so the other ones shouldn't work.
> Thank you for the comment.> As you are playing around, can you try "--ba" and "--badnamesblablabla"
> options?
> Yeah, Tried that and it is not working, "--ba" and "--badnamesblablabla" both the options are showing invalid.
shadow-utils is using the getopt_long() API to parse the command line arguments. I would expect this API to only match the exact string with an option, but it is matched even if some characters are missing (--bad, --badn, --badna, etc.). I don't see any reference to this in the man page. Siddhesh could you please clarify if this is intentional?
Comment 5Siddhesh Poyarekar
2022-05-03 04:52:32 UTC
(In reply to Iker Pedrosa from comment #4)
> shadow-utils is using the getopt_long() API to parse the command line
> arguments. I would expect this API to only match the exact string with an
> option, but it is matched even if some characters are missing (--bad,
> --badn, --badna, etc.). I don't see any reference to this in the man page.
> Siddhesh could you please clarify if this is intentional?
There is no reference to this behaviour in the glibc manual, but there is in the man page and in code comments. Excerpt from the `man getopt_long` on F35:
getopt_long() and getopt_long_only()
...
Long option names may be abbreviated if the abbreviation is unique or is an exact match for some defined option.
...
Comment 6Siddhesh Poyarekar
2022-05-03 05:00:13 UTC
(In reply to Siddhesh Poyarekar from comment #5)
> (In reply to Iker Pedrosa from comment #4)
> > shadow-utils is using the getopt_long() API to parse the command line
> > arguments. I would expect this API to only match the exact string with an
> > option, but it is matched even if some characters are missing (--bad,
> > --badn, --badna, etc.). I don't see any reference to this in the man page.
> > Siddhesh could you please clarify if this is intentional?
>
> There is no reference to this behaviour in the glibc manual, but there is in
> the man page and in code comments. Excerpt from the `man getopt_long` on
> F35:
>
> getopt_long() and getopt_long_only()
> ...
> Long option names may be abbreviated if the abbreviation is unique or is
> an exact match for some defined option.
> ...
... and to close the gap, I've posted a glibc patch upstream to also document this behaviour in the glibc manual:
https://patchwork.sourceware.org/project/glibc/patch/20220503045743.2887439-1-siddhesh@sourceware.org/
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory (glibc bug fix and enhancement update), and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://access.redhat.com/errata/RHBA-2022:8272
Description of problem: 1. The useradd command now allows names that do not conform to standards using the option "--badnames". 2. Now if the option --bad is used then also it allows the user to be created with bad names. The below options are being resulted in successful user account creation by useradd: 2.1: --bad 2.2: --badn 2.3: --badna 2.4: --badnam 2.5: --badname 2.6: --badnames Version-Release number of selected component (if applicable): shadow-utils-4.9-3.el9.x86_64 How reproducible: Always Steps to Reproduce: 1. log in as a privileged/root user 2. useradd --bad @user1 3. useradd --badn @user2 4. useradd --badna @user3 5. useradd --badnam @user4 6. useradd --badname @user5 7. useradd --badnames @user6 Actual results: All the users from user1 to user6 get added successfully Expected results: Steps 2-6 should be failed I think and it should throw warning message and only the 7th step should get succeeded i.e the useradd command should only allow adding a user with badname with a single option "--badnames" Additional info: