Skip to content

Sudo and numbers in usernames

03/05/2011

I ran into a sudoers file that gave me a syntax error I couldn’t explain. I first needed to find the line of code responsible for the syntax error, which was line 80. But since visudo wasn’t displaying line numbers on the bottom of the screen, I forced visudo to use vim.

export EDITOR=$(which vim)

After that I located line 80, which read something like

#5berry ALL=(ALL) ALL

All the vi colours were setup properly, everything looked fine. Adding the user ‘tomcat6′ didn’t work either, the text turned from red (used for usernames in sudoers) to white the second I added the ’6′ at the end. After a little Googling, I learned one could add users by using their uid, like so:

User_Alias TOMCAT = #500
Cmnd_Alias WEBSERVICES = /etc/init.d/tomcat, /etc/init.d/apache2
TOMCAT ALL = WEBSERVICES

That should work, but didn’t. Then it hit me; sudo was interpreting “#5berry ALL=(ALL) ALL” as “uid 5 berry ALL=(ALL) ALL”, while vi was interpreting it as a comment line. So I changed it to “##5berry”, although “# 5berry” probably also would work.

So, as you can see, weird things can happen once you combine usernames that contain numbers with a sudoers file.

Update: W.T. Fawkes figured out that “5berry” or “tomcat6″ (enclosed in double quotes) should also work… and it does. Thanks for the info.

Advertisement

From → Configuration

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.