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