Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
define allowed format of usernames - login.defs does not wrk
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
DawgG
l33t
l33t


Joined: 17 Sep 2003
Posts: 812

PostPosted: Wed Apr 20, 2016 1:20 pm    Post subject: define allowed format of usernames - login.defs does not wrk Reply with quote

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!
_________________
DUMM KLICKT GUT.
Back to top
View user's profile Send private message
Syl20
Guru
Guru


Joined: 04 Aug 2005
Posts: 564
Location: France

PostPosted: Wed Apr 20, 2016 1:33 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
DawgG
l33t
l33t


Joined: 17 Sep 2003
Posts: 812

PostPosted: Wed Apr 20, 2016 1:47 pm    Post subject: Reply with quote

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
Code:
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.
_________________
DUMM KLICKT GUT.
Back to top
View user's profile Send private message
guitou
Guru
Guru


Joined: 02 Oct 2003
Posts: 391
Location: France

PostPosted: Wed Apr 20, 2016 3:22 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Wed Apr 20, 2016 3:54 pm    Post subject: Reply with quote

DawG ...

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

libmisc/chkname.c:
* 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
Back to top
View user's profile Send private message
Chiitoo
Administrator
Administrator


Joined: 28 Feb 2010
Posts: 1712
Location: Here and Away Again

PostPosted: Wed Apr 20, 2016 4:32 pm    Post subject: Reply with quote

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

There can be only one. ^^
_________________
Kind Regards,
~ The Noob Unlimited ~

Sore wa sore, kore wa kore.
Back to top
View user's profile Send private message
DawgG
l33t
l33t


Joined: 17 Sep 2003
Posts: 812

PostPosted: Fri Apr 22, 2016 9:46 am    Post subject: changed function in shadow - can be done now Reply with quote

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!)
_________________
DUMM KLICKT GUT.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum