1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
From b93bf80525624fd7038b370f35ace90a3b3bdb1b Mon Sep 17 00:00:00 2001
From: Hongxu Jia <hongxu.jia@windriver.com>
Date: Tue, 24 Jul 2018 15:05:25 +0800
Subject: [PATCH] support user account creation
- Do not support user accout advanced setting
- Add main for debugging test
Upstream-Status: Inappropriate [oe specific]
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
pyanaconda/ui/gui/spokes/user.py | 7 +------
pyanaconda/users.py | 15 +++++++++++++++
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/user.py b/pyanaconda/ui/gui/spokes/user.py
index 2398810..9d7de2a 100644
--- a/pyanaconda/ui/gui/spokes/user.py
+++ b/pyanaconda/ui/gui/spokes/user.py
@@ -267,6 +267,7 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke, GUISpokeInputCheckHandler):
self._password_required_checkbox = self.builder.get_object("password_required_checkbox")
# advanced user configration dialog button
self._advanced_button = self.builder.get_object("advanced_button")
+ self._advanced_button.set_sensitive(False)
# password checking status bar & label
self._password_bar = self.builder.get_object("password_bar")
self._password_label = self.builder.get_object("password_label")
@@ -500,12 +501,6 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke, GUISpokeInputCheckHandler):
"""Called by Gtk on all username changes."""
new_username = editable.get_text()
- # Disable the advanced user dialog button when no username is set
- if editable.get_text():
- self._advanced_button.set_sensitive(True)
- else:
- self._advanced_button.set_sensitive(False)
-
# update the username in checker
self.checker.username = new_username
diff --git a/pyanaconda/users.py b/pyanaconda/users.py
index 3db06dd..edf3469 100644
--- a/pyanaconda/users.py
+++ b/pyanaconda/users.py
@@ -28,6 +28,8 @@ from pyanaconda.errors import errorHandler, PasswordCryptError, ERROR_RAISE
from pyanaconda.core.regexes import GROUPLIST_FANCY_PARSE, NAME_VALID, PORTABLE_FS_CHARS, GROUPLIST_SIMPLE_VALID
import crypt
from pyanaconda.core.i18n import _
+from pyanaconda.core import constants
+
import re
from pyanaconda.anaconda_loggers import get_module_logger
@@ -200,6 +202,7 @@ class Users(object):
homedir will be interpreted relative to this. Defaults
to util.getSysroot().
"""
+ log.info("kwargs %s" % kwargs)
root = kwargs.get("root", util.getSysroot())
if self._getgrnam(group_name, root):
@@ -431,3 +434,15 @@ class Users(object):
if not authfile_existed:
os.chown(authfile, int(uid), int(gid))
util.execWithRedirect("restorecon", ["-r", sshdir])
+
+# For testing
+if __name__ == "__main__":
+ from pyanaconda import anaconda_logging
+ anaconda_logging.init()
+ anaconda_logging.logger.setupVirtio(constants.VIRTIO_PORT)
+
+ from pyanaconda.anaconda_loggers import get_anaconda_root_logger
+ log = get_anaconda_root_logger()
+
+ users = Users()
+ users.createUser("test", password="123456", shell="/bin/bash", groups=["wheel"])
--
2.7.4
|