Commit Graph
37496 Commits
Author SHA1 Message Date
Lennart Poettering faaa6ea076 analyze: split out log control verb 2022-02-21 17:22:23 +01:00
Lennart Poettering c649b343b4 analyze: split out cat-config verb 2022-02-21 17:22:23 +01:00
Lennart Poettering ba474dada8 analyze: split out "plot" verb 2022-02-21 17:22:23 +01:00
Lennart Poettering 113dd9cbc4 analyze: split out "blame" verb + time helpers 2022-02-21 17:22:23 +01:00
Lennart Poettering 6488e8443b analyze: split out "capability" verb 2022-02-21 17:22:23 +01:00
Lennart Poettering 73cb64c44d analyze: split out "exit-status" verb 2022-02-21 17:22:23 +01:00
Lennart Poettering ab86ccbab0 analyze: highlight the range of deprecated verbs in comments a bit better 2022-02-21 17:22:23 +01:00
Lennart Poettering 2b04e72cd1 analyze: split out "service-watchdogs" verb 2022-02-21 17:22:23 +01:00
Lennart Poettering cccd2af6f5 analyze: split out "dot" verb 2022-02-21 17:22:23 +01:00
Lennart Poettering 25eb70af8b analyze: split out "dump" verb 2022-02-21 17:22:23 +01:00
Lennart Poettering 389638d395 analyze: split out "syscall-filter" verb 2022-02-21 17:22:23 +01:00
Lennart Poettering 08e36480d4 analyze: split out "filesystems" verb into its own .c/.h file pair 2022-02-21 17:22:23 +01:00
Lennart Poettering 5229b03c10 analyze: split out calendar verb into own .c/.h file 2022-02-21 17:22:23 +01:00
Lennart Poettering 503ccaaa5b analyze: split out "timestamp" verb into its own .c/.h files 2022-02-21 17:22:23 +01:00
Lennart Poettering 30bddc066a analyze: split out "timespan" verb into its own .c/.h file 2022-02-21 17:22:23 +01:00
Lennart Poettering 67e993b9e0 Merge pull request #22573 from mrc0mmand/epoch-timestamp
time-util: introduce TIMESTAMP_UNIX
2022-02-21 16:13:47 +01:00
Frantisek Sumsal b58b4a9f37 systemctl,man: update docs for --timestamp= 2022-02-21 13:22:02 +01:00
Frantisek Sumsal ed4a5b4345 time-util: introduce TIMESTAMP_UNIX
Allow formatting timestamps as number of seconds since the Epoch for easier
machine parsing.

Fixes: #22567

```
$ systemctl show systemd-journald | grep Timestamp
WatchdogTimestampMonotonic=0
ExecMainStartTimestamp=Sat 2021-12-11 15:25:57 CET
ExecMainStartTimestampMonotonic=13030408
ExecMainExitTimestampMonotonic=0
StateChangeTimestamp=Sat 2021-12-11 15:25:57 CET
StateChangeTimestampMonotonic=13049273
InactiveExitTimestamp=Sat 2021-12-11 15:25:57 CET
InactiveExitTimestampMonotonic=13030430
ActiveEnterTimestamp=Sat 2021-12-11 15:25:57 CET
ActiveEnterTimestampMonotonic=13049273
ActiveExitTimestamp=Sat 2021-12-11 15:25:57 CET
ActiveExitTimestampMonotonic=12997236
InactiveEnterTimestamp=Sat 2021-12-11 15:25:57 CET
InactiveEnterTimestampMonotonic=13028890
ConditionTimestamp=Sat 2021-12-11 15:25:57 CET
ConditionTimestampMonotonic=13029539
AssertTimestamp=Sat 2021-12-11 15:25:57 CET
AssertTimestampMonotonic=13029540

$ systemctl show --timestamp=unix systemd-journald | grep Timestamp
WatchdogTimestampMonotonic=0
ExecMainStartTimestamp=@1639232757
ExecMainStartTimestampMonotonic=13030408
ExecMainExitTimestampMonotonic=0
StateChangeTimestamp=@1639232757
StateChangeTimestampMonotonic=13049273
InactiveExitTimestamp=@1639232757
InactiveExitTimestampMonotonic=13030430
ActiveEnterTimestamp=@1639232757
ActiveEnterTimestampMonotonic=13049273
ActiveExitTimestamp=@1639232757
ActiveExitTimestampMonotonic=12997236
InactiveEnterTimestamp=@1639232757
InactiveEnterTimestampMonotonic=13028890
ConditionTimestamp=@1639232757
ConditionTimestampMonotonic=13029539
AssertTimestamp=@1639232757
AssertTimestampMonotonic=13029540
```
2022-02-21 13:21:58 +01:00
Lennart Poettering e99ca14741 env-util: replace unsetenv_erase() by new getenv_steal_erase() helper
The new helper combines a bunch of steps every invocation of
unsetenv_erase() did so far: getenv() + strdup() + unsetenv_erase().
Let's unify this into one helper that is harder to use incorrectly. It's
in inspired by TAKE_PTR() in a way: get the env var out and invalidate
where it was before.
2022-02-20 12:38:06 +09:00
Frantisek Sumsal a59e5c625d systemctl: make --timestamp= affect the show verb as well
Currently the `--timestamp=` option has no effect on timestamps shown by
`systemctl show`, let's fix that.

