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:
*** Bug 2069680 has been marked as a duplicate of this bug. ***
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?
(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?
(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. ...
(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