summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/systemd/systemd-systemctl/systemctl
AgeCommit message (Collapse)Author
2024-02-21systemd-systemctl: fix dead loop when multi services enable each otherXiangyu Chen
libvirt has added a feature that all sockets for a service being enabled when a single one of them is enabled since 9.9.x[1], it likes serviceA enable serviceB, serviceB enable serviceA, that cause our systemctl script trap into a dead loop in postinstall stage, the error message as below: Traceback (most recent call last): File "/usr/lib/python3.8/pathlib.py", line 722, in __str__ return self._str AttributeError: _str During handling of the above exception, another exception occurred: Traceback (most recent call last): File "recipe-sysroot-native/usr/bin/systemctl", line 255, in enable SystemdUnit(self.root, also).enable(unit) File "recipe-sysroot-native/usr/bin/systemctl", line 255, in enable SystemdUnit(self.root, also).enable(unit) File "recipe-sysroot-native/usr/bin/systemctl", line 255, in enable SystemdUnit(self.root, also).enable(unit) [Previous line repeated 988 more times] ...... RecursionError: maximum recursion depth exceeded while calling a Python object Here using an array to record the services which has been enabled to filter the duplicates. Ref: [1] https://github.com/libvirt/libvirt/commit/826931e95a38af8322f8ad069dc89117c6404a00 Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-07-10systemd-systemctl: fix errors in instance name expansionYuta Hayama
If the instance name indicated by %i begins with a number, the meaning of the replacement string "\\1{}".format(instance) is ambiguous. To indicate group number 1 regardless of the instance name, use "\g<1>". Signed-off-by: Yuta Hayama <hayama@lineo.co.jp> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-06-15systemd-systemctl: support instance expansion in WantedByIan Ray
Refactor _process_deps to expand systemd instance specifier "%i" to the template instance. This change expands on prior commit e510222b57 ("systemd-systemctl: fix instance template WantedBy symlink construction") by substituting every "%i" pattern-match with the instance name. The regexp handles the following cases: * svc-wants@%i.service * sys-subsystem-net-devices-%i.device Signed-off-by: Ian Ray <ian.ray@ge.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2023-05-05systemd-systemctl: fix instance template WantedBy symlink constructionMartin Siegumfeldt
Fix issue of the below instance template systemd service dependency [Install] WantedBy=svc-wants@%i.service creating the symlink (instance "a" example) /etc/systemd/system/svc-wants@%i.service.wants/svc-wanted-by@a.service which should be /etc/systemd/system/svc-wants@a.service.wants/svc-wanted-by@a.service as implemented by this change. The functionality appears regressed just after "thud" baseline when the logic was refactored from shell script into python (commit 925e30cb104ece7bfa48b78144e758a46dc9ec3f) Signed-off-by: Martin Siegumfeldt <mns@gomspace.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-03-16Revert "systemd-systemctl: Create machine-id with "uninitialized" text in it"Chen Qi
This reverts commit 33d9b3a8ed186c2d212acb83f715367912010e7f. The reverted patch was forcing systemd to do preset-all at boot time (first boot) in a function that simuilates 'preset-all' at rootfs time. This is not right. To force a first boot, just do not run this function, as said in the comment: """ # If we populate the systemd links we also create /etc/machine-id, which # allows systemd to boot with the filesystem read-only before generating # a real value and then committing it back. # # For the stateless configuration, where /etc is generated at runtime # (for example on a tmpfs), this script shouldn't run at all and we # allow systemd to completely populate /etc. """ For example, removing 'systemd_preset_all;' from IMAGE_PREPROCESS_COMMAND in some distro conf file will achieve the same effect of the original patch. Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-02-27systemd-systemctl: Create machine-id with "uninitialized" text in itMarek Vasut
Instead of creating empty /etc/machine-id file using touch, write text "uninitialized" into it. Systemd requires "uninitialized" in the /etc/machine-id file to trigger systemd-firstboot . Signed-off-by: Marek Vasut <marex@denx.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-09-28systemd-systemctl: Fix WantedBy processingBob Henz
An empty string assignment to WantedBy should clear all prior WantedBy settings. This matches behavior of the current systemd implementation. Signed-off-by: Bob Henz <robert_henz@jabil.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-06-17systemd: systemd-systemctl: Support instance conf files during enableNick Potenski
Add ability to parse instance-specific conf files when enabling an instance of a templated unit during postinstall. Signed-off-by: Nick Potenski <nick.potenski@garmin.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-09-04systemd: Add homed PACKAGECONFIGKristian Klausen
If systemd is built with fdisk support[1] and the openssl and cryptsetup PACKAGECONFIG are enabled, systemd-homed[1] is automatically enabled. The org.freedesktop.home1.conf file was forgotten, so this commit adds the file and make enabling homed a explicit choice. systemd-homed.service and systemd-homed-activate.service have a Also= on each other, so "systemctl" has been fixed to handle the circular dependency. userdb isn't strictly speaking needed for homed but "systemctl" can't handle the missing unit file and upstream recommend enabling both[3]. [1] Automatically enabled if the fdisk dependency is installed which it is as util-linux is pulled in by systemd [2] https://www.freedesktop.org/software/systemd/man/systemd-homed.service.html [3] https://github.com/systemd/systemd/commit/871dc8d644eef7542a5330f84c25b1db2617317c Signed-off-by: Kristian Klausen <kristian@klausen.dk> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-06-01systemctl: Stop tracebacks use formated error messagesArmin Kuster
When systemctl fail it would throw an exception and dump a traceback. Lets use a more controlled workflow. [Yocto #14395] Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-12-06systemd-systemctl-native: capable to call without argumentKai Kang
In systemd.bbclass, it will replace criterion command 'type systemctl' with 'systemctl' without any argument to judge whether command systemctl is available. The change is to fix install/remove package error in container when command systemctl exists but not callable. Make native systemctl wrapper prints help mesages if called without any argument to follow the update. Signed-off-by: Kai Kang <kai.kang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-12-16systemd-systemctl: Fix handling of aliased targetsSlavic Brutalik
The script scans for services, parses them and makes sure those targets are still there. The exists file check fails if the target is an alias, such as default.target so add an additional test. [YOCTO #13685] Signed-off-by: Werner Grift <sky.captin@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-09-19systemd-systemctl-native: don't care about line endingsRoss Burton
It's possible for a service file to accidentally contain mixed line endings, but the string cleanup code was assuming Unix endings. [ YOCTO #13535 ] Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-07-26systemd: Add partial support of drop-in configuration files to ↵Frederic Ouellet
systemd-systemctl-native Support for serive-name.service.d/ folders containing .conf files It don't support all the partial folder names See https://www.freedesktop.org/software/systemd/man/systemd.unit.html Signed-off-by: Frederic Ouellet <fredericouellet@eaton.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-09systemd-systemctl: Restore support for enable commandAlex Kiernan
Refactor so that SystemdUnit is its own class, then add support for the enable command. This restores the ability of systemd.bbclass to create instances using syntax such as: SYSTEMD_SERVICE_${PN} = "serial-getty@ttyAMA0.service" Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-09systemd: Default to non-stateless imagesAlex Kiernan
When creating images, for anything other than the explicitly stateless case, touch /etc/machine-id so that the images can be booted without an initramfs and with `ro` set on the kernel command line, otherwise system refuses to start: [ 7.222134] systemd[1]: No hostname configured. [ 7.227266] systemd[1]: Set hostname to <localhost>. [ 7.232622] systemd[1]: System cannot boot: Missing /etc/machine-id and /etc is mounted read-only. [ 7.241750] systemd[1]: Booting up is supported only when: [ 7.247362] systemd[1]: 1) /etc/machine-id exists and is populated. [ 7.253752] systemd[1]: 2) /etc/machine-id exists and is empty. [ 7.259757] systemd[1]: 3) /etc/machine-id is missing and /etc is writable. If IMAGE_FEATURES includes `stateless-rootfs` then systemctl-native is not run on the image leaving the image for population at runtime by systemd. Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-02systemctl-native: Rewrite in Python supporting preset-all and maskAlex Kiernan
Rewrite systemctl-native in Python so that extending/testing it is easier. Now that the systemd class sets up service presets instead of actively enabling services, the 'enable' and 'disable' subcommands for systemctl are not actually used anywhere. As such, we can remove these to make sure that nobody inadvertently introduces new uses of them. This implementation covers `preset-all` and `mask` which are the only options used in the current code, but should be readily extensible to other commands. We use `preset-all` at image construction time to populate the symlinks used by systemd. Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-11-13systemd-systemctl-native: handle Install wildcardsBrad Bishop
Handle the %i wildcard appearing in a dependency in the Install section of a template unit, e.g. $ cat foo@.service [Install] WantedBy=bar@%i.target Using the real systemctl something like: $ systemctl enable foo@baz.service will create a symlink in /etc/systemd/system/bar@baz.target.wants. Detect wildcards in templates and make the appropriate substitution. Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-11-08systemctl-native: add target.wants to target regexMartin Kelly
The regex for acceptable systemd WantedBy/RequiredBy targets does not include target.wants, so a line like this: WantedBy=multi-user.target.wants gets silently ignored, even though it works fine on a real system. Signed-off-by: Martin Kelly <mkelly@xevo.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-04-08systemd-systemctl-native: fix unit detectionRoss Burton
The regexs were too strict and didn't allow for trailing whitespace. [ YOCTO #9337 ] Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-02-28systemctl: handle RequiredBy dependenciesTomas Novotny
Install section of a systemd service may contain RequiredBy dependency, which is not handled currently. This means that symlinks to enable the service are not created and the service may not be started. Also fix debug output (all dependencies were printed instead of the one which was enabled or disabled). Signed-off-by: Tomas Novotny <tomas@novotny.cz> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-01-29systemd: fix systemctl enable script for template unitsEnrico Jorns
The systemctl script supports enabling template units by evaluating "DefaultInstance" parameter. Unfortunately, due to the sed replacement mechanism, all escaping used in the DefaultInstance string, e.g. for giving path names with dashes, is expanded too early. Thus for DefaultInstance=-path\x2dwith\x2ddashes a path unit `foobar@.path` will be installed with a symlink named foobar@-path-with-dashed.path that is interpreted as the path `/path/with/dashes` instead of the intended path nam `/path-with-dashes`. To fix this behavior additional escaping of the backslashes in the `DefaultInstance` string is required so that sed does not expand the escaped characters. Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-03-20systemctl: Don't try to remove directory which doesn't existMartin Jansa
Noticed in this log.do_rootfs error: Started /OE/build/shr-core/tmp-glibc/sysroots/x86_64-linux/usr/bin/systemctl --root=/OE/build/shr-core/tmp-glibc/work/nokia900-oe-linux-gnueabi/shr-image/2.0-r20/rootfs disable bluetooth.service Try to find location of bluetooth.service... Found bluetooth.service in /lib/systemd/system/bluetooth.service WantedBy=bluetooth.target found in bluetooth.service rmdir: failed to remove '/OE/build/shr-core/tmp-glibc/work/nokia900-oe-linux-gnueabi/shr-image/2.0-r20/rootfs/etc/systemd/system/bluetooth.target.wants': No such file or directory Disabled bluetooth.service for bluetooth.target. Disabled bluetooth.service for dbus-org.bluez.service. Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2014-12-19systemd-systemctl: add handling of template unit filesTomas Novotny
Template unit files (those with '@' in their names) are not handled with native version of systemctl. This is usually not a problem, as the native systemctl fails and systemctl command is executed during first boot. But some early boot template units may fail during first boot because opkg configure for first boot is pulled too late for them (although I encouter it only with some of my services, not with oe-core ones). Handling of template unit files is same as in original systemctl. Also DefaultInstance directive in template is respected. As with original systemctl, enabling of template without instance and DefaultInstance does nothing. Signed-off-by: Tomas Novotny <tomas@novotny.cz> Signed-off-by: Ross Burton <ross.burton@intel.com>
2013-12-14systemd-systemctl: Add preset capabilityKhem Raj
systemd has presets as described here http://lists.freedesktop.org/archives/systemd-devel/2011-July/002830.html This patch will let distros define presets file which will override the enable/disable specified by recipes. systemctl preset without any argument will run presents on all services systemctl preset service1 service2 will run presets on specified pervice. something like enable * or disable * would mean that all services will be either enabled or disabled by default. If no user-presets are specified then 'enable' is default systemd allows basic globs but we do not implement them except '*' Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Saul Wold <sgw@linux.intel.com>
2013-06-25systemctl: Support all unit types in the directives.Randy Witt
The Alias and WantedBy directives can accept all valid unit types when using the systemctl from systemd. And since the systemctl script should match the behavior of systemd as much as possible, add the current set of unit types listed at http://www.freedesktop.org/software/systemd/man/systemd.unit.html to the Alias and WantedBy directives. The deficiency was exposed when trying to use: Alias=default.target in a foo.target. No symlink was created by running "systemctl enable foo.target" during the package's postinst. Signed-off-by: Randy Witt <rewitt@declaratino.com> Signed-off-by: Saul Wold <sgw@linux.intel.com>
2013-04-29systemd-systemctl: parse unit files more correctlyEnrico Scholz
Old script failed to parse unit files containing comments like | #Alias=some-alias or whitespaces like | WantedBy = foo correctly. Patch changes script to interpret keywords only when they are at the beginning of a line and ignores whitespaces before the '='. Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Signed-off-by: Saul Wold <sgw@linux.intel.com>
2013-01-20systemd: add systemd recipesRadu Moisan
Add systemd recipes and associated support recipes. Mostly based on meta-oe/meta-systemd, so almost all credit should go to: Andreas Müller <schnitzeltony@googlemail.com> Denis 'GNUtoo' Carikli <GNUtoo@no-log.org> Holger Hans Peter Freyther <holger@moiji-mobile.com> Khem Raj <raj.khem@gmail.com> Koen Kooi <koen@dominion.thruhere.net> Martin Jansa <Martin.Jansa@gmail.com> Signed-off-by: Radu Moisan <radu.moisan@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>