diff options
author | Khem Raj <raj.khem@gmail.com> | 2016-05-17 21:20:15 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-05-19 22:32:06 +0100 |
commit | 553fa35147adb996d515c3d27f62555d9c969cd8 (patch) | |
tree | 33500f18ae4ce5b17428dff3a9dc4c9d104b8469 | |
parent | c9867c4624b88fb19deacf70b7a3ff46d4fa4699 (diff) | |
download | poky-553fa35147adb996d515c3d27f62555d9c969cd8.tar.gz |
useradd.bbclass: Strip trailing ';' in cmd params
When there are more than 1 packages in a recipe requiring useradd
services, they are concatnated and a ';' is inserted just after
each of the users being added by the packages. A situation arises
in cases where this is controlled by PACKAGECONFIG then we add a
';' separator in the USERADD_PARAM value itself for each packagecofig
since we do not know which one will be picked, we end up in situation
where the final string returned from get_all_cmd_params() appears to be
a; ; b; c;
and then the logic which uses these cmds triggers with ';' as separator
but in this case it will fail after executing useradd 'a' because the next
cmd it will call will be just a whitespace
This is highlighted by the systemd patch to add more users as needed
by systemd 229 components.
(From OE-Core rev: e8d4356c38e3c2aacd6dc49231c73bcb7d597308)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/useradd.bbclass | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/meta/classes/useradd.bbclass b/meta/classes/useradd.bbclass index 8283bf301b..67dae880b7 100644 --- a/meta/classes/useradd.bbclass +++ b/meta/classes/useradd.bbclass | |||
@@ -54,14 +54,14 @@ if test "x`echo $GROUPADD_PARAM | tr -d '[:space:]'`" != "x"; then | |||
54 | echo "Running groupadd commands..." | 54 | echo "Running groupadd commands..." |
55 | # Invoke multiple instances of groupadd for parameter lists | 55 | # Invoke multiple instances of groupadd for parameter lists |
56 | # separated by ';' | 56 | # separated by ';' |
57 | opts=`echo "$GROUPADD_PARAM" | cut -d ';' -f 1` | 57 | opts=`echo "$GROUPADD_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'` |
58 | remaining=`echo "$GROUPADD_PARAM" | cut -d ';' -f 2-` | 58 | remaining=`echo "$GROUPADD_PARAM" | cut -d ';' -f 2-` |
59 | while test "x$opts" != "x"; do | 59 | while test "x$opts" != "x"; do |
60 | perform_groupadd "$SYSROOT" "$OPT $opts" | 60 | perform_groupadd "$SYSROOT" "$OPT $opts" |
61 | if test "x$opts" = "x$remaining"; then | 61 | if test "x$opts" = "x$remaining"; then |
62 | break | 62 | break |
63 | fi | 63 | fi |
64 | opts=`echo "$remaining" | cut -d ';' -f 1` | 64 | opts=`echo "$remaining" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'` |
65 | remaining=`echo "$remaining" | cut -d ';' -f 2-` | 65 | remaining=`echo "$remaining" | cut -d ';' -f 2-` |
66 | done | 66 | done |
67 | fi | 67 | fi |
@@ -70,14 +70,14 @@ if test "x`echo $USERADD_PARAM | tr -d '[:space:]'`" != "x"; then | |||
70 | echo "Running useradd commands..." | 70 | echo "Running useradd commands..." |
71 | # Invoke multiple instances of useradd for parameter lists | 71 | # Invoke multiple instances of useradd for parameter lists |
72 | # separated by ';' | 72 | # separated by ';' |
73 | opts=`echo "$USERADD_PARAM" | cut -d ';' -f 1` | 73 | opts=`echo "$USERADD_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'` |
74 | remaining=`echo "$USERADD_PARAM" | cut -d ';' -f 2-` | 74 | remaining=`echo "$USERADD_PARAM" | cut -d ';' -f 2-` |
75 | while test "x$opts" != "x"; do | 75 | while test "x$opts" != "x"; do |
76 | perform_useradd "$SYSROOT" "$OPT $opts" | 76 | perform_useradd "$SYSROOT" "$OPT $opts" |
77 | if test "x$opts" = "x$remaining"; then | 77 | if test "x$opts" = "x$remaining"; then |
78 | break | 78 | break |
79 | fi | 79 | fi |
80 | opts=`echo "$remaining" | cut -d ';' -f 1` | 80 | opts=`echo "$remaining" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'` |
81 | remaining=`echo "$remaining" | cut -d ';' -f 2-` | 81 | remaining=`echo "$remaining" | cut -d ';' -f 2-` |
82 | done | 82 | done |
83 | fi | 83 | fi |
@@ -86,14 +86,14 @@ if test "x`echo $GROUPMEMS_PARAM | tr -d '[:space:]'`" != "x"; then | |||
86 | echo "Running groupmems commands..." | 86 | echo "Running groupmems commands..." |
87 | # Invoke multiple instances of groupmems for parameter lists | 87 | # Invoke multiple instances of groupmems for parameter lists |
88 | # separated by ';' | 88 | # separated by ';' |
89 | opts=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 1` | 89 | opts=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'` |
90 | remaining=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 2-` | 90 | remaining=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 2-` |
91 | while test "x$opts" != "x"; do | 91 | while test "x$opts" != "x"; do |
92 | perform_groupmems "$SYSROOT" "$OPT $opts" | 92 | perform_groupmems "$SYSROOT" "$OPT $opts" |
93 | if test "x$opts" = "x$remaining"; then | 93 | if test "x$opts" = "x$remaining"; then |
94 | break | 94 | break |
95 | fi | 95 | fi |
96 | opts=`echo "$remaining" | cut -d ';' -f 1` | 96 | opts=`echo "$remaining" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'` |
97 | remaining=`echo "$remaining" | cut -d ';' -f 2-` | 97 | remaining=`echo "$remaining" | cut -d ';' -f 2-` |
98 | done | 98 | done |
99 | fi | 99 | fi |
@@ -203,7 +203,7 @@ def get_all_cmd_params(d, cmd_type): | |||
203 | for pkg in useradd_packages.split(): | 203 | for pkg in useradd_packages.split(): |
204 | param = d.getVar(param_type % pkg, True) | 204 | param = d.getVar(param_type % pkg, True) |
205 | if param: | 205 | if param: |
206 | params.append(param) | 206 | params.append(param.rstrip(" ;")) |
207 | 207 | ||
208 | return "; ".join(params) | 208 | return "; ".join(params) |
209 | 209 | ||