Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1 | From ca472d6866e545aaa70a70020e3226f236a8aafc Mon Sep 17 00:00:00 2001 |
| 2 | From: Shan Hai <shan.hai@windriver.com> |
| 3 | Date: Tue, 13 Sep 2016 13:45:46 +0800 |
| 4 | Subject: [PATCH] shadow: use relaxed usernames |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 5 | |
| 6 | The groupadd from shadow does not allow upper case group names, the |
| 7 | same is true for the upstream shadow. But distributions like |
| 8 | Debian/Ubuntu/CentOS has their own way to cope with this problem, |
| 9 | this patch is picked up from CentOS release 7.0 to relax the usernames |
| 10 | restrictions to allow the upper case group names, and the relaxation is |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 11 | POSIX compliant because POSIX indicate that usernames are composed of |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12 | characters from the portable filename character set [A-Za-z0-9._-]. |
| 13 | |
| 14 | Upstream-Status: Pending |
| 15 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 16 | Signed-off-by: Shan Hai <shan.hai@windriver.com> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 17 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 18 | --- |
| 19 | libmisc/chkname.c | 30 ++++++++++++++++++------------ |
| 20 | man/groupadd.8.xml | 6 ------ |
| 21 | man/useradd.8.xml | 8 +------- |
| 22 | 3 files changed, 19 insertions(+), 25 deletions(-) |
| 23 | |
| 24 | diff --git a/libmisc/chkname.c b/libmisc/chkname.c |
| 25 | index 90f185c..65762b4 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 26 | --- a/libmisc/chkname.c |
| 27 | +++ b/libmisc/chkname.c |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 28 | @@ -55,22 +55,28 @@ static bool is_valid_name (const char *name) |
| 29 | } |
| 30 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 31 | /* |
| 32 | - * User/group names must match [a-z_][a-z0-9_-]*[$] |
| 33 | - */ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 34 | - |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 35 | - if (('\0' == *name) || |
| 36 | - !((('a' <= *name) && ('z' >= *name)) || ('_' == *name))) { |
| 37 | + * User/group names must match gnu e-regex: |
| 38 | + * [a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,30}[a-zA-Z0-9_.$-]? |
| 39 | + * |
| 40 | + * as a non-POSIX, extension, allow "$" as the last char for |
| 41 | + * sake of Samba 3.x "add machine script" |
| 42 | + */ |
| 43 | + if ( ('\0' == *name) || |
| 44 | + !((*name >= 'a' && *name <= 'z') || |
| 45 | + (*name >= 'A' && *name <= 'Z') || |
| 46 | + (*name >= '0' && *name <= '9') || |
| 47 | + (*name == '_') || (*name == '.') |
| 48 | + )) { |
| 49 | return false; |
| 50 | } |
| 51 | |
| 52 | while ('\0' != *++name) { |
| 53 | - if (!(( ('a' <= *name) && ('z' >= *name) ) || |
| 54 | - ( ('0' <= *name) && ('9' >= *name) ) || |
| 55 | - ('_' == *name) || |
| 56 | - ('-' == *name) || |
| 57 | - ('.' == *name) || |
| 58 | - ( ('$' == *name) && ('\0' == *(name + 1)) ) |
| 59 | - )) { |
| 60 | + if (!( (*name >= 'a' && *name <= 'z') || |
| 61 | + (*name >= 'A' && *name <= 'Z') || |
| 62 | + (*name >= '0' && *name <= '9') || |
| 63 | + (*name == '_') || (*name == '.') || (*name == '-') || |
| 64 | + (*name == '$' && *(name + 1) == '\0') |
| 65 | + )) { |
| 66 | return false; |
| 67 | } |
| 68 | } |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 69 | diff --git a/man/groupadd.8.xml b/man/groupadd.8.xml |
| 70 | index 1e58f09..d804b61 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 71 | --- a/man/groupadd.8.xml |
| 72 | +++ b/man/groupadd.8.xml |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 73 | @@ -272,12 +272,6 @@ |
| 74 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 75 | <refsect1 id='caveats'> |
| 76 | <title>CAVEATS</title> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 77 | - <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 78 | - Groupnames must start with a lower case letter or an underscore, |
| 79 | - followed by lower case letters, digits, underscores, or dashes. |
| 80 | - They can end with a dollar sign. |
| 81 | - In regular expression terms: [a-z_][a-z0-9_-]*[$]? |
| 82 | - </para> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 83 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 84 | Groupnames may only be up to &GROUP_NAME_MAX_LENGTH; characters long. |
| 85 | </para> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 86 | diff --git a/man/useradd.8.xml b/man/useradd.8.xml |
| 87 | index a16d730..c0bd777 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 88 | --- a/man/useradd.8.xml |
| 89 | +++ b/man/useradd.8.xml |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 90 | @@ -366,7 +366,7 @@ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 91 | </term> |
| 92 | <listitem> |
| 93 | <para> |
| 94 | - Do no create the user's home directory, even if the system |
| 95 | + Do not create the user's home directory, even if the system |
| 96 | wide setting from <filename>/etc/login.defs</filename> |
| 97 | (<option>CREATE_HOME</option>) is set to |
| 98 | <replaceable>yes</replaceable>. |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 99 | @@ -660,12 +660,6 @@ |
| 100 | the user account creation request. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 101 | </para> |
| 102 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 103 | - <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 104 | - Usernames must start with a lower case letter or an underscore, |
| 105 | - followed by lower case letters, digits, underscores, or dashes. |
| 106 | - They can end with a dollar sign. |
| 107 | - In regular expression terms: [a-z_][a-z0-9_-]*[$]? |
| 108 | - </para> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 109 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 110 | Usernames may only be up to 32 characters long. |
| 111 | </para> |