systemd: fix useradd parameter generation
PATCH 1/1 systemd: fix useradd parameter generation
Constructing the USERADD_PARAM_${PN} value with += (as done before) resulted in having a whitespace added for each entry not having its PACKAGECONFIG parameter activated.
This is not only a cosmetical issue. The useradd class concatenates all useradd commands from all subpackages of a package by doing a ";".join(). When having a useradd command that ends with ";" and some extra spaces, concatenation will result in an empty useradd argument
("commandA; ;commandB"). The useradd command will be called with this
and make the Yocto build break by returning an error code.
Fortunately, there is no problem when having a "commandA;;commandB" in the useradd string, this will be ignored. Thus using "_append" instead of "+=" is sufficient here.
--- meta/recipes-core/systemd/systemd_230.bb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
meta/recipes-core/systemd/systemd_230.bb +7 -7
@@ -298,13 +298,13 @@ SYSTEMD_PACKAGES = "${@bb.utils.contains('PACKAGECONFIG', 'binfmt', '${PN}-binfm SYSTEMD_SERVICE_${PN}-binfmt = "systemd-binfmt.service" USERADD_PACKAGES = "${PN} ${PN}-extra-utils" -USERADD_PARAM_${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'microhttpd', '--system -d / -M --shell /bin/nologin systemd-journal-gateway;', '', d)}" -USERADD_PARAM_${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'microhttpd', '--system -d / -M --shell /bin/nologin systemd-journal-remote;', '', d)}" -USERADD_PARAM_${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'journal-upload', '--system -d / -M --shell /bin/nologin systemd-journal-upload;', '', d)}" -USERADD_PARAM_${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'timesyncd', '--system -d / -M --shell /bin/nologin systemd-timesync;', '', d)}" -USERADD_PARAM_${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'networkd', '--system -d / -M --shell /bin/nologin systemd-network;', '', d)}" -USERADD_PARAM_${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'coredump', '--system -d / -M --shell /bin/nologin systemd-coredump;', '', d)}" -USERADD_PARAM_${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'resolved', '--system -d / -M --shell /bin/nologin systemd-resolve;', '', d)}" +USERADD_PARAM_${PN}_append = "${@bb.utils.contains('PACKAGECONFIG', 'microhttpd', '--system -d / -M --shell /bin/nologin systemd-journal-gateway;', '', d)}" +USERADD_PARAM_${PN}_append = "${@bb.utils.contains('PACKAGECONFIG', 'microhttpd', '--system -d / -M --shell /bin/nologin systemd-journal-remote;', '', d)}" +USERADD_PARAM_${PN}_append = "${@bb.utils.contains('PACKAGECONFIG', 'journal-upload', '--system -d / -M --shell /bin/nologin systemd-journal-upload;', '', d)}" +USERADD_PARAM_${PN}_append = "${@bb.utils.contains('PACKAGECONFIG', 'timesyncd', '--system -d / -M --shell /bin/nologin systemd-timesync;', '', d)}" +USERADD_PARAM_${PN}_append = "${@bb.utils.contains('PACKAGECONFIG', 'networkd', '--system -d / -M --shell /bin/nologin systemd-network;', '', d)}" +USERADD_PARAM_${PN}_append = "${@bb.utils.contains('PACKAGECONFIG', 'coredump', '--system -d / -M --shell /bin/nologin systemd-coredump;', '', d)}" +USERADD_PARAM_${PN}_append = "${@bb.utils.contains('PACKAGECONFIG', 'resolved', '--system -d / -M --shell /bin/nologin systemd-resolve;', '', d)}" GROUPADD_PARAM_${PN} = "-r lock; -r systemd-journal" USERADD_PARAM_${PN}-extra-utils += "--system -d / -M --shell /bin/nologin systemd-bus-proxy;"
Signature · 1 line
2.8.1
Quoted 11 lines · Enrico Jorns
Constructing the USERADD_PARAM_${PN} value with += (as done before) resulted in having a whitespace added for each entry not having its PACKAGECONFIG parameter activated.
This is not only a cosmetical issue. The useradd class concatenates all useradd commands from all subpackages of a package by doing a ";".join(). When having a useradd command that ends with ";" and some extra spaces, concatenation will result in an empty useradd argument
("commandA; ;commandB"). The useradd command will be called with this
and make the Yocto build break by returning an error code.
Quoted 6 lines
Fortunately, there is no problem when having a "commandA;;commandB" in the useradd string, this will be ignored. Thus using "
_append" instead of "+=" is sufficient here.Signed-off-by Enrico Jorns <[email protected]>
Use .=, not _append. _append is a postponed operation, .= is immediate like += is.
Also, why not make useradd.bbclass sanitize the input / ignore empty entries?
Signature · 5 lines
Christopher Larson clarson at kergoth dot com Founder - BitBake, OpenEmbedded, OpenZaurus Maintainer - Tslib Senior Software Engineer, Mentor Graphics
Anders Darander
NAKQuoted 11 lines · Enrico Jorns
Constructing the USERADD_PARAM_${PN} value with += (as done before) resulted in having a whitespace added for each entry not having its PACKAGECONFIG parameter activated.
This is not only a cosmetical issue. The useradd class concatenates all useradd commands from all subpackages of a package by doing a ";".join(). When having a useradd command that ends with ";" and some extra spaces, concatenation will result in an empty useradd argument
("commandA; ;commandB"). The useradd command will be called with this
and make the Yocto build break by returning an error code.
Quoted 3 lines
Fortunately, there is no problem when having a "commandA;;commandB" in the useradd string, this will be ignored. Thus using "
_append" instead of "+=" is sufficient here.
NAK
Fix useradd.bbclass instead. Otherwise, the same issue will happen with other recipes. Having a single variable, that you're not allowed to use the normal way to add to, would be more confusing. Personally, I would find it hard to rember that I need to use .= for USERADD_PARAM...
Cheers,
Anders
Signature · 2 lines
Anders Darander, Senior System Architect ChargeStorm AB / eStorm AB
Quoted 16 lines · Anders Darander
Quoted 11 lines · Enrico Jorns
Constructing the USERADD_PARAM_${PN} value with += (as done before) resulted in having a whitespace added for each entry not having its PACKAGECONFIG parameter activated.
This is not only a cosmetical issue. The useradd class concatenates all useradd commands from all subpackages of a package by doing a ";".join(). When having a useradd command that ends with ";" and some extra spaces, concatenation will result in an empty useradd argument
("commandA; ;commandB"). The useradd command will be called with this
and make the Yocto build break by returning an error code.Quoted 3 lines
Fortunately, there is no problem when having a "commandA;;commandB" in the useradd string, this will be ignored. Thus using "
_append" instead of "+=" is sufficient here.
Quoted 6 lines
NAK
Fix useradd.bbclass instead. Otherwise, the same issue will happen with other recipes. Having a single variable, that you're not allowed to use the normal way to add to, would be more confusing. Personally, I would find it hard to rember that I need to use .= for
USERADD_PARAM...
Yes, I did not have .= in mind when creating this solution, but this would be the better approach. Nevertheless, I also prefer a more general solution, but was not sure about how it could look like. Maybe I've found one now.
So, forget about this patch, I will post a useradd class patch in a separate thread instead.
Regards, Enrico
Signature · 4 lines
Pengutronix e.K. | Enrico Jörns | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-5080 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Quoted 25 lines · Enrico Joerns
Quoted 17 lines · Anders Darander
Quoted 11 lines · Enrico Jorns
Constructing the USERADD_PARAM_${PN} value with += (as done before) resulted in having a whitespace added for each entry not having its PACKAGECONFIG parameter activated.
This is not only a cosmetical issue. The useradd class concatenates all useradd commands from all subpackages of a package by doing a ";".join(). When having a useradd command that ends with ";" and some extra spaces, concatenation will result in an empty useradd argument
("commandA; ;commandB"). The useradd command will be called with this
and make the Yocto build break by returning an error code.Quoted 4 lines
Fortunately, there is no problem when having a "commandA;;commandB" in the useradd string, this will be ignored. Thus using "
_append" instead of
"+=" is sufficient here.Quoted 6 lines
NAK
Fix useradd.bbclass instead. Otherwise, the same issue will happen with other recipes. Having a single variable, that you're not allowed to use the normal way to add to, would be more confusing. Personally, I would find it hard to rember that I need to use .= for
USERADD_PARAM...
Quoted 7 lines
Yes, I did not have .= in mind when creating this solution, but this would be the better approach.
Nevertheless, I also prefer a more general solution, but was not sure about how it could look like. Maybe I've found one now.So, forget about this patch, I will post a useradd class patch in a separate thread instead.
Just saw yocto patch 553fa35147adb996d515c3d27f62555d9c969cd8 (oe-core: e8d4356c38e3c2aacd6dc49231c73bcb7d597308) seems to address and fix this problem. Did not find that before... :-|
Signature · 4 lines
Pengutronix e.K. | Enrico Jörns | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-5080 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |