162 lines
6.5 KiB
Diff
162 lines
6.5 KiB
Diff
|
From bb3d9ee61f69488c18035d16c804af5ff079b7b7 Mon Sep 17 00:00:00 2001
|
||
|
From: Marek Marczykowski <marmarek@invisiblethingslab.com>
|
||
|
Date: Fri, 19 Oct 2018 08:02:12 +0200
|
||
|
Subject: [PATCH] anaconda: add option to lock root account
|
||
|
MIME-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
|
||
|
Not only default setting, so one could leave account locked if entered
|
||
|
password setting spoke.
|
||
|
|
||
|
Signed-off-by: Frédéric Pierret <frederic.epitre@orange.fr>
|
||
|
---
|
||
|
pyanaconda/ui/gui/spokes/password.glade | 18 +++++++++++-
|
||
|
pyanaconda/ui/gui/spokes/password.py | 51 +++++++++++++++++++++++----------
|
||
|
2 files changed, 53 insertions(+), 16 deletions(-)
|
||
|
|
||
|
diff --git a/pyanaconda/ui/gui/spokes/password.glade b/pyanaconda/ui/gui/spokes/password.glade
|
||
|
index 1a4e77720..1f1fe5837 100644
|
||
|
--- a/pyanaconda/ui/gui/spokes/password.glade
|
||
|
+++ b/pyanaconda/ui/gui/spokes/password.glade
|
||
|
@@ -40,6 +40,22 @@
|
||
|
<object class="GtkBox" id="AnacondaSpokeWindow-action_area1">
|
||
|
<property name="can_focus">False</property>
|
||
|
<property name="orientation">vertical</property>
|
||
|
+ <child>
|
||
|
+ <object class="GtkCheckButton" id="lock">
|
||
|
+ <property name="label" translatable="yes">Lock root account</property>
|
||
|
+ <property name="visible">True</property>
|
||
|
+ <property name="can_focus">True</property>
|
||
|
+ <property name="receives_default">False</property>
|
||
|
+ <property name="xalign">0</property>
|
||
|
+ <property name="draw_indicator">True</property>
|
||
|
+ <signal name="clicked" handler="on_lock_clicked" swapped="no"/>
|
||
|
+ </object>
|
||
|
+ <packing>
|
||
|
+ <property name="expand">False</property>
|
||
|
+ <property name="fill">True</property>
|
||
|
+ <property name="position">0</property>
|
||
|
+ </packing>
|
||
|
+ </child>
|
||
|
<child>
|
||
|
<object class="GtkGrid" id="pwgrid">
|
||
|
<property name="visible">True</property>
|
||
|
@@ -174,7 +190,7 @@
|
||
|
<packing>
|
||
|
<property name="expand">False</property>
|
||
|
<property name="fill">True</property>
|
||
|
- <property name="position">0</property>
|
||
|
+ <property name="position">1</property>
|
||
|
</packing>
|
||
|
</child>
|
||
|
</object>
|
||
|
diff --git a/pyanaconda/ui/gui/spokes/password.py b/pyanaconda/ui/gui/spokes/password.py
|
||
|
index 92acfa8f3..3e8ada1cc 100644
|
||
|
--- a/pyanaconda/ui/gui/spokes/password.py
|
||
|
+++ b/pyanaconda/ui/gui/spokes/password.py
|
||
|
@@ -56,6 +56,7 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke, GUISpokeInputCheckHandler)
|
||
|
def __init__(self, *args):
|
||
|
NormalSpoke.__init__(self, *args)
|
||
|
GUISpokeInputCheckHandler.__init__(self)
|
||
|
+ self._lock = self.data.rootpw.lock
|
||
|
self._kickstarted = False
|
||
|
|
||
|
def initialize(self):
|
||
|
@@ -63,6 +64,7 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke, GUISpokeInputCheckHandler)
|
||
|
# place holders for the text boxes
|
||
|
self.pw = self.builder.get_object("pw")
|
||
|
self.confirm = self.builder.get_object("confirmPW")
|
||
|
+ self.lock = self.builder.get_object("lock")
|
||
|
|
||
|
# Install the password checks:
|
||
|
# - Has a password been specified?
|
||
|
@@ -119,17 +121,31 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke, GUISpokeInputCheckHandler)
|
||
|
# Enable the input checks in case they were disabled on the last exit
|
||
|
for check in self.checks:
|
||
|
check.enabled = True
|
||
|
-
|
||
|
- self.pw.grab_focus()
|
||
|
+ self.lock.set_active(self._lock)
|
||
|
+ self.on_lock_clicked(self.lock)
|
||
|
self.pw.emit("changed")
|
||
|
self.confirm.emit("changed")
|
||
|
|
||
|
+ def on_lock_clicked(self, lock):
|
||
|
+ self.pw.set_sensitive(not lock.get_active())
|
||
|
+ self.confirm.set_sensitive(not lock.get_active())
|
||
|
+ if not lock.get_active():
|
||
|
+ self.pw.grab_focus()
|
||
|
+
|
||
|
+# Caps lock detection isn't hooked up right now
|
||
|
+# def setCapsLockLabel(self):
|
||
|
+# if isCapsLockEnabled():
|
||
|
+# self.capslock.set_text("<b>" + _("Caps Lock is on.") + "</b>")
|
||
|
+# self.capslock.set_use_markup(True)
|
||
|
+# else:
|
||
|
+# self.capslock..set_text("")
|
||
|
+
|
||
|
@property
|
||
|
def status(self):
|
||
|
- if self.data.rootpw.password:
|
||
|
- return _("Root password is set")
|
||
|
- elif self.data.rootpw.lock:
|
||
|
+ if self.data.rootpw.lock:
|
||
|
return _("Root account is disabled")
|
||
|
+ elif self.data.rootpw.password:
|
||
|
+ return _("Root password is set")
|
||
|
else:
|
||
|
return _("Root password is not set")
|
||
|
|
||
|
@@ -145,15 +161,10 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke, GUISpokeInputCheckHandler)
|
||
|
self.data.rootpw.seen = False
|
||
|
self._kickstarted = False
|
||
|
|
||
|
- self.data.rootpw.lock = False
|
||
|
-
|
||
|
- if not pw:
|
||
|
- self.data.rootpw.password = ''
|
||
|
- self.data.rootpw.isCrypted = False
|
||
|
- return
|
||
|
-
|
||
|
- self.data.rootpw.password = cryptPassword(pw)
|
||
|
- self.data.rootpw.isCrypted = True
|
||
|
+ if pw:
|
||
|
+ self.data.rootpw.password = cryptPassword(pw)
|
||
|
+ self.data.rootpw.isCrypted = True
|
||
|
+ self.data.rootpw.lock = self._lock
|
||
|
|
||
|
self.pw.set_placeholder_text("")
|
||
|
self.confirm.set_placeholder_text("")
|
||
|
@@ -173,6 +184,8 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke, GUISpokeInputCheckHandler)
|
||
|
# If the password was set by kickstart, skip this check
|
||
|
if self._kickstarted and not self.policy.changesok:
|
||
|
return InputCheck.CHECK_OK
|
||
|
+ if self.lock.get_active():
|
||
|
+ return InputCheck.CHECK_OK
|
||
|
|
||
|
if not self.get_input(inputcheck.input_obj):
|
||
|
if inputcheck.input_obj == self.pw:
|
||
|
@@ -187,9 +200,17 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke, GUISpokeInputCheckHandler)
|
||
|
|
||
|
pw = self.pw.get_text()
|
||
|
confirm = self.confirm.get_text()
|
||
|
+ lock = self.lock.get_active()
|
||
|
+
|
||
|
+ if lock:
|
||
|
+ self._lock = True
|
||
|
+ self._password = None
|
||
|
+ self.clear_info()
|
||
|
+ self._error = False
|
||
|
+ result = InputCheck.CHECK_OK
|
||
|
|
||
|
# Skip the check if no password is required
|
||
|
- if (not pw and not confirm) and self._kickstarted:
|
||
|
+ elif (not pw and not confirm) and self._kickstarted:
|
||
|
result = InputCheck.CHECK_OK
|
||
|
elif confirm and (pw != confirm):
|
||
|
result = _(PASSWORD_CONFIRM_ERROR_GUI)
|
||
|
--
|
||
|
2.14.4
|
||
|
|