chiark / gitweb /
elogind.git
6 years agolog: let's make use of the fact that our functions return the negative error code...
Lennart Poettering [Mon, 25 Sep 2017 18:26:47 +0000 (20:26 +0200)]
log: let's make use of the fact that our functions return the negative error code for log_oom() too

6 years agoswap: adjust swap.c in a similar way to what we just did to mount.c
Lennart Poettering [Mon, 25 Sep 2017 17:53:19 +0000 (19:53 +0200)]
swap: adjust swap.c in a similar way to what we just did to mount.c

Also drop the redundant states and make all similar changes too.
Thankfully the swap.c state engine is much simpler than mount.c's, hence
this should be easier to digest.

6 years agomount: rework mount state engine
Lennart Poettering [Mon, 25 Sep 2017 17:13:37 +0000 (19:13 +0200)]
mount: rework mount state engine

This changes the mount unit state engine in the following ways:

1. The MOUNT_MOUNTING_SIGTERM and MOUNT_MOUNTING_SIGKILL are removed.
   They have been pretty much equivalent to MOUNT_UNMOUNTING_SIGTERM and
   MOUNT_UNMOUNTING_SIGKILL in what they do, and the outcome has been
   the same as well: the unit is stopped. Hence, let's simplify things a
   bit, and merge them. Note that we keep
   MOUNT_REMOUNTING_{SIGTERM|SIGKILL} however, as those states have a
   different outcome: the unit remains started.

2. mount_enter_signal() will now honour the SendSIGKILL= option of the
   mount unit if it was set. This was previously done already when we
   entered the signal states through a timeout, and was simply missing
   here.

3. A new helper function mount_enter_dead_or_mounted() is added that
   places the mount unit in either MOUNT_DEAD or MOUNT_MOUNTED,
   depending on what the kernel thinks about the mount's state. This
   function is called at various places now, wherever we finished an
   operation, and want to make sure our own state reflects again what
   the kernel thinks. Previously we had very similar code in a number of
   places and in other places didn't recheck the kernel state. Let's do
   that with the same logic and function at all relevant places now.

4. Rework mount_stop(): never forget about running control processes.
   Instead: when we have a start (i.e. a /bin/mount) process running,
   and are asked to stop, then enter the kill states for it, so that it
   gets cleaned up. This fixes #6048. Moreover, when we have a reload
   process running convert the possible states into the relevant
   unmounting states, so that we can properly execute the requested
   operation.

Fixes #6048

6 years agoset: add new helper set_make() which is like set_new() + multiple set_put() in vararg
Lennart Poettering [Mon, 25 Sep 2017 15:15:59 +0000 (17:15 +0200)]
set: add new helper set_make() which is like set_new() + multiple set_put() in vararg

6 years agobasic/log: fix return value from log_struct_iovec_internal()
Zbigniew Jędrzejewski-Szmek [Tue, 26 Sep 2017 14:04:33 +0000 (16:04 +0200)]
basic/log: fix return value from log_struct_iovec_internal()

This returned value so far wasn't used anywhere, so there's no change
in behaviour.

