systemd/.git
5 years agofirstboot: fill empty color if ansi_color unavailable from os-release
afg [Tue, 1 Sep 2020 21:20:25 +0000 (05:20 +0800)]
firstboot: fill empty color if ansi_color unavailable from os-release

5 years agoMerge pull request #16925 from cgzones/selinux_create_label
Zbigniew Jędrzejewski-Szmek [Tue, 1 Sep 2020 20:19:52 +0000 (22:19 +0200)]
Merge pull request #16925 from cgzones/selinux_create_label

selinux/core: create several file objects with default SELinux context

5 years agoMerge pull request #16911 from keszybz/userdb-json-invalid-utf8
Lennart Poettering [Tue, 1 Sep 2020 18:34:22 +0000 (20:34 +0200)]
Merge pull request #16911 from keszybz/userdb-json-invalid-utf8

Deal properly with invalid utf-8 in userdb entries

5 years agoMerge pull request #16922 from keszybz/ordered-set-ensure-allocated
Zbigniew Jędrzejewski-Szmek [Tue, 1 Sep 2020 17:44:28 +0000 (19:44 +0200)]
Merge pull request #16922 from keszybz/ordered-set-ensure-allocated

Ordered set ensure allocated

5 years agoMerge pull request #16727 from wusto/core-fix-securebits
Lennart Poettering [Tue, 1 Sep 2020 15:21:48 +0000 (17:21 +0200)]
Merge pull request #16727 from wusto/core-fix-securebits

core: fix securebits setting

5 years agosocket: New option 'FlushPending' (boolean) to flush socket before entering listening...
Renaud Métrich [Thu, 20 Aug 2020 11:00:37 +0000 (13:00 +0200)]
socket: New option 'FlushPending' (boolean) to flush socket before entering listening state

Disabled by default. When Enabled, before listening on the socket, flush the content.
Applies when Accept=no only.

5 years agoTODO: add entry
Zbigniew Jędrzejewski-Szmek [Mon, 31 Aug 2020 11:01:23 +0000 (13:01 +0200)]
TODO: add entry

5 years agouser-record-nss: check if strings from pwd/spwd/grp/sgrp are valid utf-8
Zbigniew Jędrzejewski-Szmek [Sun, 30 Aug 2020 18:34:12 +0000 (20:34 +0200)]
user-record-nss: check if strings from pwd/spwd/grp/sgrp are valid utf-8

strv_extend_strv_utf8_only() uses a temporary buffer to make the implementation
conscise. Otherwise we'd have to rewrite all of strv_extend_strv() which didn't
seem worth the trouble for this one use outside of a hot path.

If the data is not serializable, we just pretend it doesn't exists.
This fixes #16683 and https://bugs.gentoo.org/735072 in a second way.

5 years agoshared: merge {user,group}-record-nss.{c,h}
Zbigniew Jędrzejewski-Szmek [Sun, 30 Aug 2020 19:25:12 +0000 (21:25 +0200)]
shared: merge {user,group}-record-nss.{c,h}

They both are both short and contain similar parts and various helper will be
shared between both parts of the code so it's easier to use a single file.

5 years agotest-json: add function headers
Zbigniew Jędrzejewski-Szmek [Tue, 1 Sep 2020 07:29:13 +0000 (09:29 +0200)]
test-json: add function headers

5 years agoshared/json: reject non-utf-8 strings
Zbigniew Jędrzejewski-Szmek [Sun, 30 Aug 2020 17:52:10 +0000 (19:52 +0200)]
shared/json: reject non-utf-8 strings

JSON strings must be utf-8-clean. We also verify this in json_parse_string()
so we would reject a message with invalid utf-8 anyway.

It would probably be slightly cheaper to detect non-conformaning strings in
serialization, but then we'd have to fail serialization. By doing this early,
we give the caller a chance to handle the error nicely.

The test is adjusted to contain a valid utf-8 string after decoding of the
utf-32 encoding in json ("विवेकख्यातिरविप्लवा हानोपायः।", something about the
cessation of ignorance).

5 years agoshared/utf8: add utf8_is_valid_n()
Zbigniew Jędrzejewski-Szmek [Tue, 1 Sep 2020 08:43:21 +0000 (10:43 +0200)]
shared/utf8: add utf8_is_valid_n()

Sometimes we need to check strings without the terminating NUL. Add a variant
that does that.

5 years agoMerge pull request #16877 from poettering/tmpfiles-statx
Zbigniew Jędrzejewski-Szmek [Tue, 1 Sep 2020 14:32:50 +0000 (16:32 +0200)]
Merge pull request #16877 from poettering/tmpfiles-statx

tmpfiles: use statx()

5 years agoselinux: create /run/systemd/userdb directory and sockets with default SELinux context
Christian Göttsche [Tue, 1 Sep 2020 13:49:44 +0000 (15:49 +0200)]
selinux: create /run/systemd/userdb directory and sockets with default SELinux context

5 years agoselinux: create systemd/notify socket with default SELinux context
Christian Göttsche [Tue, 1 Sep 2020 13:49:20 +0000 (15:49 +0200)]
selinux: create systemd/notify socket with default SELinux context

