Commit graph

23592 commits

Author SHA1 Message Date
Michal Koutný d3340e6f95 analyze: Fix build without seccomp (#10899) 2018-11-24 02:40:32 +09:00
Evgeny Vereshchagin a4aa59bae2 tests: add a fuzzer for server_process_native_file 2018-11-23 17:29:59 +01:00
Thomas Haller 0e408b82b8 dhcp6-client: handle IAID with value zero
config_parse_iaid(), dhcp_identifier_set_iaid() and sd_dhcp6_client_set_iaid() all
allow for the IAID to be zero. Also, RFC 3315 makes no mention that zero
would be invalid.

However, client_ensure_iaid() would take an IAID of zero as a sign that
the values was unset. Fix that by keeping track whether IAID is
initialized.
2018-11-23 17:09:29 +01:00
Lennart Poettering acf2932711
Merge pull request #10887 from poettering/run-love
systemd-run: modernizations, some new switches and let's set $INVOCATION_ID
2018-11-23 16:00:16 +01:00
Lennart Poettering b8b6f32104 cgroup: when we unload a unit, also update all its parent's members mask
This way we can corectly ensure that when a unit that requires some
controller goes away, we propagate the removal of it all the way up, so
that the controller is turned off in all the parents too.
2018-11-23 13:41:37 +01:00
Lennart Poettering 5af8805872 cgroup: drastically simplify caching of cgroups members mask
Previously we tried to be smart: when a new unit appeared and it only
added controllers to the cgroup mask we'd update the cached members mask
in all parents by ORing in the controller flags in their cached values.
Unfortunately this was quite broken, as we missed some conditions when
this cache had to be reset (for example, when a unit got unloaded),
moreover the optimization doesn't work when a controller is removed
anyway (as in that case there's no other way for the parent to iterate
though all children if any other, remaining child unit still needs it).
Hence, let's simplify the logic substantially: instead of updating the
cache on the right events (which we didn't get right), let's simply
invalidate the cache, and generate it lazily when we encounter it later.
This should actually result in better behaviour as we don't have to
calculate the new members mask for a whole subtree whever we have the
suspicion something changed, but can delay it to the point where we
actually need the members mask.

This allows us to simplify things quite a bit, which is good, since
validating this cache for correctness is hard enough.

Fixes: #9512
2018-11-23 13:41:37 +01:00
Lennart Poettering 8a0d538815 cgroup: extend comment on what unit_release_cgroup() is for 2018-11-23 13:41:37 +01:00
Lennart Poettering 1fd3a10c38 cgroup: extend reasons when we realize the enable mask
After creating a cgroup we need to initialize its
"cgroup.subtree_control" file with the controllers its children want to
use. Currently we do so whenever the mkdir() on the cgroup succeeded,
i.e. when we know the cgroup is "fresh". Let's update the condition
slightly that we also do so when internally we assume a cgroup doesn't
exist yet, even if it already does (maybe left-over from a previous
run).

This shouldn't change anything IRL but make things a bit more robust.
2018-11-23 13:41:37 +01:00
Lennart Poettering d5095dcd30 cgroup: tighten call that detects whether we need to realize a unit's cgroup a bit, and comment why 2018-11-23 13:41:37 +01:00
Lennart Poettering 5a62e5e2ac cgroup: document what the various masks variables are used for 2018-11-23 13:41:37 +01:00
Lennart Poettering 67558d15ec cgroup: extend cg_mask_supported() comment a bit 2018-11-23 13:41:37 +01:00
Lennart Poettering 27c4ed790a cgroup: simplify check whether it makes sense to realize a cgroup 2018-11-23 13:41:37 +01:00
Lennart Poettering e00068e71f cgroup: in unit_invalidate_cgroup() actually modify invalidation mask
Previously this would manipulate the realization mask for invalidating
the realization. This is a bit ugly though as the realization mask's
primary purpose to is to reflect in which hierarchies a cgroup currently
exists, and it's probably a good idea to keep that in sync with
realities.

We nowadays have the an explicit fields for invalidating cgroup
controller information, the "cgroup_invalidated_mask", let's use this
one instead.

The effect is pretty much the same, as the main consumer of these masks
(unit_has_mask_realize()) checks both anyway.
2018-11-23 13:41:37 +01:00
Lennart Poettering 27adcc9737 cgroup: be more careful with which controllers we can enable/disable on a cgroup
This changes cg_enable_everywhere() to return which controllers are
enabled for the specified cgroup. This information is then used to
correctly track the enablement mask currently in effect for a unit.
Moreover, when we try to turn off a controller, and this works, then
this is indicates that the parent unit might succesfully turn it off
now, too as our unit might have kept it busy.

So far, when realizing cgroups, i.e. when syncing up the kernel
representation of relevant cgroups with our own idea we would strictly
work from the root to the leaves. This is generally a good approach, as
when controllers are enabled this has to happen in root-to-leaves order.
However, when controllers are disabled this has to happen in the
opposite order: in leaves-to-root order (this is because controllers can
only be enabled in a child if it is already enabled in the parent, and
if it shall be disabled in the parent then it has to be disabled in the
child first, otherwise it is considered busy when it is attempted to
remove it in the parent).

To make things complicated when invalidating a unit's cgroup membershup
systemd can actually turn off some controllers previously turned on at
the very same time as it turns on other controllers previously turned
off. In such a case we have to work up leaves-to-root *and*
root-to-leaves right after each other. With this patch this is
implemented: we still generally operate root-to-leaves, but as soon as
we noticed we successfully turned off a controller previously turned on
for a cgroup we'll re-enqueue the cgroup realization for all parents of
a unit, thus implementing leaves-to-root where necessary.
2018-11-23 13:41:37 +01:00
Zbigniew Jędrzejewski-Szmek e5e0a79623 pid1,sd-device: use PATH_STARTSWITH_SET more 2018-11-23 13:37:47 +01:00
Zbigniew Jędrzejewski-Szmek f5a9bd21b9 basic/path-util: add missing header
PATH_STARTSWITH_SET uses STRV_FOREACH...
2018-11-23 13:37:40 +01:00
Lennart Poettering 00f8eea8fc run: set $INVOCATION_ID for scope units
Services invoked by PID1 have $INVOCATION_ID initialized, hence let's do
that for scope units (where the payload process is invoked by us on the
client side) too, to minimize needless differences.

Fixes: #8082
2018-11-23 12:49:00 +01:00
Lennart Poettering 0565120f00 run: port to static destructors 2018-11-23 12:49:00 +01:00
Lennart Poettering ef08ad7aa8 run: port to DEFINE_MAIN_FUNCTION() 2018-11-23 12:49:00 +01:00
Lennart Poettering badd28e158 run: add new --shell switch for spawning a shell as service
I keep running "systemd-run -t /bin/bash" to quickly get a shell running
in service context. I suspect I am not the only one, hence let's add a
shortcut for it. While we are at it, let's make it smarter, and
automatically inherit the $SHELL of the invoking user as well as the
working directory, and let's imply --pty. --shell (or -S) is hence
equivalent to "-t -d $SHELL".
2018-11-23 12:49:00 +01:00
Lennart Poettering 2d21165a4e run: add a switch for specifiying the working directory of a service
I find myself testing service management quite often with "systemd-run
-t /bin/bash". For that it is handy if the invoked shell would use the
working directory I am currently in. Hence introduce a shorthand for
that:

        $ systemd-run -dt /bin/bash

This will automatically insert a WorkingDirectory= property into the
transient service, pointing to the working directory of the caller.
2018-11-23 12:49:00 +01:00
Lennart Poettering 94f344fb03 cgroup: tweak log message, so that it doesn't claim we always enable controllers when we actually disable them 2018-11-23 12:24:37 +01:00
Lennart Poettering 54b5ba1d1f cgroup: propagate errors when we cannot open cgroup.subtree_control 2018-11-23 12:24:37 +01:00
Lennart Poettering 26a17ca280 cgroup: add explanatory comment 2018-11-23 12:24:37 +01:00
Lennart Poettering 442ce7759c cgroup: units that aren't loaded properly should not result in cgroup controllers being pulled in
This shouldn't make much difference in real life, but is a bit cleaner.
2018-11-23 12:24:37 +01:00
Lennart Poettering 0adf88b68c cgroup: dump delegation mask too 2018-11-23 12:24:37 +01:00
Lennart Poettering 1649244588 cgroup: make unit_get_needs_bpf_firewall() static too 2018-11-23 12:24:37 +01:00
Lennart Poettering 53aea74a60 cgroup: make some functions static 2018-11-23 12:24:37 +01:00
Lennart Poettering 52fecf20b9 cgroup: fine tune when to apply cgroup attributes to the root cgroup
Let's tweak when precisely to apply cgroup attributes on the root
cgroup.

With this we now follow the following rules:

1. On cgroupsv2 we never apply any regular cgroups to the host root,
   since the attributes generally do not exist there.

2. On cgroupsv1 we do not apply any "weight" or "shares" style
   attributes to the host root cgroup, since they don't make much sense
   on the top level where there's only one group, hence no need to
   compare weights against each other. The other attributes are applied
   to the host root cgroup however.

3. In any case we don't apply attributes to the root of container
   environments (and --user roots), under the assumption that this is
   managed by the manager further up. (Note that on cgroupsv2 this is
   even enforced by the kernel)

4. BPF pseudo-attributes are applied in all cases (since we can have as
   many of them as we want)
2018-11-23 12:24:37 +01:00
Lennart Poettering 589a5f7a38 cgroup: append \n to static strings we write to cgroup attributes
This is a bit cleaner since we when we format numeric limits we append
it. And this way write_string_file() doesn't have to append it.
2018-11-23 12:24:37 +01:00
Lennart Poettering 28cfdc5aeb cgroup: tighten manager_owns_host_root_cgroup() a bit
This tightening is not strictly necessary (as the m->cgroup_root check
further down does the same), but let's make this explicit.
2018-11-23 12:24:37 +01:00
Lennart Poettering 611c4f8afb cgroup: rename {manager_owns|unit_has}_root_cgroup() → .._host_root_cgroup()
Let's emphasize that this function checks for the host root cgroup, i.e.
returns false for the root cgroup when we run in a container where
CLONE_NEWCGROUP is used. There has been some confusion around this
already, for example cgroup_context_apply() uses the function
incorrectly (which we'll fix in a later commit).

Just some refactoring, not change in behaviour.
2018-11-23 12:24:37 +01:00
Lennart Poettering 293d32df39 cgroup: add a common routine for writing to attributes, and logging about it
We can use this at quite a few places, and this allows us to shorten our
code quite a bit.
2018-11-23 12:24:37 +01:00
Lennart Poettering 39b9fefb2e cgroup: add a new macro for determining log level for cgroup attr write failures
For now, let's use it only at one place, but a follow-up commit will
make more use of it.
2018-11-23 12:24:37 +01:00
Lennart Poettering 2c74e12bb3 cgroup: ignore EPERM for a couple of more attribute writes 2018-11-23 12:24:37 +01:00
Lennart Poettering 8c83840772 cgroup: add comment explaining why we ignore EINVAL at two places
These are just copies from further down.
2018-11-23 12:24:37 +01:00
Lennart Poettering 73fe5314bf cgroup: suffix settings with "=" in log messages where appropriate 2018-11-23 12:24:37 +01:00
Lennart Poettering a0c339ed4b cgroup: only install cgroup release agent when we own the root cgroup
If we run in a container we shouldn't patch around this, and most likely
we can't anyway, and there's not much point in complaining about this.
Hence let's strictly say: the agent is private property of the host's
system instance, nothing else.
2018-11-23 12:24:37 +01:00
Lennart Poettering de8a711a58 cgroup: use structured initialization 2018-11-23 12:24:37 +01:00
Zbigniew Jędrzejewski-Szmek 527ead383d libudev: drop unnecessary check
sd_device_get_subsystem returns -ENOENT if subsystem is not set.
2018-11-23 09:16:11 +01:00
Zbigniew Jędrzejewski-Szmek 91540eaa5c
Merge pull request #10861 from yuwata/udev-list-cleanups
libudev: several cleanups for udev-list
2018-11-23 09:12:56 +01:00
Zbigniew Jędrzejewski-Szmek 7f22ad1083
Merge pull request #10886 from yuwata/sd-device-monitor-fix-filter
sd-device: fix subsystem filter
2018-11-23 08:53:33 +01:00
Lennart Poettering 00e7b3c8e5 unit: minor optimization, use stack over heap, when we can 2018-11-23 00:46:56 +01:00
Lennart Poettering 50111496dd
Merge pull request #10891 from yuwata/use-main-macro-2
tree-wide: use recently introduced macros
2018-11-23 00:46:02 +01:00
Lennart Poettering 27da878e7e unit: drop an unused fields from Unit struct 2018-11-23 00:37:00 +01:00
Yu Watanabe a5a59a2447 test: add more tests for subsystem filter 2018-11-23 06:46:29 +09:00
Lennart Poettering 66fa4bdd70 core: add two minor comments (#10890) 2018-11-23 06:25:27 +09:00
Yu Watanabe c6f09e6a2d locale: define main through macro 2018-11-23 06:22:30 +09:00
Yu Watanabe af7865c1b7 locale: store polkit_registry in Context 2018-11-23 06:22:30 +09:00
Yu Watanabe 6804d7a849 locale: rename context_free() to context_clear() 2018-11-23 06:22:30 +09:00
Yu Watanabe f6aa61909e resolvectl: use static destructor and define main through macro 2018-11-23 06:22:30 +09:00
Yu Watanabe 7a83c3aee0 rfkill: define main through macro 2018-11-23 06:22:30 +09:00
Yu Watanabe 5f5f0afc8b rfkill: store write queue and rfkill fd in struct Context 2018-11-23 06:22:30 +09:00
Yu Watanabe a160567e20 socket-proxy: define main through macro 2018-11-23 06:22:30 +09:00
Yu Watanabe dd2fd972b7 sysusers: use ordered_hashmap_steal_first_key_and_value() 2018-11-23 06:22:30 +09:00
Yu Watanabe 1d03c5c16f time-wait: define main through macro 2018-11-23 06:22:30 +09:00
Yu Watanabe 1f47bc3349 timedate: define main through macro 2018-11-23 06:22:30 +09:00
Yu Watanabe fd1bff7db5 update-done: quit earlier on failure 2018-11-23 06:22:30 +09:00
Yu Watanabe 3664cbabdd update-utmp: use _cleanup_ attribute to finalize process 2018-11-23 06:22:30 +09:00
Yu Watanabe d850ad9a30 veritysetup-generator: use static destructors and define main through macro 2018-11-23 06:22:30 +09:00
Yu Watanabe 2cb52121e5 veritysetup-generator: make arg_dest const 2018-11-23 06:22:30 +09:00
Yu Watanabe 6b9306b29c veritysetup: use static destructors and define main through macro
This also changes the return value when crypt_init_by_name() fails in 'detach'.
2018-11-23 06:22:30 +09:00
Evgeny Vereshchagin 4928e8adba tests: add a fuzzer for catalog_import_file 2018-11-22 21:02:34 +01:00
Yu Watanabe 65fe9c319f sd-device-monitor: fix subsystem filter
This fixes a bug introduced by 759d9f3f8d.

Fixes #10882.
2018-11-23 02:49:28 +09:00
Yu Watanabe 8c19dc54d3 udev-rules: update log messages 2018-11-23 01:15:42 +09:00
Yu Watanabe d6601495be meson: also add option for debugging siphash 2018-11-23 00:36:35 +09:00
Yu Watanabe 20e97dd3de meson: add option for debugging udev 2018-11-23 00:28:27 +09:00
Yu Watanabe 67e4b38563 udev-rules: trivial coding style cleanups 2018-11-23 00:22:09 +09:00
Yu Watanabe 981fae90df udev: rename udev_rules_unref() to udev_rules_free()
As udev_rules do not have a reference counter.
2018-11-23 00:07:40 +09:00
Yu Watanabe 3f14e7217a libudev: do not ignore error in udev_list_entry_add() 2018-11-22 23:50:02 +09:00
Yu Watanabe fd05c424c0 libudev: introduce return_with_errno() and use it where applicable 2018-11-22 23:49:55 +09:00
Yu Watanabe 6f9fe58189 test: add tests for libudev-list 2018-11-22 23:42:07 +09:00
Yu Watanabe f349626bed libudev-list: drop unused udev argument from udev_list_init() 2018-11-22 23:19:25 +09:00
Yu Watanabe 876affad43 libudev-list: drop unused private functions 2018-11-22 23:19:17 +09:00
Yu Watanabe 03b35f8775
Merge pull request #10871 from keszybz/more-cleanup-2
Allow "synthetic" errno to be used in log calls
2018-11-22 23:16:43 +09:00
Lennart Poettering ca64ce4ad8 sysctl: when debug logging about sysctl changes, truncate trailing newline 2018-11-22 11:45:37 +01:00
Zbigniew Jędrzejewski-Szmek 5dc881a359 basic/log: add note about operator precendence 2018-11-22 10:56:43 +01:00
Zbigniew Jędrzejewski-Szmek d4e98880e9 Also drop a few more unnecessary uses of synthethic errno 2018-11-22 10:54:38 +01:00
Zbigniew Jędrzejewski-Szmek 886cf317c4 coccinelle: also mark previous synthetic errnos as such 2018-11-22 10:54:38 +01:00
Zbigniew Jędrzejewski-Szmek baaa35ad70 coccinelle: make use of SYNTHETIC_ERRNO
Ideally, coccinelle would strip unnecessary braces too. But I do not see any
option in coccinelle for this, so instead, I edited the patch text using
search&replace to remove the braces. Unfortunately this is not fully automatic,
in particular it didn't deal well with if-else-if-else blocks and ifdefs, so
there is an increased likelikehood be some bugs in such spots.

I also removed part of the patch that coccinelle generated for udev, where we
returns -1 for failure. This should be fixed independently.
2018-11-22 10:54:38 +01:00
Zbigniew Jędrzejewski-Szmek 52d86690d6 basic/log: add concept of "synthethic errnos"
Synthetic errnos are processed like normal, and may be used in %m and become
the return value from log_*(), but they are not logged in the journal.
2018-11-22 10:45:08 +01:00
Tim Ruffing 883eb9be98 vconsole: Don't skip udev call for dummy device
Kernel 4.19 supports deferred console takeover [0], i.e., fbcon will
take over the console only when the first text is displayed on the
console. Before that event, only the dummy console is active. Our
currently udev rules call systemd-vconsole on every vtcon except for
dummy consoles. Thus the exception for dummy consoles prevents a call
to systemd-vconsole when no text is displayed on the console, and as a
consequence, the keymap will not be set in that case. This is wrong and
leads to issues when keyboard input is expected without text on the
console, e.g., when a graphical password prompt is used in the boot
process.

This reverts commit 6b169c13ec,
which introduced the exception for dummy devices to save unnecessary
udev calls.

Fixes #10826.

[0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=83d83bebf40132e2d55ec58af666713cc76f9764
2018-11-22 00:59:24 +01:00
Yann E. MORIN 66a5b5ce9b basic/user-util: properly protect use of gshadow
Commit 100d5f6ee6 (user-util: add new wrappers for [...] database
files), ammended by commit 4f07ffa8f5 (Use #if instead of #ifdef for
ENABLE_GSHADOW) moved code from sysuser to basic/user-util.

In doing so, the combination of both commits properly propagated the
ENABLE_GSHADOW conditions around the function manipulating gshadow, but
they forgot to protect the inclusion of the gshadow.h header.

Fix that to be able to build on C libraries that do not provide gshadow
(e.g. uClibc-ng, where it does not exist.)
2018-11-22 00:57:08 +01:00
Lennart Poettering 9d52a6e5a9
Merge pull request #9961 from fbuihuu/logind-fix-vt-reinit-race
Logind fix vt reinit race
2018-11-21 17:28:23 +01:00
Zbigniew Jędrzejewski-Szmek 6d176522f5 Revert 5fdf2d51c2
This reverts 5fdf2d51c2, except for one improved
log message.

Fixes #10613.

Checking if resume= is configured is a good idea, but it turns out we cannot do
it reliably:
- the code only supported boot options with sd-boot, and it's not very widely
  used. This means that for most systemd we could only check the current
  commandline, not the next one.
- Various systems resume without, e.g. Debian has
  /etc/initramfs-tools/conf.d/resume in the initramfs.

Making those checks better would be possible with enough effort, but there'll
be always new systems that boot in a slightly different way and we would need
to keep adding new cases. Longer term, we want to rely on autodetecting the
resume partition, and then checks like this will not be necessary at all. It is
quite clear from the number of bug reports that the number of poeple impacted
by this is quite high now, so let's just drop this.
2018-11-21 15:04:22 +01:00
Franck Bui adb8688b3f logind: stop managing VT switches if no sessions are registered on that VT
When no sessions are registered on a given VT (anymore), we should always let
the kernel processes VT switching (instead of simply emitting a warning)
otherwise the requests sent by the kernel are simply ignored making the VT
switch requested by users simply impossible.

Even if it shouldn't happen, this case was encountered in issue #9754, so
better to be safe than sorry.
2018-11-21 14:29:01 +01:00
Franck Bui 27dafac92b terminal-util: introduce vt_release() helper 2018-11-21 14:28:34 +01:00
Franck Bui ad96887a12 logind: become the controlling terminal process before restoring VT
Basically when a session ends, logind notices and restores VT_AUTO so the
kernel takes back VT-switching over.

logind achieves that by watching the process that took control of the session
(via the "TakeControl" D-Bus method), aka "the watched process", which can
be different from the one that initially opened the VT aka "the terminal
controlling process".

In this case the terminal controlling process can exit after the watched one
did and while logind is restoring the VT.

Even if logind took care to re-open the VT in case the VT was already in HUP
state, it wasn't enough because the terminal controlling process could have
exited right after, leaving the VT in HUP state and in VT_PROCESS mode making
further VT-switching impossible.

This patch fixes this situation by forcing logind to become the terminal
controlling process.

Fixes: #9754.
2018-11-21 14:25:10 +01:00
Franck Bui 6179ede1c5 terminal-util: introduce vt_restore() helper 2018-11-21 14:25:10 +01:00
Franck Bui 0212126c45 logind: make session_restore_vt() static
It's only used in logind-session.c.
2018-11-21 14:20:01 +01:00
Zbigniew Jędrzejewski-Szmek 053254e3cb generators: drop umask calls
systemd already sets the umask (see e3b8d0637d). When
running under systemd, we don't need to set it. And when *not* running under
systemd, for example during development, there is no reason to override the user
config. Let's just drop those calls.

$ git grep -e 'umask\(' -l 'src/*generator*' |xargs perl -i -0pe 's|^[^\n]*umask\([^\n]+\n\n||gms'
2018-11-21 13:40:24 +01:00
Michal Koutný aa1f95d264 core: Detect initial timer state from serialized data
We keep a mark whether a single-shot timer was triggered in the caller's
variable initial. When such a timer elapses while we are
serializing/deserializing the inner state, we consider the timer
incorrectly as elapsed and don't trigger it later.

This patch exploits last_trigger timestamp that we already serialize,
hence we can eliminate the argument initial completely.

A reproducer for OnBootSec= timers:
        cat >repro.c <<EOD
        /*
         * Compile:	gcc repro.c -o repro
         * Run:		./repro
         */
        #include <errno.h>
        #include <fcntl.h>
        #include <stdio.h>
        #include <stdlib.h>
        #include <sys/stat.h>
        #include <sys/types.h>
        #include <time.h>
        #include <unistd.h>

        int main(int argc, char *argv[]) {
        	char command[1024];
        	int pause;

        	struct timespec now;

        	while (1) {
        		usleep(rand() % 200000); // prevent periodic repeats
               		clock_gettime(CLOCK_MONOTONIC, &now);
        		printf("%i\n", now.tv_sec);

        		system("rm -f $PWD/mark");
        		snprintf(command, 1024, "systemd-run --user --on-boot=%i --timer-property=AccuracySec=100ms "
        					"touch $PWD/mark", now.tv_sec + 1);
        		system(command);
        		system("systemctl --user list-timers");
        		pause = (1000000000 - now.tv_nsec)/1000 - 70000; // fiddle to hit the middle of reloading
        		usleep(pause > 0 ? pause : 0);
        		system("systemctl --user daemon-reload");
        		sync();
        		sleep(2);
        		if (open("./mark", 0) < 0)
        			if (errno == ENOENT) {
        				printf("mark file does not exist\n");
        				break;
        			}
        	}

        	return 0;
        }
        EOD
2018-11-21 11:28:33 +01:00
Lennart Poettering b390455cbb
Merge pull request #10866 from yuwata/libudev-util-cleanups
libudev-util: several cleanups and tests
2018-11-21 11:15:35 +01:00
Lennart Poettering 818623aca5
Merge pull request #10860 from keszybz/more-cleanup-2
Do more stuff from main macros
2018-11-21 11:07:31 +01:00
Yu Watanabe 4ec739f19f test: add tests for util_resolve_subsys_kernel() 2018-11-21 17:31:22 +09:00
Yu Watanabe 3839535a53 libudev: make util_resolve_subsys_kernel() return negative errno
This also replaces udev_device by sd_device in the function.
2018-11-21 17:31:16 +09:00
Yu Watanabe c0c591544a udev/scsi_id: fix buffer length 2018-11-21 17:30:49 +09:00
Yu Watanabe 01cbafe184 test: add tests for util_replace_whitespace() 2018-11-21 17:30:49 +09:00
Yu Watanabe df8ba4fa0e libudev-util: make util_replace_whitespace() not count leading white spaces 2018-11-21 17:30:45 +09:00
Zbigniew Jędrzejewski-Szmek 0c5a109a25 udevd: define main through macro
This removes the call to log_close(), and refactors how fork() is done. Now
the parent also goes through normal cleanup. This isn't necessary to use the
macro, but it feels cleaner this way.
2018-11-21 09:14:00 +01:00
Zbigniew Jędrzejewski-Szmek 138715dc12 udevadm: define main through macro
This removes a call to log_close(). I don't think this should matter.
The call to mac_selinux_init() is moved after parse_argv(). We probably
don't need selinux when printing help().
2018-11-21 09:14:00 +01:00
Zbigniew Jędrzejewski-Szmek 8d38b8ad56 Call mac_selinux_close() from main func macros, convert user-sessions and test-udev 2018-11-21 09:14:00 +01:00
Zbigniew Jędrzejewski-Szmek d1405af399 systemctl: define main through macro and call ask_password_agent_close() from the macro
This doesn't save us anything, but I like consistency.
2018-11-21 09:14:00 +01:00
Yu Watanabe 646acebd58 libudev-util: make util_replace_*() return size_t 2018-11-21 16:35:20 +09:00
Yu Watanabe 805a7097ee libudev-util: add assertions 2018-11-21 16:32:54 +09:00
Lennart Poettering e3b8d0637d core: run env generators with non-zero umask
For PID 1 we adjust the umask to 0, but generators should not run that
way, given that they might be implemented as shell scripts and such.
Let's hence explicitly adjust the umask for them.

We already do this for unit generators. Let's do this for env
generators, too.
2018-11-20 23:35:04 +01:00
Evgeny Vereshchagin f5f9a580dd tests: skip test_exec_ambientcapabilities on Travis CI under ASan
Let's not bother contributors with spurious failures nobody can't
seem to reproduce. There is an issue about that where we're trying
to figure out what's going on: https://github.com/systemd/systemd/issues/10696.
2018-11-20 20:23:19 +01:00
Lennart Poettering f81f8bac2c
Merge pull request #10853 from poettering/thaw-containers
main: don't freeze PID 1 in containers, exit with non-zero instead
2018-11-20 19:35:30 +01:00
Yu Watanabe 0c760322a4 portablectl: make "arg_host" const 2018-11-20 18:40:02 +01:00
Yu Watanabe f2fae6fbae mount-tool: use static destructor and DEFINE_MAIN_FUNCTION() macro 2018-11-20 18:40:02 +01:00
Yu Watanabe c3d6fb26ed modules-load: use static destructor and DEFINE_MAIN_FUNCTION() macro 2018-11-20 18:40:02 +01:00
Yu Watanabe f66da783fa machinectl: use static destructor and DEFINE_MAIN_FUNCTION() macro 2018-11-20 18:40:02 +01:00
Zbigniew Jędrzejewski-Szmek a6db316372 shared/main-func: also close the polkit agent automatically
The agent is closed after the static destuctors but before the pager.
No users of DEFINE_MAIN_FUNCTION* were using a polkit agent, so this makes no
functional difference.
2018-11-20 18:40:02 +01:00
Zbigniew Jędrzejewski-Szmek 294bf0c34a Split out pretty-print.c and move pager.c and main-func.h to shared/
This is high-level functionality, and fits better in shared/ (which is for
our executables), than in basic/ (which is also for libraries).
2018-11-20 18:40:02 +01:00
Yu Watanabe 0166c42868 machine-id: use static destructor and DEFINE_MAIN_FUNCTION() macro 2018-11-20 18:40:02 +01:00
Yu Watanabe eae5c847f8 loginctl: use static destructor and DEFINE_MAIN_FUNCTION() macro 2018-11-20 18:40:02 +01:00
Yu Watanabe 847da1ac1b locale: make "arg_host" const 2018-11-20 18:40:02 +01:00
Yu Watanabe 85ae63ee87 hostnamed: use DEFINE_MAIN_FUNCTION() macro
This also renames context_free() to context_clear().
2018-11-20 18:40:02 +01:00
Yu Watanabe 77182cc65e hibernate-resume-generator: use static destructor and DEFINE_MAIN_FUNCTION() macro 2018-11-20 18:40:02 +01:00
Yu Watanabe a4ef3e4dbb fstab-generator: use static destructor and DEFINE_MAIN_FUNCTION() macro 2018-11-20 18:40:02 +01:00
Yu Watanabe 45f394187a firstboot: use static destructor and DEFINE_MAIN_FUNCTION() macro 2018-11-20 18:40:02 +01:00
Yu Watanabe 149afb45dc dissect: use static destructor and DEFINE_MAIN_FUNCTION() macro 2018-11-20 18:40:02 +01:00
Yu Watanabe a8a7e5fcf2 bless-boot: use static destructor and DEFINE_MAIN_FUNCTION() macro 2018-11-20 18:40:02 +01:00
Yu Watanabe 3a40f366b2 cryptsetup: use static destructor and DEFINE_MAIN_FUNCTION() macro 2018-11-20 18:40:02 +01:00
Yu Watanabe 88325bf6e5 cgls: use static destructor and DEFINE_MAIN_FUNCTION() macro 2018-11-20 18:40:02 +01:00
Lennart Poettering bb25977244 main: don't freeze PID 1 in containers, exit with non-zero instead
After all we have a nice way to propagate total failures, hence let's
use it.
2018-11-20 17:04:07 +01:00
Lennart Poettering bb85a58208 main: use EXIT_EXCEPTION instead of EXIT_FAILURE at two more exceptional places 2018-11-20 17:04:07 +01:00
Lennart Poettering f2fb2ec942 nspawn: use EXIT_EXCEPTION where appropriate 2018-11-20 17:04:07 +01:00
Lennart Poettering 3584d3ca4f exit-status: introduce EXIT_EXCEPTION mapping to 255 2018-11-20 17:04:07 +01:00
Yu Watanabe 2428944eb0 cgls: add const 2018-11-20 16:48:21 +01:00
Yu Watanabe 360f3dc275 busctl: use static destructor and DEFINE_MAIN_FUNCTION() macro 2018-11-20 16:48:21 +01:00
Yu Watanabe 608f8ec92e bootctl: use static destructor and DEFINE_MAIN_FUNCTION() macro 2018-11-20 16:48:21 +01:00
Yu Watanabe 1ddae15a4e backlight: use DEFINE_MAIN_FUNCTION() macro 2018-11-20 16:48:21 +01:00
Yu Watanabe c7d7adf5eb ask-password: use static destructor and DEFINE_MAIN_FUNCTION() macro 2018-11-20 16:48:21 +01:00
Yu Watanabe d665c7b2db analyze: use static destructors 2018-11-20 16:48:21 +01:00
Zbigniew Jędrzejewski-Szmek 3be1cabe98 binfmt: define main through macro 2018-11-20 16:48:21 +01:00
Zbigniew Jędrzejewski-Szmek 7280b07627 delta: define main through macro 2018-11-20 16:48:21 +01:00
Zbigniew Jędrzejewski-Szmek 4e2ca44233 networkctl: define main through macro 2018-11-20 16:48:21 +01:00
Zbigniew Jędrzejewski-Szmek c55a594ef2 portablectl: define main through macro 2018-11-20 16:48:21 +01:00
Zbigniew Jędrzejewski-Szmek 39daad0a81 localectl: define main through macro 2018-11-20 16:48:21 +01:00
Zbigniew Jędrzejewski-Szmek 7add4883cb coredumpctl: fix "leak" of bus connection
$ valgrind --show-leak-kinds=all --leak-check=full build/coredumpctl dump --output /tmp/ff
...
==16431== HEAP SUMMARY:
==16431==     in use at exit: 3,680 bytes in 13 blocks
==16431==   total heap usage: 831 allocs, 818 frees, 197,776 bytes allocated
==16431==
==16431== 2 bytes in 1 blocks are still reachable in loss record 1 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x4C4D5AD: strdup (strdup.c:42)
==16431==    by 0x49B2387: bus_message_parse_fields (bus-message.c:5300)
==16431==    by 0x49A23AF: bus_message_from_malloc (bus-message.c:560)
==16431==    by 0x49C459B: bus_socket_make_message (bus-socket.c:1099)
==16431==    by 0x49C4C5B: bus_socket_read_message (bus-socket.c:1213)
==16431==    by 0x49CE4CE: bus_read_message (sd-bus.c:1777)
==16431==    by 0x49CFA2C: sd_bus_call (sd-bus.c:2176)
==16431==    by 0x1105F3: check_units_active (coredumpctl.c:1029)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==    by 0x110A45: main (coredumpctl.c:1100)
==16431==
==16431== 9 bytes in 1 blocks are still reachable in loss record 2 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x4939067: malloc_multiply (alloc-util.h:78)
==16431==    by 0x493921D: hexmem (hexdecoct.c:62)
==16431==    by 0x49C2B75: bus_socket_start_auth_client (bus-socket.c:626)
==16431==    by 0x49C2D78: bus_socket_start_auth (bus-socket.c:665)
==16431==    by 0x49C3B09: bus_socket_connect (bus-socket.c:915)
==16431==    by 0x49CBB08: bus_start_address (sd-bus.c:1103)
==16431==    by 0x49CBFEA: sd_bus_start (sd-bus.c:1187)
==16431==    by 0x49CC452: sd_bus_open_system_with_description (sd-bus.c:1294)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==
==16431== 9 bytes in 1 blocks are still reachable in loss record 3 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x4C4D5AD: strdup (strdup.c:42)
==16431==    by 0x497364E: free_and_strdup (string-util.c:1013)
==16431==    by 0x49C9FB1: hello_callback (sd-bus.c:547)
==16431==    by 0x49D0A3A: process_reply (sd-bus.c:2498)
==16431==    by 0x49D13E0: process_message (sd-bus.c:2677)
==16431==    by 0x49D165F: process_running (sd-bus.c:2739)
==16431==    by 0x49D20DD: bus_process_internal (sd-bus.c:2957)
==16431==    by 0x49D21E8: sd_bus_process (sd-bus.c:2984)
==16431==    by 0x49CF21E: bus_ensure_running (sd-bus.c:2053)
==16431==    by 0x49CF51F: sd_bus_call (sd-bus.c:2095)
==16431==    by 0x1105F3: check_units_active (coredumpctl.c:1029)
==16431==
==16431== 24 bytes in 1 blocks are still reachable in loss record 4 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x495CB0D: malloc_multiply (alloc-util.h:78)
==16431==    by 0x495CB2A: prioq_new (prioq.c:35)
==16431==    by 0x495CC02: prioq_ensure_allocated (prioq.c:60)
==16431==    by 0x49CEF84: sd_bus_call_async (sd-bus.c:1995)
==16431==    by 0x49CA0E6: bus_send_hello (sd-bus.c:581)
==16431==    by 0x49CC019: sd_bus_start (sd-bus.c:1196)
==16431==    by 0x49CC452: sd_bus_open_system_with_description (sd-bus.c:1294)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==
==16431== 38 bytes in 1 blocks are still reachable in loss record 5 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x4C4D5AD: strdup (strdup.c:42)
==16431==    by 0x497364E: free_and_strdup (string-util.c:1013)
==16431==    by 0x49C7F97: sd_bus_set_address (sd-bus.c:269)
==16431==    by 0x49CC314: bus_set_address_system (sd-bus.c:1262)
==16431==    by 0x49CC3E0: sd_bus_open_system_with_description (sd-bus.c:1281)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==    by 0x110A45: main (coredumpctl.c:1100)
==16431==
==16431== 64 bytes in 1 blocks are still reachable in loss record 6 of 13
==16431==    at 0x4838748: malloc (vg_replace_malloc.c:298)
==16431==    by 0x483AD63: realloc (vg_replace_malloc.c:826)
==16431==    by 0x4902663: greedy_realloc (alloc-util.c:55)
==16431==    by 0x49C7D7D: sd_bus_new (sd-bus.c:255)
==16431==    by 0x49CC398: sd_bus_open_system_with_description (sd-bus.c:1271)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==    by 0x110A45: main (coredumpctl.c:1100)
==16431==
==16431== 64 bytes in 1 blocks are still reachable in loss record 7 of 13
==16431==    at 0x4838748: malloc (vg_replace_malloc.c:298)
==16431==    by 0x483AD63: realloc (vg_replace_malloc.c:826)
==16431==    by 0x4902663: greedy_realloc (alloc-util.c:55)
==16431==    by 0x49CE54E: bus_rqueue_make_room (sd-bus.c:1786)
==16431==    by 0x49C44FC: bus_socket_make_message (bus-socket.c:1087)
==16431==    by 0x49C4C5B: bus_socket_read_message (bus-socket.c:1213)
==16431==    by 0x49CE4CE: bus_read_message (sd-bus.c:1777)
==16431==    by 0x49CE6AF: dispatch_rqueue (sd-bus.c:1814)
==16431==    by 0x49D162E: process_running (sd-bus.c:2733)
==16431==    by 0x49D20DD: bus_process_internal (sd-bus.c:2957)
==16431==    by 0x49D21E8: sd_bus_process (sd-bus.c:2984)
==16431==    by 0x49CF21E: bus_ensure_running (sd-bus.c:2053)
==16431==
==16431== 65 bytes in 1 blocks are still reachable in loss record 8 of 13
==16431==    at 0x483AB1A: calloc (vg_replace_malloc.c:752)
==16431==    by 0x496E5D6: getpeersec (socket-util.c:969)
==16431==    by 0x49C291C: bus_get_peercred (bus-socket.c:594)
==16431==    by 0x49C2CB2: bus_socket_start_auth (bus-socket.c:650)
==16431==    by 0x49C3B09: bus_socket_connect (bus-socket.c:915)
==16431==    by 0x49CBB08: bus_start_address (sd-bus.c:1103)
==16431==    by 0x49CBFEA: sd_bus_start (sd-bus.c:1187)
==16431==    by 0x49CC452: sd_bus_open_system_with_description (sd-bus.c:1294)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==
==16431== 181 bytes in 1 blocks are still reachable in loss record 9 of 13
==16431==    at 0x483AD19: realloc (vg_replace_malloc.c:826)
==16431==    by 0x49C4791: bus_socket_read_message (bus-socket.c:1143)
==16431==    by 0x49CE4CE: bus_read_message (sd-bus.c:1777)
==16431==    by 0x49CFA2C: sd_bus_call (sd-bus.c:2176)
==16431==    by 0x1105F3: check_units_active (coredumpctl.c:1029)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==    by 0x110A45: main (coredumpctl.c:1100)
==16431==
==16431== 256 bytes in 1 blocks are still reachable in loss record 10 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x496E740: getpeergroups (socket-util.c:998)
==16431==    by 0x49C29BD: bus_get_peercred (bus-socket.c:599)
==16431==    by 0x49C2CB2: bus_socket_start_auth (bus-socket.c:650)
==16431==    by 0x49C3B09: bus_socket_connect (bus-socket.c:915)
==16431==    by 0x49CBB08: bus_start_address (sd-bus.c:1103)
==16431==    by 0x49CBFEA: sd_bus_start (sd-bus.c:1187)
==16431==    by 0x49CC452: sd_bus_open_system_with_description (sd-bus.c:1294)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==
==16431== 256 bytes in 1 blocks are still reachable in loss record 11 of 13
==16431==    at 0x4838748: malloc (vg_replace_malloc.c:298)
==16431==    by 0x483AD63: realloc (vg_replace_malloc.c:826)
==16431==    by 0x495D1A0: prioq_put (prioq.c:162)
==16431==    by 0x49CF0EA: sd_bus_call_async (sd-bus.c:2023)
==16431==    by 0x49CA0E6: bus_send_hello (sd-bus.c:581)
==16431==    by 0x49CC019: sd_bus_start (sd-bus.c:1196)
==16431==    by 0x49CC452: sd_bus_open_system_with_description (sd-bus.c:1294)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==
==16431== 856 bytes in 1 blocks are still reachable in loss record 12 of 13
==16431==    at 0x483AB1A: calloc (vg_replace_malloc.c:752)
==16431==    by 0x49A1F33: bus_message_from_header (bus-message.c:458)
==16431==    by 0x49A22B1: bus_message_from_malloc (bus-message.c:535)
==16431==    by 0x49C459B: bus_socket_make_message (bus-socket.c:1099)
==16431==    by 0x49C4C5B: bus_socket_read_message (bus-socket.c:1213)
==16431==    by 0x49CE4CE: bus_read_message (sd-bus.c:1777)
==16431==    by 0x49CFA2C: sd_bus_call (sd-bus.c:2176)
==16431==    by 0x1105F3: check_units_active (coredumpctl.c:1029)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==    by 0x110A45: main (coredumpctl.c:1100)
==16431==
==16431== 1,856 bytes in 1 blocks are still reachable in loss record 13 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x49C6EDF: malloc_multiply (alloc-util.h:78)
==16431==    by 0x49C7C81: sd_bus_new (sd-bus.c:235)
==16431==    by 0x49CC398: sd_bus_open_system_with_description (sd-bus.c:1271)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==    by 0x110A45: main (coredumpctl.c:1100)
==16431==
==16431== LEAK SUMMARY:
==16431==    definitely lost: 0 bytes in 0 blocks
==16431==    indirectly lost: 0 bytes in 0 blocks
==16431==      possibly lost: 0 bytes in 0 blocks
==16431==    still reachable: 3,680 bytes in 13 blocks
==16431==         suppressed: 0 bytes in 0 blocks
==16431==
2018-11-20 16:48:21 +01:00
Zbigniew Jędrzejewski-Szmek c118b577fa coredumpctl: define main through macro
We want to propagate the return value from gdb, hence this commit makes
use of the liberalization of DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE()
in previous commit.
2018-11-20 16:48:21 +01:00
Zbigniew Jędrzejewski-Szmek 158ecef56b coredumpctl: open output file only before writing
We would open the file very early, which is not nice, if we e.g. fail when
parsing later options. Let's do the usual thing and just open it just before
writing, and close immediately after writing.
2018-11-20 16:48:21 +01:00
Zbigniew Jędrzejewski-Szmek cac0b95790 basic/main-func: propagate all positive return values
This changes DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE() to propagate positive
return values as they were, i.e. stops mapping them all to EXIT_FAILURE. This
was suggested in review, but I thought that we only ever return EXIT_FAILURE,
so we don't need to propagate multiple return values.

I was wrong. Turns out that we already *do* have multiple positive return
values, when we call external binaries and propagate the result. systemd-inhibit
is one example, and b453c447e0 actually broke
this propagation. This commit fixes it.

In systemd-fsck we have the opposite case: we have only one failure value, and the
code needs to be adjusted, so that it keeps returning EXIT_FAILURE.

All other users of DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE() return <= 1, and
are unaffected by this change.
2018-11-20 16:48:21 +01:00
Zbigniew Jędrzejewski-Szmek 50378e5d97 timedatectl: define main through macro
pager_close() is called from DEFINE_MAIN_FUNCTION().
2018-11-20 16:48:21 +01:00
Zbigniew Jędrzejewski-Szmek a34c79d006 basic/main-func: also close the pager automatically
We generally want to close the pager last. This patch closes the pager last,
after the static destuctor calls. This means that they can do logging and such
like during normal program runtime.
2018-11-20 16:48:21 +01:00
Zbigniew Jędrzejewski-Szmek ec5e594831 basic/main-func: unify the two macros
No functional change.
2018-11-20 16:48:21 +01:00
Lennart Poettering fd8bdbc79b sysctl: use STATIC_DESTRUCTOR_REGISTER() to free arg_prefixes 2018-11-20 16:48:21 +01:00
Lennart Poettering 07a91a45c7 sysctl: use _cleanup_ in one more occasion 2018-11-20 16:48:21 +01:00
Lennart Poettering 8eb42d9050 sysctl: port to use DEFINE_MAIN_FUNCTION() 2018-11-20 16:48:20 +01:00
Zbigniew Jędrzejewski-Szmek 6bc7a6ac2c inhibit: fix return value in error path 2018-11-20 16:48:20 +01:00
Lennart Poettering bd0ce2447d tmpfiles: also order glob child/parent relationships
This is necessary so that "r" can be nested and are always executed in
the same order.

Fixes: #10191
2018-11-20 16:36:29 +01:00
Lennart Poettering 09f467ac24 tmpfiles: fix typo 2018-11-20 16:32:19 +01:00
Lennart Poettering 44ac4f8854 tmpfiles: label phases explicitly 2018-11-20 16:15:09 +01:00
Lennart Poettering 48d9690430 tmpfiles: behind → below in log msgs
As suggested here:

https://github.com/systemd/systemd/pull/10538#pullrequestreview-176710207
2018-11-20 15:56:55 +01:00
Zbigniew Jędrzejewski-Szmek 7fa0269bca
Merge pull request #10850 from poettering/log-setup
reduce some logging boilerplate
2018-11-20 13:36:45 +01:00
Zbigniew Jędrzejewski-Szmek ad0cdb6b67 veritysetup-generator: treat '-' and '_' as equivalent 2018-11-20 13:19:08 +01:00
Zbigniew Jędrzejewski-Szmek 606b0b64a7
Merge pull request #10538 from poettering/tmpfiles-reorder
tmpfiles: remove children before their parents plus other fixlets
2018-11-20 13:00:28 +01:00
Lennart Poettering e27686053c
Merge pull request #10831 from keszybz/less-libbasic
Move various files that don't need to be in basic/ to shared/
2018-11-20 12:44:30 +01:00
Lennart Poettering 6bf3c61c57 log: introduce new helper call log_setup_service()
Let's reduce the common boilerplate and have a single setup function
used by all service code to setup logging.
2018-11-20 11:18:22 +01:00
Lennart Poettering afe44c8ffd generators: introduce a common implementation for the log setup boilerplate 2018-11-20 10:57:50 +01:00
Zbigniew Jędrzejewski-Szmek a03d43593c journal: fix sort order of header includes 2018-11-20 07:27:37 +01:00
Zbigniew Jędrzejewski-Szmek 4de8d971f0 meson: drop libblkid from libbasic
This doesn't seem to change anything, because libmount links to libblkid anyway.
But we don't need to include this dep directly in libbasic.
2018-11-20 07:27:37 +01:00
Zbigniew Jędrzejewski-Szmek d284b82b3e Move various files that don't need to be in basic/ to shared/
This doesn't have much effect on the final build, because we link libbasic.a
into libsystemd-shared.so, so in the end, all the object built from basic/
end up in libsystemd-shared. And when the static library is linked into binaries,
any objects that are included in it but are not used are trimmed. Hence, the
size of output artifacts doesn't change:

$ du -sb /var/tmp/inst*
54181861	/var/tmp/inst1    (old)
54207441	/var/tmp/inst1s   (old split-usr)
54182477	/var/tmp/inst2    (new)
54208041	/var/tmp/inst2s   (new split-usr)

(The negligible change in size is because libsystemd-shared.so is bigger
by a few hundred bytes. I guess it's because symbols are named differently
or something like that.)

The effect is on the build process, in particular partial builds. This change
effectively moves the requirements on some build steps toward the leaves of the
dependency tree. Two effects:
- when building items that do not depend on libsystemd-shared, we
  build less stuff for libbasic.a (which wouldn't be used anyway,
  so it's a net win).
- when building items that do depend on libshared, we reduce libbasic.a as a
  synchronization point, possibly allowing better parallelism.

Method:
1. copy list of .h files from src/basic/meson.build to /tmp/basic
2. $ for i in $(grep '.h$' /tmp/basic); do echo $i; git --no-pager grep "include \"$i\"" src/basic/ 'src/lib*' 'src/nss-*' 'src/journal/sd-journal.c' |grep -v "${i%.h}.c";echo ;done | less
2018-11-20 07:27:37 +01:00
Yu Watanabe f921b457a7 libudev: coding style fixes 2018-11-20 14:38:35 +09:00
Yu Watanabe 5ea78a39e5 libudev-list: move libudev-list related definitions to libudev-list-internal.h
This also rename libudev-private.h to libudev-util.h, and cleanups
several unnecessary headers from udev.h and libudev-util.h
2018-11-20 14:38:35 +09:00
Yu Watanabe 170e4380b6 libudev: drop prototypes for nonexistent functions 2018-11-20 14:38:35 +09:00
Yu Watanabe c84954e8ed libudev-monitor: drop unused private functions 2018-11-20 14:38:35 +09:00
Yu Watanabe 53369277ec libudev-device: drop unused private functions 2018-11-20 14:38:35 +09:00
Yu Watanabe 02edd80d87 udev: move definition of READ_END and WRITE_END from libudev-private.h to udev.h 2018-11-20 14:38:35 +09:00
Yu Watanabe 278939be7a
Merge pull request #10847 from evverx/journald-stream-fuzzer
tests: add a fuzzer for journald streams
2018-11-20 13:37:27 +09:00
Yu Watanabe f23ff5ba51
Merge pull request #10835 from poettering/transient-env-fix
fix flushing out of transient env vars from PID1's Manager object
2018-11-20 12:53:51 +09:00
Lennart Poettering cc7a0bfa15 bootspec: introduce SYSTEMD_ESP_PATH for overriding where to look for the ESP (#10834) 2018-11-20 12:37:01 +09:00
David Leeds 53640e6fb9 process-util: check for correct kill return value (#10841)
Code was not doing a wait() after kill() due to checking for a return value > 0, and was leaving zombie processes. This affected things like  sd-bus unixexec connections.
2018-11-20 12:35:36 +09:00
Lennart Poettering 012c2f761b tree-wide: use __ prefixed gcc attributes (#10843)
As suggest here:

https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html#Attribute-Syntax

    "You may optionally specify attribute names with ‘__’ preceding and
    following the name. This allows you to use them in header files without
    being concerned about a possible macro of the same name. For example,
    you may use the attribute name __noreturn__ instead of noreturn. "
2018-11-20 12:34:08 +09:00
Yu Watanabe 52048013b7
Merge pull request #10845 from poettering/static-destruct
RFC: introduce automatic destructors for static variables
2018-11-20 12:31:52 +09:00
Lennart Poettering bd7989a3d9 tests: always use the right vtable wrapper calls
Prompted by https://github.com/systemd/systemd/pull/10836#discussion_r234598868
2018-11-20 05:34:29 +03:00
Evgeny Vereshchagin 9541f5ff5c tests: add a fuzzer for journald streams 2018-11-20 03:03:32 +01:00
Lennart Poettering 1acacd737b test-execute: fix killing of unit processes
Let's use the correct wrapper for calling unit vtable functions. Let's
make sure we always use the right wrappers, and never bypass them
needlessly.

Moreover use SIGKILL rather than "9" as signal name. Let's not be
needlessly cryptic.

Follow-up for: f7f8e8cbb9
2018-11-19 21:53:23 +01:00
Lennart Poettering a64841779a meson: order source files alphabetically 2018-11-19 21:50:54 +01:00
Lennart Poettering 4197fde5c7 debug-generator: port over to using static destructors 2018-11-19 21:14:34 +01:00
Lennart Poettering f60947d970 debug-generator: port over to DEFINE_MAIN_FUNCTION() 2018-11-19 21:14:34 +01:00
Lennart Poettering 8a4fdaf292 main-func: automatically call static destructors from main-func.h macros 2018-11-19 21:14:34 +01:00
Lennart Poettering 67e16c31e9 util: add set of macros for declaring _cleanup_-style destructors for static variables 2018-11-19 21:14:34 +01:00
Lennart Poettering 5e332028f2 util-lib: move main() definition macros to its own header file
This way, we can extend the macro a bit with stuff pulled in from other
headers without this affecting everything which pulls in macro.h, which
is one of our most basic headers.

This is just refactoring, no change in behaviour, in prepartion for
later changes.
2018-11-19 21:14:34 +01:00
Lennart Poettering 2a44bf5099
Merge pull request #10811 from keszybz/define-main-through-macro
Define main through macro
2018-11-19 15:28:17 +01:00
Lennart Poettering 2675747f3c pam_systemd: suppress LOG_DEBUG log messages if debugging is off
In the PAM module we need to suppress LOG_DEBUG messages manually, if
debug logging is not on, as PAM won't do this for us. We did this
correctly for most log messages already, but two were missing. Let's fix
those too.

Fixes: #10822
2018-11-19 14:03:34 +01:00
Lennart Poettering 79a224c460 main: when reloading PID 1 let's reset the default environment
Otherwise we keep collecting stuff from env generators, and we really
shouldn't.

This was working properly on reexec but not on reload, as for reexec we
would always start fresh, but for reload would reuse the Manager object
and hence its default environment set.

Fixes: #10671
2018-11-19 13:01:19 +01:00
Lennart Poettering 2fbbbf9a5f manager: log on two OOM occasions 2018-11-19 12:22:56 +01:00
Lennart Poettering e16f425654
Merge pull request #10698 from yuwata/udevd-replace-udev-device
udevd: replace udev_device by sd_device
2018-11-19 11:28:45 +01:00
Lennart Poettering b08020893a
Merge pull request #10809 from keszybz/unit-log-result
Add helper function for logging unit results
2018-11-19 11:07:07 +01:00
Lennart Poettering 431957c959
Merge pull request #10814 from poettering/logind-suspend-fallback
if we need to hibernate/suspend-then-hibernate/hybrid-sleep due to keypress/lid switch but can't, fallback to regular suspend
2018-11-19 11:05:48 +01:00
Lennart Poettering a44088f10f
Merge pull request #10825 from keszybz/advertize-followup
udev link advertizing followup
2018-11-19 11:05:18 +01:00
Lennart Poettering 2b38a8ea80
Merge pull request #10507 from cdown/cpu_acct
cgroup v2: Don't require CPU controller for CPU accounting in 4.15+
2018-11-19 10:57:48 +01:00
Evgeny Vereshchagin f7f8e8cbb9 test: kill all processes launched by test-execute before exiting
As was shown in https://github.com/systemd/systemd/issues/10696#issuecomment-439613204,
currently `meson` waits for 1080 seconds (which is three times the global timeout) for the
test to fail completely even though it takes just two minutes for it to really fail. This
happens because the test itself leaves the services it has launched behind, which, in turn, makes
meson think that the test is still in progress. KILL_ALL with SIGKILL should make the issue
go away.
2018-11-19 09:24:22 +01:00
Zbigniew Jędrzejewski-Szmek 64d9f7568b basic/missing: drop _ETHTOOL_LINK_MODE_MAX
It was only used in one place, where we don't actually need it, and
it is too easy to forget to update it when adding new items to the table.
Let's just drop it.
2018-11-18 16:14:21 +01:00
Zbigniew Jędrzejewski-Szmek 5dd101186b udev: use an "inline" array instead of allocating for advertise mode
The code is a bit shorter and we don't allocate the uint32_t[127] array.
2018-11-18 16:14:19 +01:00
Zbigniew Jędrzejewski-Szmek 7f6bfc561f basic/util: import memeqzero from casync 2018-11-18 16:12:53 +01:00
Chris Down a88c5b8ac4 cgroup v2: DefaultCPUAccounting=yes if CPU controller isn't required
We now don't enable the CPU controller just for CPU accounting if we are
on 4.15+ and using pure unified hierarchy, as this is provided
externally to the CPU controller. This makes CPUAccounting=yes
essentially free, so enabling it by default when it's cheap seems like a
good idea.
2018-11-18 12:21:41 +00:00
Chris Down 94ddb08d74 cgtop: Still try to get CPU statistics if controller-free
If CPU accounting is cheap, no controller necessarily needs to be
enabled here for us to be able to read statistics.
2018-11-18 12:21:41 +00:00