[Pkg-shadow-devel] [pkg-shadow-Bugs][311367] useradd not accepting multibyte UTF8 string (unable to create username in local language/script )

pkg-shadow-bugs at alioth.debian.org pkg-shadow-bugs at alioth.debian.org
Thu Feb 5 20:42:07 UTC 2009

Bugs item #311367, was opened at 23/01/2009 10:11
>Status: Closed
Priority: 3
Submitted By: Pravin Satpute (pravins-guest)
Assigned to: Nobody (None)
Summary:  useradd not accepting multibyte UTF8 string (unable to create username in local language/script ) 
Category: None
Group: None
Resolution: None

Initial Comment:
Description of problem:
useradd giving error while inputting name in local language Devanagari

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1.become root
2.try to add user using useradd command
3.input any user name in UTF 8 string, says प्रविण
4.it is giving error invalid username

Actual results:
we cant create user in our own script/language

Expected results:
it should be get accepted, person should able to create username in his own
script/language other than Latin, 

Additional info:


>Comment By: Nicolas FRANCOIS  (nekral-guest)
Date: 05/02/2009 21:42


I also don't think non-ASCII usernames will be supported by every applications.

Regarding the full name, note that we cannot check if the username is enterred in UTF-8, and applications probably will not convert the encoding if the user uses another encoding. This should still be OK if everybody on the system uses an UTF-8 encoding.

I'm closing the bug, as proposed.


Comment By: Pravin Satpute (pravins-guest)
Date: 03/02/2009 07:41

looks like submitted wrong bug :(
i think creating userid in utf8 will add difficulty in processing it at console level
so no need that,
but we can put user full name in UTF-8 so that is sufficient

please feel free to close it as NOTABUG


Comment By: Pravin Satpute (pravins-guest)
Date: 23/01/2009 10:20

solution will be
for checking good name we suppose to convert UTF8 string to UTF16 and then check it using glibc CTYPE fuctions 
iswalpha(i), iswdigit(i) etc.
using that thing i think we can check good name for all unicode characters and can cover all available scripts for username

i am trying for that will submit patch soon
please let me know if any suggestions


Comment By: Pravin Satpute (pravins-guest)
Date: 23/01/2009 10:16

the problem in present in good_name function its check for ascii characters

if (!*name || !((*name >= 'a' && *name <= 'z')
             || (*name >= 'A' && *name <= 'Z')
             || (*name >= '0' && *name <= '9')
             || *name == '_' || *name == '.'))
  return 0;

 while (*++name) {
  if (!(  (*name >= 'a' && *name <= 'z')
       || (*name >= 'A' && *name <= 'Z')
                     || (*name >= '0' && *name <= '9')
                     || *name == '_' || *name == '.' || *name == '-'
                     || (*name == '$' && *(name + 1) == '\0')))
   return 0;

but if we input U+0915, its UTF-8 =  E0 A4 95
since E0 it is not valid, 
useradd not adding username saying its invalid username


You can respond by visiting: 

More information about the Pkg-shadow-devel mailing list