5 years agodoc: cross link sd_listen_fd() docs a bit
Lennart Poettering [Mon, 31 Aug 2020 21:41:30 +0000 (23:41 +0200)]
doc: cross link sd_listen_fd() docs a bit

Let's make sure the sd_listen_fd() docs are really found from the
.socket file documentation as well as the FileDescriptorStoreMax=
documentation.

Let's also emphasize that that's where the order in which the fds are
passed are documented.

Fixes: #16647

5 years agoselinux: create unit invocation links with default SELinux context
Christian Göttsche [Tue, 1 Sep 2020 13:48:53 +0000 (15:48 +0200)]
selinux: create unit invocation links with default SELinux context

5 years agobasic/hashmap,set: move pointer symbol adjactent to the returned value
Zbigniew Jędrzejewski-Szmek [Tue, 1 Sep 2020 11:22:14 +0000 (13:22 +0200)]
basic/hashmap,set: move pointer symbol adjactent to the returned value

I think this is nicer in general, and here in particular we have a lot
of code like:
 static inline IteratedCache* hashmap_iterated_cache_new(Hashmap *h) {
         return (IteratedCache*) _hashmap_iterated_cache_new(HASHMAP_BASE(h));
 }
and it's visually appealing to use the same whitespace in the function
signature and the cast in the body of the function.

5 years agobasic/hashmap,set: inline trivial set_iterate() wrapper
Zbigniew Jędrzejewski-Szmek [Tue, 1 Sep 2020 11:18:56 +0000 (13:18 +0200)]
basic/hashmap,set: inline trivial set_iterate() wrapper

The compiler would do this to, esp. with LTO, but we can short-circuit the
whole process and make everything a bit simpler by avoiding the separate
definition.

(It would be nice to do the same for _set_new(), _set_ensure_allocated()
and other similar functions which are one-line trivial wrappers too. Unfortunately
that would require enum HashmapType to be made public, which we don't want
to do.)

5 years agobasic: pass allocation info for ordered_set_new() and introduce ordered_set_ensure_put()
Zbigniew Jędrzejewski-Szmek [Tue, 1 Sep 2020 10:42:35 +0000 (12:42 +0200)]
basic: pass allocation info for ordered_set_new() and introduce ordered_set_ensure_put()

5 years agobasic: Introduce ordered_hashmap_ensure_put
Susant Sahani [Fri, 28 Aug 2020 10:38:18 +0000 (10:38 +0000)]
basic: Introduce ordered_hashmap_ensure_put

5 years agocore: fix securebits setting
Tobias Kaufmann [Mon, 31 Aug 2020 11:48:31 +0000 (13:48 +0200)]
core: fix securebits setting

Desired functionality:
Set securebits for services started as non-root user.

Failure:
The starting of the service fails if no ambient capability shall be
raised.
... systemd[217941]: ...: Failed to set process secure bits: Operation
not permitted
... systemd[217941]: ...: Failed at step SECUREBITS spawning
/usr/bin/abc.service: Operation not permitted
... systemd[1]: abc.service: Failed with result 'exit-code'.

Reason:
For setting securebits the capability CAP_SETPCAP is required. However
the securebits (if no ambient capability shall be raised) are set after
setresuid.
When setresuid is invoked all capabilities are dropped from the
permitted, effective and ambient capability set. If the securebit
SECBIT_KEEP_CAPS is set the permitted capability set is retained, but
the effective and the ambient set are cleared.

If ambient capabilities shall be set, the securebit SECBIT_KEEP_CAPS is
added to the securebits configured in the service file and set together
with the securebits from the service file before setresuid is executed
(in enforce_user).
Before setresuid is executed the capabilities are the same as for pid1.
This means that all capabilities in the effective, permitted and
bounding set are set. Thus the capability CAP_SETPCAP is in the
effective set and the prctl(PR_SET_SECUREBITS, ...) succeeds.
However, if the secure bits aren't set before setresuid is invoked they
shall be set shortly after the uid change in enforce_user.
This fails as SECBIT_KEEP_CAPS wasn't set before setresuid and in
consequence the effective and permitted set was cleared, hence
CAP_SETPCAP is not set in the effective set (and cannot be raised any
longer) and prctl(PR_SET_SECUREBITS, ...) failes with EPERM.

Proposed solution:
The proposed solution consists of three parts
1. Check in enforce_user, if securebits are configured in the service
   file. If securebits are configured, set SECBIT_KEEP_CAPS
   before invoking setresuid.
2. Don't set any other securebits than SECBIT_KEEP_CAPS in enforce_user,
   but set all requested ones after enforce_user.
   This has the advantage that securebits are set at the same place for
   root and non-root services.
3. Raise CAP_SETPCAP to the effective set (if not already set) before
   setting the securebits to avoid EPERM during the prctl syscall.

For gaining CAP_SETPCAP the function capability_bounding_set_drop is
splitted into two functions:
- The first one raises CAP_SETPCAP (required for dropping bounding
  capabilities)
- The second drops the bounding capabilities

Why are ambient capabilities not affected by this change?
Ambient capabilities get cleared during setresuid, no matter if
SECBIT_KEEP_CAPS is set or not.
For raising ambient capabilities for a user different to root, the
requested capability has to be raised in the inheritable set first. Then
the SECBIT_KEEP_CAPS securebit needs to be set before setresuid is
invoked. Afterwards the ambient capability can be raised, because it is
in the inheritable and permitted set.

