[PATCH] Forbid "root" as a user or group name. (#968451)

David Shea dshea at redhat.com
Fri Sep 20 13:13:06 UTC 2013


On 09/18/2013 04:15 PM, David Shea wrote:
> +_USERNAME_BASE = r'[a-zA-Z0-9._](([a-zA-Z0-9._-]{1,2})|([a-zA-Z0-9._-]{3}(?<!root))|([a-zA-Z0-9._-]{,30}\$)|([a-zA-Z0-9._-]{4,31}))?'
So, looking at this thing, I think it'd be slightly better to rearrange 
the choices in the part of the expression after the first character.

_USERNAME_BASE = r'[a-zA-Z0-9._](([a-zA-Z0-9._-]{0,2})|([a-zA-Z0-9._-]{3}(?<!root))|([a-zA-Z0-9._-]{4,31})|([a-zA-Z0-9._-]{,30}\$))'


That way it reads as an expression matching 0-2 characters, an 
expression matching 3 characters that isn't "root", an expression 
matching 4-31 characters, or an expression matching 0-30 characters 
followed by a dollar sign. It reads a little better (lol), and having 
the empty string matched by the first part means we don't need the 
question mark at the end.


More information about the anaconda-patches mailing list