[OE-core] [PATCH] systemd: quote SYSTEMD_SERVICE in prerm and postinst
Damien Riegel
damien.riegel at savoirfairelinux.com
Fri Jun 22 15:45:20 UTC 2018
On Fri, Jun 22, 2018 at 08:32:14AM -0700, Christopher Larson wrote:
> Have you tried something like this? Might need to shift it to a def'd python function to
> ensure shlex gets imported, though.
>
> systemctl $OPTS disable ${@' '.join(shlex.quote(s) for s in d.getVar
> ('SYSTEMD_SERVICE').split()}
Cool, looks way cleaner. I'll give it a try and send a v2 with that if I
can make it work.
Thanks,
--
Damien
> On Thu, Jun 21, 2018 at 1:36 PM Damien Riegel <[1]damien.riegel at savoirfairelinux.com>
> wrote:
>
> Systemd mount configuration file must have a name that match the mount
> point directory they control. So for instance, if a mount file contains
>
> [Mount]
> ...
> Where=/mnt/my-data
>
> The file must be named `mnt-my\x2ddata.mount`, or systemd will refuse to
> honour it.
>
> If this config file contains an [Install] section, it will silently fail
> because the unit file is not quoted when systemctl is called. To fix
> that, quote `${SYSTEMD_SERVICE}` in prerm and postinst hooks.
>
> Signed-off-by: Damien Riegel <[2]damien.riegel at savoirfairelinux.com>
> ---
> meta/classes/systemd.bbclass | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/meta/classes/systemd.bbclass b/meta/classes/systemd.bbclass
> index 1b134322fb..589e73c855 100644
> --- a/meta/classes/systemd.bbclass
> +++ b/meta/classes/systemd.bbclass
> @@ -34,10 +34,10 @@ if type systemctl >/dev/null 2>/dev/null; then
> systemctl daemon-reload
> fi
>
> - systemctl $OPTS ${SYSTEMD_AUTO_ENABLE} ${SYSTEMD_SERVICE}
> + systemctl $OPTS ${SYSTEMD_AUTO_ENABLE} "${SYSTEMD_SERVICE}"
>
> if [ -z "$D" -a "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
> - systemctl --no-block restart ${SYSTEMD_SERVICE}
> + systemctl --no-block restart "${SYSTEMD_SERVICE}"
> fi
> fi
> }
> @@ -51,10 +51,10 @@ fi
>
> if type systemctl >/dev/null 2>/dev/null; then
> if [ -z "$D" ]; then
> - systemctl stop ${SYSTEMD_SERVICE}
> + systemctl stop "${SYSTEMD_SERVICE}"
> fi
>
> - systemctl $OPTS disable ${SYSTEMD_SERVICE}
> + systemctl $OPTS disable "${SYSTEMD_SERVICE}"
> fi
> }
>
> --
> 2.17.1
>
> --
> _______________________________________________
> Openembedded-core mailing list
> [3]Openembedded-core at lists.openembedded.org
> [4]http://lists.openembedded.org/mailman/listinfo/openembedded-core
>
>
>
> --
> Christopher Larson
> kergoth at gmail dot com
> Founder - BitBake, OpenEmbedded, OpenZaurus
> Senior Software Engineer, Mentor Graphics
>
> References:
>
> [1] mailto:damien.riegel at savoirfairelinux.com
> [2] mailto:damien.riegel at savoirfairelinux.com
> [3] mailto:Openembedded-core at lists.openembedded.org
> [4] http://lists.openembedded.org/mailman/listinfo/openembedded-core
More information about the Openembedded-core
mailing list