Security considerations:
Although the manpage is ambiguous SECBIT_KEEP_CAPS is cleared during
execve no matter if SECBIT_KEEP_CAPS_LOCKED is set or not. If both are
set only SECBIT_KEEP_CAPS_LOCKED is set after execve.
Setting SECBIT_KEEP_CAPS in enforce_user for being able to set
securebits is no security risk, as the effective and permitted set are
set to the value of the ambient set during execve (if the executed file
has no file capabilities. For details check man 7 capabilities).

Remark:
In capability-util.c is a comment complaining about the missing
capability CAP_SETPCAP in the effective set, after the kernel executed
/sbin/init. Thus it is checked there if this capability has to be raised
in the effective set before dropping capabilities from the bounding set.
If this were true all the time, ambient capabilities couldn't be set
without dropping at least one capability from the bounding set, as the
capability CAP_SETPCAP would miss and setting SECBIT_KEEP_CAPS would
fail with EPERM.

5 years agocapability-util: add new function for raising setpcap
Tobias Kaufmann [Mon, 31 Aug 2020 10:50:25 +0000 (12:50 +0200)]
capability-util: add new function for raising setpcap

Up to now the capability CAP_SETPCAP was raised implicitly in the
function capability_bounding_set_drop.

This functionality is moved into a new function
(capability_gain_cap_setpcap).

The new function optionally provides the capability set as it was
before raisining CAP_SETPCAP.

5 years agojson: split out string formatting to a separate function
Zbigniew Jędrzejewski-Szmek [Fri, 28 Aug 2020 17:47:19 +0000 (19:47 +0200)]
json: split out string formatting to a separate function

It's complicated enough to deserve it's own function.

No functional change.

5 years agovarlink: do not parse invalid messages twice
Zbigniew Jędrzejewski-Szmek [Fri, 28 Aug 2020 17:22:20 +0000 (19:22 +0200)]
varlink: do not parse invalid messages twice

Upon reception of a message which fails in json_parse(), we would proceed to
parse it again from a deferred callback and hang. Once we have realized that
the message is invalid, let's move the pointer in the buffer even if the
message is invalid. We don't want to look at this data again.

(before) $ build-rawhide/userdbctl --output=json user test.user
n/a: varlink: setting state idle-client
/run/systemd/userdb/io.systemd.Multiplexer: Sending message: {"method":"io.systemd.UserDatabase.GetUserRecord","parameters":{"userName":"test.user","service":"io.systemd.Multiplexer"}}
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state idle-client → awaiting-reply
/run/systemd/userdb/io.systemd.Multiplexer: New incoming message: {...}
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state awaiting-reply → pending-disconnect
/run/systemd/userdb/io.systemd.Multiplexer: New incoming message: {...}
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state pending-disconnect → disconnected
^C

(after) $ n/a: varlink: setting state idle-client
/run/systemd/userdb/io.systemd.Multiplexer: Sending message: {"method":"io.systemd.UserDatabase.GetUserRecord","parameters":{"userName":"test.user","service":"io.systemd.Multiplexer"}}
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state idle-client → awaiting-reply
/run/systemd/userdb/io.systemd.Multiplexer: New incoming message: {...}
/run/systemd/userdb/io.systemd.Multiplexer: Failed to parse JSON: Invalid argument
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state awaiting-reply → pending-disconnect
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state pending-disconnect → processing-disconnect
Got lookup error: io.systemd.Disconnected
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state processing-disconnect → disconnected
Failed to find user test.user: Input/output error

This should fix #16683 and https://bugs.gentoo.org/735072.

5 years agoman: add hint how to show password strings with userdbctl
Zbigniew Jędrzejewski-Szmek [Fri, 28 Aug 2020 16:21:33 +0000 (18:21 +0200)]
man: add hint how to show password strings with userdbctl

I started working on a command-line switch to show passwords also in
"pretty" mode. I can submit that code for review if anyone thinks that
woul be useful, but after writing the man page I realized that it's a
fairly niche case, and the hint in the man page is a sufficient
replacement.

5 years agouserdb: fix typo
Zbigniew Jędrzejewski-Szmek [Fri, 28 Aug 2020 16:11:48 +0000 (18:11 +0200)]
userdb: fix typo

5 years agouserdbctl: add forgotten --output mode in help
Zbigniew Jędrzejewski-Szmek [Fri, 28 Aug 2020 15:25:14 +0000 (17:25 +0200)]
userdbctl: add forgotten --output mode in help

5 years agoshared: merge {user,group}-record-show.[ch]
Zbigniew Jędrzejewski-Szmek [Fri, 28 Aug 2020 15:11:46 +0000 (17:11 +0200)]
shared: merge {user,group}-record-show.[ch]

It is natural to include both, and in total they declared three
functions. Let's merge them for simplicity.

5 years agoMerge pull request #16885 from keszybz/rework-cache-timestamps
Anita Zhang [Tue, 1 Sep 2020 06:21:12 +0000 (23:21 -0700)]
Merge pull request #16885 from keszybz/rework-cache-timestamps

Rework cache timestamps

