LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Case-insensitive User Name Creation (https://www.linuxquestions.org/questions/linux-newbie-8/case-insensitive-user-name-creation-924957/)

SMurf7 01-21-2012 07:27 AM

Case-insensitive User Name Creation
 
Hello,

I am having a go at setting up an e-mail server using CentOS 6.2 running under VirtualBox. I have never done this before, only previously using Linux as a desktop OS.

So I installed CentOS, using a "minimal" install with the "E-mail Server" option selected. postfix and dovecot are available. I also installed mailx for testing.

I can send an e-mail to "root" and this will appear in /var/mail/root. However, after creating a user with my forum username and trying to send e-mail to that, nothing seems to happen. Examining /var/log/maillog shows that the e-mail bounced due to an unknown user "smurf7".

Reading around this, it seems that postfix converts the requested user name into lowercase before looking anywhere (putting "smurf7:SMurf7" into \etc\aliases and running newaliases didn't fix it). Short of butchering the code, there is little I can do about that.

Most people also infer that creating usernames with uppercase letters is bad form, yet adduser did not complain when I did it.

Is there a way that I can force adduser to treat all usernames as lowercase, preventing duplicate names in different case (and allowing e-mail to work)?

lucmove 01-21-2012 04:00 PM

Well, you could make a wrapper:

lcadduser.sh (lowercase adduser):

Code:

#!/bin/bash

LCUSER=`echo $1 | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
adduser $LCUSER

Code:

# lcadduser SMurf7
Or something like that. Though it's probably not the "proper" way to handle your problem.

David the H. 01-22-2012 04:25 AM

No need to use tr for this in modern versions of bash. It has built-in case conversion.

Code:

#!/bin/bash
adduser "${1,,}"

parameter substitution

But first take a look at man adduser.conf for details on the NAME_REGEX value. According to mine, the default value is set to accept lowercase-only anyway.


All times are GMT -5. The time now is 01:47 AM.