summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
* firstboot: Include <crypt.h> for declaration of crypt() if needed (#7944)Björn Esser2018-05-30
| | | | | | | | Not every target system may provide a crypt() function in its stdlibc and may use an external or replacement library, like libxcrypt, for providing such functions. See https://fedoraproject.org/wiki/Changes/Replace_glibc_libcrypt_with_libxcrypt.
* bus-util: fix format of NextElapseUSecRealtime= and LastTriggerUSec=Yu Watanabe2018-05-30
| | | | | | | | | | | | | Before this, `systemctl show` for calendar type timer unit outputs something like below. ``` NextElapseUSecRealtime=48y 3w 3d 15h NextElapseUSecMonotonic=0 LastTriggerUSec=48y 3w 3d 3h 41min 44.093095s LastTriggerUSecMonotonic=0 ``` As both NextElapseUSecRealtime= and LastTriggerUSec= are not timespan but timestamp, this makes format these values by `format_timestamp()`.
* coccinelle: O_NDELAY → O_NONBLOCKLennart Poettering2018-05-30
| | | | | | Apparently O_NONBLOCK is the modern name used in most documentation and for most cases in our sources. Let's hence replace the old alias O_NDELAY and stick to O_NONBLOCK everywhere.
* tmpfiles: make "f" lines behaviour match what the documentation saysLennart Poettering2018-05-30
| | | | | | | | | | | | | | | | | | | | CHANGE OF BEHAVIOUR — with this commit "f" line's behaviour is altered to match what the documentation says: if an "argument" string is specified it is written to the file only when the file didn't exist before. Previously, it would be appended to the file each time systemd-tmpfiles was invoked — which is not a particularly useful behaviour as the tool is not idempotent then and the indicated files grow without bounds each time the tool is invoked. I did some spelunking whether this change in behaviour would break things, but afaics nothing relies on the previous O_APPEND behaviour of this line type, hence I think it's relatively safe to make "f" lines work the way the docs say, rather than adding a new modifier for it or so. Triggered by: https://lists.freedesktop.org/archives/systemd-devel/2018-January/040171.html
* update TODOLennart Poettering2018-05-30
|
* core: propagate TasksMax= on the root slice to sysctlsLennart Poettering2018-05-30
| | | | | | | | | | The cgroup "pids" controller is not supported on the root cgroup. However we expose TasksMax= on it, but currently don't actually apply it to anything. Let's correct this: if set, let's propagate things to the right sysctls. This way we can expose TasksMax= on all units in a somewhat sensible way.
* cgroup: when querying the number of tasks in the root slice use the pid_max ↵Lennart Poettering2018-05-30
| | | | | | | sysctl The root cgroup doesn't expose and properties in the "pids" cgroup controller, hence we need to get the data from somewhere else.
* cgroup: add proper API to determine whether our unit manags to root cgroupLennart Poettering2018-05-30
|
* util: rework system_tasks_max() to make use of procfs_tasks_max()Lennart Poettering2018-05-30
| | | | Let's use our new code.
* util-lib: add new procfs-util.[ch] API for dealing with tasks limitsLennart Poettering2018-05-30
| | | | | As it turns out the limit on concurrent tasks on Linux nasty to determine, hence let's appropriate helpers for this.
* cgroup: use CGROUP_LIMIT_MAX where appropriateLennart Poettering2018-05-30
|
* util: introduce more accurate definitions of TASKS_MAXLennart Poettering2018-05-30
| | | | | | | The maximum number of processes a tasks on the system is usually lower than what pid_t would allow, and is compiled into the kernel (and documented in proc(5)). Let's add proper defines for that, so that we can adjust the pid_max sysctl without fearing invalid accesses.
* log: remove LOG_TARGET_SAFE pseudo log targetLennart Poettering2018-05-30
| | | | | | | | | | | | | This removes LOG_TARGET_SAFE. It's made redundant by the new "prohibit-ipc" logging flag, as it used to have a similar effect: avoid logging to the journal/syslog, i.e. any local services in order to avoid deadlocks when we lock from PID 1 or its utility processes (such as generators). All previous users of LOG_TARGET_SAFE are switched over to the new setting. This makes things a bit safer for all, as not even the SYSTEMD_LOG_TARGET env var can be used to accidentally log to the journal anymore in these programs.
* log: add brief comment for log_set_open_when_needed() and ↵Lennart Poettering2018-05-30
| | | | | | log_set_always_reopen_console() These two deserve some explanation...
* log: add new "prohibit_ipc" flag to logging systemLennart Poettering2018-05-30
| | | | | | | | | | | | | | | | | | | If set, we'll avoid logging to any IPC log targets, i.e. syslog or the journal, but allow stderr, kmsg, console logging. This is useful as PID 1 wants to turn this off explicitly as long as the journal is not up. Previously we'd open/close the log stream to these services whenever needed but this is incompatible with the "open_when_needed" logic introduced in #6915, which might open the log streams whenever it likes, including possibly inside of the child process we fork off that'll become journald later on. Hence, let's make this all explicit, and instead of managing when we open/close log streams add a boolean that clearly prohibits the IPC targets when needed, so that opening can be done at any time, but will honour this. See: #7985
* log: make log_set_upgrade_syslog_to_journal() take effect immediatelyLennart Poettering2018-05-30
| | | | | | This doesn't matter much, and we don't rely on it, but I think it's much nicer if we log_set_target() and log_set_upgrade_syslog_to_journal() can be called in either order and have the same effect.
* Add fd close support to sd_event_sourceNathaniel McCallum2018-05-30
| | | | | | | | | | | | | | It is often the case that a file descriptor and its corresponding IO sd_event_source share a life span. When this is the case, developers will have to unref the event source and close the file descriptor. Instead, we can just have the event source take ownership of the file descriptor and close it when the event source is freed. This is especially useful when combined with cleanup attributes and sd_event_source_unrefp(). This patch adds two new public functions: sd_event_source_get_io_fd_own() sd_event_source_set_io_fd_own()
* Include time.h in sd-event.hNathaniel McCallum2018-05-30
| | | | | | The time-related functions in sd-event.h take as inputs constants (CLOCK_*) defined in time.h. By including time.h in sd-event.h, we free the developer from having to do this manually.
* update TODOLennart Poettering2018-05-30
|
* core: rework how we track which PIDs to watch for a unitLennart Poettering2018-05-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we'd maintain two hashmaps keyed by PIDs, pointing to Unit interested in SIGCHLD events for them. This scheme allowed a specific PID to be watched by exactly 0, 1 or 2 units. With this rework this is replaced by a single hashmap which is primarily keyed by the PID and points to a Unit interested in it. However, it optionally also keyed by the negated PID, in which case it points to a NULL terminated array of additional Unit objects also interested. This scheme means arbitrary numbers of Units may now watch the same PID. Runtime and memory behaviour should not be impact by this change, as for the common case (i.e. each PID only watched by a single unit) behaviour stays the same, but for the uncommon case (a PID watched by more than one unit) we only pay with a single additional memory allocation for the array. Why this all? Primarily, because allowing exactly two units to watch a specific PID is not sufficient for some niche cases, as processes can belong to more than one unit these days: 1. sd_notify() with MAINPID= can be used to attach a process from a different cgroup to multiple units. 2. Similar, the PIDFile= setting in unit files can be used for similar setups, 3. By creating a scope unit a main process of a service may join a different unit, too. 4. On cgroupsv1 we frequently end up watching all processes remaining in a scope, and if a process opens lots of scopes one after the other it might thus end up being watch by many of them. This patch hence removes the 2-unit-per-PID limit. It also makes a couple of other changes, some of them quite relevant: - manager_get_unit_by_pid() (and the bus call wrapping it) when there's ambiguity will prefer returning the Unit the process belongs to based on cgroup membership, and only check the watch-pids hashmap if that fails. This change in logic is probably more in line with what people expect and makes things more stable as each process can belong to exactly one cgroup only. - Every SIGCHLD event is now dispatched to all units interested in its PID. Previously, there was some magic conditionalization: the SIGCHLD would only be dispatched to the unit if it was only interested in a single PID only, or the PID belonged to the control or main PID or we didn't dispatch a signle SIGCHLD to the unit in the current event loop iteration yet. These rules were quite arbitrary and also redundant as the the per-unit handlers would filter the PIDs anyway a second time. With this change we'll hence relax the rules: all we do now is dispatch every SIGCHLD event exactly once to each unit interested in it, and it's up to the unit to then use or ignore this. We use a generation counter in the unit to ensure that we only invoke the unit handler once for each event, protecting us from confusion if a unit is both associated with a specific PID through cgroup membership and through the "watch_pids" logic. It also protects us from being confused if the "watch_pids" hashmap is altered while we are dispatching to it (which is a very likely case). - sd_notify() message dispatching has been reworked to be very similar to SIGCHLD handling now. A generation counter is used for dispatching as well. This also adds a new test that validates that "watch_pid" registration and unregstration works correctly.
* core: unify call we use to synthesize cgroup empty events when we stopped ↵Lennart Poettering2018-05-30
| | | | | | | | | watching any unit PIDs This code is very similar in scope and service units, let's unify it in one function. This changes little for service units, but for scope units makes sure we go through the cgroup queue, which is something we should do anyway.
* core: fix manager_get_unit_by_pid() special casing of manager PIDLennart Poettering2018-05-30
| | | | | | | Previously, we'd hard map PID 1 to the manager scope unit. That's wrong however when we are run in --user mode, as the PID 1 is outside of the subtree we manage and the manager PID might be very differently. Correct that by checking for getpid() rather than hardcoding 1.
* test: test-process-util additionsLennart Poettering2018-05-30
| | | | | Add some extra paranoia tests that PTR_TO_PID() and PID_TO_PTR() deals correctly with negative PID.
* process-util: replace PTR_TO_PID() and PID_TO_PTR macro by inline functionsLennart Poettering2018-05-30
| | | | This way we gain some typesafety at no cost.
* Add support for SD_BUS_DEFAULT*Nathaniel McCallum2018-05-30
| | | | | | | | | | | | | | | | | | | | | | Currently, sd-bus supports the ability to have thread-local default busses. However, this is less useful than it can be since all functions which require an sd_bus* as input require the caller to pass it. This patch adds a new macro which allows the developer to pass a constant SD_BUS_DEFAULT, SD_BUS_DEFAULT_USER or SD_BUS_DEFAULT_SYSTEM instead. This reduces work for the caller. For example: r = sd_bus_default(&bus); r = sd_bus_call_method(bus, ...); sd_bus_unref(bus); Becomes: r = sd_bus_call_method(SD_BUS_DEFAULT, ...); If the specified thread-local default bus does not exist, the function calls will return -ENOPKG. No bus will ever be implicitly created.
* Add support for SD_EVENT_DEFAULTNathaniel McCallum2018-05-30
| | | | | | | | | | | | | | | | | | | | | Currently, sd-event supports the ability to have a thread-local default event loop. However, this is less useful than it can be since all functions which require an sd_event* as input require the caller to pass it. This patch adds a new macro which allows the developer to pass a constant SD_EVENT_DEFAULT instead. This reduces work for the caller. For example: r = sd_event_default(&e); r = sd_event_add_io(e, ...); sd_event_unref(e); Becomes: r = sd_event_add_io(SD_EVENT_DEFAULT, ...); If no thread-local default event loop exists, the function calls will return -ENOPKG. No event loop will ever be implicitly created.
* pid1: add option to disable service watchdogsJan Klötzke2018-05-30
| | | | | Add a "systemd.service_watchdogs=" option to the command line which disables all service runtime watchdogs and emergency actions.
* bus-util: add bool property setterJan Klötzke2018-05-30
|
* hwdb: map zoomin/out keys to up/downMartin Pitt2018-05-30
| | | | | | | | | | | | | | | | | | | Some keyboards come with a zoom see-saw or rocker which until now got mapped to the Linux "zoomin/out" keys in hwdb. However, these keycodes are not recognized by any major desktop. They now produce Up/Down key events so that they can be used for scrolling. The internet is full of instructions how to "unbreak" these keys, e. g. https://askubuntu.com/questions/471802/make-the-zoom-slider-of-microsoft-natural-ergonomic-keyboard-4000-and-7000-scrol https://unix.stackexchange.com/questions/322075/how-to-get-ms-natural-ergonomic-4000-slider-work-on-linux-mint So let's make it official. But keep their physical meaning in comments in case desktops start to do something useful with them at some point. Thanks to Finn Christiansen for the original patch! Replaces #6953
* update TODOLennart Poettering2018-05-30
|
* remove canonicalize_file_name() mention from TODOReverend Homer2018-05-30
| | | | | canonicalize_file_name() invocations were replaced by chase_symlinks() in Decemeber 2016 with PR #4694, so we don't need this mention in the TODO anymore
* fs-util: chase_symlinks(): prevent double freeYu Watanabe2018-05-30
| | | | Fixes CID #1385316.
* fs-util: use _cleanup_close_ attributeYu Watanabe2018-05-30
| | | | | | | The commit f14f1806e329fe92d01f15c22a384702f0cb4ae0 introduced CHASE_SAFE flag. When the flag is set, then `fd_parent` may not be properly closed. This sets `_cleanup_close_` attribute to `fd_parent`. Thus, now `fd_parent` is always closed properly.
* NEWS: fix typoZbigniew Jędrzejewski-Szmek2018-05-30
|
* unaligned: let gcc generate optimal codeShawn Landden2018-05-30
| | | | | | | on some architectures such as MIPS there are special unaligned load/store sequences, instead of having to do bitwise accesses https://www.linux-mips.org/wiki/Alignment
* fs-util: chase_symlinks(): support empty rootYu Watanabe2018-05-30
| | | | | | | | | The commit b1bfb848046e457f3cd623286b8cc1a5e5440023 makes chase_symlinks() recognize empty string for root as an invalid parameter. However, empty root is often used e.g. systemd-nspawn. This makes chase_symlinks() support empty string safely. Fixes #7927.
* bus-message: avoid -Wnull-pointer-arithmetic warning on new clangZbigniew Jędrzejewski-Szmek2018-05-30
| | | | | We just need some pointer, so use alignment directly converted to the right type.
* core: un-break PrivateDevices= by allowing it to mknod /dev/ptmxAlan Jenkins2018-05-30
| | | | | | | | | | | | #7886 caused PrivateDevices= to silently fail-open. https://github.com/systemd/systemd/pull/7886#issuecomment-358542849 Allow PrivateDevices= to succeed, in creating /dev/ptmx, even though DeviceControl=closed applies. No specific justification was given for blocking mknod of /dev/ptmx. Only that we didn't seem to need it, because we weren't creating it correctly as a device node.
* fuzz: allow building fuzzers outside of oss-fuzzJonathan Rudenberg2018-05-30
| | | | | | Add a new -Dllvm-fuzz=true option that can be used to build against libFuzzer and update the oss-fuzz script to work outside of the oss-fuzz build environment.
* fuzz: disable all deps when building with oss-fuzzJonathan Rudenberg2018-05-30
| | | | | | | | The fuzz targets are intended to be fast and only target systemd code, so they don't need to call out to any dependencies. They also shouldn't depend on shared libraries outside of libc, so we disable every dependency when compiling against oss-fuzz. This also simplifies the upstream build environment significantly.
* fuzz: add initial fuzzing infrastructureJonathan Rudenberg2018-05-30
| | | | | | | | The fuzzers will be used by oss-fuzz to automatically and continuously fuzz systemd. This commit includes the build tooling necessary to build fuzz targets, and a fuzzer for the DNS packet parser.
* path-util: don't insert duplicate "/" in path_make_absolute_cwd()Lennart Poettering2018-05-30
| | | | | When the working directory is "/" it's prettier not to insert a second "/" in the path, even though it is technically correct.
* tree-wide: port all code to use safe_getcwd()Lennart Poettering2018-05-30
|
* path-util: introduce new safe_getcwd() wrapperLennart Poettering2018-05-30
| | | | | | | It's like get_current_dir_name() but protects us from CVE-2018-1000001-style exploits: https://www.halfdog.net/Security/2017/LibcRealpathBufferUnderflow/
* path-util: don't add extra "/" when prefix already is suffixed by slashLennart Poettering2018-05-30
| | | | | No need to insert duplicate "/" if we can avoid it. This is particularly relevant if the prefix passed in is the root directory.
* path-util: do something useful if the prefix is "" in path_make_absolute()Lennart Poettering2018-05-30
| | | | | Do not insert a "/" if the prefix we shall use is empty. It's a corner case we should probably take care of.
* fs-util: refuse taking a relative path to chase if "root" is specified and ↵Lennart Poettering2018-05-30
| | | | | | | | | | | CHASE_PREFIX_ROOT is set If we take a relative path we first make it absolute, based on the current working directory. But if CHASE_PREFIX_ROOT is passe we are supposed to make the path absolute taking the specified root path into account, but that makes no sense if we talk about the current working directory as that is relative to the host's root in any case. Hence, let's refuse this politely.
* fs-util: extra chase_symlink() safety check on "path" parameterLennart Poettering2018-05-30
| | | | | It's not clear what an empty "path" is even supposed to mean, hence refuse.
* fs-util: extra safety checks on chase_symlinks() root parameterLennart Poettering2018-05-30
| | | | Let's handle root="" and root="/" safely.
* parse-util: detect overflows in parse_percent_unbounded()Lennart Poettering2018-05-30
| | | | | We shouldn't accept percentages beyon INT32_MAX and consider them valid.