5 years agoMerge pull request #16917 from poettering/contrib-rfe
Anita Zhang [Tue, 1 Sep 2020 00:25:36 +0000 (17:25 -0700)]
Merge pull request #16917 from poettering/contrib-rfe

CONTRIBUTING: be clearer about versions and RFE process

5 years agoCONTRIBUTING: be clearer about versions and RFE process
Lennart Poettering [Mon, 31 Aug 2020 21:23:29 +0000 (23:23 +0200)]
CONTRIBUTING: be clearer about versions and RFE process

Fixes: #16550

5 years agodissect-image: generate nice error when we can't detect any file system
Lennart Poettering [Mon, 31 Aug 2020 17:01:49 +0000 (19:01 +0200)]
dissect-image: generate nice error when we can't detect any file system

5 years agobasic/escape: use consistent location for "*" in function declarations
Zbigniew Jędrzejewski-Szmek [Fri, 28 Aug 2020 14:37:09 +0000 (16:37 +0200)]
basic/escape: use consistent location for "*" in function declarations

I think it's nicer to move it to the left, since the function
is already a pointer by itself, and it just happens to return a pointer,
and the two concepts are completely separate.

5 years agoshared/{user,group}-record-nss: adjust filtering of "valid" passwords
Zbigniew Jędrzejewski-Szmek [Fri, 28 Aug 2020 14:23:16 +0000 (16:23 +0200)]
shared/{user,group}-record-nss: adjust filtering of "valid" passwords

We would reject various passwords that glibc accepts, for example ""
or any descrypted password. Accounts with empty password are definitely
useful, for example for testing or in scenarios where a password is not
needed. Also, using weak encryption methods is probably not a good idea,
it's not the job of our nss helpers to decide that: they should just
faithfully forward whatever data is there.

Also rename the function to make it more obvious that the returned answer
is not in any way certain.

5 years agoRework how we cache mtime to figure out if units changed
Zbigniew Jędrzejewski-Szmek [Fri, 28 Aug 2020 10:21:48 +0000 (12:21 +0200)]
Rework how we cache mtime to figure out if units changed

Instead of assuming that more-recently modified directories have higher mtime,
just look for any mtime changes, up or down. Since we don't want to remember
individual mtimes, hash them to obtain a single value.

This should help us behave properly in the case when the time jumps backwards
during boot: various files might have mtimes that in the future, but we won't
care. This fixes the following scenario:

We have /etc/systemd/system with T1. T1 is initially far in the past.
We have /run/systemd/generator with time T2.
The time is adjusted backwards, so T2 will be always in the future for a while.
Now the user writes new files to /etc/systemd/system, and T1 is updated to T1'.
Nevertheless, T1 < T1' << T2.
We would consider our cache to be up-to-date, falsely.

5 years agocore: always try to reload not-found unit
Zbigniew Jędrzejewski-Szmek [Mon, 31 Aug 2020 18:44:00 +0000 (20:44 +0200)]
core: always try to reload not-found unit

This check was added in d904afc730268d50502f764dfd55b8cf4906c46f. It would only
apply in the case where the cache hasn't been loaded yet. I think we pretty
much always have the cache loaded when we reach this point, but even if we
didn't, it seems better to try to reload the unit. So let's drop this check.

5 years agopid1: use the cache mtime not clock to "mark" load attempts
Zbigniew Jędrzejewski-Szmek [Fri, 28 Aug 2020 09:19:38 +0000 (11:19 +0200)]
pid1: use the cache mtime not clock to "mark" load attempts

We really only care if the cache has been reloaded between the time when we
last attempted to load this unit and now. So instead of recording the actual
time we try to load the unit, just store the timestamp of the cache. This has
the advantage that we'll notice if the cache mtime jumps forward or backward.

Also rename fragment_loadtime to fragment_not_found_time. It only gets set when
we failed to load the unit and the old name was suggesting it is always set.

