Re: Specifications for username
On Thu, Feb 27, 2003 at 03:43:16PM +0200, Johann Spies wrote:
> My manager wants to know what is allowed and what not when choosing a
> linux username.
>
> I know it must be lowercase, not have spaces or special characters,
> but I don't know where it is documented.
>
> Any reference to documentation that specify this?
adduser(8) says that you need to use the --force-badname option to allow
anything other than "a lowercase letter followed by zero or more
lowercase letters or numbers", with dashes accepted as well. Looking at
the source for adduser:
# is name ok?
sub checkname {
my ($name) = @_;
if ($allow_badname && $name !~ /^[A-Za-z_][-_A-Za-z0-9]*\$?$/) {
print STDERR
"$0: ",_("To avoid problems, the username should consist of a letter or
underscore followed by letters, digits, underscores, and dashes. For
compatibility with Samba machine accounts also \$ is supported at the
end of the username\n");
exit 1;
}
elsif ($name !~ /^[a-z][a-z0-9\-]*$/) {
if (!$allow_badname) {
print STDERR
"$0: ",_("Please enter a username consisting of a lower case letter
followed by lower case letters and numbers. Use the `--force-badname'
option to allow underscores, and uppercase.\n");
exit 1;
}
print _("Allowing use of questionable username.\n") if ($verbose);
}
}
The first message there is if --force-badname is used. The second is the
strict format, which you should definitely stick to for new login names.
(Yes, this could all do with being better-documented.)
--
Colin Watson [cjwatson@flatline.org.uk]
Reply to: