summaryrefslogtreecommitdiff
path: root/src/core
AgeCommit message (Collapse)Author
2016-06-22pid1: initialize TERM environment variable correctlyFranck Bui
When systemd is started by the kernel, the kernel set the TERM environment variable unconditionnally to "linux" no matter the console device used. This might be an issue for dumb devices with no colors support. This patch uses default_term_for_tty() for getting a more accurate value. But it makes sure to keep the user preferences (if any) which might be passed via the kernel command line. For that purpose /proc should be mounted.
2016-06-20Revert "do not pass-along the environment from the kernel or initrd"Franck Bui
This reverts commit ce8aba568156f2b9d0d3b023e960cda3d9d7db81. We should pass an environment as close as possible to what we originally got.
2016-06-20pid1: reconnect to the console before being re-executedFranck Bui
When re-executed, reconnect the console to PID1's stdios as it was the case when PID1 was initially started by the kernel.
2016-06-13core/execute: pass env vars to PAM session setup (#3503)Jouke Witteveen
Move the merger of environment variables before setting up the PAM session and pass the aggregate environment to PAM setup. This allows control over the PAM session hooks through environment variables. PAM session initiation may update the environment. On successful initiation of a PAM session, we adopt the environment of the PAM context.
2016-06-10core: disable colors when displaying cylon when systemd.log_color=off (#3495)Franck Bui
2016-06-10core/execute: add the magic character '!' to allow privileged execution (#3493)Alessandro Puccetti
This patch implements the new magic character '!'. By putting '!' in front of a command, systemd executes it with full privileges ignoring paramters such as User, Group, SupplementaryGroups, CapabilityBoundingSet, AmbientCapabilities, SecureBits, SystemCallFilter, SELinuxContext, AppArmorProfile, SmackProcessLabel, and RestrictAddressFamilies. Fixes partially https://github.com/systemd/systemd/issues/3414 Related to https://github.com/coreos/rkt/issues/2482 Testing: 1. Create a user 'bob' 2. Create the unit file /etc/systemd/system/exec-perm.service (You can use the example below) 3. sudo systemctl start ext-perm.service 4. Verify that the commands starting with '!' were not executed as bob, 4.1 Looking to the output of ls -l /tmp/exec-perm 4.2 Each file contains the result of the id command. ````````````````````````````````````````````````````````````````` [Unit] Description=ext-perm [Service] Type=oneshot TimeoutStartSec=0 User=bob ExecStartPre=!/usr/bin/sh -c "/usr/bin/rm /tmp/exec-perm*" ; /usr/bin/sh -c "/usr/bin/id > /tmp/exec-perm-start-pre" ExecStart=/usr/bin/sh -c "/usr/bin/id > /tmp/exec-perm-start" ; !/usr/bin/sh -c "/usr/bin/id > /tmp/exec-perm-star-2" ExecStartPost=/usr/bin/sh -c "/usr/bin/id > /tmp/exec-perm-start-post" ExecReload=/usr/bin/sh -c "/usr/bin/id > /tmp/exec-perm-reload" ExecStop=!/usr/bin/sh -c "/usr/bin/id > /tmp/exec-perm-stop" ExecStopPost=/usr/bin/sh -c "/usr/bin/id > /tmp/exec-perm-stop-post" [Install] WantedBy=multi-user.target] `````````````````````````````````````````````````````````````````
2016-06-09load-fragment: don't try to do a template instance replacement if we are not ↵Lennart Poettering
an instance (#3451) Corrects: 7aad67e7 Fixes: #3438
2016-06-09execute: check whether the specified fd is a tty before chowning/chmoding ↵Lennart Poettering
it (#3457) Let's add an extra safety check before we chmod/chown a TTY to the right user, as we might end up having connected something to STDIN/STDOUT that is actually not a TTY, even though this might have been requested, due to permissive StandardInput= settings or transient service activation with fds passed in. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=85255
2016-06-06core: add minor commentLennart Poettering
Let's explain #3444 briefly in the sources, too.
2016-06-06mount: make sure got into MOUNT_DEAD state after a successful umount (#3444)michaelolbrich
Without this code the following can happen: 1. Open a file to keep a mount busy 2. Try to stop the corresponding mount unit with systemctl -> umount fails and the failure is remembered in mount->result 3. Close the file and umount the filesystem manually -> mount_dispatch_io() calls "mount_enter_dead(mount, MOUNT_SUCCESS)" -> Old error in mount->result is reused and the mount unit enters a failed state Clear the old error result when 'mountinfo' reports a successful umount to fix this.
2016-06-05automount: handle expire_tokens when the mount unit changes its state (#3434)michaelolbrich
This basically reverts 7b2fd9d51259f6cf350791434e640ac3519acc6c ("core: remove duplicate code in automount_update_mount()"). This was not duplicate code. The expire_tokens need to be handled as well: Send 0 == success for MOUNT_DEAD (umount successful), do nothing for MOUNT_UNMOUNTING (not yet done) and an error for everything else. Otherwise the automount logic will assume unmounting is not done and will not send any new requests for mounting. As a result, the corresponding mount unit is never mounted. Without this, automounts with TimeoutIdleSec= are broken. Once the idle timeout triggered a umount, any access to the corresponding filesystem hangs forever. Fixes #3332.
2016-06-03core: Restrict mmap and mprotect with PAGE_WRITE|PAGE_EXEC (#3319) (#3379)Topi Miettinen
New exec boolean MemoryDenyWriteExecute, when set, installs a seccomp filter to reject mmap(2) with PAGE_WRITE|PAGE_EXEC and mprotect(2) with PAGE_EXEC.
2016-06-03Merge pull request #3418 from htejun/cgroup2-log-compatLennart Poettering
core: log cgroup legacy and unified hierarchy setting translations
2016-06-03core: always use "infinity" for no upper limit instead of "max" (#3417)Tejun Heo
Recently added cgroup unified hierarchy support uses "max" in configurations for no upper limit. While consistent with what the kernel uses for no upper limit, it is inconsistent with what systemd uses for other controllers such as memory or pids. There's no point in introducing another term. Update cgroup unified hierarchy support so that "infinity" is the only term that systemd uses for no upper limit.
2016-06-02core: log cgroup legacy and unified hierarchy setting translationsTejun Heo
To accommodate changes in kernel interface, cgroup unified hierarchy support added several configuration items which overlap with the existing resource control settings and there is simple config translation between the overlapping settings to ease the transition. As why certain cgroup knobs are being configured can become confusing, this patch adds a master warning message which is printed once when such translation is first used and logs each translation with a debug message. v2: - Switched to log_unit*().
2016-06-02core: pass Unit into cgroup_context_apply() and use log_unit*()Tejun Heo
cgroup_context_apply() and friends take CGroupContext and cgroup path as input and has no way of getting back to the associated Unit and thus uses raw cgroup path for logging. This makes the log messages difficult to track down. There's no reason to avoid passing in Unit into these functions. Pass in Unit and use log_unit*() instead. While at it, make cgroup_context_apply(), which has no outside users, static. Also, drop cgroup path from log messages where the path itself isn't too interesting and can be easily obtained from the unit.
2016-06-01core: add pre-defined syscall groups to SystemCallFilter= (#3053) (#3157)Topi Miettinen
Implement sets of system calls to help constructing system call filters. A set starts with '@' to distinguish from a system call. Closes: #3053, #3157
2016-05-29util-lib: Add sparc64 support for process creation (#3348)Michael Karcher
The current raw_clone function takes two arguments, the cloning flags and a pointer to the stack for the cloned child. The raw cloning without passing a "thread main" function does not make sense if a new stack is specified, as it returns in both the parent and the child, which will fail in the child as the stack is virgin. All uses of raw_clone indeed pass NULL for the stack pointer which indicates that both processes should share the stack address (so you better don't pass CLONE_VM). This commit refactors the code to not require the caller to pass the stack address, as NULL is the only sensible option. It also adds the magic code needed to make raw_clone work on sparc64, which does not return 0 in %o0 for the child, but indicates the child process by setting %o1 to non-zero. This refactoring is not plain aesthetic, because non-NULL stack addresses need to get mangled before being passed to the clone syscall (you have to apply STACK_BIAS), whereas NULL must not be mangled. Implementing the conditional mangling of the stack address would needlessly complicate the code. raw_clone is moved to a separete header, because the burden of including the assert machinery and sched.h shouldn't be applied to every user of missing_syscalls.h
2016-05-28tree-wide: remove newlines from unit_write_drop_inZbigniew Jędrzejewski-Szmek
This reverts part of #3329, but all for a good cause.
2016-05-28core/unit: append newline when writing drop insZbigniew Jędrzejewski-Szmek
unit_write_drop_in{,_private}{,_format} are all affected. We already append a header to the file (and section markers), so those functions can only be used to write a whole file at once. Including the newline at the end feels natural. After this commit newlines will be duplicated. They will be removed in subsequent commit. Also, rewrap the "autogenerated" header to fit within 80 columns.
2016-05-28Merge pull request #3328 from poettering/ipv4ll-ipv4acd-fixesZbigniew Jędrzejewski-Szmek
various sd-Ipv4ll/sd-ipv4acd fixes
2016-05-27core: add cgroup memory controller support on the unified hierarchy (#3315)Tejun Heo
On the unified hierarchy, memory controller implements three control knobs - low, high and max which enables more useable and versatile control over memory usage. This patch implements support for the three control knobs. * MemoryLow, MemoryHigh and MemoryMax are added for memory.low, memory.high and memory.max, respectively. * As all absolute limits on the unified hierarchy use "max" for no limit, make memory limit parse functions accept "max" in addition to "infinity" and document "max" for the new knobs. * Implement compatibility translation between MemoryMax and MemoryLimit. v2: - Fixed missing else's in config_parse_memory_limit(). - Fixed missing newline when writing out drop-ins. - Coding style updates to use "val > 0" instead of "val". - Minor updates to documentation.
2016-05-27Merge pull request #3329 from htejun/dbus-cgroup-fixesLennart Poettering
dbus-cgroup fixes
2016-05-27core: fix missing newline when writing drop-in for WorkingDirectory (#3337)Tejun Heo
2016-05-26manager: remove spurious newlineLennart Poettering
2016-05-23core: fix missing newlines when writing out drop-ins for cgroup settingsTejun Heo
Except for per-device BlockIO, IO and DeviceAllow/Deny settings, all were missing newline causing the next drop-in to be concatenated at the end of the line. Fix it.
2016-05-23core: fix the reversed sanity check when setting StartupBlockIOWeight over dbusTejun Heo
bus_cgroup_set_property() was rejecting if the input value was in range. Reverse it.
2016-05-20core: put opening curly braces on the same line as function names (#3313)Tejun Heo
Recently added cgroup helper functions break the style convention. Fix them up.
2016-05-20Revert "core/dbus: further simplify branch code" (#3307)Lennart Poettering
2016-05-20Merge pull request #3290 from htejun/cgroup2-io-compatLennart Poettering
Implement compat translation between IO* and BlockIO* settings
2016-05-20core/dbus: revert oversimplification (#3309)Jonathan Boulle
free_and_strdup handles NULL but not empty strings. See also: https://github.com/systemd/systemd/pull/3283#issuecomment-220603145 https://github.com/systemd/systemd/pull/3307
2016-05-20core/dbus: expose SELinuxContext property (#3284)Jonathan Boulle
Adds support to core for systemd D-Bus clients to send the `SELinuxContext` property . This means `systemd-run -p SELinuxContext=foo` should now work.
2016-05-18core/dbus: further simplify branch code (#3283)Jonathan Boulle
free_and_strdup already handles the NULL case for us, so we can remove an extraneous conditional check. As noted in https://github.com/systemd/systemd/pull/3279/files#r63687717
2016-05-18core: translate between IO and BlockIO settings to ease transitionTejun Heo
Due to the substantial interface changes in cgroup unified hierarchy, new IO settings are introduced. Currently, IO settings apply only to unified hierarchy and BlockIO to legacy. While the transition is necessary, it's painful for users to have to provide configs for both. This patch implements translation from one config set to another for configs which make sense. * The translation takes place during application of the configs. Users won't see IO or BlockIO settings appearing without being explicitly created. * The translation takes place only if there is no config for the matching cgroup hierarchy type at all. While this doesn't provide comprehensive compatibility, it should considerably ease transition to the new IO settings which are a superset of BlockIO settings. v2: - Update test-cgroup-mask.c so that it accounts for the fact that CGROUP_MASK_IO and CGROUP_MASK_BLKIO move together. Also, test/parent.slice now sets IOWeight instead of BlockIOWeight.
2016-05-18core: factor out io and blkio helper functions from cgroup_context_apply()Tejun Heo
Factor out the following functions out of cgroup_context_apply() * cgroup_context_[blk]io_weight() * cgroup_apply_[blk]io_device_weight() * cgroup_apply_[blk]io_device_limit() This is pure refactoring and shouldn't cause any functional differences.
2016-05-18core: update CGroupBlockIODeviceBandwidth to record both rbps and wbpsTejun Heo
CGroupBlockIODeviceBandwith is used to keep track of IO bandwidth limits for legacy cgroup hierarchies. Unlike the unified hierarchy counterpart CGroupIODeviceLimit, a CGroupBlockIODeviceBandwiddth records either a read or write limit and has a couple issues. * There's no way to clear specific config entry. * When configs are cleared for an IO direction of a unit, the kernel settings aren't cleared accordingly creating discrepancies. This patch updates CGroupBlockIODeviceBandwidth so that it behaves similarly to CGroupIODeviceLimit - each entry records both rbps and wbps limits and is cleared if both are at default values after kernel settings are updated.
2016-05-18core: add support for IOReadIOPSMax and IOWriteIOPSMaxTejun Heo
cgroup IO controller supports maximum limits for both bandwidth and IOPS but systemd resource control currently only supports bandwidth limits. This patch adds support for IOReadIOPSMax and IOWriteIOPSMax when unified cgroup hierarchy is in use. It isn't difficult to also add BlockIOReadIOPS and BlockIOWriteIOPS for legacy hierarchies but IO control on legacy hierarchies is half-broken anyway, so let's leave it alone for now.
2016-05-18core: introduce CGroupIOLimitType enumsTejun Heo
Currently, there are two cgroup IO limits, bandwidth max for read and write, and they are hard-coded in various places. This is fine for two limits but IO is expected to grow more limits - low, high and max limits for bandwidth and IOPS - and hard-coding each limit won't make sense. This patch replaces hard-coded limits with an array indexed by CGroupIOLimitType and accompanying string and default value tables so that new limits can be added trivially.
2016-05-17core/dbus: use free_and_strdup to simplify code (#3279)Jonathan Boulle
Makes it consistent with the other branches here.
2016-05-16Merge pull request #3193 from htejun/cgroup-io-controllerLennart Poettering
core: add io controller support on the unified hierarchy
2016-05-16core: don't log job status message in case job was effectively NOP (#3199)Michal Sekletar
We currently generate log message about unit being started even when unit was started already and job didn't do anything. This is because job was requested explicitly and hence became anchor job of the transaction thus we could not eliminate it. That is fine but, let's not pollute journal with useless log messages. $ systemctl start systemd-resolved $ systemctl start systemd-resolved $ systemctl start systemd-resolved Current state: $ journalctl -u systemd-resolved | grep Started May 05 15:31:42 rawhide systemd[1]: Started Network Name Resolution. May 05 15:31:59 rawhide systemd[1]: Started Network Name Resolution. May 05 15:32:01 rawhide systemd[1]: Started Network Name Resolution. After patch applied: $ journalctl -u systemd-resolved | grep Started May 05 16:42:12 rawhide systemd[1]: Started Network Name Resolution. Fixes #1723
2016-05-15namespace: Make private /dev noexec and readonly (#3263)topimiettinen
Private /dev will not be managed by udev or others, so we can make it noexec and readonly after we have made all device nodes. As /dev/shm needs to be writable, we can't use bind_remount_recursive().
2016-05-14core: allow slice to be overriden if cgroups aren't realized (#3246)Tejun Heo
unit_set_slice() fails with -EBUSY if the unit already has a slice associated with it. This makes it impossible to override slice through dropin config or over dbus. There's no reason to disallow slice changes as long as cgroups aren't realized. Fix it. Fixes #3240. Signed-off-by: Tejun Heo <htejun@fb.com> Reported-by: Davide Cavalca <dcavalca@fb.com>
2016-05-14namespace: unmount old /dev under our new private /dev (#3254)topimiettinen
Drop all dangling old /dev mounts before mounting a new private /dev tree.
2016-05-12core: added ListUnitsByNames dbus method (#3182)kayrus
This new method returns information by unit names. Instead of ListUnitsByPatterns this method returns information of inactive and even unexisting units. Moved dbus unit reply logic into a separate shared function. Resolves https://github.com/coreos/fleet/pull/1418
2016-05-10Merge pull request #3220 from keszybz/install-fixesLennart Poettering
Fix "preset-all" with dangling symlinks and install-section hint emitted too eagerly
2016-05-09tree-wide: port more code to use ifname_valid()Lennart Poettering
2016-05-08Merge pull request #3202 from poettering/socket-fixesMartin Pitt
don't reopen socket fds when reloading the daemon
2016-05-07core/mount: add helper function for mount statesZbigniew Jędrzejewski-Szmek
2016-05-07Merge pull request #3160 from htejun/cgroup-fixes-rev2Zbigniew Jędrzejewski-Szmek
Cgroup fixes.