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.
Bug 2073743 - getopt_long: manual clarification: getopt_long long option names may be abbreviated
Summary: getopt_long: manual clarification: getopt_long long option names may be abbre...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: glibc
Version: 9.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: glibc team
QA Contact: Sergey Kolosov
URL: http//
Whiteboard:
: 2069680 (view as bug list)
Depends On: 2091541
Blocks: 2010412
TreeView+ depends on / blocked
 
Reported: 2022-04-10 05:46 UTC by Abdul Rehman Quadri
Modified: 2023-07-18 14:29 UTC (History)
11 users (show)

Fixed In Version: glibc-2.34-35.el9
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-11-15 11:11:50 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-118476 0 None None None 2022-04-10 05:48:34 UTC
Red Hat Issue Tracker SSSD-4564 0 None None None 2022-04-11 11:52:36 UTC
Red Hat Product Errata RHBA-2022:8272 0 None None None 2022-11-15 11:12:26 UTC

Description Abdul 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:

Comment 1 Iker Pedrosa 2022-04-11 07:16:20 UTC
*** Bug 2069680 has been marked as a duplicate of this bug. ***

Comment 2 Iker Pedrosa 2022-04-11 07:19:06 UTC
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 3 Abdul 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.

Comment 4 Iker Pedrosa 2022-05-02 08:58:06 UTC
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 5 Siddhesh 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 6 Siddhesh 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/

Comment 18 errata-xmlrpc 2022-11-15 11:11:50 UTC
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


Note You need to log in before you can comment on or make changes to this bug.