[PATCH 4/4] Behave nice when root password is set by kickstart

Martin Sivak msivak at redhat.com
Thu Feb 28 10:09:42 UTC 2013


---
 pyanaconda/ui/gui/spokes/password.py | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/password.py b/pyanaconda/ui/gui/spokes/password.py
index 7e62ec7..e6bb5a3 100644
--- a/pyanaconda/ui/gui/spokes/password.py
+++ b/pyanaconda/ui/gui/spokes/password.py
@@ -53,6 +53,7 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke):
         self._password = None
         self._error = False
         self._oldweak = None
+        self._kickstarted = False
 
     def initialize(self):
         NormalSpoke.initialize(self)
@@ -60,6 +61,11 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke):
         self.pw = self.builder.get_object("pw")
         self.confirm = self.builder.get_object("confirm")
 
+        self._kickstarted = self.data.rootpw.seen
+        if self._kickstarted:
+            self.pw.set_placeholder_text(_("The password was set by kickstart."))
+            self.confirm.set_placeholder_text(_("The password was set by kickstart."))
+
     def refresh(self):
 #        self.setCapsLockLabel()
         self.pw.grab_focus()
@@ -76,7 +82,9 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke):
     def status(self):
         if self._error:
             return _("Error setting root password")
-        if self.data.rootpw.password:
+        elif self._kickstarted:
+            return _("Root password was set by kickstart")
+        elif self.data.rootpw.password:
             return _("Root password is set")
         elif self.data.rootpw.lock:
             return _("Root account is disabled")
@@ -87,11 +95,17 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke):
     def mandatory(self):
         return not any(user for user in self.data.user.userList
                             if "wheel" in user.groups)
-        
+
     def apply(self):
+        if self._password == "" and self._kickstarted:
+            return
+
         self.data.rootpw.password = cryptPassword(self._password)
         self.data.rootpw.isCrypted = True
         self.data.rootpw.lock = False
+        self._kickstarted = False
+        self.pw.set_placeholder_text("")
+        self.confirm.set_placeholder_text("")
 
     @property
     def completed(self):
@@ -106,8 +120,11 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke):
         confirm = self.confirm.get_text()
 
         if not pw and not confirm:
-            self._error = _("You must provide and confirm a password.")
-            return False
+            if self._kickstarted:
+                return True
+            else:
+                self._error = _("You must provide and confirm a password.")
+                return False
 
         try:
             self._error = validatePassword(pw, confirm)
-- 
1.7.11.7



More information about the anaconda-patches mailing list