[PATCH 3/3] Ignore the home directory setting if no change was requested (#1119900)

David Shea dshea at redhat.com
Tue Jul 15 21:54:31 UTC 2014


This fixes a bug in which the value of username upon entering the
advanced user dialog is used as the path for the user's home directory,
regardless of any further changes to the username and regardless of
whether the advanced user dialog was exited with OK or cancel. Only use
the advanced homedir path if the path was changed and OK was clicked,
but if the path was explicitly set at any point then do not use the
/home/<username> default.
---
 pyanaconda/ui/gui/spokes/user.py | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/user.py b/pyanaconda/ui/gui/spokes/user.py
index 1444348..654a647 100644
--- a/pyanaconda/ui/gui/spokes/user.py
+++ b/pyanaconda/ui/gui/spokes/user.py
@@ -78,6 +78,11 @@ class AdvancedUserDialog(GUIObject, GUIDialogInputCheckHandler):
         self._user = user
         self._groupDict = groupDict
 
+        # Track whether the user has requested a home directory other
+        # than the default.
+        self._origHome = None
+        self._homeSet = False
+
     def _grabObjects(self):
         self._cUid = self.builder.get_object("c_uid")
         self._cGid = self.builder.get_object("c_gid")
@@ -128,11 +133,12 @@ class AdvancedUserDialog(GUIObject, GUIDialogInputCheckHandler):
 
     def refresh(self):
         if self._user.homedir:
-            self._tHome.set_text(self._user.homedir)
+            homedir = self._user.homedir
         elif self._user.name:
             homedir = "/home/" + self._user.name
-            self._tHome.set_text(homedir)
-            self._user.homedir = homedir
+
+        self._tHome.set_text(homedir)
+        self._origHome = homedir
 
         self._cUid.set_active(bool(self._user.uid))
         self._cGid.set_active(bool(self._user.gid))
@@ -161,7 +167,13 @@ class AdvancedUserDialog(GUIObject, GUIDialogInputCheckHandler):
 
         #OK clicked
         if rc == 1:
-            self._user.homedir = self._tHome.get_text()
+            # If the user changed the home directory input, either this time or
+            # during any earlier run of the dialog, set homedir to the value
+            # in the input box.
+            homedir = self._tHome.get_text()
+            if self._homeSet or self._origHome != homedir:
+                self._homeSet = True
+                self._user.homedir = homedir
 
             if self._cUid.get_active():
                 self._user.uid = int(self._uid.get_value())
-- 
2.0.0



More information about the anaconda-patches mailing list