summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/useradd-staticids.bbclass16
1 files changed, 14 insertions, 2 deletions
diff --git a/meta/classes/useradd-staticids.bbclass b/meta/classes/useradd-staticids.bbclass
index 421a70a6ab..924d6eae60 100644
--- a/meta/classes/useradd-staticids.bbclass
+++ b/meta/classes/useradd-staticids.bbclass
@@ -2,6 +2,7 @@
2# we need a function to reformat the params based on a static file 2# we need a function to reformat the params based on a static file
3def update_useradd_static_config(d): 3def update_useradd_static_config(d):
4 import argparse 4 import argparse
5 import itertools
5 import re 6 import re
6 7
7 class myArgumentParser( argparse.ArgumentParser ): 8 class myArgumentParser( argparse.ArgumentParser ):
@@ -16,6 +17,11 @@ def update_useradd_static_config(d):
16 def error(self, message): 17 def error(self, message):
17 raise bb.build.FuncFailed(message) 18 raise bb.build.FuncFailed(message)
18 19
20 def list_extend(iterable, length, obj = None):
21 """Ensure that iterable is the specified length by extending with obj
22 and return it as a list"""
23 return list(itertools.islice(itertools.chain(iterable, itertools.repeat(obj)), length))
24
19 # We parse and rewrite the useradd components 25 # We parse and rewrite the useradd components
20 def rewrite_useradd(params): 26 def rewrite_useradd(params):
21 # The following comes from --help on useradd from shadow 27 # The following comes from --help on useradd from shadow
@@ -84,7 +90,10 @@ def update_useradd_static_config(d):
84 for line in f: 90 for line in f:
85 if line.startswith('#'): 91 if line.startswith('#'):
86 continue 92 continue
87 field = line.rstrip().split(":") 93 # Make sure there always are at least seven elements in
94 # the field list. This allows for leaving out trailing
95 # colons in the passwd file.
96 field = list_extend(line.rstrip().split(":"), 7)
88 if field[0] == uaargs.LOGIN: 97 if field[0] == uaargs.LOGIN:
89 if uaargs.uid and field[2] and (uaargs.uid != field[2]): 98 if uaargs.uid and field[2] and (uaargs.uid != field[2]):
90 bb.warn("%s: Changing username %s's uid from (%s) to (%s), verify configuration files!" % (d.getVar('PN', True), uaargs.LOGIN, uaargs.uid, field[2])) 99 bb.warn("%s: Changing username %s's uid from (%s) to (%s), verify configuration files!" % (d.getVar('PN', True), uaargs.LOGIN, uaargs.uid, field[2]))
@@ -220,7 +229,10 @@ def update_useradd_static_config(d):
220 for line in f: 229 for line in f:
221 if line.startswith('#'): 230 if line.startswith('#'):
222 continue 231 continue
223 field = line.rstrip().split(":") 232 # Make sure there always are at least four elements in
233 # the field list. This allows for leaving out trailing
234 # colons in the group file.
235 field = list_extend(line.rstrip().split(":"), 4)
224 if field[0] == gaargs.GROUP and field[2]: 236 if field[0] == gaargs.GROUP and field[2]:
225 if gaargs.gid and (gaargs.gid != field[2]): 237 if gaargs.gid and (gaargs.gid != field[2]):
226 bb.warn("%s: Changing groupname %s's gid from (%s) to (%s), verify configuration files!" % (d.getVar('PN', True), gaargs.GROUP, gaargs.gid, field[2])) 238 bb.warn("%s: Changing groupname %s's gid from (%s) to (%s), verify configuration files!" % (d.getVar('PN', True), gaargs.GROUP, gaargs.gid, field[2]))