diff options
author | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2015-12-19 00:53:47 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-01-18 11:47:06 +0000 |
commit | c03ea8dddc491770dbbc0e32a604924dfeb950bd (patch) | |
tree | 685661984c585ab99d4ff4455db951c3d1f1e9a9 /meta/classes | |
parent | af8b00556e09253dac3cf75934e7719268abe198 (diff) | |
download | poky-c03ea8dddc491770dbbc0e32a604924dfeb950bd.tar.gz |
useradd-staticids.bbclass: Treat mutually exclusive options as such
The useradd options --create-home/--no-create-home and
--user-group/--no-user-group are mutually exclusive and should be
treated as such.
(From OE-Core rev: 908eca7fb4af8a60026f53e2bb2cf1d5daf089ab)
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/useradd-staticids.bbclass | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/meta/classes/useradd-staticids.bbclass b/meta/classes/useradd-staticids.bbclass index 924d6eae60..9d59aca45c 100644 --- a/meta/classes/useradd-staticids.bbclass +++ b/meta/classes/useradd-staticids.bbclass | |||
@@ -37,21 +37,21 @@ def update_useradd_static_config(d): | |||
37 | parser.add_argument("-k", "--skel", metavar="SKEL_DIR", help="use this alternative skeleton directory") | 37 | parser.add_argument("-k", "--skel", metavar="SKEL_DIR", help="use this alternative skeleton directory") |
38 | parser.add_argument("-K", "--key", metavar="KEY=VALUE", help="override /etc/login.defs defaults") | 38 | parser.add_argument("-K", "--key", metavar="KEY=VALUE", help="override /etc/login.defs defaults") |
39 | parser.add_argument("-l", "--no-log-init", help="do not add the user to the lastlog and faillog databases", action="store_true") | 39 | parser.add_argument("-l", "--no-log-init", help="do not add the user to the lastlog and faillog databases", action="store_true") |
40 | parser.add_argument("-m", "--create-home", help="create the user's home directory", action="store_true") | 40 | parser.add_argument("-m", "--create-home", help="create the user's home directory", action="store_const", const=True) |
41 | parser.add_argument("-M", "--no-create-home", help="do not create the user's home directory", action="store_true") | 41 | parser.add_argument("-M", "--no-create-home", dest="create_home", help="do not create the user's home directory", action="store_const", const=False) |
42 | parser.add_argument("-N", "--no-user-group", help="do not create a group with the same name as the user", action="store_true") | 42 | parser.add_argument("-N", "--no-user-group", dest="user_group", help="do not create a group with the same name as the user", action="store_const", const=False) |
43 | parser.add_argument("-o", "--non-unique", help="allow to create users with duplicate (non-unique UID)", action="store_true") | 43 | parser.add_argument("-o", "--non-unique", help="allow to create users with duplicate (non-unique UID)", action="store_true") |
44 | parser.add_argument("-p", "--password", metavar="PASSWORD", help="encrypted password of the new account") | 44 | parser.add_argument("-p", "--password", metavar="PASSWORD", help="encrypted password of the new account") |
45 | parser.add_argument("-R", "--root", metavar="CHROOT_DIR", help="directory to chroot into") | 45 | parser.add_argument("-R", "--root", metavar="CHROOT_DIR", help="directory to chroot into") |
46 | parser.add_argument("-r", "--system", help="create a system account", action="store_true") | 46 | parser.add_argument("-r", "--system", help="create a system account", action="store_true") |
47 | parser.add_argument("-s", "--shell", metavar="SHELL", help="login shell of the new account") | 47 | parser.add_argument("-s", "--shell", metavar="SHELL", help="login shell of the new account") |
48 | parser.add_argument("-u", "--uid", metavar="UID", help="user ID of the new account") | 48 | parser.add_argument("-u", "--uid", metavar="UID", help="user ID of the new account") |
49 | parser.add_argument("-U", "--user-group", help="create a group with the same name as the user", action="store_true") | 49 | parser.add_argument("-U", "--user-group", help="create a group with the same name as the user", action="store_const", const=True) |
50 | parser.add_argument("LOGIN", help="Login name of the new user") | 50 | parser.add_argument("LOGIN", help="Login name of the new user") |
51 | 51 | ||
52 | # Return a list of configuration files based on either the default | 52 | # Return a list of configuration files based on either the default |
53 | # files/passwd or the contents of USERADD_UID_TABLES | 53 | # files/passwd or the contents of USERADD_UID_TABLES |
54 | # paths are resulved via BBPATH | 54 | # paths are resolved via BBPATH |
55 | def get_passwd_list(d): | 55 | def get_passwd_list(d): |
56 | str = "" | 56 | str = "" |
57 | bbpath = d.getVar('BBPATH', True) | 57 | bbpath = d.getVar('BBPATH', True) |
@@ -106,7 +106,8 @@ def update_useradd_static_config(d): | |||
106 | # So if the implicit username-group creation is on, then the implicit groupname (LOGIN) | 106 | # So if the implicit username-group creation is on, then the implicit groupname (LOGIN) |
107 | # is used, and we disable the user_group option. | 107 | # is used, and we disable the user_group option. |
108 | # | 108 | # |
109 | uaargs.groupname = [uaargs.gid, uaargs.LOGIN][not uaargs.gid or uaargs.user_group] | 109 | user_group = uaargs.user_group is None or uaargs.user_group is True |
110 | uaargs.groupname = [uaargs.gid, uaargs.LOGIN][not uaargs.gid or user_group] | ||
110 | uaargs.groupid = [uaargs.gid, uaargs.groupname][not uaargs.gid] | 111 | uaargs.groupid = [uaargs.gid, uaargs.groupname][not uaargs.gid] |
111 | uaargs.groupid = [field[3], uaargs.groupid][not field[3]] | 112 | uaargs.groupid = [field[3], uaargs.groupid][not field[3]] |
112 | 113 | ||
@@ -120,7 +121,7 @@ def update_useradd_static_config(d): | |||
120 | # We don't have a number, so we have to add a name | 121 | # We don't have a number, so we have to add a name |
121 | bb.debug(1, "Adding group %s!" % (uaargs.groupname)) | 122 | bb.debug(1, "Adding group %s!" % (uaargs.groupname)) |
122 | uaargs.gid = uaargs.groupid | 123 | uaargs.gid = uaargs.groupid |
123 | uaargs.user_group = False | 124 | uaargs.user_group = None |
124 | groupadd = d.getVar("GROUPADD_PARAM_%s" % pkg, True) | 125 | groupadd = d.getVar("GROUPADD_PARAM_%s" % pkg, True) |
125 | newgroup = "%s %s" % (['', ' --system'][uaargs.system], uaargs.groupname) | 126 | newgroup = "%s %s" % (['', ' --system'][uaargs.system], uaargs.groupname) |
126 | if groupadd: | 127 | if groupadd: |
@@ -131,7 +132,7 @@ def update_useradd_static_config(d): | |||
131 | # We have a group name and a group number to assign it to | 132 | # We have a group name and a group number to assign it to |
132 | bb.debug(1, "Adding group %s gid (%s)!" % (uaargs.groupname, uaargs.groupid)) | 133 | bb.debug(1, "Adding group %s gid (%s)!" % (uaargs.groupname, uaargs.groupid)) |
133 | uaargs.gid = uaargs.groupid | 134 | uaargs.gid = uaargs.groupid |
134 | uaargs.user_group = False | 135 | uaargs.user_group = None |
135 | groupadd = d.getVar("GROUPADD_PARAM_%s" % pkg, True) | 136 | groupadd = d.getVar("GROUPADD_PARAM_%s" % pkg, True) |
136 | newgroup = "-g %s %s" % (uaargs.gid, uaargs.groupname) | 137 | newgroup = "-g %s %s" % (uaargs.gid, uaargs.groupname) |
137 | if groupadd: | 138 | if groupadd: |
@@ -161,16 +162,16 @@ def update_useradd_static_config(d): | |||
161 | newparam += ['', ' --skel %s' % uaargs.skel][uaargs.skel != None] | 162 | newparam += ['', ' --skel %s' % uaargs.skel][uaargs.skel != None] |
162 | newparam += ['', ' --key %s' % uaargs.key][uaargs.key != None] | 163 | newparam += ['', ' --key %s' % uaargs.key][uaargs.key != None] |
163 | newparam += ['', ' --no-log-init'][uaargs.no_log_init] | 164 | newparam += ['', ' --no-log-init'][uaargs.no_log_init] |
164 | newparam += ['', ' --create-home'][uaargs.create_home] | 165 | newparam += ['', ' --create-home'][uaargs.create_home is True] |
165 | newparam += ['', ' --no-create-home'][uaargs.no_create_home] | 166 | newparam += ['', ' --no-create-home'][uaargs.create_home is False] |
166 | newparam += ['', ' --no-user-group'][uaargs.no_user_group] | 167 | newparam += ['', ' --no-user-group'][uaargs.user_group is False] |
167 | newparam += ['', ' --non-unique'][uaargs.non_unique] | 168 | newparam += ['', ' --non-unique'][uaargs.non_unique] |
168 | newparam += ['', ' --password %s' % uaargs.password][uaargs.password != None] | 169 | newparam += ['', ' --password %s' % uaargs.password][uaargs.password != None] |
169 | newparam += ['', ' --root %s' % uaargs.root][uaargs.root != None] | 170 | newparam += ['', ' --root %s' % uaargs.root][uaargs.root != None] |
170 | newparam += ['', ' --system'][uaargs.system] | 171 | newparam += ['', ' --system'][uaargs.system] |
171 | newparam += ['', ' --shell %s' % uaargs.shell][uaargs.shell != None] | 172 | newparam += ['', ' --shell %s' % uaargs.shell][uaargs.shell != None] |
172 | newparam += ['', ' --uid %s' % uaargs.uid][uaargs.uid != None] | 173 | newparam += ['', ' --uid %s' % uaargs.uid][uaargs.uid != None] |
173 | newparam += ['', ' --user-group'][uaargs.user_group] | 174 | newparam += ['', ' --user-group'][uaargs.user_group is True] |
174 | newparam += ' %s' % uaargs.LOGIN | 175 | newparam += ' %s' % uaargs.LOGIN |
175 | 176 | ||
176 | newparams.append(newparam) | 177 | newparams.append(newparam) |
@@ -192,7 +193,7 @@ def update_useradd_static_config(d): | |||
192 | 193 | ||
193 | # Return a list of configuration files based on either the default | 194 | # Return a list of configuration files based on either the default |
194 | # files/group or the contents of USERADD_GID_TABLES | 195 | # files/group or the contents of USERADD_GID_TABLES |
195 | # paths are resulved via BBPATH | 196 | # paths are resolved via BBPATH |
196 | def get_group_list(d): | 197 | def get_group_list(d): |
197 | str = "" | 198 | str = "" |
198 | bbpath = d.getVar('BBPATH', True) | 199 | bbpath = d.getVar('BBPATH', True) |