chiark / gitweb /
elogind.git
5 years agomeson: use array type option
Yu Watanabe [Wed, 2 May 2018 04:56:28 +0000 (13:56 +0900)]
meson: use array type option

Array type option is supported since 0.44.0.

5 years agomeson: use warning() method
Yu Watanabe [Thu, 10 May 2018 05:50:52 +0000 (14:50 +0900)]
meson: use warning() method

This bumps the required minimum version of meson to 0.44, as
`warning()` method is supported since 0.44.

5 years agomeson: use get_supported_arguments()
Yu Watanabe [Thu, 10 May 2018 06:30:42 +0000 (15:30 +0900)]
meson: use get_supported_arguments()

This bumps the required minimum version of meson to 0.43, as
`get_supported_arguments()` is supported since meson-0.43.

5 years agotest: use _cleanup_hashmap_free_ instread of _cleanup_(hashmap_freep)
Yu Watanabe [Mon, 14 May 2018 05:14:17 +0000 (14:14 +0900)]
test: use _cleanup_hashmap_free_ instread of _cleanup_(hashmap_freep)

5 years agosd-bus: use free_and_strdup()
Yu Watanabe [Mon, 14 May 2018 05:09:03 +0000 (14:09 +0900)]
sd-bus: use free_and_strdup()

5 years agobus-util: add several macros for defining functions of getting dbus properties
Yu Watanabe [Sun, 13 May 2018 03:20:51 +0000 (12:20 +0900)]
bus-util: add several macros for defining functions of getting dbus properties

5 years agobasic: add log_level argument to timezone_is_valid
Mike Gilbert [Sat, 12 May 2018 19:20:13 +0000 (15:20 -0400)]
basic: add log_level argument to timezone_is_valid

5 years agobasic: timezone_is_valid: check for magic bytes "TZif"
Mike Gilbert [Thu, 10 May 2018 19:10:48 +0000 (15:10 -0400)]
basic: timezone_is_valid: check for magic bytes "TZif"

Fixes: https://github.com/systemd/systemd/issues/8905
5 years agotest: do not call alloca() inside the list of arguments
Yu Watanabe [Fri, 11 May 2018 06:01:35 +0000 (15:01 +0900)]
test: do not call alloca() inside the list of arguments

5 years agohexdecoct: drop an unnecessary check
Yu Watanabe [Fri, 11 May 2018 04:56:28 +0000 (13:56 +0900)]
hexdecoct: drop an unnecessary check

5 years agobasic: fix comment style
Yu Watanabe [Fri, 11 May 2018 04:55:28 +0000 (13:55 +0900)]
basic: fix comment style

5 years agohexdecoct: ignore whitespace within the input hexadecimal text of unhexmem()
Yu Watanabe [Fri, 11 May 2018 05:36:22 +0000 (14:36 +0900)]
hexdecoct: ignore whitespace within the input hexadecimal text of unhexmem()

5 years agoterminal-util: add a function that shows a pretty separator line
Lennart Poettering [Thu, 10 May 2018 18:28:33 +0000 (11:28 -0700)]
terminal-util: add a function that shows a pretty separator line

Follow-up for #8824

5 years agostring-util: rename strdash_if_empty() to empty_to_dash()
Yu Watanabe [Thu, 10 May 2018 16:55:46 +0000 (01:55 +0900)]
string-util: rename strdash_if_empty() to empty_to_dash()

5 years agopath-util: introduce empty_to_root() and use it many places
Yu Watanabe [Thu, 10 May 2018 16:47:33 +0000 (01:47 +0900)]
path-util: introduce empty_to_root() and use it many places

5 years agobasic/terminal-util: fix output of files without a final newline
Zbigniew Jędrzejewski-Szmek [Fri, 27 Apr 2018 07:39:53 +0000 (09:39 +0200)]
basic/terminal-util: fix output of files without a final newline

If the main config file or one of the drop-ins did not have the final newline,
there would be no seperating empty line (or if this was the last file
displayed, our own output would end without the final newline, possibly running
into the subsequent prompt or such). copy_bytes() does not know anything about
lines, so let's just use a normal loop with read_line() and puts().

5 years agoanalyze: add --root option for cat-config
Zbigniew Jędrzejewski-Szmek [Fri, 27 Apr 2018 06:55:16 +0000 (08:55 +0200)]
analyze: add --root option for cat-config

5 years agosysusers: add --cat-config
Zbigniew Jędrzejewski-Szmek [Thu, 26 Apr 2018 18:38:39 +0000 (20:38 +0200)]
sysusers: add --cat-config

5 years agotmpfiles: add --cat-config
Zbigniew Jędrzejewski-Szmek [Thu, 26 Apr 2018 17:07:54 +0000 (19:07 +0200)]
tmpfiles: add --cat-config

This implements similar logic as conf_files_cat(), but with slightly different
file gathering logic. I also want to add support for replacement files later on,
so it seems better to keep those two file-gathering functions separate.

