summaryrefslogtreecommitdiff
path: root/src/core
Commit message (Collapse)AuthorAgeFilesLines
...
* core/systemctl: when switching root default to /sysroot/Lennart Poettering2023-04-281-9/+15
| | | | | | | | | We hardcode the path the initrd uses to prepare the final mount point at so many places, let's also imply it in "systemctl switch-root" if not specified. This adds the fallback both to systemctl and to PID 1 (this is because both to — different – checks on the path).
* Merge pull request #27424 from dtardon/auto-cleanupYu Watanabe2023-04-283-25/+29
|\ | | | | More automatic cleanup
| * transaction: make transaction_free() staticDavid Tardon2023-04-282-2/+1
| | | | | | | | ... as it's not needed outside transaction.c anymore.
| * manager: use _cleanup_ in manager_propagate_reload()David Tardon2023-04-281-9/+4
| |
| * manager: use _cleanup_ in manager_add_job()David Tardon2023-04-281-11/+6
| |
| * transaction: introduce transaction_abort_and_free()David Tardon2023-04-282-0/+11
| | | | | | | | Will be used in following commits.
| * transaction: modernize transaction_free()David Tardon2023-04-272-3/+7
| |
* | core: change ownership of subcgroup we create recursively, it shall be owned ↵Lennart Poettering2023-04-271-1/+1
| | | | | | | | | | | | | | | | | | by the user delegated to If we create a subcroup (regardless if the '.control' subgroup we always created or one configured via DelegateSubgroup=) it's inside of the delegated territory of the cgroup tree, hence it should be owned fully by the unit's users. Hence do so.
* | execute: don't apply journal + oomd xattrs to subcgroupLennart Poettering2023-04-271-6/+4
| | | | | | | | | | | | | | | | | | We don't need to apply the journal/oomd xattrs to the subcgroups we add, since those daemons already look for the xattrs up the tree anyway. Hence remove this. This is in particular relevant as it means later changes to the xattr don#t need to be replicated on the subcgroup either.
* | core: add DelegateSubgroup= settingLennart Poettering2023-04-277-9/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements a minimal subset of #24961, but in a lot more restrictive way: we only allow one level of subcgroup (as that's enough to address the no-processes in inner cgroups rule), and does not change anything about threaded cgroup logic or similar, or make any of this new behaviour mandatory. All this does is this: all non-control processes we invoke for a unit we'll invoke in a subgroup by the specified name. We'll later port all our current services that use cgroup delegation over to this, i.e. user@.service, systemd-nspawn@.service and systemd-udevd.service.
* | cgroup: rework how we validate/escape cgroupsLennart Poettering2023-04-273-26/+37
| | | | | | | | | | | | Let's clean up validation/escaping of cgroup names. i.e. split out code that tests if name needs escaping. Return proper error codes, and extend test a bit.
* | Merge pull request #27413 from yuwata/core-job-cleanupsYu Watanabe2023-04-272-5/+32
|\ \ | | | | | | core/job: cleanups for job ID
| * | core/job: use new job ID when we failed to deserialize job IDYu Watanabe2023-04-271-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | This is for the case when we fail to deserialize job ID. In job_install_deserialized(), we also check the job type, and that is for the case when we failed to deserialize the job. Let's gracefully handle the failure in deserializing the job ID. This is paranoia, and just for safety. Should not change any behavior.
| * | core/job: handle job ID overflow or conflict more sanelyYu Watanabe2023-04-271-1/+23
| | | | | | | | | | | | This is paranoia, and just for safety. Should not change any behavior.
| * | core/job: fix indentationYu Watanabe2023-04-271-2/+2
| | |
| * | core/job: add one more assertionYu Watanabe2023-04-271-0/+1
| | | | | | | | | | | | In this stage, the unit should not have installed job of the type.
| * | core/transaction: use hashmap_remove_value() to make not remove job with same IDYu Watanabe2023-04-271-2/+2
| | | | | | | | | | | | | | | | | | | | | When we fail to deserialize job ID, or the current_job_id is overflowed, we may have jobs with the same ID. This is paranoia, and just for safety. Note, we already use hashmap_remove_value() in job_uninstall().
* | | core/service: make service_add_fd_store() always consume provided fdYu Watanabe2023-04-271-32/+33
|/ / | | | | | | No functional change, just refactoring.
* | Merge pull request #27380 from poettering/bpf-meson-tweaksYu Watanabe2023-04-252-122/+6
|\ \ | | | | | | two bpf build system changes
| * | pid1: simplify bpf meson importLennart Poettering2023-04-241-7/+6
| | |
| * | meson: move bpf hookup into main meson build fileLennart Poettering2023-04-242-115/+0
| |/ | | | | | | This way we can use it in systemd-userdbd later on, too.
* | Merge pull request #27113 from keszybz/variable-expansion-reworkZbigniew Jędrzejewski-Szmek2023-04-244-21/+41
|\ \ | |/ |/| Rework serialization of command lines in pid1 and make run not expand variables
| * core: fix writing of ExecStartEx and friendsZbigniew Jędrzejewski-Szmek2023-04-242-8/+13
| | | | | | | | | | | | | | | | | | | | The property name is called ExecStartEx, but we have to write it as ExecStart= in the unit file. :( Bug introduced in b3d593673c5b8b0b7d781fd26ab2062ca6e7dbdb when ex-properties were initially added. In addition, we cannot escape $ as $$, because when ":" is used, we wouldn't unescape $$ back to $.
| * core/unit: add UNIT_ESCAPE_EXEC_SYNTAXZbigniew Jędrzejewski-Szmek2023-04-242-8/+14
| | | | | | | | | | | | | | | | | | | | Unfortunately we can't escape $ when ':' is used to prohibit variable expansion: ExecStart=:echo $$ is not the same as ExecStart=:echo $ This just adds the functionality and the unittests, without using it anywhere for real yet.
| * core/unit: rename UNIT_ESCAPE_EXEC_SYNTAX → *_ENVZbigniew Jędrzejewski-Szmek2023-04-243-12/+12
| | | | | | | | In preparation for future changes.
| * core/unit: fix shell-escaping of stringsZbigniew Jędrzejewski-Szmek2023-04-241-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our escaping of '$' is '$$', not '\$'. We would write unit files that were not valid: $ systemd-run --user bash -c 'echo $$; sleep 1000' Running as unit: run-r1c7c45b5b69f487c86ae205e12100808.service $ systemctl cat --user run-r1c7c45b5b69f487c86ae205e12100808 # /run/user/1000/systemd/transient/run-r1c7c45b5b69f487c86ae205e12100808.service ... ExecStart="/usr/bin/bash" "-c" "echo \$\$\; sleep 1000" $ systemd-analyze verify /run/user/1000/systemd/transient/run-r1c7c45b5b69f487c86ae205e12100808.service /run/user/1000/systemd/transient/run-r1c7c45b5b69f487c86ae205e12100808.service:7: Ignoring unknown escape sequences: "echo \$\$\; sleep 1000" Similarly, ';' cannot be escaped as '\;'. Only a handful of characters listed in "Supported escapes" is allowed. Escaping of "'" can be done, but it's not useful because we use double quotes around the string anyway whenever we do escaping. unit_write_setting() is called all over the place. In a great majority of places we write either fixed strings or something that we generate ourselves, so no escaping or quoting is needed. (And it's not allowed, e.g. 'Type="oneshot"' would not work.) But if we forgot to add escaping or quoting for a free-style string, it would probably allow writing a unit file that would be read completely wrong. I looked over various places where unit_write_setting() is called, and I couldn't find any place where quoting/escaping was forgotten. But trying to figure out the full ramifications of this change is not easy.
* | Merge pull request #27327 from DaanDeMeyer/hotplugLennart Poettering2023-04-202-16/+48
|\ \ | | | | | | kmod-setup: Add early loading for virtio_console
| * | kmod-setup: Add early loading for virtio_consoleDaan De Meyer2023-04-201-8/+33
| | | | | | | | | | | | | | | | | | | | | getty-generator enables serial-getty@.service for virtualizer consoles that it can find in /sys/class/tty. To make sure this works for virtio consoles, let's make sure we load the module is loaded early so that the /sys/class/tty/hvc0 exists before we run getty-generator.
| * | core: Parse logging environment earlierDaan De Meyer2023-04-201-4/+10
| | | | | | | | | | | | | | | | | | Let's make sure we parse the logging environment ASAP so that the options apply to more code. e.g. to allow debugging kmod-setup.c for example.
| * | kmod-setup: Introduce match_modalias_recurse_dir_cb()Daan De Meyer2023-04-201-4/+5
| | | | | | | | | | | | Let's make the logic around matching a modalias a bit more generic.
* | | core/device: rewrite how device unit is removed from Manager.devices_by_sysfsYu Watanabe2023-04-201-7/+14
| | | | | | | | | | | | | | | | | | | | | If the device unit is not the head of the list saved in Manager.devices_by_sysfs, then it is not necessary to replace the existing hashmap entry. This should not change any behavior, just refactoring.
* | | core: add one missing assertion for release_resource_queueYu Watanabe2023-04-191-0/+1
|/ / | | | | | | Follow-up for 6ac62d61db737b01ad3776a7688d8a4c57b3f7d9.
* | kmod-setup: bypass heavy virtio-rng check if we are not running in a VM anywayLennart Poettering2023-04-181-0/+4
| | | | | | | | | | detect_vm() is cheap, because cached, let's hence do that early before we get out the big guns and sweep through sysfs.
* | kmod-setup: use STARTSWITH_SET() where appropriateLennart Poettering2023-04-181-4/+2
| |
* | lsm-util: move detection of support of LSMs into a new lsm-util.[ch] helperLennart Poettering2023-04-181-37/+2
| | | | | | | | | | | | | | This makes the bpf LSM check generic, so that we can use it elsewhere. it also drops the caching inside it, given that bpf-lsm code in PID1 will cache it a second time a stack frame further up when it checks for various other bpf functionality.
* | bpf-firewall: give a name to maps usedDominique Martinet2023-04-181-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Running systemd with IP accounting enabled generates many bpf maps (two per unit for accounting, another two if IPAddressAllow/Deny are used). Systemd itself knows which maps belong to what unit and commands like `systemctl status <unit>` can be used to query what service has which map, but monitoring these values all the time costs 4 dbus requests (calling the .IP{E,I}gress{Bytes,Packets} method for each unit) and makes services like the prometheus systemd_exporter[1] somewhat slow when doing that for every units, while less precise information could quickly be obtained by looking directly at the maps. Unfortunately, bpf map names are rather limited: - only 15 characters in length (16, but last byte must be 0) - only allows isalnum(), _ and . characters If it wasn't for the length limit we could use the normal unit escape functions but I've opted to just make any forbidden character into underscores for maximum brievty -- the map prefix is also rather short: This isn't meant as a precise mapping, but as a hint for admins who want to look at these. (Note there is no problem if multiple maps have the same name) Link: https://github.com/povilasv/systemd_exporter [1]
* | creds: make available to all ExecStartPre= and ExecStart= processesLuca Boccassi2023-04-171-1/+2
| | | | | | | | Fixes https://github.com/systemd/systemd/issues/27275
* | preset: Add ignore directiveDaan De Meyer2023-04-143-6/+5
| | | | | | | | | | | | The ignore directive specifies to not do anything with the given unit and leave existing configuration intact. This allows distributions to gradually adopt preset files by shipping a ignore * preset file.
* | Merge pull request #27254 from poettering/cmsg-align-checkYu Watanabe2023-04-141-2/+2
|\ \ | | | | | | socket-util: tighten CMSG_TYPED_DATA() alignment checks
| * | tree-wide: port more code over to CMSG_TYPED_DATA()Lennart Poettering2023-04-131-2/+2
| | |
* | | Merge pull request #27144 from enr0n/fix-scope-timer-on-coldplugLuca Boccassi2023-04-141-1/+1
|\ \ \ | | | | | | | | scope: do not disable timer event source when state is SCOPE_RUNNING
| * | | scope: do not disable timer event source when state is SCOPE_RUNNINGNick Rosbrook2023-04-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In scope_set_state(), the timer event source may be disabled depending on the state. Currently, it will be disabled when the state is SCOPE_RUNNING. This has the effect of new RuntimeMaxSec values being ignored on coldplug. Note that this issue is not currently present when scopes are started because when scope_start() is called, scope_arm_timer() is called after scope_set_state().
* | | | user units: implicitly enable PrivateUsers= when sandboxing options are setLuca Boccassi2023-04-131-3/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enabling these options when not running as root requires a user namespace, so implicitly enable PrivateUsers=. This has a side effect as it changes which users are visible to the unit. However until now these options did not work at all for user units, and in practice just a handful of user units in Fedora, Debian and Ubuntu mistakenly used them (and they have been all fixed since). This fixes the long-standing confusing issue that the user and system units take the same options but the behaviour is wildly (and sometimes silently) different depending on which is which, with user units requiring manually specifiying PrivateUsers= in order for sandboxing options to actually work and not be silently ignored.
* | | | Merge pull request #27244 from bluca/uphold_retryLuca Boccassi2023-04-134-6/+68
|\ \ \ \ | | | | | | | | | | Uphold/StopWhenUnneeded/BindsTo: add retry timer on rate limit
| * | | | Uphold/StopWhenUnneeded/BindsTo: requeue when job finishesLuca Boccassi2023-04-131-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a unit is upheld and fails, and there are no state changes in the upholder, it will not be retried, which is against what the documentation suggests. Requeue when the job finishes. Same for the other two queues.
| * | | | Uphold/StopWhenUnneeded/BindsTo: add retry timer on rate limitLuca Boccassi2023-04-123-6/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Upholds= promise is that as long as unit A is up and Upholds=B, B will be activated if failed or inactive. But there is a hard-coded, non-configurable rate limit for this, so add a timed retry after the ratelimit has expired. Apply to BindsTo= and StopWhenUnneeded= as well.
* | | | | core/main: fix a typo for --log-targetMike Yuan2023-04-131-1/+1
| |/ / / |/| | | | | | | | | | | | | | | | | | | Follow-up for d2ebd50d7f9740dcf30e84efc75610af173967d2 Fixes #27105
* | | | image-policy: introduce parse_image_policy_argument() helperYu Watanabe2023-04-133-40/+1
| |/ / |/| | | | | | | | | | | | | | | | | | | | | | | Addresses https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1060130312, https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1067927293, and https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1067926416. Follow-up for 84be0c710d9d562f6d2cf986cc2a8ff4c98a138b.
* | | Merge pull request #27027 from dtardon/unit-file-list-cleanupLennart Poettering2023-04-131-11/+5
|\ \ \ | | | | | | | | Use _cleanup_ for UnitFileList hash
| * | | dbus-manager: use _cleanup_ for UnitFileList hashDavid Tardon2023-03-281-11/+5
| | | |