FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 06-28-2011, 11:21 AM
Martin Gracik
 
Default Get UID_MIN from /etc/login.defs (#717113)

Get the UID_MIN value from /etc/login.defs and use it to
determine proper user id number, instead of hardcoded 500.

Use 500 if the /etc/login.defs parsing fails.
---
modules/create_user.py | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/modules/create_user.py b/modules/create_user.py
index a5e1f78..7e87dd6 100644
--- a/modules/create_user.py
+++ b/modules/create_user.py
@@ -23,6 +23,7 @@ import os, string, sys, time
import os.path
import pwd
import unicodedata
+import re

from firstboot.config import *
from firstboot.constants import *
@@ -134,7 +135,32 @@ class moduleClass(Module):

user = self.admin.lookupUserByName(username)

- if user != None and user.get(libuser.UIDNUMBER)[0] < 500:
+ # get UID_MIN from /etc/login.defs
+ __ld_line = re.compile(r'^[ ]*' # Initial whitespace
+ r'([^ ]+)' # Variable name
+ r'[ ][ "]*' # Separator - yes, may have multiple "s
+ r'(([^"]*)".*' # Value, case 1 - terminated by "
+ r'|([^"]*S)?s*' # Value, case 2 - only drop trailing s
+ r')$')
+
+ res = {}
+ with open('/etc/login.defs') as f:
+ for line in f:
+ match = __ld_line.match(line)
+ if match is not None:
+ name = match.group(1)
+ if name.startswith('#'):
+ continue
+ value = match.group(3)
+ if value is None:
+ value = match.group(4)
+ if value is None:
+ value = '
+ res[name] = value # Override previous definition
+
+ uid_min = res.get('UID_MIN', 500)
+
+ if user != None and user.get(libuser.UIDNUMBER)[0] < uid_min:
self._showErrorMessage(_("The username '%s' is a reserved system "
"account. Please specify another username."
% username))
--
1.7.3.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 08:31 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org