5 years agoanalyze: add 'cat-config' verb
Zbigniew Jędrzejewski-Szmek [Thu, 26 Apr 2018 11:49:50 +0000 (13:49 +0200)]
analyze: add 'cat-config' verb

This is used as 'systemd-analyze show-config systemd/logind.conf', which
will dump
   /etc/systemd/system/user@.service
   /etc/systemd/system/user@.service.d/*.conf
   /run/systemd/system/user@.service.d/*.conf
   /usr/local/lib/systemd/system/user@.service.d/*.conf
   /usr/lib/systemd/system/user@.service.d/*.conf

The idea is to make it easy to dump the configuration using the same locations
and order that systemd programs use themselves (including masking, in the right
order, etc.). This is the generic variant that works with any configuration
scheme that follows the same general rules:

$ systemd-analyze cat-config systemd/system.conf
$ systemd-analyze cat-config systemd/user.conf
$ systemd-analyze cat-config systemd/logind.conf
$ systemd-analyze cat-config systemd/sleep.conf
$ systemd-analyze cat-config systemd/journald.conf
$ systemd-analyze cat-config systemd/journal-remote.conf
$ systemd-analyze cat-config systemd/journal-upload.conf
$ systemd-analyze cat-config systemd/coredump.conf
$ systemd-analyze cat-config systemd/resolved.conf
$ systemd-analyze cat-config systemd/timesyncd.conf
$ systemd-analyze cat-config udev/udev.conf

5 years agoMove function to cat file & dropins into basic/
Zbigniew Jędrzejewski-Szmek [Thu, 26 Apr 2018 11:03:39 +0000 (13:03 +0200)]
Move function to cat file & dropins into basic/

This fixes a buglet where the second and later drop-in would not be seperated
properly by a newline.

5 years agosd-bus: use automatic cleanup more
David Tardon [Thu, 10 May 2018 13:55:56 +0000 (15:55 +0200)]
sd-bus: use automatic cleanup more

5 years agobasic: use automatic cleanup more
David Tardon [Thu, 10 May 2018 12:10:53 +0000 (14:10 +0200)]
basic: use automatic cleanup more

5 years agobasic: use automatic cleanup more
David Tardon [Thu, 10 May 2018 12:08:35 +0000 (14:08 +0200)]
basic: use automatic cleanup more

5 years agocore/mount-setup: remove part of check which is always true
Zbigniew Jędrzejewski-Szmek [Thu, 10 May 2018 00:03:23 +0000 (02:03 +0200)]
core/mount-setup: remove part of check which is always true

k was set to join_controllers at this point and only incremented, so
it cannot be null at this point.

CID #1390949.

5 years agobasic/fs-util: remove logically dead code
Zbigniew Jędrzejewski-Szmek [Wed, 9 May 2018 23:55:05 +0000 (01:55 +0200)]
basic/fs-util: remove logically dead code

We can jump to chase_one from two places. In the first 'todo' is set to
'buffer', which comes from path_make_absolute_cwd() and is nonnull In the
second 'todo' is set to 'joined' which is checked to be nonull a few lines
above the jump. So let's kill the code that deals with null todo there.

CID #1390941.

5 years agologind: fix borked r check
Zbigniew Jędrzejewski-Szmek [Wed, 9 May 2018 23:34:33 +0000 (01:34 +0200)]
logind: fix borked r check

CID #1390947, #1390952.

5 years agobasic/format-table: add missing va_end()
Zbigniew Jędrzejewski-Szmek [Wed, 9 May 2018 23:22:29 +0000 (01:22 +0200)]
basic/format-table: add missing va_end()

CID #1390930, #1390940.

5 years agoshared/sleep-config: fix memleak of strv, add test
Zbigniew Jędrzejewski-Szmek [Wed, 9 May 2018 23:04:53 +0000 (01:04 +0200)]
shared/sleep-config: fix memleak of strv, add test

CID #1390921, #1390951.

5 years agoconf-parser: accept trailing backslash at the end of the file (#8941)
Filipe Brandenburger [Thu, 10 May 2018 01:10:07 +0000 (18:10 -0700)]
conf-parser: accept trailing backslash at the end of the file (#8941)

This makes it behave the same whether there is a blank line or not at
the end of the file.  This is also consistent with the behavior of the
shell on a shell script that ends on a trailing backslash at the last
line.

Added tests to test_config_parse(), which only pass if the corresponding
change to config_parse() is included.

5 years agomeson: recompile all sources for install_libudev_static and install_libsystemd_static
Zbigniew Jędrzejewski-Szmek [Wed, 25 Apr 2018 13:29:48 +0000 (15:29 +0200)]
meson: recompile all sources for install_libudev_static and install_libsystemd_static

This means that when those targets are built, all the sources are built again,
instead of reusing the work done to create libbasic.a and other convenience static
libraries. It would be nice to not do this, but there seems to be no support in
our toolchain for joining multiple static libraries into one. When linking
a static library, any -l arguments are simply ignored by ar/gcc-ar, and .a
libraries given as positional arguments are copied verbatim into the archive
so they objects in them cannot be accessed.

https://stackoverflow.com/questions/2157629/linking-static-libraries-to-other-static-libraries
suggests either unzipping all the archives and putting them back togather,
or using a linker script. Unzipping and zipping back together seems ugly.
The other option is not very nice. The linker script language does not
allow "+" to appear in the filenames, and filenames that meson generates
use that, so files would have to be renamed before a linker script was used.
And we would have to generate the linker script on the fly. Either way, this
doesn't seem attractive. Since those static libraries are a niche use case,
it seems reasonable to just go with the easiest and safest solution and
recompile all the source files. Thanks to ccache, this is probably almost as
cheap as actually reusing the convenience .a libraries.

test-libsystemd-sym.c and test-libudev-sym.c compile fine with the generated
static libs, so it seems that they indeed provide all the symbols they should.

5 years agomeson: only build test-lib{systemd,udev}-static-sym for pic
Davide Cavalca [Tue, 24 Apr 2018 20:34:48 +0000 (13:34 -0700)]
meson: only build test-lib{systemd,udev}-static-sym for pic

5 years agomeson: add test-lib{systemd,udev}-static-sym
Zbigniew Jędrzejewski-Szmek [Mon, 23 Apr 2018 11:49:27 +0000 (13:49 +0200)]
meson: add test-lib{systemd,udev}-static-sym

This is the same as test-lib{systemd,udev}-sym, but linked to the static
variants of those libraries.

5 years agomeson: add support for building static libsystemd and libudev
Davide Cavalca [Mon, 9 Apr 2018 09:43:35 +0000 (02:43 -0700)]
meson: add support for building static libsystemd and libudev

5 years agotree-wide: use strv_free_and_replace() macro
Yu Watanabe [Wed, 9 May 2018 15:34:46 +0000 (00:34 +0900)]
tree-wide: use strv_free_and_replace() macro

5 years agotime-util: fix indentation for comments
Yu Watanabe [Wed, 9 May 2018 13:50:07 +0000 (22:50 +0900)]
time-util: fix indentation for comments

5 years agosd-bus: add bus_freep and use _cleanup_
Zbigniew Jędrzejewski-Szmek [Wed, 9 May 2018 07:44:37 +0000 (09:44 +0200)]
sd-bus: add bus_freep and use _cleanup_

5 years agosd-bus: use automatic cleanup more
Zbigniew Jędrzejewski-Szmek [Wed, 9 May 2018 07:35:01 +0000 (09:35 +0200)]
sd-bus: use automatic cleanup more

5 years agosd-bus: trivial simplification
Zbigniew Jędrzejewski-Szmek [Wed, 9 May 2018 07:25:03 +0000 (09:25 +0200)]
sd-bus: trivial simplification

5 years agouse max. message size allowed by DBus spec (#8936)
David Tardon [Wed, 9 May 2018 08:33:28 +0000 (10:33 +0200)]
use max. message size allowed by DBus spec (#8936)

C.f. https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages.

5 years agobus-util: print a friendly message when PID1 is not systemd
Yu Watanabe [Wed, 9 May 2018 08:06:46 +0000 (17:06 +0900)]
bus-util: print a friendly message when PID1 is not systemd

Follow-up for 861f16d2679eeda79e8185057cef24653913e300.

Fixes #8913.

5 years agologin: do not wall message on cancelling shutdown when Manager.enable_wall_messages...
Yu Watanabe [Mon, 7 May 2018 01:16:04 +0000 (10:16 +0900)]
login: do not wall message on cancelling shutdown when Manager.enable_wall_messages is false

Fixes #8904.

5 years agologin: change variable type of enable_wall_messages as it matches Manager.enable_wall...
Yu Watanabe [Mon, 7 May 2018 01:13:54 +0000 (10:13 +0900)]
login: change variable type of enable_wall_messages as it matches Manager.enable_wall_messages

5 years agoupdate TODO
Lennart Poettering [Mon, 30 Apr 2018 19:20:31 +0000 (21:20 +0200)]
update TODO

5 years agoman: update references to systemd-journal-{remote,upload}
Yu Watanabe [Tue, 8 May 2018 01:14:02 +0000 (10:14 +0900)]
man: update references to systemd-journal-{remote,upload}

Fixes #8920 and #8921.

5 years agomeson: generate m4 preprocessor from config.h (#8914)
Yu Watanabe [Mon, 7 May 2018 09:17:35 +0000 (18:17 +0900)]
meson: generate m4 preprocessor from config.h (#8914)

5 years agoman: add explanations of show-timesync and timesync-status commands
Yu Watanabe [Mon, 30 Apr 2018 13:42:40 +0000 (22:42 +0900)]
man: add explanations of show-timesync and timesync-status commands

5 years agotimedatectl: add timesync-status and show-timesync commands
Yu Watanabe [Thu, 3 May 2018 09:07:43 +0000 (18:07 +0900)]
timedatectl: add timesync-status and show-timesync commands

Closes #1589.

5 years agotest: add tests for signal_from_string()
Yu Watanabe [Thu, 3 May 2018 07:47:12 +0000 (16:47 +0900)]
test: add tests for signal_from_string()

5 years agoutil: rename signal_from_string_try_harder() to signal_from_string()
Yu Watanabe [Thu, 3 May 2018 07:38:57 +0000 (16:38 +0900)]
util: rename signal_from_string_try_harder() to signal_from_string()

Also this makes the new `signal_from_string()` function reject
e.g, `SIG3` or `SIG+5`.

5 years agoutil: make signal_from_string() accept RTMIN, RTMAX, and RTMAX-n
Yu Watanabe [Thu, 3 May 2018 07:40:02 +0000 (16:40 +0900)]
util: make signal_from_string() accept RTMIN, RTMAX, and RTMAX-n

Before this, `signal_from_string()` accepts simple signal name
or RTMIN+n. This makes the function also accept RTMIN, RTMAX,
and RTMAX-n.
Note that RTMIN+0 is equivalent to RTMIN, and RTMAX-0 is to RTMAX.

This also fixes the integer overflow reported by oss-fuzz #8064.
https://oss-fuzz.com/v2/testcase-detail/5648573352902656

5 years agomeson.build: Fix new executable systemd-user-runtime-dir, that we do not need.
Sven Eden [Fri, 10 Aug 2018 15:31:26 +0000 (17:31 +0200)]
meson.build: Fix new executable systemd-user-runtime-dir, that we do not need.

5 years agovirt: simplifications
Lennart Poettering [Mon, 30 Apr 2018 10:24:57 +0000 (12:24 +0200)]
virt: simplifications

Let's simplify the code a bit. Let's reduce the number of redundant if
checks a bit, (i.e. if we want to check for equality with
VIRTUALIZATION_VM_OTHER there's no need to check for non-equality with
VIRTUALIZATION_NONE first). As a very welcome side-effect this means we
lose some lines of code and our level of indentation is reduced.

No changes in behaviour.

5 years agovirt: if we detect Xen by DMI, trust that over CPUID
Lennart Poettering [Mon, 30 Apr 2018 10:23:03 +0000 (12:23 +0200)]
virt: if we detect Xen by DMI, trust that over CPUID

Apparently Xen sometimes lies about its identity when queried via CPUID.
Let's hence prefer DMI tests for CPUID

Fixes: #8844
5 years agopwx: Use latest check_tree.pl revision.
Sven Eden [Fri, 10 Aug 2018 05:57:45 +0000 (07:57 +0200)]
pwx: Use latest check_tree.pl revision.

5 years agotest: add tests for signal_from_string()
Yu Watanabe [Thu, 3 May 2018 07:47:12 +0000 (16:47 +0900)]
test: add tests for signal_from_string()

5 years agoutil: rename signal_from_string_try_harder() to signal_from_string()
Yu Watanabe [Thu, 3 May 2018 07:38:57 +0000 (16:38 +0900)]
util: rename signal_from_string_try_harder() to signal_from_string()

Also this makes the new `signal_from_string()` function reject
e.g, `SIG3` or `SIG+5`.

5 years agoutil: make signal_from_string() accept RTMIN, RTMAX, and RTMAX-n
Yu Watanabe [Thu, 3 May 2018 07:40:02 +0000 (16:40 +0900)]
util: make signal_from_string() accept RTMIN, RTMAX, and RTMAX-n

Before this, `signal_from_string()` accepts simple signal name
or RTMIN+n. This makes the function also accept RTMIN, RTMAX,
and RTMAX-n.
Note that RTMIN+0 is equivalent to RTMIN, and RTMAX-0 is to RTMAX.

This also fixes the integer overflow reported by oss-fuzz #8064.
https://oss-fuzz.com/v2/testcase-detail/5648573352902656

5 years agomeson: drop 'name' argument in cc.has_argument() (#8878)
Yu Watanabe [Wed, 2 May 2018 08:05:51 +0000 (17:05 +0900)]
meson: drop 'name' argument in cc.has_argument() (#8878)

5 years agoBump pwx migration tools and fix doubled line in meson.build.
Sven Eden [Wed, 8 Aug 2018 06:00:08 +0000 (08:00 +0200)]
Bump pwx migration tools and fix doubled line in meson.build.

5 years agovirt: simplifications
Lennart Poettering [Mon, 30 Apr 2018 10:24:57 +0000 (12:24 +0200)]
virt: simplifications

Let's simplify the code a bit. Let's reduce the number of redundant if
checks a bit, (i.e. if we want to check for equality with
VIRTUALIZATION_VM_OTHER there's no need to check for non-equality with
VIRTUALIZATION_NONE first). As a very welcome side-effect this means we
lose some lines of code and our level of indentation is reduced.

No changes in behaviour.

5 years agovirt: if we detect Xen by DMI, trust that over CPUID
Lennart Poettering [Mon, 30 Apr 2018 10:23:03 +0000 (12:23 +0200)]
virt: if we detect Xen by DMI, trust that over CPUID

Apparently Xen sometimes lies about its identity when queried via CPUID.
Let's hence prefer DMI tests for CPUID

Fixes: #8844
5 years agolocale-util: add comment with link to unicode chars supported by eurlatgr (#8894)
Lennart Poettering [Thu, 3 May 2018 14:15:04 +0000 (16:15 +0200)]
locale-util: add comment with link to unicode chars supported by eurlatgr (#8894)

See: #6443

5 years agomount-setup: add a comment that the character/block device nodes are "optional" ...
Lennart Poettering [Thu, 3 May 2018 14:10:35 +0000 (16:10 +0200)]
mount-setup: add a comment that the character/block device nodes are "optional" (#8893)

if we lack privs to create device nodes that's fine, and creating
/run/systemd/inaccessible/chr or /run/systemd/inaccessible/blk won't
work then. Document this in longer comments.

Fixes: #4484
5 years agotest: add tests for signal_from_string()
Yu Watanabe [Thu, 3 May 2018 07:47:12 +0000 (16:47 +0900)]
test: add tests for signal_from_string()

5 years agoutil: rename signal_from_string_try_harder() to signal_from_string()
Yu Watanabe [Thu, 3 May 2018 07:38:57 +0000 (16:38 +0900)]
util: rename signal_from_string_try_harder() to signal_from_string()

Also this makes the new `signal_from_string()` function reject
e.g, `SIG3` or `SIG+5`.

5 years agoutil: make signal_from_string() accept RTMIN, RTMAX, and RTMAX-n
Yu Watanabe [Thu, 3 May 2018 07:40:02 +0000 (16:40 +0900)]
util: make signal_from_string() accept RTMIN, RTMAX, and RTMAX-n

Before this, `signal_from_string()` accepts simple signal name
or RTMIN+n. This makes the function also accept RTMIN, RTMAX,
and RTMAX-n.
Note that RTMIN+0 is equivalent to RTMIN, and RTMAX-0 is to RTMAX.

This also fixes the integer overflow reported by oss-fuzz #8064.
https://oss-fuzz.com/v2/testcase-detail/5648573352902656

5 years agoupdate TODO
Lennart Poettering [Thu, 3 May 2018 13:13:42 +0000 (15:13 +0200)]
update TODO

5 years agoset: drop unused set_make() function (#8879)
Yu Watanabe [Wed, 2 May 2018 08:54:52 +0000 (17:54 +0900)]
set: drop unused set_make() function (#8879)

The function causes compiler error when built with '-Ddebug=hashmap',
and is not used anymore. Let's drop it.

5 years agomeson: drop 'name' argument in cc.has_argument() (#8878)
Yu Watanabe [Wed, 2 May 2018 08:05:51 +0000 (17:05 +0900)]
meson: drop 'name' argument in cc.has_argument() (#8878)

5 years agoadd __nr_statx defines for extra architectures (#8872)
Adam Duskett [Wed, 2 May 2018 08:04:50 +0000 (04:04 -0400)]
add __nr_statx defines for extra architectures (#8872)

This includes:
 - arm
 - arm64
 - alpha
 - powerpc64
 - sparc

Taken from kernel 4.16.6

5 years agoupdate TODO
Lennart Poettering [Fri, 27 Apr 2018 19:31:43 +0000 (21:31 +0200)]
update TODO

5 years agologind: (void)ify all things we knowingly ignore
Lennart Poettering [Tue, 24 Apr 2018 16:16:14 +0000 (18:16 +0200)]
logind: (void)ify all things we knowingly ignore

5 years agologind: terminate cleanly on SIGTERM/SIGINT
Lennart Poettering [Tue, 24 Apr 2018 16:14:25 +0000 (18:14 +0200)]
logind: terminate cleanly on SIGTERM/SIGINT

Let's properly terminate on SIGTERM or SIGINT. Previously we'd just rely
on the implicit process clean-up logic on UNIX. By shutting down
properly on SIGTERM/SIGINT we make it easier to track down memory leaks
by employing valgrind.

5 years agologind: modernize Manager object allocation and freeing
Lennart Poettering [Tue, 24 Apr 2018 16:13:12 +0000 (18:13 +0200)]
logind: modernize Manager object allocation and freeing

Let's propagate errors correctly, and stick to the usual naming and
behaviour of these functions. Or in other words, make this closer to the
matching code in machined.

5 years agobasic/log: always ignore errno from the enviornment (#8841)
Zbigniew Jędrzejewski-Szmek [Fri, 27 Apr 2018 16:00:58 +0000 (18:00 +0200)]
basic/log: always ignore errno from the enviornment (#8841)

This extends the change done in b29f6480ec to other logging functions.

This actually fixes some bugs in callers of log_struct(), for example
config_parse_alias() called 'return log_syntax(..., 0, ...)' which could result
in a bogus non-zero return value.

Calls to log_object() and log_format_iovec() — which is only used by
server_driver_message() — appear correct.

5 years agoupdate TODO
Lennart Poettering [Fri, 27 Apr 2018 12:28:51 +0000 (14:28 +0200)]
update TODO

5 years agotree-wide: use newa() rather than alloca() where we can
Lennart Poettering [Fri, 27 Apr 2018 12:28:35 +0000 (14:28 +0200)]
tree-wide: use newa() rather than alloca() where we can

5 years agoalloca: add an overflow check too
Lennart Poettering [Fri, 27 Apr 2018 12:27:14 +0000 (14:27 +0200)]
alloca: add an overflow check too

Of course, alloca() shouldn't be used with anything that can grow
without bounds anyway, but let's better safe than sorry, and catch this
early.

Since alloca() is not supposed to return an error we trigger an
assert() instead, which is still better than heap trickery.

5 years agotree-wide: be more careful with the type of array sizes
Lennart Poettering [Fri, 27 Apr 2018 12:09:31 +0000 (14:09 +0200)]
tree-wide: be more careful with the type of array sizes

Previously we were a bit sloppy with the index and size types of arrays,
we'd regularly use unsigned. While I don't think this ever resulted in
real issues I think we should be more careful there and follow a
stricter regime: unless there's a strong reason not to use size_t for
array sizes and indexes, size_t it should be. Any allocations we do
ultimately will use size_t anyway, and converting forth and back between
unsigned and size_t will always be a source of problems.

Note that on 32bit machines "unsigned" and "size_t" are equivalent, and
on 64bit machines our arrays shouldn't grow that large anyway, and if
they do we have a problem, however that kind of overly large allocation
we have protections for usually, but for overflows we do not have that
so much, hence let's add it.

So yeah, it's a story of the current code being already "good enough",
but I think some extra type hygiene is better.

This patch tries to be comprehensive, but it probably isn't and I missed
a few cases. But I guess we can cover that later as we notice it. Among
smaller fixes, this changes:

1. strv_length()' return type becomes size_t

2. the unit file changes array size becomes size_t

3. DNS answer and query array sizes become size_t

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=76745
5 years agologin: drop unnecessary headers
Yu Watanabe [Fri, 27 Apr 2018 08:50:26 +0000 (17:50 +0900)]
login: drop unnecessary headers

5 years agologind: remove manager_start_slice()
Zbigniew Jędrzejewski-Szmek [Tue, 24 Apr 2018 07:41:34 +0000 (09:41 +0200)]
logind: remove manager_start_slice()

It is now unused.

5 years agologind: split %t directory creation to a helper unit
Zbigniew Jędrzejewski-Szmek [Sat, 9 Dec 2017 18:30:17 +0000 (19:30 +0100)]
logind: split %t directory creation to a helper unit

Unfortunately this needs a new binary to do the mount because there's just
too many special steps to outsource this to systemd-mount:
- EPERM needs to be treated specially
- UserRuntimeDir= setting must be obeyed
- SELinux label must be adjusted

This allows user@.service to be started independently of logind.
So 'systemctl start user@nnn' will start the user manager for user nnn.
Logind will start it too when the user logs in, and will stop it (unless
lingering is enabled) when the user logs out.

Fixes #7339.

5 years agoUse a dash-truncated drop-in for user-%j.slice configuration
Zbigniew Jędrzejewski-Szmek [Thu, 7 Dec 2017 21:25:26 +0000 (22:25 +0100)]
Use a dash-truncated drop-in for user-%j.slice configuration

This removes the UserTasksMax= setting in logind.conf. Instead, the generic
TasksMax= setting on the slice should be used. Instead of a transient unit we
use a drop-in to tweak the default definition of a .slice. It's better to use
the normal unit mechanisms instead of creating units on the fly. This will also
make it easier to start user@.service independently of logind, or set
additional settings like MemoryMax= for user slices.

The setting in logind is removed, because otherwise we would have two sources
of "truth": the slice on disk and the logind config. Instead of trying to
coordinate those two sources of configuration (and maintainer overrides to
both), let's just convert to the new one fully.

Right now now automatic transition mechanism is provided. logind will emit a
hint when it encounters the setting, but otherwise it will be ignored.

Fixes #2556.

5 years agologind: move two functions to logind_core utility lib
Zbigniew Jędrzejewski-Szmek [Sat, 9 Dec 2017 10:53:17 +0000 (11:53 +0100)]
logind: move two functions to logind_core utility lib

In preparation to reusing them later in other places...

5 years agotests: add some tests for unit_name_is_valid() and related functions
Zbigniew Jędrzejewski-Szmek [Thu, 7 Dec 2017 13:42:45 +0000 (14:42 +0100)]
tests: add some tests for unit_name_is_valid() and related functions

I was surprised to see that foo@bar@bar.service is a valid unit
name. Apparently it is according to current code and docs.

5 years agoconf-parse: add a generic config_parse_mtu() conf file parser function
Lennart Poettering [Fri, 20 Apr 2018 14:31:17 +0000 (16:31 +0200)]
conf-parse: add a generic config_parse_mtu() conf file parser function

It's mostly a wrapper around parse_mtu() but with some nicer logging.

The address family is initialized from the "ltype" parameter, so that
configuration file parser tables can be easily declare it.

5 years agoparse-util: add explicit parsers for MTU values
Lennart Poettering [Fri, 20 Apr 2018 14:28:12 +0000 (16:28 +0200)]
parse-util: add explicit parsers for MTU values

We use MTUs all over the place, let's add a unified, strict parser for
it, that takes MTU ranges into account.

We already have parse_ifindex() close-by, hence this appears to be a
natural addition, in particular as the range checking is not entirely
trivial to do, as it depends on the protocol used.

5 years agomissing: add IPV4_MIN_MTU
Lennart Poettering [Fri, 20 Apr 2018 14:18:09 +0000 (16:18 +0200)]
missing: add IPV4_MIN_MTU

Similar to IPV6_MIN_MTU, let's add the same for IPv4.

5 years agocgroup-util: fix enabling of controllers (#8816)
Antique [Thu, 26 Apr 2018 10:37:35 +0000 (12:37 +0200)]
cgroup-util: fix enabling of controllers (#8816)

If enabling controller for some reason fails we need to clear error
for the FILE stream.  Enabling remaining controllers would otherwise
fail because write_string_stream_ts() checks for ferror(f) and returns
-EIO if there is one.

Broken by commit <77fa610b22>.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
5 years agomeson: drop 'name' argument in cc.has_argument() (#8823)
Yu Watanabe [Thu, 26 Apr 2018 08:53:10 +0000 (17:53 +0900)]
meson: drop 'name' argument in cc.has_argument() (#8823)

This fixes the following warning with clang and meson-0.46.0,
```
WARNING: Passed invalid keyword argument "name".
WARNING: This will become a hard error in the future.
WARNING: Passed invalid keyword argument "name".
WARNING: This will become a hard error in the future.
Compiler for C supports arguments -Wno-typedef-redefinition: YES
WARNING: Passed invalid keyword argument "name".
WARNING: This will become a hard error in the future.
WARNING: Passed invalid keyword argument "name".
WARNING: This will become a hard error in the future.
Compiler for C supports arguments -Wno-gnu-variable-sized-type-not-at-end: YES
```

5 years agoman: fix description of --value option for loginctl (#8820)
Yu Watanabe [Thu, 26 Apr 2018 07:51:11 +0000 (16:51 +0900)]
man: fix description of --value option for loginctl (#8820)

5 years agomeson: do not link libsystemd_static into libcore (#8813)
Zbigniew Jędrzejewski-Szmek [Wed, 25 Apr 2018 11:47:18 +0000 (13:47 +0200)]
meson: do not link libsystemd_static into libcore (#8813)

(or in terms of the names of the actual files on disk, do not link
libsystemd-shared-238.a into libcore.a).

libsystemd_static is linked into libsystemd_shared, which in turn means that
anything that links to libcore and libsystemd_shared will get libsystemd_static
twice:

$ cc -o systemd 'systemd@exe/src_core_main.c.o' -Wl,--no-undefined -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -pie -DVALGRIND -Wl,--start-group src/core/libcore.a src/shared/libsystemd-shared-238.a src/shared/libsystemd-shared-238.so -pthread -lrt -lseccomp -lselinux -lmount -lblkid -Wl,--end-group -lseccomp -lpam -L/lib64 -laudit -lkmod -lmount -lrt -lcap -lacl -lcryptsetup -lgcrypt -lip4tc -lip6tc -lseccomp -lselinux -lidn -llzma -llz4 -lblkid '-Wl,-rpath,$ORIGIN/src/shared' -Wl,-rpath-link,/home/zbyszek/src/systemd/build/src/shared

This propagation of the dependency seems correct (in the sense that meson is
doing the expected thing based on the given configuration). Linking was done
this way in the original meson conversion. I was probably trying to get
everything to compile and link, I'm not sure why this particular choice was
made. In the meantime, meson has gotten better at propagating dependencies, so
it's possible that this had slightly different effect in the original
conversion, but I did not verify this. Either way, I think we should drop this.

With the patch:
$ cc -o systemd 'systemd@exe/src_core_main.c.o' -Wl,--no-undefined -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -pie -DVALGRIND -Wl,--start-group src/core/libcore.a src/shared/libsystemd-shared-238.so -pthread -lrt -lseccomp -lselinux -lmount -Wl,--end-group -lblkid -lrt -lseccomp -lpam -L/lib64 -laudit -lkmod -lselinux -lmount '-Wl,-rpath,$ORIGIN/src/shared' -Wl,-rpath-link,/home/zbyszek/src/systemd/build/src/shared

This is more correct because we're not linking the same code twice.
With the patch, libystemd_static is used in exactly four places:
- src/shared/libsystemd-shared-238.so
- src/udev/libudev.so.1.6.10
- pam_systemd.so
- test-bus-error
(compared to a bunch more executables before, including systemd,
systemd-analyze, test-hostname, test-ns, etc.)

Size savings are also noticable:

$ size /var/tmp/inst?/usr/lib/systemd/libsystemd-shared-238.so
   text    data     bss     dec     hex filename
2397826  578488   15920 2992234  2da86a /var/tmp/inst1/usr/lib/systemd/libsystemd-shared-238.so
2397826  578488   15920 2992234  2da86a /var/tmp/inst2/usr/lib/systemd/libsystemd-shared-238.so

$ size /var/tmp/inst?/usr/lib/systemd/systemd
   text    data     bss     dec     hex filename
1858790  261688    9320 2129798  207f86 /var/tmp/inst1/usr/lib/systemd/systemd
1556358  258704    8072 1823134  1bd19e /var/tmp/inst2/usr/lib/systemd/systemd

$ du -s /var/tmp/inst?
52216 /var/tmp/inst1
50844 /var/tmp/inst2

https://github.com/google/oss-fuzz/issues/1330#issuecomment-384054530 might be related.

5 years agotree-wide: drop redundant _cleanup_ macros (#8810)
Lennart Poettering [Wed, 25 Apr 2018 10:31:45 +0000 (12:31 +0200)]
tree-wide: drop redundant _cleanup_ macros (#8810)

This drops a good number of type-specific _cleanup_ macros, and patches
all users to just use the generic ones.

In most recent code we abstained from defining type-specific macros, and
this basically removes all those added already, with the exception of
the really low-level ones.

Having explicit macros for this is not too useful, as the expression
without the extra macro is generally just 2ch wider. We should generally
emphesize generic code, unless there are really good reasons for
specific code, hence let's follow this in this case too.

Note that _cleanup_free_ and similar really low-level, libc'ish, Linux
API'ish macros continue to be defined, only the really high-level OO
ones are dropped. From now on this should really be the rule: for really
low-level stuff, such as memory allocation, fd handling and so one, go
ahead and define explicit per-type macros, but for high-level, specific
program code, just use the generic _cleanup_() macro directly, in order
to keep things simple and as readable as possible for the uninitiated.

Note that before this patch some of the APIs (notable libudev ones) were
already used with the high-level macros at some places and with the
generic _cleanup_ macro at others. With this patch we hence unify on the
latter.

5 years agofileio.c: fix incorrect mtime
Chris Lesiak [Tue, 24 Apr 2018 14:50:42 +0000 (09:50 -0500)]
fileio.c: fix incorrect mtime

A regression was introduced that caused the mtime of /etc/.updated
and /var/.updated to be the current time when systemd-update-done
ran instead of being copied from /usr.

This was nearly fixed, but due to fflush being called after mtime
was carefully set, it was overwritten with the current time.

Regression introduced in 872c40396384f9fa89b01baf4e739d28ed590299

A fix was just missed in 39c38d773fbe2b4f76ff29ecd3344640efb9a86c

Fixes #8806

5 years agoupdate TODO
Lennart Poettering [Fri, 20 Apr 2018 13:22:02 +0000 (15:22 +0200)]
update TODO

5 years agostring-util: use fflush_and_check() where appropriate
Lennart Poettering [Fri, 20 Apr 2018 13:22:29 +0000 (15:22 +0200)]
string-util: use fflush_and_check() where appropriate

5 years agostring-util: teach strip_tab_ansi() to deal with CSO sequences
Lennart Poettering [Fri, 20 Apr 2018 13:16:13 +0000 (15:16 +0200)]
string-util: teach strip_tab_ansi() to deal with CSO sequences

With the recent terminal_urlify() APIs we'll now sometimes generate
clickable link CSO sequences. Hence we should also be able to remove
them again from strings. This beefs up the logic to do so.

Follow-up for: 23b27b39d2a3a002ad827a2e8a9872a51495d797

5 years agobasic/log: do not use global errno in log_*_errno()
Zbigniew Jędrzejewski-Szmek [Tue, 24 Apr 2018 11:57:38 +0000 (13:57 +0200)]
basic/log: do not use global errno in log_*_errno()

Quoting https://github.com/systemd/systemd/pull/8760#discussion_r183321060:

> When we originally added the errno patching we went for a "best of both
> worlds" approach, i.e. that we override errno if an error is specified, but
> if no error is specified (i.e. 0 is passed as error code) then we use the
> previously set errno, similar in style how plain `printf()` would do it. In
> retrospect I think we almost never purposefully made use of the second,
> i.e. the plain `printf()` logic, but we multiple times ran into this case
> accidentally and introduced a bug. Hence yes, it probably makes sense to
> switch this over, and consistently ignore the `errno` already set and always
> override it with the error passed in. The only problem I see with that is: I
> wonder if there might be a case or two lurking somewhere where we actually
> made use of the "best of both worlds" approach, and if so, if we can detect
> where... (But then again, even if there is, and we fail to find those cases,
> maybe that's not all bad, as it's just a few new bugs against probably fixing
> many more old and future bugs, if you follow what I mean).

I scanned our codebase, and found some bugs in the value passed to log_*_errno,
but no intentional cases of error=0 being passed.

5 years agobasic/audit-util: always log the reason when disabling audit logs
Zbigniew Jędrzejewski-Szmek [Tue, 24 Apr 2018 11:46:58 +0000 (13:46 +0200)]
basic/audit-util: always log the reason when disabling audit logs

This state is cached, and it's seems OK to log at least once.