adduser: Allow '@', '%', '/' and '\' in username

Allow '@', '%', '/' and '\' in username for adduser command to support
usernames in the form of :

  username@domain
  username%domain
  domain/username
  domain\username

Username in those forms may have some limitations in various services
like email, ssh, but simply disallowing them prevents more generic
use of the username based on email address or name with realm.
pull/7/head
Kyeong Yoo 2018-02-14 13:36:13 +13:00
parent 3459024bf4
commit d94d2b0a9e
1 changed files with 4 additions and 0 deletions

View File

@ -32,6 +32,10 @@ void FAST_FUNC die_if_bad_username(const char *name)
/* These chars are valid unless they are at the 1st pos: */
if (*name == '-'
|| *name == '.'
|| *name == '@'
|| *name == '%'
|| *name == '/'
|| *name == '\\'
/* $ is allowed if it's the last char: */
|| (*name == '$' && !name[1])
) {