# define allowed format of usernames - login.defs does not wrk

## DawgG

on my systems i need usernames in the format

NN.NNN.NNN-N

(N=0-9)

useradd won't accept usernames in this format and /etc/login.defs has no setting for the allowed format/chars. Adding the entry CHARACTER_CLASS produces a configuration error (i tried shadow with and without USE="pam")

How to change the allowed format of the usernames?

THX for your help!

----------

## Syl20

You can't set a username beginning with a number. And, even if you could, it's a really bad idea, as some shell commands are able to play with usernames and UIDs/GIDs indifferently.

You can't set a username containing a dot (period) character. And, even if you could, it's a really bad idea, as some shell commands are able to use it as a separator.

----------

## DawgG

 *Quote:*   

> You can't set a username beginning with a number. And, even if you could, 

 

yes, you can, just not with useradd.

 *Quote:*   

> You can't set a username containing a dot (period) character. 

 

try 

```
useradd user.33
```

 *Quote:*   

> it's a really bad idea, as some shell commands are able to use it as a separator.

 

i know that but it was not my question.

----------

## guitou

Can't you simply try and change your requested username format to something more suitable, like prefixing with USER, or even U, and replacing dots with underscores? Would be simple using regular expressions.

----------

## khayyam

DawG ...

forget about login.defs, shadow defines the following match:

```
* User/group names must match [a-z_][a-z0-9_-]*[$]
```

... but it's not shadow but pam that is handling what happens when useradd is run, I'd suspect pam_unix or pam_permit. So, I would search there, or the pam docs.

best ... khay

----------

## Chiitoo

Merged the above two posts from define allowed format of usernames - login.defs does not wrk.

There can be only one.  ^^

----------

## DawgG

THX to all for your help!

i bluntly changed the function in libmisc/chkname.c (in shadow) to return true (instread of false) in the case of such a username, emerged it via PORTDIR_OVERLAY and now this can be done.

(of course it's not good, smart, etc, but still thank you!)

----------