Spotted in #22567.

Before:
```
$ systemctl show --timestamp=us+utc systemd-journald | grep Timestamp=
ExecMainStartTimestamp=Sat 2021-12-11 15:25:57 CET
StateChangeTimestamp=Sat 2021-12-11 15:25:57 CET
InactiveExitTimestamp=Sat 2021-12-11 15:25:57 CET
ActiveEnterTimestamp=Sat 2021-12-11 15:25:57 CET
ActiveExitTimestamp=Sat 2021-12-11 15:25:57 CET
InactiveEnterTimestamp=Sat 2021-12-11 15:25:57 CET
ConditionTimestamp=Sat 2021-12-11 15:25:57 CET
AssertTimestamp=Sat 2021-12-11 15:25:57 CET
```

After:
```
$ systemctl show --timestamp=us+utc systemd-journald | grep Timestamp=
ExecMainStartTimestamp=Sat 2021-12-11 14:25:57.177848 UTC
StateChangeTimestamp=Sat 2021-12-11 14:25:57.196714 UTC
InactiveExitTimestamp=Sat 2021-12-11 14:25:57.177871 UTC
ActiveEnterTimestamp=Sat 2021-12-11 14:25:57.196714 UTC
ActiveExitTimestamp=Sat 2021-12-11 14:25:57.144677 UTC
InactiveEnterTimestamp=Sat 2021-12-11 14:25:57.176331 UTC
ConditionTimestamp=Sat 2021-12-11 14:25:57.176980 UTC
AssertTimestamp=Sat 2021-12-11 14:25:57.176980 UTC

```
2022-02-19 10:16:30 +01:00
Jan Janssen b7de9651db generator: Rename password arg
This function does not expect a password, but a key file path. The
cryptsetup helper binary even calls it that.

No Code changes.

Follow up on: 6e41f4dd91
Fixes: https://github.com/systemd/systemd/security/code-scanning/81
2022-02-19 10:15:38 +01:00
Lennart Poettering 2471a977b1 resolved: rework how we reply to D-Bus messages for resolution requests
This reworks how we reply to D-Bus messages that come in for resolution
requests. Previously, we'd store them in the .bus_request field of
the main DnsQuery (but not any auxiliary one), and reply to it whenever
we had something to reply. In error paths this could mean we'd
accidentally reply twice.

This cleans this logic up: whenever we reply to a message we'll now go up
the tree of auxiliary queries, to find the primary query, i.e. the one
we actually want to reply to. Once we found it, we take out the bus
message object, resetting it to NULL. This way we can be sure we'll
reply at most once to each message.

Fixes: #22477
2022-02-18 18:50:24 +01:00
Yu Watanabe 08275791d8 resolve: add reference of the original bus message to the aux queries
Otherwise, the error in aux queries cannot be replied.

