[PATCH] Allow setting the default GID of the new user.
Martin Sivak
msivak at redhat.com
Wed Mar 20 16:32:27 UTC 2013
---
pyanaconda/ui/gui/spokes/user.py | 6 ++----
pyanaconda/users.py | 5 +++++
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/user.py b/pyanaconda/ui/gui/spokes/user.py
index d0b67cd..d62a2c7 100644
--- a/pyanaconda/ui/gui/spokes/user.py
+++ b/pyanaconda/ui/gui/spokes/user.py
@@ -103,11 +103,9 @@ class AdvancedUserDialog(GUIObject):
self._user.uid = None
if self.builder.get_object("c_gid").get_active():
- pass
- #self._user.gid = int(self.builder.get_widget("gid").get_value())
+ self._user.gid = int(self.builder.get_widget("gid").get_value())
else:
- #self._user.gid = None
- pass
+ self._user.gid = None
groups = self.builder.get_object("t_groups").get_text().split(",")
self._user.groups = []
diff --git a/pyanaconda/users.py b/pyanaconda/users.py
index f102a29..bd50536 100644
--- a/pyanaconda/users.py
+++ b/pyanaconda/users.py
@@ -239,6 +239,8 @@ class Users:
libuser default is used.
uid -- The UID for the new user. If none is given, the next
available one is used.
+ gid -- The GID for the new user. If none is given, the next
+ available one is used.
"""
childpid = os.fork()
root = kwargs.get("root", "/mnt/sysimage")
@@ -257,6 +259,9 @@ class Users:
userEnt = self.admin.initUser(user_name)
groupEnt = self.admin.initGroup(user_name)
+ if kwargs.get("gid", -1) >= 0:
+ groupEnt.set(libuser.GIDNUMBER, kwargs["gid"])
+
grpLst = filter(lambda grp: grp,
map(lambda name: self.admin.lookupGroupByName(name), kwargs.get("groups", [])))
userEnt.set(libuser.GIDNUMBER, [groupEnt.get(libuser.GIDNUMBER)[0]] +
--
1.7.11.7
More information about the anaconda-patches
mailing list