chiark / gitweb /
2 years agocore: introduce cg_mask_from_string()/cg_mask_to_string()
Franck Bui [Tue, 2 May 2017 07:59:17 +0000 (09:59 +0200)]
core: introduce cg_mask_from_string()/cg_mask_to_string()

2 years agoconfig parser: Introduce config_parse_ip_port
Susant Sahani [Thu, 27 Apr 2017 05:11:46 +0000 (10:41 +0530)]
config parser: Introduce config_parse_ip_port

2 years agoimprove readability (#5814)
Matija Skala [Thu, 27 Apr 2017 00:08:52 +0000 (02:08 +0200)]
improve readability (#5814)

2 years agoparse-util: introduce parse_dev() helper
Franck Bui [Wed, 26 Apr 2017 16:18:03 +0000 (18:18 +0200)]
parse-util: introduce parse_dev() helper

2 years agologind: when setting a new controller, don't prepare the VT if logind is restarted
Franck Bui [Wed, 26 Apr 2017 12:20:41 +0000 (14:20 +0200)]
logind: when setting a new controller, don't prepare the VT if logind is restarted

When assigning a new session controller to a session, the VT is prepared so the
controller can expect the VT to be in a good default state.

However when logind is restarted and a session controller already took control
of a session, there's no need to prepare th VT otherwise logind may screw up
the VT state set by the controller.

This patch prevents the preparation of the VT in this case.

2 years agotmpfiles: use safe_glob()
Zbigniew Jędrzejewski-Szmek [Wed, 26 Apr 2017 03:50:35 +0000 (23:50 -0400)]
tmpfiles: use safe_glob()

This filters out "." and ".." from glob results. Fixes #5655 and #5644.

Any judgements on whether the path is "safe" are removed. We will not remove
"/" under any name (including "/../" and such), but we will remove stuff that
is specified using paths that include "//", "/./" and "/../". Such paths can be
created when joining strings automatically, or for other reasons, and people
generally know what ".." and "." is.

Tests are added to make sure that the helper functions behave as expected.

2 years agobasic: add readdir_no_dot and safe_glob functions
Zbigniew Jędrzejewski-Szmek [Wed, 26 Apr 2017 03:44:34 +0000 (23:44 -0400)]
basic: add readdir_no_dot and safe_glob functions

safe_glob filters out "." and "..".

This converts all users of glob_extend() and glob_exists() to safe_glob.

2 years agotest-sizeof: print the size of an enum
Zbigniew Jędrzejewski-Szmek [Wed, 26 Apr 2017 01:14:59 +0000 (21:14 -0400)]
test-sizeof: print the size of an enum

2 years agobus: report builtins in GetManagedObjects() (#5799)
David Herrmann [Wed, 26 Apr 2017 00:36:30 +0000 (02:36 +0200)]
bus: report builtins in GetManagedObjects() (#5799)

We already report builtin interfaces with InterfacesAdded and InterfacesRemoved. However,
we never reported them in GetManagedObjects(). This might end up confusing callers that
want to use those interfaces (or simply rely on the interface count to be coherent).

Report the builtins for all objects that are queried.

2 years agoconfig parser: Introduce config_parse_uint8
Susant Sahani [Tue, 25 Apr 2017 13:11:50 +0000 (18:41 +0530)]
config parser: Introduce config_parse_uint8

2 years agofix parenthesis in pager.c (#5798)
Matija Skala [Tue, 25 Apr 2017 12:44:29 +0000 (14:44 +0200)]
fix parenthesis in pager.c (#5798)

- result of dup2 should be compared against 0
- making parenthesis around comparisons just to be sure

2 years agoExport sd_bus_message_append_ap. It is renamed to sd_bus_message_appendv to follow...
Federico [Tue, 25 Apr 2017 07:32:24 +0000 (09:32 +0200)]
Export sd_bus_message_append_ap. It is renamed to sd_bus_message_appendv to follow elogind naming conventions. (#5753)

Moreover, man page for sd_bus_message_append is updated with reference to new exposed function.
Makefile-man is updated too, to reflect new alias.

2 years agoAdd Geneve netlink properties to missing.h
Susant Sahani [Tue, 25 Apr 2017 04:13:41 +0000 (09:43 +0530)]
Add Geneve netlink properties to missing.h

2 years agoredirect stdout/stderr back when closing the pager (#5661)
Matija Skala [Mon, 24 Apr 2017 16:30:50 +0000 (18:30 +0200)]
redirect stdout/stderr back when closing the pager (#5661)

2 years agoshared/extract-word: replace enum with unsigned int to avoid undefined behaviour
Zbigniew Jędrzejewski-Szmek [Sat, 22 Apr 2017 23:04:02 +0000 (19:04 -0400)]
shared/extract-word: replace enum with unsigned int to avoid undefined behaviour

../src/basic/extract-word.c:255:22: warning: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Wvarargs]
        va_start(ap, flags);
../src/basic/extract-word.c:244:77: note: parameter of type 'ExtractFlags' (aka 'enum ExtractFlags') is declared here
int extract_many_words(const char **p, const char *separators, ExtractFlags flags, ...) {
../src/basic/extract-word.c:286:22: warning: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Wvarargs]
        va_start(ap, flags);
../src/basic/extract-word.c:244:77: note: parameter of type 'ExtractFlags' (aka 'enum ExtractFlags') is declared here
int extract_many_words(const char **p, const char *separators, ExtractFlags flags, ...) {
2 warnings generated.

I think the relevant part of C99 is Enumeration specifiers:

Each enumerated type shall be compatible with char, a signed integer type, or
an unsigned integer type. The choice of type is implementation-defined, but
shall be capable of representing the values of all the members of the


The parameter parmN is the identifier of the rightmost parameter in the
variable parameter list in the function definition (the one just before the
...). If the parameter parmN is declared with the register storage class, with
a function or array type, or with a type that is not compatible with the type
that results after application of the default argument promotions, the behavior
is undefined.

This might cause a real issue if the compiler chooses something that is not an
integer for ExtractFlags. Rework the code to avoid the warning, but add an
assert_cc in a large-valued ExtractFlags element is ever defined and the type
is bumped to something wider than an int.

2 years agobasic/log: expose log_dispatch
Zbigniew Jędrzejewski-Szmek [Fri, 21 Apr 2017 16:52:54 +0000 (12:52 -0400)]
basic/log: expose log_dispatch

This is useful when we want to avoid printf formatting on the message.
It's nicer than using log_struct with "%s" as the format, because printf
is slow and with a large message (like from a backtrace) this would require
extra unnecessary memory.

I'm not exposing all the fields in the wrapper: only level and errno.
Those are the most likely to be useful.

2 years agotree-wide: mark log_struct with _printf_ and fix fallout
Zbigniew Jędrzejewski-Szmek [Thu, 20 Apr 2017 18:15:28 +0000 (14:15 -0400)]
tree-wide: mark log_struct with _printf_ and fix fallout

log_struct takes multiple format strings, each one followed by arguments.
The _printf_ annotation is not sufficiently flexible to express this,
but we can still annotate the first format string, though not its
arguments (because their number is unknown).

With the annotation, the places which specified the message id or similar
as the first pattern cause a warning from -Wformat-nonliteral. This can
be trivially fixed by putting the MESSAGE= first.

This change will help find issues where a non-literal is erroneously used
as the pattern.

2 years agobasic/log: fix _printf_ annotation on log_object_internalv
Zbigniew Jędrzejewski-Szmek [Thu, 20 Apr 2017 18:09:47 +0000 (14:09 -0400)]
basic/log: fix _printf_ annotation on log_object_internalv

Fixup for 4b58153dd22172d817055d2a09a0cdf3f4bd9db3.

I saw this because of a clang warning. With gcc the -Wformat-nonliteral warning
doesn't seem to work as expected.

In two places, a string constructed with strjoina is used as the pattern. This
is safe, because we're taking a pattern which was already marked with _printf_
and prepending a known value to it.  Those places are marked with #pragma to
silence the warning.

2 years agotest-exec-util: drop duplicate const
Zbigniew Jędrzejewski-Szmek [Wed, 19 Apr 2017 20:32:52 +0000 (16:32 -0400)]
test-exec-util: drop duplicate const

gcc-7 warns about this with -Wduplicate-decl-specifier.

2 years agobasic/random-util: add new header for getrandom()
Zbigniew Jędrzejewski-Szmek [Wed, 19 Apr 2017 20:13:27 +0000 (16:13 -0400)]
basic/random-util: add new header for getrandom()

There's some confusion: older man pages specify that linux/random.h
contains getrandom, but newer glibc has it in sys/random.h. Detect if
the newer header is available and include it. We still need the older
header for the flags.

2 years agotree-wide: fix wrong indent (#5757)
Yu Watanabe [Wed, 19 Apr 2017 06:48:29 +0000 (15:48 +0900)]
tree-wide: fix wrong indent (#5757)

Fixes wrong indent introduced by the commit 43688c49d1fdb585196d94e2e30bb29755fa591b.

2 years agobasic/missing.h: drop inclusion of macro.h
Zbigniew Jędrzejewski-Szmek [Tue, 18 Apr 2017 23:04:15 +0000 (19:04 -0400)]
basic/missing.h: drop inclusion of macro.h

It's not necessary for anything.

2 years agologinctl: fix typo causing ignoring multiple session IDs (#5732)
slodki [Thu, 13 Apr 2017 10:34:59 +0000 (12:34 +0200)]
loginctl: fix typo causing ignoring multiple session IDs (#5732)

Fixes #5733

2 years agobasic/def.h: drop TTY_GID definition
Zbigniew Jędrzejewski-Szmek [Thu, 6 Apr 2017 04:12:40 +0000 (00:12 -0400)]
basic/def.h: drop TTY_GID definition

We already provide a definition through the configuration system, this
one is duplicate.

2 years agologind: Stopped inhibitions should be considered inactive (#5698)
afrantzis [Wed, 5 Apr 2017 08:32:55 +0000 (11:32 +0300)]
logind: Stopped inhibitions should be considered inactive (#5698)

2 years agotest-sizeof: add some struct-timespec related fields
Zbigniew Jędrzejewski-Szmek [Thu, 30 Mar 2017 01:31:58 +0000 (21:31 -0400)]
test-sizeof: add some struct-timespec related fields

Might help with #5264.

2 years agotest-sizeof: do not link with libelogind-shared
Zbigniew Jędrzejewski-Szmek [Thu, 30 Mar 2017 01:31:21 +0000 (21:31 -0400)]
test-sizeof: do not link with libelogind-shared

This makes it much quicker to compile.

2 years agobasic: forbid rm_rf() to remove paths ending with ".." (#5653)
Jan Synacek [Wed, 29 Mar 2017 06:25:52 +0000 (08:25 +0200)]
basic: forbid rm_rf() to remove paths ending with ".." (#5653)

Fixes: #5644

2 years agologind: save/restore session devices and their respective file descriptors
Franck Bui [Thu, 16 Mar 2017 10:17:09 +0000 (11:17 +0100)]
logind: save/restore session devices and their respective file descriptors

This patch ensures that session devices are saved for each session.

In order to make the revokation logic work when logind is restarted, the
session devices are now saved in the session state files and their respective
file descriptors sent to PID1's fdstore in order to keep them open accross

This is mandatory in order to keep the revokation logic working. Indeed in case
of input-devices, the same file descriptors must be shared by logind and a
given session controller in order EVIOCREVOKE to work otherwise multiple
sessions can have device access in parallel.

This should be the only remaining and missing piece for making logind fully

Fixes: #1163

2 years agocheck for _POSIX_C_SOURCE instead of __USE_POSIX*
Matija Skala [Wed, 15 Mar 2017 13:16:40 +0000 (14:16 +0100)]
check for _POSIX_C_SOURCE instead of __USE_POSIX*

check for _GNU_SOURCE as well as sd_event_child_handler_t needs to be
defined correctly while compiling elogind

2 years agoassigning stdout and stderr is not allowed
Matija Skala [Wed, 15 Mar 2017 12:49:05 +0000 (13:49 +0100)]
assigning stdout and stderr is not allowed

2 years agofix includes
Matija Skala [Wed, 15 Mar 2017 12:21:10 +0000 (13:21 +0100)]
fix includes

linux/sockios.h is needed for the SIOCGSTAMPNS macro

xlocale.h is included indirectly in glibc and doesn't even exist in
other libcs

2 years agoheaders: check that __INCLUDE_LEVEL__ is defined before using it (#5575)
Zbigniew Jędrzejewski-Szmek [Mon, 13 Mar 2017 07:11:24 +0000 (03:11 -0400)]
headers: check that __INCLUDE_LEVEL__ is defined before using it (#5575)

That macro is a gcc extension, and while widely supported, not ubiquitous.
In particular the coverity scanner is having trouble with it.

2 years agoFix typo in function name (#5565)
Michal Sekletar [Fri, 10 Mar 2017 14:16:24 +0000 (15:16 +0100)]
Fix typo in function name (#5565)

2 years agomissing.h: add vxlan netlink properties
Susant Sahani [Wed, 8 Mar 2017 13:09:43 +0000 (18:39 +0530)]
missing.h: add vxlan netlink properties

2 years agosd-bus: drop kdbus-related docs (#5533)
AsciiWolf [Tue, 7 Mar 2017 06:51:35 +0000 (07:51 +0100)]
sd-bus: drop kdbus-related docs (#5533)

2 years agotest: skip instead of fail if crypto kmods are not available
Martin Pitt [Thu, 2 Mar 2017 22:42:01 +0000 (23:42 +0100)]
test: skip instead of fail if crypto kmods are not available

Package build machines may have module loading disabled, thus AF_ALG
sockets are not available. Skip the tests that cover those (khash and
id128) instead of failing them in this case.

Fixes #5524

2 years agoRip out setting of the log level from udev_new and put it in a new function
Zbigniew Jędrzejewski-Szmek [Thu, 23 Feb 2017 08:16:44 +0000 (03:16 -0500)]
Rip out setting of the log level from udev_new and put it in a new function

This function is internal to elogind code, so external users of libudev
will not see those log messages. I think this is better. If we want to
allow that, the function could be put in libudev and exported.

v2: check that the string is more than one char before stripping quotes

2 years agobasic/log: split max log level into multiple "realms"
Zbigniew Jędrzejewski-Szmek [Thu, 23 Feb 2017 03:57:34 +0000 (22:57 -0500)]
basic/log: split max log level into multiple "realms"

The single log level is split into an array of log levels. Which index in the
array is used can be determined for each compilation unit separately by setting
a macro before including log.h. All compilation units use the same index
(LOG_REALM_SYSTEMD), so there should be no functional change.

- the "realm" is squished into the level (upper bits that are not used by
  priority or facility), and unsquished later in functions in log.c.


2 years agoVersion 233.3 Release v233.3
Sven Eden [Fri, 21 Jul 2017 05:48:48 +0000 (07:48 +0200)]
Version 233.3 Release

2 years agoPrep v233.3: Add HAVE_UTMP information to basic/build.h
Sven Eden [Fri, 21 Jul 2017 05:46:20 +0000 (07:46 +0200)]
Prep v233.3: Add HAVE_UTMP information to basic/build.h

2 years agoPrep v233.3: Remove stray character.
Sven Eden [Fri, 21 Jul 2017 05:41:40 +0000 (07:41 +0200)]
Prep v233.3: Remove stray character.

2 years agoPrep v233.3: Add 'loginctl list' as a shorthand for list-sessions
Sven Eden [Thu, 20 Jul 2017 16:25:48 +0000 (18:25 +0200)]
Prep v233.3: Add 'loginctl list' as a shorthand for list-sessions

2 years agoPrep v233.3: Moved four functions, that did not need adaptation in elogind-dbus.c...
Sven Eden [Thu, 20 Jul 2017 16:16:13 +0000 (18:16 +0200)]
Prep v233.3: Moved four functions, that did not need adaptation in elogind-dbus.c, back to logind-dbus.c.

2 years agoPrep v233.3: Moved shutdown_or_sleep() and run_helper() to elogind-dbus.c, so elogind...
Sven Eden [Thu, 20 Jul 2017 15:16:50 +0000 (17:16 +0200)]
Prep v233.3: Moved shutdown_or_sleep() and run_helper() to elogind-dbus.c, so elogind-action.c is not needed any more.

2 years agoPrep v233.3: Apply upstream updates to systemctl commands we mimic.
Sven Eden [Thu, 20 Jul 2017 15:03:33 +0000 (17:03 +0200)]
Prep v233.3: Apply upstream updates to systemctl commands we mimic.

2 years agoPrep v233.3: Add a traget 'cccc' to
Sven Eden [Thu, 20 Jul 2017 06:24:36 +0000 (08:24 +0200)]
Prep v233.3: Add a traget 'cccc' to

2 years agoPrep v233.3: Add missing documentation for API functions exported by elogind. (unrevi...
Sven Eden [Wed, 19 Jul 2017 11:46:39 +0000 (13:46 +0200)]
Prep v233.3: Add missing documentation for API functions exported by elogind. (unreviewed)

2 years agoPrep v233.3: Add all possible coverage tests for elogind
Sven Eden [Wed, 19 Jul 2017 09:55:18 +0000 (11:55 +0200)]
Prep v233.3: Add all possible coverage tests for elogind

2 years agoPrep v233.3: Unmask various functions for future coverage tests.
Sven Eden [Tue, 18 Jul 2017 22:56:25 +0000 (00:56 +0200)]
Prep v233.3: Unmask various functions for future coverage tests.

These functions, although not used by elogind itself, are mostly tiny
and crucial for important tests to work.

2 years agoPrep v233.3: Update po files to not include files that do not exist in elogind.
Sven Eden [Tue, 18 Jul 2017 18:30:57 +0000 (20:30 +0200)]
Prep v233.3: Update po files to not include files that do not exist in elogind.

2 years agoPrep v233.3: Remove obsolete test-hash.c
Sven Eden [Tue, 18 Jul 2017 13:42:39 +0000 (15:42 +0200)]
Prep v233.3: Remove obsolete test-hash.c

2 years agoVersion 233.2 Release
Sven Eden [Tue, 18 Jul 2017 07:37:20 +0000 (09:37 +0200)]
Version 233.2 Release

2 years agoPrep v233.2: Mask unneeded functions and definitions in src/shared
Sven Eden [Mon, 17 Jul 2017 16:21:47 +0000 (18:21 +0200)]
Prep v233.2: Mask unneeded functions and definitions in src/shared

2 years agoPrep v233.2: Mask unneeded functions and definitions in src/basic
Sven Eden [Tue, 18 Jul 2017 06:04:37 +0000 (08:04 +0200)]
Prep v233.2: Mask unneeded functions and definitions in src/basic

2 years agoVersion 233.1 Release
Sven Eden [Mon, 17 Jul 2017 16:15:05 +0000 (18:15 +0200)]
Version 233.1 Release

2 years agoPrep v233: Add missing updates from upstream in src/systemd
Sven Eden [Mon, 17 Jul 2017 15:38:58 +0000 (17:38 +0200)]
Prep v233: Add missing updates from upstream in src/systemd

2 years agoPrep v233: Add missing updates from upstream in src/sleep
Sven Eden [Mon, 17 Jul 2017 15:38:46 +0000 (17:38 +0200)]
Prep v233: Add missing updates from upstream in src/sleep

2 years agoPrep v233: Add missing updates from upstream in src/login
Sven Eden [Mon, 17 Jul 2017 15:37:38 +0000 (17:37 +0200)]
Prep v233: Add missing updates from upstream in src/login

2 years agoPrep v233: Add missing updates from upstream in src/libelogind
Sven Eden [Mon, 17 Jul 2017 16:09:52 +0000 (18:09 +0200)]
Prep v233: Add missing updates from upstream in src/libelogind

2 years agoPrep v233: Add missing updates from upstream in src/core
Sven Eden [Mon, 17 Jul 2017 16:09:39 +0000 (18:09 +0200)]
Prep v233: Add missing updates from upstream in src/core

2 years agoPrep v233: Add missing updates from upstream in src/basic
Sven Eden [Mon, 17 Jul 2017 15:13:40 +0000 (17:13 +0200)]
Prep v233: Add missing updates from upstream in src/basic

2 years agoPrep v233: Add missing includes in src/libelogind/sd-id128
Sven Eden [Mon, 17 Jul 2017 15:36:59 +0000 (17:36 +0200)]
Prep v233: Add missing includes in src/libelogind/sd-id128

2 years agoPrep v233: Add missing includes in src/shared
Sven Eden [Mon, 17 Jul 2017 15:38:19 +0000 (17:38 +0200)]
Prep v233: Add missing includes in src/shared

2 years agoPrep v233: Add missing includes in src/basic
Sven Eden [Mon, 17 Jul 2017 15:33:24 +0000 (17:33 +0200)]
Prep v233: Add missing includes in src/basic

2 years agoPrep v233: Unmask now needed functions in src/basic
Sven Eden [Mon, 17 Jul 2017 15:13:52 +0000 (17:13 +0200)]
Prep v233: Unmask now needed functions in src/basic

2 years agoPrep v233: Add missing files from upstream and rename formats-util.[hc]
Sven Eden [Mon, 17 Jul 2017 13:03:10 +0000 (15:03 +0200)]
Prep v233: Add missing files from upstream and rename formats-util.[hc]

Some functionality has been exported to the following files:

 - src/basic/env-util.[hc]
 - src/basic/exec-util.[hc]
 - src/shared/nsflags.[hc]

The content of these files is now needed in elogind, and the files have been
added as-is. Cleanup is done later.

Further the header
has been renamed to

2 years agoPrep v233: Update root build files to upstream version
Sven Eden [Mon, 17 Jul 2017 10:55:17 +0000 (12:55 +0200)]
Prep v233: Update root build files to upstream version

2 years agoRevert "util: Fine tune running_in_chroot() a bit" (#5506)
Lennart Poettering [Wed, 1 Mar 2017 20:22:02 +0000 (21:22 +0100)]
Revert "util: Fine tune running_in_chroot() a bit" (#5506)

This reverts commit 295ee9845c801300298d01256eb5a9e3ff117ae0.

Let'd revert this for now, see #5446 for discussions.

We want elogind-detect-virt --chroot to return true for all chroot-like stuff, for
example mock environments which have use a mount namespace. The downside
of this revert that systemctl will not work from our own namespaced services, anything
with RootDirectory=/RootImage= set.

2 years agomount-util: accept that name_to_handle_at() might fail with EPERM (#5499)
Lennart Poettering [Wed, 1 Mar 2017 16:35:05 +0000 (17:35 +0100)]
mount-util: accept that name_to_handle_at() might fail with EPERM (#5499)

Container managers frequently block name_to_handle_at(), returning
EACCES or EPERM when this is issued. Accept that, and simply fall back
to to fdinfo-based checks.

Note that we accept either EACCES or EPERM here, as container managers
can choose the error code and aren't very good on agreeing on just one.

(note that this is a non-issue with nspawn, as we permit
name_to_handle_at() there, only block open_by_handle_at(), which should
be sufficiently safe).

2 years agosocket-util: introduce address_label_valid
Susant Sahani [Tue, 28 Feb 2017 11:23:58 +0000 (16:53 +0530)]
socket-util: introduce address_label_valid

2 years agoFix missing space in comments (#5439)
AsciiWolf [Fri, 24 Feb 2017 17:14:02 +0000 (18:14 +0100)]
Fix missing space in comments (#5439)

2 years agocgroup: rework cg_all_unified()
Lennart Poettering [Fri, 24 Feb 2017 17:05:31 +0000 (18:05 +0100)]
cgroup: rework cg_all_unified()

Let's just check the unified level, directly. There's really no value in
wrapping cg_unified_controllers() with this, i.e. potentially do string
comparison when there's no reason to.

Also, this makes the clal more alike cg_hybrid_unified().

2 years agocgroup: rename cg_update_unified() → cg_unified_update()
Lennart Poettering [Fri, 24 Feb 2017 17:03:09 +0000 (18:03 +0100)]
cgroup: rename cg_update_unified() → cg_unified_update()

We usually put the noun first, the verb (i.e. method) secont, for
example in cg_unified_flush(), let's follow the logic here...

2 years agocgroup: rename cg_unified() → cg_unified_controller()
Lennart Poettering [Fri, 24 Feb 2017 17:00:04 +0000 (18:00 +0100)]
cgroup: rename cg_unified() → cg_unified_controller()

cg_unified() is a bit generic a name, let's make clear that it checks
whether a specified controller is in unified mode.

2 years agocgroup: change cg_unified() to possibly return errors again
Lennart Poettering [Fri, 24 Feb 2017 16:52:58 +0000 (17:52 +0100)]
cgroup: change cg_unified() to possibly return errors again

We use our cgroup APIs in various contexts, including from our libraries
sd-login, sd-bus. As we don#t control those environments we can't rely
that the unified cgroup setup logic succeeds, and hence really shouldn't
assert on it.

This more or less reverts 415fc41ceaeada2e32639f24f134b1c248b9e43f.

2 years agocgroup-util: check unified_cache before invoking streq()
Lennart Poettering [Fri, 24 Feb 2017 14:53:17 +0000 (15:53 +0100)]
cgroup-util: check unified_cache before invoking streq()

Just a minor optimization.

2 years agocgroup-util: fix the case of default=unified, unified-cgroup-hierarchy=0
Zbigniew Jędrzejewski-Szmek [Thu, 23 Feb 2017 00:55:31 +0000 (19:55 -0500)]
cgroup-util: fix the case of default=unified, unified-cgroup-hierarchy=0

We should mount the hybrid hierarchy if the user disabled the unified
hierarchy on the kernel command line.

2 years agocgroup-util: cache all cg_is_*_wanted answers, disable /sys/fs/cgroups/unified on...
Zbigniew Jędrzejewski-Szmek [Wed, 22 Feb 2017 17:57:43 +0000 (12:57 -0500)]
cgroup-util: cache all cg_is_*_wanted answers, disable /sys/fs/cgroups/unified on unified

If we encounter an error in proc cmdline parsing, just treat that as permanent,
i.e. the same as if the option was not specified. Realistically, it is better
to use the same condition for all related mounts, then to have e.g.
/sys/fs/cgroup mounted and /sys/fs/cgroup/unified not. If we find something is
mounted and base our answer on that, cache that result too.

Fix the conditions so that if "unified" is used, make sure any "hybrid" mounts
are not mounted.

2 years agoFix check for signal in set (#5416)
stuart-mclaren [Tue, 21 Feb 2017 20:39:52 +0000 (20:39 +0000)]
Fix check for signal in set (#5416)

IN_SET(SIGCONT, SIGKILL) will always evaluate to false.
The signal needs to be included as the first argument.

Fixup for 26f417d3e8dd2522adfdc4c8fed4c36fa40f48fc.

2 years agoRevert "basic/strv: allow NULLs to be inserted into strv"
Lennart Poettering [Tue, 21 Feb 2017 17:11:12 +0000 (18:11 +0100)]
Revert "basic/strv: allow NULLs to be inserted into strv"

This reverts commit 18f71a3c8174774c5386c4aba94d54f3b5c36a84.

According to @keszybz we don't need this anymore, hence drop it:

2 years agolog: never log into foreign fd #2 in PID 1 or its pre-execve() children
Lennart Poettering [Tue, 21 Feb 2017 16:57:55 +0000 (17:57 +0100)]
log: never log into foreign fd #2 in PID 1 or its pre-execve() children

Fixes: #5401

2 years agobootctl: create loader.conf only if it doesn't exist yet
Lennart Poettering [Tue, 21 Feb 2017 16:44:35 +0000 (17:44 +0100)]
bootctl: create loader.conf only if it doesn't exist yet

If the snippet aleady exists, don't do anything, as the file was already
installed then.

(This also reworks the code to create the file atomically)

Fixes: #5396

2 years agobasic/fileio: use IN_SET
Zbigniew Jędrzejewski-Szmek [Tue, 21 Feb 2017 16:15:27 +0000 (11:15 -0500)]
basic/fileio: use IN_SET

2 years agobasic/fileio: fix memleak when discarding an invalid variable
Zbigniew Jędrzejewski-Szmek [Tue, 21 Feb 2017 16:15:19 +0000 (11:15 -0500)]
basic/fileio: fix memleak when discarding an invalid variable

Fixes #5405.

2 years agocopy: a plain unlink() works here too
Lennart Poettering [Tue, 21 Feb 2017 16:13:28 +0000 (17:13 +0100)]
copy: a plain unlink() works here too

2 years agoSyntax for defines that is also unterstood by the GNU C/C++ compilers. (#5397)
pyBlob [Mon, 20 Feb 2017 21:24:45 +0000 (22:24 +0100)]
Syntax for defines that is also unterstood by the GNU C/C++ compilers. (#5397)

2 years agocgroup-util: fix the reversed return value of cg_is_unified_elogind_contoller_wanted
Zbigniew Jędrzejewski-Szmek [Mon, 20 Feb 2017 17:26:53 +0000 (12:26 -0500)]
cgroup-util: fix the reversed return value of cg_is_unified_elogind_contoller_wanted

1d84ad944520fc3e062ef518c4db4e1 reversed the meaning of the option.
The kernel command line option has the opposite meaning to the function,
i.e. specifying "legacy=yes" means "unifed elogind controller=no".

2 years agocore/mount-setup: if unified hierarchy is not supported, fall back to legacy
Zbigniew Jędrzejewski-Szmek [Sun, 19 Feb 2017 20:59:21 +0000 (15:59 -0500)]
core/mount-setup: if unified hierarchy is not supported, fall back to legacy

We need this to gracefully support older or strangely configured kernels.

- do not install a callback handler, just embed the right conditions into

- fix bug in cg_is_legacy_wanted()

2 years agoRename cg_is_unified_elogind_controller_wanted to cg_is_hybrid_wanted
Zbigniew Jędrzejewski-Szmek [Sun, 19 Feb 2017 20:36:56 +0000 (15:36 -0500)]
Rename cg_is_unified_elogind_controller_wanted to cg_is_hybrid_wanted

Less typing and doesn't make the table so incredibly wide.

2 years agoshared/pager: abort if we cannot set environment variables
Zbigniew Jędrzejewski-Szmek [Sun, 19 Feb 2017 18:52:18 +0000 (13:52 -0500)]
shared/pager: abort if we cannot set environment variables

This most likely means oom, it's better to exit than to run less with
incomplete settings.

CID #714383.

2 years agologind: check return value from lseek
Zbigniew Jędrzejewski-Szmek [Sun, 19 Feb 2017 18:43:22 +0000 (13:43 -0500)]
logind: check return value from lseek

In practice this doesn't matter much because the read that follows will
likely fail, but we'll get a better error message.

CID #1368233.

2 years agobuild.h: include default cgroup hierarchy setting in --version output
Zbigniew Jędrzejewski-Szmek [Sun, 19 Feb 2017 04:28:01 +0000 (23:28 -0500)]
build.h: include default cgroup hierarchy setting in --version output

This is pretty important, and we print this string during startup, so putting
the default hierarchy information might help with diagnosis if things go awry.

$ ./systemctl --version
elogind 232

v2: make the message nicer by including the ./configure option argument
directly in output

2 years agopid1: add ./configure switch to select default cgroup hierarchy
Zbigniew Jędrzejewski-Szmek [Sun, 19 Feb 2017 04:13:15 +0000 (23:13 -0500)]
pid1: add ./configure switch to select default cgroup hierarchy

The default default is set to "legacy", with "hybrid" and "unified"
being the other two alternatives.

There invert the behaviour for elogind.legacy_elogind_cgroup_controller:
if it is not specified on the kernel command line, "hybrid" is used if
selected as the default. If this option is specified, "hybrid" is used if false,
and full "legacy" if true.

Also make all fields in the configure summary lowercase (unless they are
capitalized names) for consistency.

- update for the fixed interpreation of elogind.legacy_elogind_cgroup_controller

2 years agoTighten checking for variable validity
Zbigniew Jędrzejewski-Szmek [Sat, 18 Feb 2017 03:56:28 +0000 (22:56 -0500)]
Tighten checking for variable validity

In the future we might want to allow additional syntax (for example
"unset VAR". But let's check that the data we're getting does not contain
anything unexpected.

2 years agomissing: add renameat2() definition for 64bit arm (#5378)
Lennart Poettering [Fri, 17 Feb 2017 18:10:09 +0000 (19:10 +0100)]
missing: add renameat2() definition for 64bit arm (#5378)

Following a similar commit in casync:

2 years agovirt: Update cache if the detected vm is virtualbox (#5364)
Benjamin Robin [Fri, 17 Feb 2017 07:45:30 +0000 (08:45 +0100)]
virt: Update cache if the detected vm is virtualbox (#5364)

2 years agohostname-util: default to the compile time default hostname in gethostname_malloc()
Lennart Poettering [Thu, 16 Feb 2017 11:02:17 +0000 (12:02 +0100)]
hostname-util: default to the compile time default hostname in gethostname_malloc()

Currently, if the hostname is not set gethostname_malloc() defaults to
the "sysname", which is "linux" on Linux. Let's change that to also
honour the compile-time fallback hostname as specified on the configure
command line.

2 years agovirt: swap order of cpuid and dmi again, but properly detect oracle (#5355)
Christian Hesse [Wed, 15 Feb 2017 22:51:31 +0000 (23:51 +0100)]
virt: swap order of cpuid and dmi again, but properly detect oracle (#5355)

This breaks again, this time for setups where Qemu is not reported via DMI for whatever
reason. So swap order of cpuid and dmi again, but properly detect oracle.

See issue #5318.

2 years agovirt: detect qemu/kvm as 'kvm'
Christian Hesse [Tue, 14 Feb 2017 13:51:12 +0000 (14:51 +0100)]
virt: detect qemu/kvm as 'kvm'

In commit 050e65a we swapped order of detect_vm_{cpuid,dmi}(). That
fixed Virtualbox but broke qemu with kvm, which is expected to return
'kvm'. So check for qemu/kvm first, then DMI, CPUID last.

This fixes #5318.

Signed-off-by: Christian Hesse <>