Fixes #22477.
2022-02-18 18:13:20 +01:00
Lennart Poettering 2c7bcdd522 machined: use one_zero() on one more occasion 2022-02-18 13:08:31 +01:00
Lennart Poettering 2e1ae3258d machined: sd-bus expects 'int', not 'bool' when returning unmarshalled booleans
Fixes: #22555
Follow-up for: #22160
2022-02-18 13:08:27 +01:00
Lennart PoetteringandLukas Märdian de90700f36 pid1: set SYSTEMD_NSS_DYNAMIC_BYPASS=1 env var for dbus-daemon
There's currently a deadlock between PID 1 and dbus-daemon: in some
cases dbus-daemon will do NSS lookups (which are blocking) at the same
time PID 1 synchronously blocks on some call to dbus-daemon. Let's break
that by setting SYSTEMD_NSS_DYNAMIC_BYPASS=1 env var for dbus-daemon,
which will disable synchronously blocking varlink calls from nss-systemd
to PID 1.

In the long run we should fix this differently: remove all synchronous
calls to dbus-daemon from PID 1. This is not trivial however: so far we
had the rule that synchronous calls from PID 1 to the dbus broker are OK
as long as they only go to interfaces implemented by the broke itself
rather than services reachable through it. Given that the relationship
between PID 1 and dbus is kinda special anyway, this was considered
acceptable for the sake of simplicity, since we quite often need
metadata about bus peers from the broker, and the asynchronous logic
would substantially complicate even the simplest method handlers.

This mostly reworks the existing code that sets SYSTEMD_NSS_BYPASS_BUS=
(which is a similar hack to deal with deadlocks between nss-systemd and
dbus-daemon itself) to set SYSTEMD_NSS_DYNAMIC_BYPASS=1 instead. No code
was checking SYSTEMD_NSS_BYPASS_BUS= anymore anyway, and it used to
solve a similar problem, hence it's an obvious piece of code to rework
like this.

Issue originally tracked down by Lukas Märdian. This patch is inspired
and closely based on his patch:

       https://github.com/systemd/systemd/pull/22038

Fixes: #15316
Co-authored-by: Lukas Märdian <slyon@ubuntu.com>
2022-02-18 10:49:36 +01:00
Lennart Poettering e39eb045a5 pid1: lookup owning PID of BusName= name of services asynchronously
A first step of removing blocking calls to the D-Bus broker from PID 1.
There's a lot more to got (i.e. grep src/core/ for sd_bus_creds
basically), but it's a start.

Removing blocking calls to D-Bus broker deals systematicallly with
deadlocks caused by dbus-daemon blocking on synchronous IPC calls back
to PID1 (e.g. Varlink calls through nss-systemd). Bugs such as #15316.

Also-see: https://github.com/systemd/systemd/pull/22038#issuecomment-1042958390
2022-02-18 10:49:31 +01:00
Lennart Poettering 1e8b312e5a pid1: watch bus name always when we have it
Previously we'd only watch configured service bus names if Type=dbus was
set. Let's also watch it for other types. This is useful to pick up the
main PID of such a service. In fact the code to pick it up was already
in place, alas it didn't do anything given the signal was never received
for it. Fix that.

