[PATCH] Encrypt normal user passwords when doing text install. (#977732)
Samantha N. Bueno
sbueno+anaconda at redhat.com
Fri Sep 20 18:44:11 UTC 2013
There isn't currently a bug against it, but I'd really like to see this
go into rhel7-branch as well. Thoughts?
====
More than simply mirroring graphical behavior, passwords shouldn't
be stored plaintext in the first place.
---
pyanaconda/ui/tui/spokes/__init__.py | 6 ++++--
pyanaconda/ui/tui/spokes/user.py | 16 ++++++++++++++--
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/pyanaconda/ui/tui/spokes/__init__.py b/pyanaconda/ui/tui/spokes/__init__.py
index 087199b..773ea67 100644
--- a/pyanaconda/ui/tui/spokes/__init__.py
+++ b/pyanaconda/ui/tui/spokes/__init__.py
@@ -226,8 +226,10 @@ class EditTUISpoke(NormalTUISpoke):
def _prep_password(i, entry):
number = tui.TextWidget("%2d)" % i)
title = tui.TextWidget(_(entry.title))
- value = getdeepattr(self.args, entry.attribute)
- value = tui.TextWidget("".join(["*"] * len(value)))
+ value = ""
+ if len(getdeepattr(self.args, entry.attribute)) > 0:
+ value = _("Password set.")
+ value = tui.TextWidget(value)
return tui.ColumnWidget([(3, [number]), (None, [title, value])], 1)
diff --git a/pyanaconda/ui/tui/spokes/user.py b/pyanaconda/ui/tui/spokes/user.py
index 6185f80..2b0d3f2 100644
--- a/pyanaconda/ui/tui/spokes/user.py
+++ b/pyanaconda/ui/tui/spokes/user.py
@@ -1,4 +1,4 @@
-# Root password text spoke
+# User creation text spoke
#
# Copyright (C) 2013 Red Hat, Inc.
#
@@ -22,7 +22,7 @@
from pyanaconda.ui.tui.spokes import EditTUISpoke
from pyanaconda.ui.tui.spokes import EditTUISpokeEntry as Entry
from pyanaconda.ui.common import FirstbootSpokeMixIn
-from pyanaconda.users import guess_username
+from pyanaconda.users import guess_username, cryptPassword
from pyanaconda.i18n import _
from pykickstart.constants import FIRSTBOOT_RECONFIG
from pyanaconda.constants import ANACONDA_ENVIRON, FIRSTBOOT_ENVIRON
@@ -123,3 +123,15 @@ class UserSpoke(FirstbootSpokeMixIn, EditTUISpoke):
self.data.user.userList.append(self.args)
elif (not self.args._create) and (self.args in self.data.user.userList):
self.data.user.userList.remove(self.args)
+
+ # encrypt and store password only if user entered anything; this should
+ # preserve passwords set via kickstart
+ if self.args._use_password and len(self.args.password) > 0:
+ self.args.password = cryptPassword(self.args.password)
+ self.args.isCrypted = True
+ self.args.password_kickstarted = False
+ # clear pw when user unselects to use pw
+ else:
+ self.args.password = ""
+ self.args.isCrypted = False
+ self.args.password_kickstarted = False
--
1.7.11.7
More information about the anaconda-patches
mailing list