In https://bugzilla.redhat.com/show_bug.cgi?id=1871327
(and most likely https://bugzilla.redhat.com/show_bug.cgi?id=1867930
and most likely https://bugzilla.redhat.com/show_bug.cgi?id=1872068) we try
to load a non-existent unit over and over from transaction_add_job_and_dependencies().
My understanding is that the clock was in the future during inital boot,
so cache_mtime is always in the future (since we don't touch the fs after initial boot),
so no matter how many times we try to load the unit and set
fragment_loadtime / fragment_not_found_time, it is always higher than cache_mtime,
so manager_unit_cache_should_retry_load() always returns true.

5 years agocore: rename manager_unit_file_maybe_loadable_from_cache()
Zbigniew Jędrzejewski-Szmek [Fri, 28 Aug 2020 08:32:39 +0000 (10:32 +0200)]
core: rename manager_unit_file_maybe_loadable_from_cache()

The name is misleading, since we aren't really loading the unit from cache — if
this function returns true, we'll try to load the unit from disk, updating the
cache in the process.

5 years agoMerge pull request #16841 from keszybz/acl-util-bitmask
Lennart Poettering [Mon, 31 Aug 2020 14:45:13 +0000 (16:45 +0200)]
Merge pull request #16841 from keszybz/acl-util-bitmask

Use a bitmask in fd_add_uid_acl_permission()

5 years agoman: document fd ownership for sd-bus fd marshalling
Lennart Poettering [Fri, 28 Aug 2020 19:18:14 +0000 (21:18 +0200)]
man: document fd ownership for sd-bus fd marshalling

Fixes: #8003

5 years agoMerge pull request #16898 from poettering/resolved-errno
Daan De Meyer [Sun, 30 Aug 2020 17:05:38 +0000 (18:05 +0100)]
Merge pull request #16898 from poettering/resolved-errno

make sure we have `answer_errno` always properly initialized before we end a transaction with ERRNO cause

5 years agohomed: fix log message to honor real homework path
Florian Klink [Sat, 29 Aug 2020 17:57:24 +0000 (19:57 +0200)]
homed: fix log message to honor real homework path

This seems to be overridable by setting the SYSTEMD_HOMEWORK_PATH env
variable, but the error message always printed the SYSTEMD_HOMEWORK_PATH
constant.

5 years agotree-wide: drop pointless zero initialization (#16900)
fangxiuning [Sat, 29 Aug 2020 21:21:20 +0000 (05:21 +0800)]
tree-wide: drop pointless zero initialization (#16900)

5 years agosrc/shared/dissect-image.c: fix build without blkdid (#16901)
Fabrice Fontaine [Sat, 29 Aug 2020 21:17:18 +0000 (23:17 +0200)]
src/shared/dissect-image.c: fix build without blkdid (#16901)

N_DEVICE_NODE_LIST_ATTEMPTS is unconditionally used since version 246 and
https://github.com/systemd/systemd/commit/ac1f3ad05f7476ae58981dcba45dfeb2c0006824

However, this variable is only defined if HAVE_BLKID is set resulting in
the following build failure if cryptsetup is enabled but not libblkid:

../src/shared/dissect-image.c:1336:34: error: 'N_DEVICE_NODE_LIST_ATTEMPTS' undeclared (first use in this function)
 1336 |         for (unsigned i = 0; i < N_DEVICE_NODE_LIST_ATTEMPTS; i++) {
      |

Fixes:
 - http://autobuild.buildroot.org/results/67782c225c08387c1bbcbea9eee3ca12bc6577cd

5 years agoMerge pull request #16850 from mbiebl/networkd-socket-activation
Michael Biebl [Sat, 29 Aug 2020 14:12:46 +0000 (16:12 +0200)]
Merge pull request #16850 from mbiebl/networkd-socket-activation

networkd: use socket activation when starting networkd

5 years agosym: fix bad symbol file addition
Lennart Poettering [Fri, 28 Aug 2020 17:52:36 +0000 (19:52 +0200)]
sym: fix bad symbol file addition

The next release is 247, not 248.

A follow-up for 2b07ec316a0e25a3e10c270c7f6baee9e0187bf8

5 years agoresolved: remove superfluous ;;
Lennart Poettering [Fri, 28 Aug 2020 20:59:26 +0000 (22:59 +0200)]
resolved: remove superfluous ;;

5 years agotree-wide: no need to negate argument to ERROR_IS_XYZ()
Lennart Poettering [Fri, 28 Aug 2020 20:58:56 +0000 (22:58 +0200)]
tree-wide: no need to negate argument to ERROR_IS_XYZ()

These macros call abs() internally, hence let's simplify invocations.

5 years agoresolved: make sure we initialize t->answer_errno before completing the transaction
Lennart Poettering [Fri, 28 Aug 2020 20:44:57 +0000 (22:44 +0200)]
resolved: make sure we initialize t->answer_errno before completing the transaction

We must have the error number around when completing the transaction.
Let's hence make sure we always initialize it *first* (we accidentally
did it once after).

Fixes: #11626

5 years agotest-network: stop networkd and its socket
Michael Biebl [Fri, 28 Aug 2020 15:21:27 +0000 (17:21 +0200)]
test-network: stop networkd and its socket

With the changes from 2c0dffe82db574b6b9e850e48f444674e4e1d7ea, starting
systemd-networkd.service will also activate systemd-networkd.socket.
When tearing down a test, we need to stop the socket as well, to make
sure networkd can't be activated accidentally with the wrong
configuration.

5 years agoMerge pull request #16874 from poettering/analyze-cap
Lennart Poettering [Fri, 28 Aug 2020 19:01:56 +0000 (21:01 +0200)]
Merge pull request #16874 from poettering/analyze-cap

introduce "systemd-analyze capability" command for dumping locally defined caps

5 years agoclock-util: read timestamp from /usr/lib/clock-epoch
Daniel Mack [Fri, 28 Aug 2020 14:14:12 +0000 (16:14 +0200)]
clock-util: read timestamp from /usr/lib/clock-epoch

On systems without an RTC, systemd currently sets the clock to a
compile-time epoch value, derived from the NEWS file in the
repository. This is not ideal as the initial clock hence depends
on the last time systemd was built, not when the image was compiled.

Let's provide a different way here and look at `/usr/lib/clock-epoch`.
If that file exists, it's timestamp for the last modification will be
used instead of the compile-time default.

5 years agounits: add missing usb-gadget.target
Kyle Russell [Fri, 28 Aug 2020 13:36:35 +0000 (09:36 -0400)]
units: add missing usb-gadget.target

5 years agoanalyze: add 'capability' verb for dumping all known and unknown caps
Lennart Poettering [Thu, 27 Aug 2020 13:45:53 +0000 (15:45 +0200)]
analyze: add 'capability' verb for dumping all known and unknown caps

5 years agoanalyze: fix error handling in one case
Lennart Poettering [Thu, 27 Aug 2020 13:46:03 +0000 (15:46 +0200)]
analyze: fix error handling in one case

5 years agobasic: make sure we include inttypes.h when we use its types
Lennart Poettering [Thu, 27 Aug 2020 13:46:28 +0000 (15:46 +0200)]
basic: make sure we include inttypes.h when we use its types

5 years agoman: extend on the usec/sec discrepancy
Lennart Poettering [Thu, 27 Aug 2020 13:45:29 +0000 (15:45 +0200)]
man: extend on the usec/sec discrepancy

Let's document the discrepancy between the Sec and USec suffixing of
unit files and D-Bus properties at three places: in "systemctl show"
(where it already was briefly mentioned), in the D-Bus interface
description (at one place at least, i.e. the most prominent of
properties that encapsulate time values, there are many more) and in the
general man page explaining time values.

By documenting this at all three places I think we now do as much as we
can do about this highlighting the discrepancy of the naming and the
reasons behind it.

Fixes: #2047

5 years agotree-wide: drop pointless zero initialization (#16884)
fangxiuning [Fri, 28 Aug 2020 15:45:54 +0000 (23:45 +0800)]
tree-wide: drop pointless zero initialization (#16884)

tree-wide: drop pointless zero initialization

5 years agonetworkd: consider any uevent other than "remove" sufficient for the network device...
Lennart Poettering [Wed, 12 Dec 2018 20:32:29 +0000 (21:32 +0100)]
networkd: consider any uevent other than "remove" sufficient for the network device to be ready

5 years agologin/logind: Include sys/stat.h for struct stat usage
Ikey Doherty [Fri, 28 Aug 2020 13:23:44 +0000 (14:23 +0100)]
login/logind: Include sys/stat.h for struct stat usage

We need to include `<sys/stat.h>` for usage of the `struct stat` in
the Manager struct, much as we already include `<stdbool.h>` for C99
booleans.

This helps alleviate another minor build failure on non-glibc systems.

5 years agotmpfiles: use statx() when aging files
Lennart Poettering [Thu, 27 Aug 2020 17:13:30 +0000 (19:13 +0200)]
tmpfiles: use statx() when aging files

This allows us to properly detect mount points, for free. (Also, allows
us to respect btimes that are newer than the cutoff, which should be
useful when people untar file trees in /var/tmp)

Fixes: #16848

5 years agotime-util: add timespec_store_nsec()
Lennart Poettering [Thu, 27 Aug 2020 17:01:48 +0000 (19:01 +0200)]
time-util: add timespec_store_nsec()

timespec_store_nsec() is to timespec_store() what timespec_load_nsec()
is to timespec_load(), i.e. the nsec version of the usual usec API

5 years agoAdd simple usage message to systemd-backlight (#16709)
Plan C [Fri, 28 Aug 2020 11:50:35 +0000 (19:50 +0800)]
Add simple usage message to systemd-backlight (#16709)

5 years agopartition/makefs: Include missing sys/file.h header
Ikey Doherty [Thu, 27 Aug 2020 16:45:45 +0000 (17:45 +0100)]
partition/makefs: Include missing sys/file.h header

This file must be included on non-glibc systems to ensure
the `LOCK_EX` definition is available.

Signed-off-by: Ikey Doherty <ikey.doherty@lispysnake.com>
5 years agodevice: propagate reload events from devices on everything but "add", and "remove"
Lennart Poettering [Wed, 12 Dec 2018 20:31:12 +0000 (21:31 +0100)]
device: propagate reload events from devices on everything but "add", and "remove"

Any uevent other then the initial and the last uevent we see for a
device (which is "add" and "remove") should result in a reload being
triggered, including "bind" and "unbind". Hence, let's fix up the check.

("move" is kinda a combined "remove" + "add", hence cover that too)

5 years agoMerge pull request #16879 from keszybz/test-last-cap-and-dbus-docs
Zbigniew Jędrzejewski-Szmek [Fri, 28 Aug 2020 06:30:00 +0000 (08:30 +0200)]
Merge pull request #16879 from keszybz/test-last-cap-and-dbus-docs

Add "developer mode" and test last cap and dbus docs

5 years agoMerge pull request #16872 from keszybz/test-50
Zbigniew Jędrzejewski-Szmek [Fri, 28 Aug 2020 06:27:55 +0000 (08:27 +0200)]
Merge pull request #16872 from keszybz/test-50

Improve handling of os-release in tests

5 years agohwdb: fix size lenovo x240 touchpad (#16871)
Jérémy Nouhaud [Thu, 27 Aug 2020 19:59:23 +0000 (21:59 +0200)]
hwdb: fix size lenovo x240 touchpad (#16871)

As discussed in https://gitlab.freedesktop.org/libinput/libinput/-/issues/521, it adds a narrower
match that only applies to X240. Other laptops that match `pvrThinkPad??40` are not affected:

$ systemd-hwdb query 'evdev:name:SynPS/2 Synaptics TouchPad:dmi:*svnLENOVO*:pvrThinkPadX240:*'
EVDEV_ABS_00=1232:5711:51
EVDEV_ABS_01=1159:4700:53
EVDEV_ABS_35=1232:5711:51
EVDEV_ABS_36=1159:4700:53
$ systemd-hwdb query 'evdev:name:SynPS/2 Synaptics TouchPad:dmi:*svnLENOVO*:pvrThinkPadX140:*'
EVDEV_ABS_00=::41
EVDEV_ABS_01=::37
EVDEV_ABS_35=::41
EVDEV_ABS_36=::37

5 years agoman: update dbus doc stubs
Zbigniew Jędrzejewski-Szmek [Thu, 27 Aug 2020 18:20:08 +0000 (20:20 +0200)]
man: update dbus doc stubs

For 4e39995371738b04d98d27b0d34ea8fe09ec9fab and
bb0c0d6f29236645c8beb7ba662b2c4e7b241407.

5 years agoupdate-dbus-docs: add hint
Zbigniew Jędrzejewski-Szmek [Thu, 27 Aug 2020 18:18:05 +0000 (20:18 +0200)]
update-dbus-docs: add hint

5 years agoupdate-dbus-docs: omit verbose output when in --test mode
Zbigniew Jędrzejewski-Szmek [Thu, 27 Aug 2020 18:15:30 +0000 (20:15 +0200)]
update-dbus-docs: omit verbose output when in --test mode

It makes the ninja output listing very long for no good purpose.

5 years agotest: verify that dbus docs are fresh
Zbigniew Jędrzejewski-Szmek [Thu, 27 Aug 2020 18:10:01 +0000 (20:10 +0200)]
test: verify that dbus docs are fresh

This makes use of the developer mode switch: the test is only done
if the user opted-in into developer mode.

Before the man/update-dbus-docs was using the argument form where
we don't need to run find_command(), but that doesn't work with test(),,
so find_command() is used and we get one more line in the config log.

5 years agonetwork: dhcp6: logs only new address
Yu Watanabe [Sat, 15 Aug 2020 10:01:49 +0000 (19:01 +0900)]
network: dhcp6: logs only new address

Closes #16731.

5 years agoMerge pull request #16863 from weblate/weblate-systemd-master
Zbigniew Jędrzejewski-Szmek [Thu, 27 Aug 2020 19:10:55 +0000 (21:10 +0200)]
Merge pull request #16863 from weblate/weblate-systemd-master

Translations update from Weblate

5 years agoupdate-dbus-docs: add test mode
Zbigniew Jędrzejewski-Szmek [Thu, 27 Aug 2020 17:55:55 +0000 (19:55 +0200)]
update-dbus-docs: add test mode

5 years agoupdate-dbus-docs: use argparse
Zbigniew Jędrzejewski-Szmek [Thu, 27 Aug 2020 17:27:18 +0000 (19:27 +0200)]
update-dbus-docs: use argparse

5 years agoupdate-dbus-docs: print statistics at the end
Zbigniew Jędrzejewski-Szmek [Thu, 27 Aug 2020 17:21:21 +0000 (19:21 +0200)]
update-dbus-docs: print statistics at the end

Right now:
org.freedesktop.LogControl1.xml: 3/3
org.freedesktop.home1.xml:       44/44
org.freedesktop.hostname1.xml:   21/21
org.freedesktop.import1.xml:     17/19
org.freedesktop.locale1.xml:     10/10
org.freedesktop.login1.xml:      172/172
org.freedesktop.machine1.xml:    49/65
org.freedesktop.resolve1.xml:    25/61
org.freedesktop.systemd1.xml:    214/1468
org.freedesktop.timedate1.xml:   12/12
total:                           567/1875

:(

5 years agobasic/missing_capability: clean up our defines and check that our fallback is up...
Zbigniew Jędrzejewski-Szmek [Thu, 27 Aug 2020 16:22:45 +0000 (18:22 +0200)]
basic/missing_capability: clean up our defines and check that our fallback is up-to-date

There is little point in #defining and #undefining CAP_LAST_CAP multiple times.

The check is only done in developer mode. After all, it's not an error to
compile on a newer kernel, and we shouldn't even warn in that case.

5 years agomeson: add "develop mode" config switch
Zbigniew Jędrzejewski-Szmek [Thu, 27 Aug 2020 15:26:49 +0000 (17:26 +0200)]
meson: add "develop mode" config switch

5 years agotest-path: remove unnecessary check
Zbigniew Jędrzejewski-Szmek [Thu, 27 Aug 2020 07:58:58 +0000 (09:58 +0200)]
test-path: remove unnecessary check

test points to an array, so it canont be NULL at this point.

5 years agoDon't run test-repart when loop devices are not available
Daan De Meyer [Wed, 26 Aug 2020 22:08:52 +0000 (23:08 +0100)]
Don't run test-repart when loop devices are not available

5 years agoMerge pull request #16864 from yuwata/coverity-fixes
Lennart Poettering [Thu, 27 Aug 2020 14:36:40 +0000 (16:36 +0200)]
Merge pull request #16864 from yuwata/coverity-fixes

Two coverity fixes

5 years agoMerge pull request #16866 from yuwata/networkctl-tiny-cleanups
Lennart Poettering [Thu, 27 Aug 2020 14:34:43 +0000 (16:34 +0200)]
Merge pull request #16866 from yuwata/networkctl-tiny-cleanups

networkctl: tiny cleanups

5 years agomissing: Add new Linux capability
Michal Koutný [Wed, 26 Aug 2020 13:37:21 +0000 (15:37 +0200)]
missing: Add new Linux capability

Yet another new capability coming in Linux kernel v5.9.
Make sure we can recongize them even when built with older kernel headers.

5 years agotest/test-functions: do not execute strip_binaries twice
Zbigniew Jędrzejewski-Szmek [Thu, 27 Aug 2020 11:10:30 +0000 (13:10 +0200)]
test/test-functions: do not execute strip_binaries twice

It is called from setup_basic_environment(), which also calls install_symtemd()
a bit earlier, so in effect it would be called twice.

5 years agotests/TEST-50: support the case when /etc/os-release is present
Zbigniew Jędrzejewski-Szmek [Thu, 27 Aug 2020 09:59:45 +0000 (11:59 +0200)]
tests/TEST-50: support the case when /etc/os-release is present

We have four legal cases:
1. /usr/lib/os-release exists and /etc/os-release is a symlink to it
2. both exist but /etc/os-release is not a symlink to /usr/lib/os-release
3. only /usr/lib/os-release exists
4. only /etc/os-release exists

The generic setup code in test-functions and create-busybox-image didn't handle
case 3.

The test-specific code in TEST-50 didn't handle 2 (because the general setup
code would only install /etc/os-release in the image and
grep -f /usr/lib/os-release would not work) and 4 (same reason) and would fail
in case 3 in generic setup.

5 years agotest: remove executable bit from testsuite-52.service
Michael Biebl [Thu, 27 Aug 2020 10:09:08 +0000 (12:09 +0200)]
test: remove executable bit from testsuite-52.service

5 years agoTEST-50: sfdisk is already installed by setup_basic_environment
Zbigniew Jędrzejewski-Szmek [Thu, 27 Aug 2020 09:31:11 +0000 (11:31 +0200)]
TEST-50: sfdisk is already installed by setup_basic_environment

5 years agojournal: fix divide-by-zero warning
Yu Watanabe [Thu, 27 Aug 2020 05:02:33 +0000 (14:02 +0900)]
journal: fix divide-by-zero warning

Fixes CID#1430209.

5 years agocore: clear bind mounts on error
Yu Watanabe [Thu, 27 Aug 2020 04:49:21 +0000 (13:49 +0900)]
core: clear bind mounts on error

Follow-up for bbb4e7f39f2c68c719c26c2c65f8b7b91b009e92.

Fixes CID#1431998.

5 years agoMerge pull request #16860 from poettering/tty-ask-pw-agent-list-fix
Zbigniew Jędrzejewski-Szmek [Thu, 27 Aug 2020 08:58:13 +0000 (10:58 +0200)]
Merge pull request #16860 from poettering/tty-ask-pw-agent-list-fix

tty-ask-password-agent: three fixes

5 years agoAdd sensor configuration for Acer SW5-017-17BU
Njibhu [Wed, 26 Aug 2020 23:46:30 +0000 (01:46 +0200)]
Add sensor configuration for Acer SW5-017-17BU

5 years agoMerge pull request #16847 from olivierlemoal/master
Zbigniew Jędrzejewski-Szmek [Thu, 27 Aug 2020 08:27:01 +0000 (10:27 +0200)]
Merge pull request #16847 from olivierlemoal/master

shell-completion/zsh: add missing verbs for networkctl

5 years agoshared/acl-util: convert rd,wr,ex to a bitmask
Zbigniew Jędrzejewski-Szmek [Wed, 26 Aug 2020 08:59:32 +0000 (10:59 +0200)]
shared/acl-util: convert rd,wr,ex to a bitmask

I find this version much more readable.

Add replacement defines so that when acl/libacl.h is not available, the
ACL_{READ,WRITE,EXECUTE} constants are also defined. Those constants were
declared in the kernel headers already in 1da177e4c3f41524e886b7f1b8a0c1f,
so they should be the same pretty much everywhere.

5 years agoadd "list" verb to autocompleted commands
Olivier Le Moal [Thu, 27 Aug 2020 08:01:36 +0000 (10:01 +0200)]
add "list" verb to autocompleted commands

5 years agoman: clarify that several networkctl commands takes device names
Yu Watanabe [Thu, 27 Aug 2020 07:35:25 +0000 (16:35 +0900)]
man: clarify that several networkctl commands takes device names

5 years agonetworkctl: label command does not take any argument
Yu Watanabe [Thu, 27 Aug 2020 07:32:13 +0000 (16:32 +0900)]
networkctl: label command does not take any argument

5 years agoudev: use path_startswith() instead of startswith() in two more cases
Lennart Poettering [Wed, 26 Aug 2020 15:22:06 +0000 (17:22 +0200)]
udev: use path_startswith() instead of startswith() in two more cases

5 years agoReplace gendered pronouns with gender neutral ones. (#16844)
PhoenixDiscord [Thu, 27 Aug 2020 02:52:48 +0000 (04:52 +0200)]
Replace gendered pronouns with gender neutral ones. (#16844)