(It's also useful for debugging)
2022-02-18 10:45:47 +01:00
Yu Watanabe 9fa31df62d udev-util: add parentheses to make coverity silent
Fixes CID#1474365.
2022-02-18 08:35:35 +01:00
Yu Watanabe 63b5e05ff9 Merge pull request #22545 from yuwata/network-match-kind
network, udev: introduce Kind= setting in [Match] section
2022-02-18 01:20:18 +09:00
Yu Watanabe 65022cd7ab network,udev/net: add Kind= settings in [Match] section
This may be useful for writing .network or .link files matching with
virtual interfaces.

Closes #22541.
2022-02-17 23:10:26 +09:00
Yu Watanabe 48c08560f4 Merge pull request #22540 from yuwata/network-call-ethtool-after-initialized
network: call ethtool after link is initialized by udevd
2022-02-17 22:59:24 +09:00
Yu Watanabe 0234f0c053 resolve: refuse AF_UNSPEC when resolving address
Fixes #22480.
2022-02-17 13:24:01 +01:00
Yu Watanabe 430f07f4f8 networkctl: show netdev kind 2022-02-17 21:15:27 +09:00
Yu Watanabe e1658632ae network: call ethtool after link is initialized by udevd
Fixes #22538.
2022-02-17 18:55:43 +09:00
Yu Watanabe 82f52245ba network: use udev_available() where applicable 2022-02-17 18:55:43 +09:00
Yu Watanabe f92c5bb18c udev-util: introduce udev_available() helper function 2022-02-17 18:51:57 +09:00
Yu Watanabe bfae960e53 Merge pull request #22535 from poettering/dbusctl-range-display
userdbctl: show UID ranges in output too
2022-02-17 16:45:39 +09:00
Yu Watanabe 9e0cb8b61f sd-dhcp-server: do not offer server address
The server address may be in the pool.
2022-02-17 16:45:10 +09:00
Lennart Poettering 3d643eda0d userdbctl: add a dash of color to users of different dispositions 2022-02-16 23:14:27 +01:00
Lennart Poettering b9fd7f5cb3 userdbctl: show min/max UID boundaries in userdbctl output 2022-02-16 23:14:27 +01:00
Lennart Poettering 0db7e17cba logind: fix bool/int confusion for KillUserProcesses bus property
sd-bus for compat with old C expects "int" for booleans. Internally we
prefer to use C99 "bool" however. When pointing a pointer to it, we need
to handle the fact that they are typically differently sized, hence use
te right accessors for it.
2022-02-16 22:58:19 +01:00
Lennart Poettering 81bb3ca13c logind: fix internal types used for EnableWallMessages
The value is used as a boolean, but stored in an unsigned. It's exposed
with sd-bus default boolean handling which however expects a (signed)
int. Let's clear this up, and use "bool" for this everywhere in
non-local scope, and make sure that when we pass it to sd-bus we
properly pass an "int".
2022-02-16 22:56:47 +01:00
Lennart Poettering 76ef5d0493 user-util: move homed/nspawn map UID_MIN/UID_MAX define into user-util.h
Let's have them at a common place, so that we have the ranges altogether
at a minimal set of places.
2022-02-16 22:40:06 +01:00
Lennart Poettering fc03e80c6b glyph-util: add new glyphs for up/down arrows 2022-02-16 22:40:06 +01:00
Lennart Poettering 3414394e0b Merge pull request #22531 from poettering/mempcpy-cocci
coccinelle: add semantic patch for using more mempcpy() instead of memcpy()
2022-02-16 22:20:33 +01:00
Lennart Poettering 281df579a7 Revert "resolved: filter out our own stub resolvers when parsing servers"
This reverts commit 0ad4efb14b.

See
https://github.com/systemd/systemd/pull/20559#issuecomment-1028011030
for reasoning. Quoting:

> I think it should be OK to advertise extra stub listeners to local
> clients, but you prohibit this now. i.e. there are two different
> concepts here, and we shouldn't mix them up:
>
> 1. tracking configured dns servers and advertise them to local programs
> 2. actually using them ourselves
>
> I am pretty sure that our own stubs are OK for 1 but not OK for 2,
> hence we should filter at the time of use not at the time of parse.
2022-02-16 22:20:10 +01:00
Luca Boccassi 5d11af60ac Merge pull request #22498 from yuwata/cgroup-threaded-mode
cgroup: ignore error in attaching process when threaded mode is used
2022-02-16 18:59:06 +00:00
Richard Neill ea583ed5a3 virt: Fix Xen Dom0 detection logic to no longer report as VM
Fixes regression introduced in 599be274c1

Moving the Xen check before the CPUID check, in order to handle the case where
a Xen domain is nested within a hypervisor which can be detected by via the
CPUID check, had an unintended consequence of causing Dom0 to report as a Xen
VM when it is not nested.

This patch stops further checks once it has been determined that Dom0 is not
nested within another hypervisor, meaning that the non-nested case matches its
previous logic (where it does not report as a VM).

Also, tidy the conditionals for the Xen and UML checks by removing handling of
a VIRTUALIZATION_VM_OTHER result, which has no code path.

Fixes #22511
2022-02-16 18:05:28 +01:00
Lennart Poettering 803e12f36b tree-wide: some coccinelle fixes 2022-02-16 17:26:26 +01:00