aboutsummaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* condition: Create AssertControlGroupController (#7630)Chris Down2017-12-184-0/+106
| | | | | | | | | | | | | | | | | | Up until now, the behaviour in systemd has (mostly) been to silently ignore failures to action unit directives that refer to an unavailble controller. The addition of AssertControlGroupController and its conditional counterpart allow explicit specification of the desired behaviour when such a situation occurs. As for how this can happen, it is possible that a particular controller is not available in the cgroup hierarchy. One possible reason for this is that, in the running kernel, the controller simply doesn't exist -- for example, the CPU controller in cgroup v2 has only recently been merged and was out of tree until then. Another possibility is that the controller exists, but has been forcibly disabled by `cgroup_disable=` on the kernel command line. In future this will also support whatever comes out of issue #7624, `DefaultXAccounting=never`, or similar.
* Merge pull request #7665 from poettering/main-cleanupZbigniew Jędrzejewski-Szmek2017-12-182-227/+348
|\ | | | | let's split up main() into more functions, to make it digestable
| * main: add some more comments for the early initialization phaseLennart Poettering2017-12-151-4/+7
| |
| * main: reorder variable declarations a bitLennart Poettering2017-12-151-17/+10
| | | | | | | | | | Let's remove a bit redundancy, and list variables of the same type/category in one declaration line.
| * main: split out 'skip_setup' check into its own functionsLennart Poettering2017-12-151-11/+21
| | | | | | | | | | And let's optimize it a tiny bit, by only iterating through the argument list once, instead of twice.
| * main: do bother with uid_to_name() unless we do debug loggingLennart Poettering2017-12-151-4/+6
| |
| * main: conditionalize fixup_environment() internallyLennart Poettering2017-12-151-14/+16
| | | | | | | | | | | | | | | | | | This code is executed before we parse command line/configuration parameters, hence let's not use arg_system to figure our how to clean up things, but instead PID == 1. Let's move that check inside of the function, to make things a bit more robust abstract from the outside. Also, let's add a log message about this, that was so far missing.
| * main: let's move ACTION_RUN test into initialize_runtime()Lennart Poettering2017-12-151-8/+9
| | | | | | | | | | Let's hide this check inside the function and make it easier to follow the general control flow of main().
| * mount-setup: fix MNT_CHECK_WRITABLE error handling, and log about the issueLennart Poettering2017-12-151-5/+10
| | | | | | | | | | Let's correct the error handling (the error is in errno, not r), and let's add logging like the rest of the function has it.
| * main: tweak timerslack message a bitLennart Poettering2017-12-151-1/+1
| | | | | | | | | | Let's clarify that this is a non-issue, by downgrading it to LOG_WARN and saying "ignoring" in the message.
| * main: move install_crash_handler() and mount_cgroup_controllers() invocationsLennart Poettering2017-12-151-27/+27
| | | | | | | | | | | | | | | | | | | | | | | | Let's place them in initialize_runtime(), where they appear to fit best. Effectively this is just a move a little bit down, swapping places with log_execution_mode(), which should require neither call to be done first. Note that changes the conditionalization a bit for these calls, from (PID == 1) to (arg_system && arg_action == ACTION_RUN). At this point this is pretty much the same however, as we don't allow PID 1 without ACTION_RUN and without arg_system set, safety_checks() ensures that.
| * core: move arg_show_status fix-up into load_configuration()Lennart Poettering2017-12-151-3/+4
| | | | | | | | | | | | | | It's part of finalizing our runtime parameters, hence let's move this into load_configuration() after we loaded everything else. This is safe, since we don't use it between the location where it was and where we place it now yet.
| * main: split out code that sets up the console/terminal and stuffLennart Poettering2017-12-151-12/+19
| | | | | | | | More refactoring to make main() more digestable.
| * main: split out code that collects passed fdsLennart Poettering2017-12-151-10/+23
| | | | | | | | More refactoring to make main() more digestable
| * main: slight modernizations for status_welcome()Lennart Poettering2017-12-151-7/+7
| | | | | | | | | | There's no point in duplicating the complex parse_env_file() invocation, hence let's not do it.
| * main: let's move the arg_show_status check into status_welcome()Lennart Poettering2017-12-151-3/+4
| | | | | | | | | | It's kinda nice to hide this check inside of status_welcome() itself, so that it handles all this on its own.
| * main: slightly rearrange serialization fdset, and logging/console setupLennart Poettering2017-12-151-18/+15
| | | | | | | | | | Let's merge two if blocks, and move log_close()/log_open() out of the testing codepath, as there's no reason to have it there.
| * main: move chdir("/") a bit earlierLennart Poettering2017-12-151-3/+3
| | | | | | | | | | | | There's no need to do this within the block where logging is closed, hence move it earlier, so that this block can be kept as small as possible.
| * main: move initialize_join_controllers() invocation into load_configuration()Lennart Poettering2017-12-151-6/+6
| | | | | | | | | | | | | | | | This just sets up some variables the loaded configuration will then modify. Let's invoke it hence right before loading the configuration. This moves the initialization just a tiny bit later, but that shouldn't matter, since we never access it in-between.
| * main: split out taint string logging into its own functionLennart Poettering2017-12-151-11/+20
| | | | | | | | It's sufficiently complex now, let's add our own function for this too.
| * core: add more safety checkLennart Poettering2017-12-151-0/+19
| | | | | | | | | | | | | | | | Let's make sure that if we are PID 1 we are invoked in ACTION_RUN mode, and in arg_system mode, as well as the opposite. Everything else is untested and probably not worth supporting hence let's bail out early if people try anyway.
| * core: split out test summary output into its own functionLennart Poettering2017-12-151-5/+11
| | | | | | | | More refactoring to make main() shorter.
| * main: split out security policy loading into its own functionLennart Poettering2017-12-151-11/+43
| | | | | | | | More refactoring to make things more digestable.
| * main: invoke pager_open() only at one placeLennart Poettering2017-12-151-2/+1
| | | | | | | | Let's just move this up a few lines and unify the invocation.
| * core: split out various startup safety checks from main() into its own functionLennart Poettering2017-12-151-26/+37
| | | | | | | | | | No functional changes, just some refactoring to make main() more digestable.
| * main: split out all parsing of command line arguments/kernel ↵Lennart Poettering2017-12-151-30/+42
| | | | | | | | | | | | | | | | | | arguments/configuration files Let's shorten main() a bit, and split out everything that loads our configuration and runtime parameters into a function of its own. No changes in behaviour.
| * main: minor optimizationLennart Poettering2017-12-151-6/+4
| | | | | | | | Let's remove one memory allocation in the common path.
* | meson: libudev_core and udevadm should have LOG_REALM=LOG_REALM_UDEV (#7666)Franck Bui2017-12-161-0/+1
| | | | | | | | | | | | | | Otherwise, setting udev_log=debug in /etc/udev/udev.conf has no effects since systemd-udevd is built with LOG_REALM=LOG_REALM_UDEV. However using LOG_REALM_UDEV (for libudev_core) reveals another similar bug for udevadm which should also define LOG_REALM_UDEV.
* | Merge pull request #7661 from keszybz/slice-cleanupsLennart Poettering2017-12-1512-113/+162
|\ \ | |/ |/| Slice cleanups and systemd-mount --owner
| * generator: add helper function for writing unit filesZbigniew Jędrzejewski-Szmek2017-12-155-66/+73
| | | | | | | | | | It doesn't save too much, but it's a common pattern so I think it's worth to factor this out.
| * mount: add option to specify uid= and gid=Zbigniew Jędrzejewski-Szmek2017-12-151-3/+52
| | | | | | | | | | | | | | | | | | | | | | | | The kernel needs two numbers, but for the user it's most convenient to provide the user name and have that resolved to uid and gid. Right now the primary group of the specified user is always used. That's the most common case anyway. In the future we can extend the --owner option to allow a group after a colon. [I added this before realizing that this will not be enough to be used for user runtime directory. But this seems useful on its own, so I'm keeping this commit.]
| * logind: use free_and_replace in one spotZbigniew Jędrzejewski-Szmek2017-12-151-3/+1
| | | | | | | | No functional change.
| * tree-wide: use SPECIAL_ROOT_SLICEZbigniew Jędrzejewski-Szmek2017-12-154-17/+21
| |
| * core: reuse slice_build_parent_sliceZbigniew Jędrzejewski-Szmek2017-12-151-14/+8
| |
| * logind: fix misleading messageZbigniew Jędrzejewski-Szmek2017-12-151-1/+1
| | | | | | | | | | This message would also be emitted at boot for any user with linger enabled, so "logged in" is the wrong term to use.
| * logind: simplify one conditionalZbigniew Jędrzejewski-Szmek2017-12-151-9/+6
| | | | | | | | Don't bother with removing the directory if we didn't create it.
* | tree-wide: add DEBUG_LOGGING macro that checks whether debug logging is on ↵Lennart Poettering2017-12-1512-11/+13
| | | | | | | | | | | | | | (#7645) This makes things a bit easier to read I think, and also makes sure we always use the _unlikely_ wrapper around it, which so far we used sometimes and other times we didn't. Let's clean that up.
* | Merge pull request #7637 from yuwata/transient-pathLennart Poettering2017-12-155-8/+154
|\ \ | | | | | | core/path: implement transient path unit
| * | bus-unit-util: add path unit related optionsYu Watanabe2017-12-151-2/+16
| | |
| * | core/path: implement transient path unitYu Watanabe2017-12-153-1/+128
| | |
| * | core/dbus-timer: improve error messagesYu Watanabe2017-12-151-1/+3
| | |
| * | bus-unit-util: improve error messagesYu Watanabe2017-12-151-2/+7
| | |
| * | bus-unit-util: remove unnecessary oom checkYu Watanabe2017-12-151-2/+0
| |/ | | | | | | We cannot detect error by alloca().
* | Merge pull request #7631 from cgwalters/systemctl-offlineLennart Poettering2017-12-154-79/+126
|\ \ | | | | | | systemctl,verbs: Introduce SYSTEMCTL_OFFLINE environment variable
| * | verbs: Rename VERB_OFFLINE to VERB_ONLINE_ONLY, expand MUSTBEROOTColin Walters2017-12-144-77/+77
| | | | | | | | | | | | | | | | | | Followup to previous commit. Suggested by @poettering. Reindented the `verbs[]` tables to match the apparent previous whitespace rules (indent to one flag, allow multiple flags to overflow?).
| * | systemctl,verbs: Introduce SYSTEMD_OFFLINE environment variableColin Walters2017-12-143-3/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A lot of code references the `running_in_chroot()` function; while I didn't dig I'm pretty certain this arose to deal with situations like RPM package builds in `mock` - there we don't want the `%post`s to `systemctl start` for example. And actually this exact same use case arises for [rpm-ostree](https://github.com/projectatomic/rpm-ostree/) where we implement offline upgrades by default; the `%post`s are always run in a new chroot using [bwrap](https://github.com/projectatomic/bubblewrap). And here's the problem: bwrap creates proper mount roots, so it passes `running_in_chroot()`, and then if a script tries to do `systemctl start` we get: `System has not been booted with systemd as init system (PID 1)` but that's an *error*, unlike the `running_in_chroot()` case where we ignore. Further complicating things is there are real world RPM packages like `glusterfs` which end up invoking `systemctl start`. A while ago, the `SYSTEMD_IGNORE_CHROOT` environment variable was added for the inverse case of running in a chroot, but still wanting to use systemd as PID 1 (presumably some broken initramfs setups?). Let's introduce a `SYSTEMD_OFFLINE` environment variable for cases like mock/rpm-ostree so we can force on the "ignore everything except preset" logic. This way we'll still not start services even if mock switches to use nspawn or bwrap or something else that isn't a chroot. We also cleanly supercede the `SYSTEMD_IGNORE_CHROOT=1` which is now spelled `SYSTEMD_OFFLINE=0`. (Suggested by @poettering) Also I made things slightly nicer here and we now print the ignored operation.
* | | Merge pull request #7644 from poettering/memzeroLennart Poettering2017-12-152-2/+4
|\ \ \ | |_|/ |/| | add memzero()/zero() coccinelle scripts and use them
| * | udev-link-config: add missing OOM checkLennart Poettering2017-12-141-0/+2
| | |
| * | link-config: make initialization to -1 less weirdLennart Poettering2017-12-141-1/+1
| | | | | | | | | | | | | | | | | | | | | memset() is weird anyway, since it expects an "int" as second parameter, which it then uses as a byte, i.e. as uint8_t or something like that. But by passing -1 to it, things get particularly weird, as that relies on sign expansion to do the right thing.
| * | coccinelle: automatically rewrite memset() to zero() or memzero() where we canLennart Poettering2017-12-141-1/+1
| | | | | | | | | | | | | | | We are pretty good at this already, hence only a single case is actually found by this.