6 years agostring-util: use size_t for strjoina macro (#6914)
Jonathan Lebon [Mon, 25 Sep 2017 19:56:57 +0000 (15:56 -0400)]
string-util: use size_t for strjoina macro (#6914)

`strlen` returns a `size_t` and `alloca` expects a `size_t`.

6 years agoshared/bus-util: format uid==-1 and gid==-1 as [not set]
Zbigniew Jędrzejewski-Szmek [Mon, 25 Sep 2017 09:23:59 +0000 (11:23 +0200)]
shared/bus-util: format uid==-1 and gid==-1 as [not set]

$ systemctl show elogind-journald -p UID,GID
UID=4294967295
GID=4294967295



$ systemctl show elogind-journald -p UID,GID
UID=[not set]
GID=[not set]

Just seeing the number is very misleading.

Fixes #6511.

6 years agobasic/cap-list: report empty capability set as ""
Zbigniew Jędrzejewski-Szmek [Mon, 25 Sep 2017 09:09:57 +0000 (11:09 +0200)]
basic/cap-list: report empty capability set as ""

$ systemctl show elogind-journald -p CapabilityBoundingSet,AmbientCapabilities
CapabilityBoundingSet=cap_chown cap_dac_override cap_dac_read_search cap_fowner cap_setgid ...
AmbientCapabilities=(null)



$ systemctl show elogind-journald -p CapabilityBoundingSet,AmbientCapabilities
CapabilityBoundingSet=cap_chown cap_dac_override cap_dac_read_search cap_fowner cap_setgid ...
AmbientCapabilities=

Partially fixes #6511. Add some basic tests for the printing function.

6 years agofileio: return 0 from read_one_line_file on success
Zbigniew Jędrzejewski-Szmek [Sun, 24 Sep 2017 12:27:21 +0000 (14:27 +0200)]
fileio: return 0 from read_one_line_file on success

Fixup for f4b51a2d09. Suggested by Evgeny Vereshchagin.

6 years agofileio: initialize errno to zero before we do fread()
Lennart Poettering [Fri, 22 Sep 2017 19:05:03 +0000 (21:05 +0200)]
fileio: initialize errno to zero before we do fread()

if there was something in the read buffer already errno might not be set
on error, let's detect that case.

6 years agofileio: try to read one byte too much in read_full_stream()
Lennart Poettering [Fri, 22 Sep 2017 19:03:33 +0000 (21:03 +0200)]
fileio: try to read one byte too much in read_full_stream()

Let's read one byte more than the file size we read from stat() on the
first fread() invocation. That way, the first read() will already be
short and indicate eof to fread().

This is a minor optimization, and replaces #3908.

6 years agofileio: move fsync() logic into write_string_stream_ts()
Lennart Poettering [Fri, 22 Sep 2017 18:59:39 +0000 (20:59 +0200)]
fileio: move fsync() logic into write_string_stream_ts()

That way, write_string_stream_ts() becomes more powerful, and we can
remove duplicate code from  write_string_file_atomic() and
write_string_file_ts().

6 years agofileio: make write_string_stream() accept flags parameter
Lennart Poettering [Fri, 22 Sep 2017 18:55:34 +0000 (20:55 +0200)]
fileio: make write_string_stream() accept flags parameter

Let's make write_string_stream() and write_string_file() more alike, and
pass the same flag set so that we can remove a number of boolean
parameters.

6 years agofileio: support writing atomic files with timestamp
Lennart Poettering [Fri, 22 Sep 2017 18:45:06 +0000 (20:45 +0200)]
fileio: support writing atomic files with timestamp

Let's make sure "ts" is taken into account when writing atomic files,
too.

6 years agocgroup: rework which files we chown() on delegation
Lennart Poettering [Fri, 22 Sep 2017 17:58:24 +0000 (19:58 +0200)]
cgroup: rework which files we chown() on delegation

On cgroupsv2 we should also chown()/chmod() the subtree_control file,
so that children can use controllers the way they like.

On cgroupsv1 we should also chown()/chmod() cgroups.clone_children, as
not setting this for new cgroups makes little sense, and hence delegated
clients should be able to write to it.

Note that error handling for both cases is different. subtree_control
matters so we check for errors, but the clone_children/tasks stuff
doesn't really, as it's legacy stuff. Hence we only log errors and
proceed.

Fixes: #6216
6 years agocgroup-util: downgrade log messages from library code to LOG_DEBUG
Lennart Poettering [Fri, 22 Sep 2017 17:57:07 +0000 (19:57 +0200)]
cgroup-util: downgrade log messages from library code to LOG_DEBUG

These errors don't really matter, that's why we log and proceed in the
current code. However, we currently log at LOG_WARNING, but we really
shouldn't given that this is library code. Hence downgrade this to
LOG_DEBUG.

6 years agocore: whenever a unit terminates, log its consumed resources to the journal
Lennart Poettering [Thu, 21 Sep 2017 12:05:35 +0000 (14:05 +0200)]
core: whenever a unit terminates, log its consumed resources to the journal

This adds a new recognizable log message for each unit invocation that
contains structured information about consumed resources of the unit as
a whole after it terminated. This is particular useful for apps that
want to figure out what the resource consumption of a unit given a
specific invocation ID was.

The log message is only generated for units that have at least one
XyzAccounting= property turned on, and currently only covers IP traffic and CPU
time metrics.

6 years agoio-util: add new IOVEC_INIT/IOVEC_MAKE macros
Lennart Poettering [Thu, 21 Sep 2017 11:52:34 +0000 (13:52 +0200)]
io-util: add new IOVEC_INIT/IOVEC_MAKE macros

This adds IOVEC_INIT() and IOVEC_MAKE() for initializing iovec structures
from a pointer and a size. On top of these IOVEC_INIT_STRING() and
IOVEC_MAKE_STRING() are added which take a string and automatically
determine the size of the string using strlen().

This patch removes the old IOVEC_SET_STRING() macro, given that
IOVEC_MAKE_STRING() is now useful for similar purposes. Note that the
old IOVEC_SET_STRING() invocations were two characters shorter than the
new ones using IOVEC_MAKE_STRING(), but I think the new syntax is more
readable and more generic as it simply resolves to a C99 literal
structure initialization. Moreover, we can use very similar syntax now
for initializing strings and pointer+size iovec entries. We canalso use
the new macros to initialize function parameters on-the-fly or array
definitions. And given that we shouldn't have so many ways to do the
same stuff, let's just settle on the new macros.

(This also converts some code to use _cleanup_ where dynamically
allocated strings were using IOVEC_SET_STRING() before, to modernize
things a bit)

6 years agocgroup: refuse to return accounting data if accounting isn't turned on
Lennart Poettering [Thu, 7 Sep 2017 14:31:01 +0000 (16:31 +0200)]
cgroup: refuse to return accounting data if accounting isn't turned on

We used to be a bit sloppy on this, and handed out accounting data even
for units where accounting wasn't explicitly enabled. Let's be stricter
here, so that we know the accounting data is actually fully valid. This
is necessary, as the accounting data is no longer stored exclusively in
cgroupfs, but is partly maintained external of that, and flushed during
unit starts. We should hence only expose accounting data we really know
is fully current.

6 years agocore: when coming back from reload/reexec, reapply all cgroup properties
Lennart Poettering [Thu, 7 Sep 2017 12:32:33 +0000 (14:32 +0200)]
core: when coming back from reload/reexec, reapply all cgroup properties

With this change we'll invalidate all cgroup settings after coming back
from a daemon reload/reexec, so that the new settings are instantly
applied.

This is useful for the BPF case, because we don't serialize/deserialize
the BPF program fd, and hence have to install a new, updated BPF program
when coming back from the reload/reexec. However, this is also useful
for the rest of the cgroup settings, as it ensures that user
configuration really takes effect wherever we can.

6 years agocore: serialize/deserialize IP accounting across daemon reload/reexec
Lennart Poettering [Thu, 7 Sep 2017 12:07:13 +0000 (14:07 +0200)]
core: serialize/deserialize IP accounting across daemon reload/reexec

Make sure the current IP accounting counters aren't lost during
reload/reexec.

Note that we destroy all BPF file objects during a reload: the BPF
programs, the access and the accounting maps. The former two need to be
regenerated anyway with the newly loaded configuration data, but the
latter one needs to survive reloads/reexec. In this implementation I
opted to only save/restore the accounting map content instead of the map
itself. While this opens a (theoretic) window where IP traffic is still
accounted to the old map after we read it out, and we thus miss a few
bytes this has the benefit that we can alter the map layout between
versions should the need arise.

7 years agoAdd test for eBPF firewall code
Daniel Mack [Thu, 3 Nov 2016 16:31:25 +0000 (17:31 +0100)]
Add test for eBPF firewall code

6 years agocgroup: dump the newly added IP settings in the cgroup context
Lennart Poettering [Fri, 1 Sep 2017 18:31:44 +0000 (20:31 +0200)]
cgroup: dump the newly added IP settings in the cgroup context

6 years agocgroup, unit, fragment parser: make use of new firewall functions
Daniel Mack [Tue, 5 Sep 2017 17:27:53 +0000 (19:27 +0200)]
cgroup, unit, fragment parser: make use of new firewall functions

6 years agoAdd firewall eBPF compiler
Daniel Mack [Fri, 11 Nov 2016 18:41:16 +0000 (19:41 +0100)]
Add firewall eBPF compiler

6 years agocgroup: add fields to accommodate eBPF related details
Daniel Mack [Fri, 11 Nov 2016 18:59:19 +0000 (19:59 +0100)]
cgroup: add fields to accommodate eBPF related details

Add pointers for compiled eBPF programs as well as list heads for allowed
and denied hosts for both directions.

6 years agoAdd IP address address ACL representation and parser
Daniel Mack [Thu, 3 Nov 2016 16:30:06 +0000 (17:30 +0100)]
Add IP address address ACL representation and parser

Add a config directive parser that takes multiple space separated IPv4
or IPv6 addresses with optional netmasks in CIDR notation rvalue and
puts a parsed version of it to linked list of IPAddressAccessItem objects.
The code actually using this will be added later.

6 years agoAdd abstraction model for BPF programs
Daniel Mack [Tue, 18 Oct 2016 15:57:10 +0000 (17:57 +0200)]
Add abstraction model for BPF programs

This object takes a number of bpf_insn members and wraps them together with
the in-kernel reference id. Will be needed by the firewall code.

6 years agoin-addr-util: add new helper call in_addr_prefix_from_string_auto()
Lennart Poettering [Fri, 1 Sep 2017 12:25:59 +0000 (14:25 +0200)]
in-addr-util: add new helper call in_addr_prefix_from_string_auto()

This is much like in_addr_prefix_from_string(), but automatically
determines whether IPv4 or IPv6 addresses are specified. Also adds a
test for it.

6 years agomanager: watching the cgroup2 inotify fd is safe in test runs too
Lennart Poettering [Tue, 5 Sep 2017 09:40:47 +0000 (11:40 +0200)]
manager: watching the cgroup2 inotify fd is safe in test runs too

Less deviation between test runs and normal runs is always a good idea,
hence enable more stuff that is safe in test runs

6 years agocgroup: always invalidate "cpu" and "cpuacct" together
Lennart Poettering [Tue, 5 Sep 2017 09:17:01 +0000 (11:17 +0200)]
cgroup: always invalidate "cpu" and "cpuacct" together

This doesn't really matter, as we never invalidate cpuacct explicitly,
and there's no real reason to care for it explicitly, however it's
prettier if we always treat cpu and cpuacct as belonging together, the
same way we conisder "io" and "blkio" to belong together.

6 years agocgroup-util: minor coding style adjustment
Lennart Poettering [Mon, 4 Sep 2017 16:18:04 +0000 (18:18 +0200)]
cgroup-util: minor coding style adjustment

6 years agoPrep v235: Updated .po files to upstream versions.
Sven Eden [Sun, 19 Nov 2017 17:50:17 +0000 (18:50 +0100)]
Prep v235: Updated .po files to upstream versions.

6 years agov235: Added missing updates
Sven Eden [Sun, 19 Nov 2017 17:48:14 +0000 (18:48 +0100)]
v235: Added missing updates

6 years agoPrep v235: Updated root files to upstream
Sven Eden [Mon, 25 Sep 2017 12:41:36 +0000 (14:41 +0200)]
Prep v235: Updated root files to upstream

6 years agoPrep v235: Added cap-list, which is needed now.
Sven Eden [Sun, 19 Nov 2017 17:47:11 +0000 (18:47 +0100)]
Prep v235: Added cap-list, which is needed now.

6 years agofileio: return 0 from read_one_line_file on success
Zbigniew Jędrzejewski-Szmek [Sun, 24 Sep 2017 12:27:21 +0000 (14:27 +0200)]
fileio: return 0 from read_one_line_file on success

Fixup for f4b51a2d09. Suggested by Evgeny Vereshchagin.

6 years agotest-conf-parser: add tests for the new long lines, including overflow handling
Zbigniew Jędrzejewski-Szmek [Thu, 21 Sep 2017 12:36:12 +0000 (14:36 +0200)]
test-conf-parser: add tests for the new long lines, including overflow handling

6 years agotest-conf-parser: use _cleanup_
Zbigniew Jędrzejewski-Szmek [Thu, 21 Sep 2017 10:02:49 +0000 (12:02 +0200)]
test-conf-parser: use _cleanup_

6 years agofileio: use _cleanup_ for FILE unlocking
Zbigniew Jędrzejewski-Szmek [Sat, 23 Sep 2017 08:48:09 +0000 (10:48 +0200)]
fileio: use _cleanup_ for FILE unlocking

6 years agoconf-parse: remove 4K line length limit
Lennart Poettering [Fri, 22 Sep 2017 16:26:35 +0000 (18:26 +0200)]
conf-parse: remove 4K line length limit

Let's use read_line() to solve our long line limitation.

Fixes #3302.

6 years agotest-conf-parser: add some basic tests for config_parse()
Zbigniew Jędrzejewski-Szmek [Thu, 21 Sep 2017 12:24:01 +0000 (14:24 +0200)]
test-conf-parser: add some basic tests for config_parse()

This function is pretty important, but we weren't calling it directly
even once in tests.

v2: add a few tests for escaping and line continuations

6 years agofileio: initialize errno to zero before we do fread()
Lennart Poettering [Fri, 22 Sep 2017 19:05:03 +0000 (21:05 +0200)]
fileio: initialize errno to zero before we do fread()

if there was something in the read buffer already errno might not be set
on error, let's detect that case.

6 years agofileio: try to read one byte too much in read_full_stream()
Lennart Poettering [Fri, 22 Sep 2017 19:03:33 +0000 (21:03 +0200)]
fileio: try to read one byte too much in read_full_stream()

Let's read one byte more than the file size we read from stat() on the
first fread() invocation. That way, the first read() will already be
short and indicate eof to fread().

This is a minor optimization, and replaces #3908.

6 years agofileio: move fsync() logic into write_string_stream_ts()
Lennart Poettering [Fri, 22 Sep 2017 18:59:39 +0000 (20:59 +0200)]
fileio: move fsync() logic into write_string_stream_ts()

That way, write_string_stream_ts() becomes more powerful, and we can
remove duplicate code from  write_string_file_atomic() and
write_string_file_ts().

6 years agofileio: make write_string_stream() accept flags parameter
Lennart Poettering [Fri, 22 Sep 2017 18:55:34 +0000 (20:55 +0200)]
fileio: make write_string_stream() accept flags parameter

Let's make write_string_stream() and write_string_file() more alike, and
pass the same flag set so that we can remove a number of boolean
parameters.

6 years agofileio: support writing atomic files with timestamp
Lennart Poettering [Fri, 22 Sep 2017 18:45:06 +0000 (20:45 +0200)]
fileio: support writing atomic files with timestamp

Let's make sure "ts" is taken into account when writing atomic files,
too.

6 years agocgroup-util: replace one use of fgets() by read_line()
Lennart Poettering [Fri, 22 Sep 2017 16:25:45 +0000 (18:25 +0200)]
cgroup-util: replace one use of fgets() by read_line()

6 years agofileio: rework read_one_line_file() on top of read_line()
Lennart Poettering [Fri, 22 Sep 2017 16:01:32 +0000 (18:01 +0200)]
fileio: rework read_one_line_file() on top of read_line()

6 years agodef: add new constant LONG_LINE_MAX
Lennart Poettering [Fri, 22 Sep 2017 18:23:58 +0000 (20:23 +0200)]
def: add new constant LONG_LINE_MAX

LONG_LINE_MAX is much like LINE_MAX, but longer.

As it turns out LINE_MAX at 4096 is too short for many usecases. Since
the general concept of having a common maximum line length limit makes
sense let's add our own, and make it larger (1MB for now).

6 years agofileio: add new helper call read_line() as bounded getline() replacement
Lennart Poettering [Fri, 22 Sep 2017 15:55:53 +0000 (17:55 +0200)]
fileio: add new helper call read_line() as bounded getline() replacement

read_line() is much like getline(), and returns a line read from a
FILE*, of arbitrary sizes. In contrast to gets() it will grow the buffer
dynamically, and in contrast to getline() it will place a user-specified
boundary on the line.

6 years agocgroup: rework which files we chown() on delegation
Lennart Poettering [Fri, 22 Sep 2017 17:58:24 +0000 (19:58 +0200)]
cgroup: rework which files we chown() on delegation

On cgroupsv2 we should also chown()/chmod() the subtree_control file,
so that children can use controllers the way they like.

On cgroupsv1 we should also chown()/chmod() cgroups.clone_children, as
not setting this for new cgroups makes little sense, and hence delegated
clients should be able to write to it.

Note that error handling for both cases is different. subtree_control
matters so we check for errors, but the clone_children/tasks stuff
doesn't really, as it's legacy stuff. Hence we only log errors and
proceed.

Fixes: #6216
6 years agocgroup-util: downgrade log messages from library code to LOG_DEBUG
Lennart Poettering [Fri, 22 Sep 2017 17:57:07 +0000 (19:57 +0200)]
cgroup-util: downgrade log messages from library code to LOG_DEBUG

These errors don't really matter, that's why we log and proceed in the
current code. However, we currently log at LOG_WARNING, but we really
shouldn't given that this is library code. Hence downgrade this to
LOG_DEBUG.

6 years agotime-util: mktime_or_timegm are changing the struct tm
Marcel Hollerbach [Wed, 20 Sep 2017 17:26:13 +0000 (19:26 +0200)]
time-util: mktime_or_timegm are changing the struct tm

after that wm_day etc. seems to be changed. Moving the check infront of
the mktime_or_timegm fixes that.

6 years agotime-util: correctly handle the timezone when parsing
Marcel Hollerbach [Wed, 20 Sep 2017 12:47:49 +0000 (14:47 +0200)]
time-util: correctly handle the timezone when parsing

The timezone was cut off the string once the timezone was not UTC.
If it is not UTC but a other timezone that matches tzname[0] or
tzname[1], then we can leave it to the impl function to parse that
correctly. If not we can just fallback to whatever is the current
timezone is in the given t_timezone.

This should fix the testuite and tests.

6 years agoLink to the right glibc commit in comment (#6884)
Zbigniew Jędrzejewski-Szmek [Thu, 21 Sep 2017 18:54:16 +0000 (20:54 +0200)]
Link to the right glibc commit in comment (#6884)

Reported by Marcos Mello.

Fixes #6882.

6 years agotime-util: fix shadowing of timezone
Marcel Hollerbach [Tue, 19 Sep 2017 15:00:56 +0000 (17:00 +0200)]
time-util: fix shadowing of timezone

timezone was shadowing timezone from time.h which leads to a buildbreak
since elogind is built with -Werror

6 years agoMake test_run into a flags field and disable generators again
Zbigniew Jędrzejewski-Szmek [Sat, 16 Sep 2017 09:19:43 +0000 (11:19 +0200)]
Make test_run into a flags field and disable generators again

Now generators are only run in elogind --test mode, where this makes
most sense (how are you going to test what would happen otherwise?).

Fixes #6842.

v2:
- rename test_run to test_run_flags

6 years agotests: change dbus tests to use user bus (#6845)
Michael Biebl [Tue, 19 Sep 2017 12:17:57 +0000 (14:17 +0200)]
tests: change dbus tests to use user bus (#6845)

This makes it possible to run more dbus tests in a build
environment/chroot where no system bus is available.
To run the dbus test one then can use dbus-run-session.

6 years agobuild-sys: bump xslt maxdepth limit (#6863)
Zbigniew Jędrzejewski-Szmek [Tue, 19 Sep 2017 06:04:02 +0000 (08:04 +0200)]
build-sys: bump xslt maxdepth limit (#6863)

With libxslt-1.30, builds were failing on some recursion depth limit
with elogind.index.xml. Bumping the limit fixes the issue.

6 years agotest-exec-util: add two test cases for scripts masked with empty file
Zbigniew Jędrzejewski-Szmek [Sun, 17 Sep 2017 13:17:50 +0000 (15:17 +0200)]
test-exec-util: add two test cases for scripts masked with empty file

A test for #6831. Fails without the previous commit.

Suggested by Evgeny Vereshchagin.

6 years agoconf-files: fix check for masking with empty files
Zbigniew Jędrzejewski-Szmek [Sun, 17 Sep 2017 13:26:01 +0000 (15:26 +0200)]
conf-files: fix check for masking with empty files

Fixes #6831.

6 years agoman: describe user@host:machine syntax
Zbigniew Jędrzejewski-Szmek [Sun, 17 Sep 2017 19:05:20 +0000 (21:05 +0200)]
man: describe user@host:machine syntax

Fixes #6734.

6 years agosd-bus: style nitpick node_vtable_get_userdata()
Alan Jenkins [Sat, 16 Sep 2017 11:32:59 +0000 (12:32 +0100)]
sd-bus: style nitpick node_vtable_get_userdata()

It's confusing to use a single void* to store data with two different
types, i.e. a userdata value which is safe to pass to ->find(), and a
userdata value which identifies the found object.

Name the latter `found_u`.  This naming treats (!c->find) as a degenerate
case.  (I.e. at that point, we know the object has already been found :).

6 years agosd-bus: fix response for GetAll on non-existent objects
Alan Jenkins [Sat, 16 Sep 2017 13:39:22 +0000 (14:39 +0100)]
sd-bus: fix response for GetAll on non-existent objects

Before this commit, if you run `loginctl user-status` from
debug-shell.service (and you have no login sessions for root), you always
see this output:

0
Linger: no

because Properties.GetAll is returning success but without any properties,
when the only find() callback had returned 0 to mean "no object found".

After:

Could not get properties: Unknown object:
'/org/freedesktop/login1/user/self'

BTW I have a fix for more user-friendly messages from logind in this case.
It is pending in my local branch for #6829 "fix `loginctl enable-linger`".

6 years agoFix for dst/non-dst timezones
Ivan Kurnosov [Sun, 17 Sep 2017 11:09:38 +0000 (23:09 +1200)]
Fix for dst/non-dst timezones

The problem was with the tm.tm_isdst that is set to the current environment
value: either DST or not. While the current state is not relevant to the state
in the desired date.

Hence — it should be reset so that the mktime_or_timegm could normalise it
later.

6 years agoSimplify the if cases for timezone checking
Zbigniew Jędrzejewski-Szmek [Sun, 17 Sep 2017 07:10:03 +0000 (09:10 +0200)]
Simplify the if cases for timezone checking

Just to reduce the indentation a bit.

6 years agoAdded timezone to the CalendarSpec, parser/formatter and the timedatectl
Ivan Kurnosov [Wed, 6 Sep 2017 09:56:36 +0000 (21:56 +1200)]
Added timezone to the CalendarSpec, parser/formatter and the timedatectl

6 years agoman: use "filename" not "file name" by default
Zbigniew Jędrzejewski-Szmek [Fri, 15 Sep 2017 12:59:45 +0000 (14:59 +0200)]
man: use "filename" not "file name" by default

We settled on "filename" and "file system", so change a couple of places for
consistency. The exception is when there's an adjective before "file" that
binds more strongly then "name": "password file name", "output file name", etc.
Those cases are left intact.

6 years agocore: add new per-unit setting KeyringMode= for controlling kernel keyring setup
Lennart Poettering [Thu, 14 Sep 2017 19:19:05 +0000 (21:19 +0200)]
core: add new per-unit setting KeyringMode= for controlling kernel keyring setup

Usually, it's a good thing that we isolate the kernel session keyring
for the various services and disconnect them from the user keyring.
However, in case of the cryptsetup key caching we actually want that
multiple instances of the cryptsetup service can share the keys in the
root user's user keyring, hence we need to be able to disable this logic
for them.

This adds KeyringMode=inherit|private|shared:

    inherit: don't do any keyring magic (this is the default in elogind --user)
    private: a private keyring as before (default in elogind --system)
    shared: the new setting

6 years agobuild-sys: require libmount >= 2.30 (#6795)
Zbigniew Jędrzejewski-Szmek [Fri, 15 Sep 2017 12:47:57 +0000 (14:47 +0200)]
build-sys: require libmount >= 2.30 (#6795)

Fixes #4871.

The new libmount has two changes relevant for us:

- x-* options are propagated to /run/mount/utab and are visible through
  libmount (fixes #4817).

- umount -c now really works (partially solves #6115).

6 years agonetworkd: add support to configure IP Rule (#5725)
Susant Sahani [Thu, 14 Sep 2017 19:51:39 +0000 (19:51 +0000)]
networkd: add support to configure IP Rule (#5725)

Routing Policy rule manipulates rules in the routing policy database control the
route selection algorithm.

This work supports to configure Rule
```
[RoutingPolicyRule]
TypeOfService=0x08
Table=7
From= 192.168.100.18

```

```
ip rule show
0: from all lookup local
0: from 192.168.100.18 tos 0x08 lookup 7
```

V2 changes:

1. Added logic to handle duplicate rules.
2. If rules are changed or deleted and networkd restarted
   then those are deleted when networkd restarts next time

V3:

1. Add parse_fwmark_fwmask

6 years agoconf-parser: when the empty string assigned to Personality= reset it
Lennart Poettering [Thu, 14 Sep 2017 14:54:32 +0000 (16:54 +0200)]
conf-parser: when the empty string assigned to Personality= reset it

Let's support assigning the empty string to reset things in one more
place.

6 years agocore: don't synthesize empty list when empty string is read in config_parse_strv()
Lennart Poettering [Thu, 14 Sep 2017 14:53:34 +0000 (16:53 +0200)]
core: don't synthesize empty list when empty string is read in config_parse_strv()

This was added to make
https://bugs.freedesktop.org/show_bug.cgi?id=62558 work, which has long
been removed, hence let's revert to the original behaviour and fully
flush out the list when an empty string is assigned.

6 years agorules: ubi mtd - add link to named partitions (#6750)
Michael Grzeschik [Thu, 14 Sep 2017 12:53:07 +0000 (14:53 +0200)]
rules: ubi mtd - add link to named partitions (#6750)

[zjs:
- rebase onto recent master
- drop signed-off-by]

6 years agoman: unify titling, fix description of precedence in sysusers.d(5)
Zbigniew Jędrzejewski-Szmek [Thu, 14 Sep 2017 09:55:00 +0000 (11:55 +0200)]
man: unify titling, fix description of precedence in sysusers.d(5)

Fixes #6639.

(This behaviour of elogind-sysusers is long established, so it's better
to adjust the documentation rather than change the code. If there are any
situations out there where it matters, users must have adjusted to the
current behaviour.)

6 years agonss: use secure_getenv for behaviour-modifying booleans (#6817)
Zbigniew Jędrzejewski-Szmek [Thu, 14 Sep 2017 07:20:27 +0000 (09:20 +0200)]
nss: use secure_getenv for behaviour-modifying booleans (#6817)

Follow up for fe102d6ab15731a199a7ea9f38c4f68d8959f86c.

6 years agobasic: ensure O_TMPFILE is always defined (#6816)
Davide Cavalca [Thu, 14 Sep 2017 04:14:29 +0000 (00:14 -0400)]
basic: ensure O_TMPFILE is always defined (#6816)

6 years agosd-bus: extend D-Bus authentication timeout considerably (#6813)
Lennart Poettering [Wed, 13 Sep 2017 17:08:26 +0000 (19:08 +0200)]
sd-bus: extend D-Bus authentication timeout considerably (#6813)

As it turns out the authentication phase times out too often than is
good, mostly due to PRNG pools not being populated during boot. Hence,
let's increase the authentication timeout from 25s to 90s, to cover for
that.

(Note that we leave the D-Bus method call timeout at 25s, matching the
reference implementation's value. And if the auth phase managed to
complete then the pools should be populated enough and mehtod calls
shouldn't take needlessly long anymore).

Fixes: #6418
6 years agoutil: make get_block_device() available
Franck Bui [Wed, 13 Sep 2017 09:47:15 +0000 (11:47 +0200)]
util: make get_block_device() available

6 years agoconf-files: log when we skip a drop-in configuration file
Lennart Poettering [Wed, 13 Sep 2017 09:41:41 +0000 (11:41 +0200)]
conf-files: log when we skip a drop-in configuration file

6 years agoexec-util,conf-files: skip non-executable files in execute_directories()
Lennart Poettering [Tue, 12 Sep 2017 14:57:33 +0000 (16:57 +0200)]
exec-util,conf-files: skip non-executable files in execute_directories()

Fixes: #6787
6 years agopager: let's create pager fds with O_CLOEXEC first
Lennart Poettering [Wed, 13 Sep 2017 08:35:28 +0000 (10:35 +0200)]
pager: let's create pager fds with O_CLOEXEC first

We make copies (without O_CLOEXEC) of the fds anyway before using them,
hence let's be safe and create them with O_CLOEXEC first, so that we
don't run into issues should pager_open() be called in a threaded
environment where another thread fork()s at the wrong time and ends up
with fds not marked O_CLOEXEC.

6 years agosystemctl: don't do ANSI underlining on TERM=linux (#6778)
Lennart Poettering [Sat, 9 Sep 2017 20:48:35 +0000 (22:48 +0200)]
systemctl: don't do ANSI underlining on TERM=linux (#6778)

The linux console apparently can't do underlining, hence let's not do it
on the console.

Also see: #6601

6 years agoutil-lib: wrap personality() to fix up broken glibc error handling (#6766)
Lennart Poettering [Fri, 8 Sep 2017 14:16:29 +0000 (16:16 +0200)]
util-lib: wrap personality() to fix up broken glibc error handling (#6766)

glibc appears to propagate different errors in different ways, let's fix
this up, so that our own code doesn't get confused by this.

See #6752 + #6737 for details.

Fixes: #6755
6 years agoshared: allow to input empty string to config_parse_path()
Yu Watanabe [Tue, 5 Sep 2017 06:12:55 +0000 (15:12 +0900)]
shared: allow to input empty string to config_parse_path()

Fixes #6633.

6 years agobuild-sys: make nonnull warning non-fatal (#6742)
Zbigniew Jędrzejewski-Szmek [Mon, 4 Sep 2017 16:49:12 +0000 (19:49 +0300)]
build-sys: make nonnull warning non-fatal (#6742)

Seems to be some kind of confusion in gcc. Insteading of playing whack-a-mole and
adding work-arounds in code, let's adjust the compilation options instead.

Fixes #6119, replaces #6657.

6 years agotmpfiles: silently ignore any path that passes through autofs (#6506)
NeilBrown [Mon, 4 Sep 2017 13:35:07 +0000 (23:35 +1000)]
tmpfiles: silently ignore any path that passes through autofs (#6506)

If a path passes though an autofs filesystem, then accessing
the path might trigger and automount.  As elogind-tmpfiles is run before
the network is up, and as automounts are often used for networked
filesystems, this can cause a deadlock.

So chase_symlinks is enhance to accept a new flag which tells it
to check for autofs, and return -EREMOTE if autofs is found.

tmpfiles is changed to check just before acting on a path so that it
can avoid autofs even if a symlink was created earlier by tmpfiles
that would send this path through an autofs.

This fixes a deadlock that happens when /home is listed in /etc/fstab as
x-elogind.automount for an NFS directory.

6 years agoelogind-mount: allow to specify an arbitrary string for arg_mount_what when vfs is...
Yu Watanabe [Mon, 4 Sep 2017 01:55:51 +0000 (10:55 +0900)]
elogind-mount: allow to specify an arbitrary string for arg_mount_what when vfs is used

Fixes #6591.

6 years agoterminal: unify code for resetting kbd utf8 mode a bit (#6692)
Lennart Poettering [Fri, 1 Sep 2017 00:09:32 +0000 (02:09 +0200)]
terminal: unify code for resetting kbd utf8 mode a bit (#6692)

We have the same code at two places, let's unify that at one place.

Follow-up for #6606

6 years agotree-wide: use pid_is_valid() at more places
Lennart Poettering [Thu, 31 Aug 2017 08:25:06 +0000 (10:25 +0200)]
tree-wide: use pid_is_valid() at more places

6 years agosd-bus: use -- when passing arguments to ssh (#6706)
Evgeny Vereshchagin [Thu, 31 Aug 2017 08:38:30 +0000 (11:38 +0300)]
sd-bus: use -- when passing arguments to ssh (#6706)

This prevents `systemctl` from runnning /bin/touch when the following
command is used:
```
systemctl -H '-oProxyCommand=/bin/touch i-shouldnt-be-here' show-environment
```

6 years agolog: reopen log for failed assertions (#6703)
Topi Miettinen [Thu, 31 Aug 2017 08:37:32 +0000 (08:37 +0000)]
log: reopen log for failed assertions (#6703)

Reopen log so that failed and aborting assertions can be written to log.

Closes: #6658
6 years agobus-util: remove unnecessary initializations
Yu Watanabe [Thu, 31 Aug 2017 08:02:33 +0000 (17:02 +0900)]
bus-util: remove unnecessary initializations

6 years agosystemctl: show capabilities in human readable format
Yu Watanabe [Thu, 31 Aug 2017 08:07:16 +0000 (17:07 +0900)]
systemctl: show capabilities in human readable format

Follow-up for 21771f338d268e06dc9a10b9b08b14ff8217d4be.

6 years agomeson: add . to include_directories (#6634)
Davide Cavalca [Wed, 30 Aug 2017 15:34:44 +0000 (08:34 -0700)]
meson: add . to include_directories (#6634)

6 years agologind: VT_GETSTATE "cannot return state for more than 16 VTs" (#6625)
Alan Jenkins [Wed, 30 Aug 2017 15:06:12 +0000 (16:06 +0100)]
logind: VT_GETSTATE "cannot return state for more than 16 VTs" (#6625)

`vt_is_busy(16)` would always return FALSE.  So we could have started
autovt@16.service even when VT 16 was already being used for something.

6 years agomeson: use current_source_dir() to scope git invocations (#6635)
Davide Cavalca [Wed, 30 Aug 2017 15:04:53 +0000 (08:04 -0700)]
meson: use current_source_dir() to scope git invocations (#6635)

6 years agosd-bus: socket - only transmit auxillary FDs once (#6603)
Tom Gundersen [Wed, 30 Aug 2017 11:09:03 +0000 (13:09 +0200)]
sd-bus: socket - only transmit auxillary FDs once (#6603)

If a message is too large to fit into the output buffer, it will be
transmitted to the kernel in several chunks. However, the FDs must
only ever be transmitted once or they will bereceived by the remote
end repeatedly.

The D-Bus specification disallows several sets of FDs attached to
one message, however, the reference implementation of D-Bus will
not reject such a message, rather it will reassign the duplicate
FDs to subsequent FD-carrying messages.

This attaches the FD array only to the first byte of the message.

6 years agoterminal reset should honour default_utf8 kernel setting (#6606)
g0tar [Wed, 30 Aug 2017 08:00:44 +0000 (10:00 +0200)]
terminal reset should honour default_utf8 kernel setting (#6606)

terminal reset should honour default_utf8 kernel setting