1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00
Commit Graph

56663 Commits

Author SHA1 Message Date
Lennart Poettering
40f55f6998 docs: document we use C11 with GNU extensions now
Follow-up for: #22711
2022-03-14 18:43:49 +00:00
Franck Bui
43c893e73e copy: fix wrong argument passed to S_ISREG() in copy_file_fd_full()
Follow-up for 2f78204498.
2022-03-14 16:46:54 +01:00
Lennart Poettering
0d67e2b584 random-util: drop left-over comment
We don't use non-blocking mode anymore, since 31234fbeec

Follow-up for: 31234fbeec
2022-03-14 16:46:54 +01:00
Yu Watanabe
d4782b51ec
Merge pull request #22721 from mrc0mmand/journalctl-tweaks
journal: convert --list-boots to a table
2022-03-14 10:59:13 +09:00
Frantisek Sumsal
a77d351e4d test: extend format-table tests with negative numbers 2022-03-13 21:03:08 +01:00
Yu Watanabe
c86efe34df man: replace full stop with colon
Fixes #22724.
2022-03-13 18:30:57 +00:00
Frantisek Sumsal
5a1355d848 journal: convert --list-boots to a table
so it can be output as JSON as well.

```
$ build-san/journalctl --list-boots --file boot-test.journal
IDX BOOT ID                          FIRST ENTRY                 LAST ENTRY
 -3 39d66eb1925f4d01b8464d502650a714 Sat 2022-03-05 15:20:33 CET Sat 2022-03-05 16:19:21 CET
 -2 5dffeb08a27344d5ae9e2fc244bbcbc5 Fri 2022-03-11 17:23:57 CET Fri 2022-03-11 17:38:31 CET
 -1 c8ebd52915b642c39eda4bf00f864f79 Fri 2022-03-11 17:38:41 CET Fri 2022-03-11 20:03:46 CET
  0 00bcba97c7094fa88cc5d1cf2a389057 Sat 2022-03-12 20:39:08 CET Sat 2022-03-12 20:40:18 CET

$ build-san/journalctl --list-boots --file boot-test.journal -q
-3 39d66eb1925f4d01b8464d502650a714 Sat 2022-03-05 15:20:33 CET Sat 2022-03-05 16:19:21 CET
-2 5dffeb08a27344d5ae9e2fc244bbcbc5 Fri 2022-03-11 17:23:57 CET Fri 2022-03-11 17:38:31 CET
-1 c8ebd52915b642c39eda4bf00f864f79 Fri 2022-03-11 17:38:41 CET Fri 2022-03-11 20:03:46 CET
 0 00bcba97c7094fa88cc5d1cf2a389057 Sat 2022-03-12 20:39:08 CET Sat 2022-03-12 20:40:18 CET

$ build-san/journalctl --list-boots --file boot-test.journal -o json-pretty
[
        {
                "index" : -3,
                "boot_id" : "39d66eb1925f4d01b8464d502650a714",
                "first_entry" : 1646490033438495,
                "last_entry" : 1646493561047353
        },
        {
                "index" : -2,
                "boot_id" : "5dffeb08a27344d5ae9e2fc244bbcbc5",
                "first_entry" : 1647015837289036,
                "last_entry" : 1647016711595489
        },
        {
                "index" : -1,
                "boot_id" : "c8ebd52915b642c39eda4bf00f864f79",
                "first_entry" : 1647016721056382,
                "last_entry" : 1647025426397414
        },
        {
                "index" : 0,
                "boot_id" : "00bcba97c7094fa88cc5d1cf2a389057",
                "first_entry" : 1647113948506002,
                "last_entry" : 1647114018943637
        }
]
```

Resolves: #14625
2022-03-13 19:25:21 +01:00
Frantisek Sumsal
e3dd9ea8ea macro: account for negative values in DECIMAL_STR_WIDTH()
With negative numbers we wouldn't account for the minus sign, thus
returning a string with one character too short, triggering buffer
overflows in certain situations.
2022-03-13 19:25:18 +01:00
Yu Watanabe
21547367cd doc: fix error code 2022-03-13 10:24:45 +00:00
Frantisek Sumsal
34c4dff4d2 time-util: support parsing OUTPUT_SHORT and OUTPUT_SHORT_PRECISE timestamps
so we can feed journalctl the localized syslog-style timestamps it shows
by default, e.g.:

```
$ LANG=cs_CZ.utf-8 build-san/journalctl -b --no-hostname | head -n1
led 30 22:13:54 systemd-journald[981]: System Journal (/var/log/journal/1588e1d9d0b74acdbaada907b163b837) is 4.1G, max 4.0G, 0B free.
$ LANG=cs_CZ.utf-8 build-san/journalctl --no-hostname --since 'led 30 22:13:54' -n1
led 30 22:13:54 systemd-journald[981]: System Journal (/var/log/journal/1588e1d9d0b74acdbaada907b163b837) is 4.1G, max 4.0G, 0B free.
$ LANG=cs_CZ.utf-8 build-san/journalctl --no-hostname --since 'led 30 22:13:54.9999' -n1
led 30 22:13:58 rsyslogd[1300]: imjournal: journal files changed, reloading...  [v8.2102.0-4.fc35 try https://www.rsyslog.com/e/0 ]
```

Resolves: #15899
2022-03-12 17:18:08 +00:00
Luca Boccassi
1627f158fc
Merge pull request #22463 from poettering/kernel-install-propagate-machine-id
kernel-install: clean-up machine-id handling
2022-03-12 17:17:28 +00:00
Yu Watanabe
27a5281f4b
Merge pull request #22711 from yuwata/c11
move to C11 (gnu11) and use u8 specifier for special characters
2022-03-12 14:27:48 +09:00
Luca Boccassi
9c9a6123d7
Merge pull request #22714 from mrc0mmand/codeql-docs
A couple of doc updates
2022-03-11 19:03:38 +00:00
Frantisek Sumsal
7fcded4055 resolve: update the referenced RFC & section for mDNS
Resolves: #20386
2022-03-11 16:55:55 +01:00
Frantisek Sumsal
42734a21eb test: document how to run CodeQL/LGTM stuff manually
Let's have this documented somewhere so I don't have to relearn all this
stuff every time I need it.
2022-03-11 16:51:53 +01:00
Luca Boccassi
1bd29614ff
Merge pull request #22631 from yuwata/network-redesign-request-queue
network: re-design request queue
2022-03-11 10:48:45 +00:00
Lennart Poettering
5e9c57d2e2 NEWS: add NEWS entry highlighting what the "entry-token" logic means for "gold image" builders 2022-03-11 11:39:34 +01:00
Lennart Poettering
f337f903df bootctl: update to new kernel-install semantics
This makes a bunch of closely related changes:

1. The "entry-token" concept already introduced in kernel-install is now
   made use of. i.e. specifically there's a new option --entry-token=
   that can be used to explicitly select by which ID to identify boot
   loader entries: the machine ID, or some OS ID (ID= or IMAGE_ID= from
   /etc/os-release, or even some completely different string. The
   selected string is then persisted to /etc/kernel/entry-token, so that
   kernel-install can find it there.

2. The --make-machine-id-directory= switch is renamed to
   --make-entry-directory= since after all it's not necessarily the
   machine ID the dir is named after, but can be any other string as
   selected by the entry token.

3. This drops all code to make automatic changes to /etc/machine-info.
   Specifically, the KERNEL_INSTALL_MACHINE_ID= field is now more
   generically implemented in /etc/kernel/entry-token described above,
   hence no need to place it at two locations. And the
   KERNEL_INSTALL_LAYOUT= field is not configurable by user switch or
   similar anyway in bootctl, but only read from
   /etc/kernel/install.conf, and hence copying it from one configuration
   file to another appears unnecessary, the second copy is fully
   redundant. Note that this just drops writing these fields, they'll
   still be honoured when already set.
2022-03-11 11:39:34 +01:00
Lennart Poettering
fe81e346c8 man: document recent changes
This drops documentation of KERNEL_INSTALL_MACHINE_ID as machine-info
field (though we'll still read it for compat).

This updates the kernel-install man page to always say "ENTRY-TOKEN"
instead of "MACHINE-ID" where appropriate, to clear the confusion up
between the two.

This also tries to fix how we denote env vars (always prefix with $ and
without = suffix), and other vars (without $ but with = suffix)

Other fixes.
2022-03-11 11:39:34 +01:00
Lennart Poettering
c73cf41844 kernel-install: add new "inspect" verb, showing paths and parameters we discovered 2022-03-11 11:39:34 +01:00
Lennart Poettering
6637cf9db6 kernel-install: search harder for kernel image/initrd drop-in dir
If not explicitly configured, let's search a bit harder for the
ENTRY_TOKEN, and let's try the machine ID, the IMAGE_ID and ID fields of
/etc/os-release and finally "Default", all below potential $XBOOTLDR.
2022-03-11 11:34:34 +01:00
Lennart Poettering
953b61004c kernel-install: only generate systemd.boot_id= in kernel command line if used for naming the boot loader spec files/dirs
Now that we can distinguish the naming of the boot loader spec
dirs/files and the machine ID let's tweak the logic for suffixing the
kernel cmdline with systemd.boot_id=: let's only do that when we
actually need the boot ID for naming these dirs/files. If we don't,
let's not bother.

This should be beneficial for "golden" images that shall not carry any
machine IDs at all, i.e acquire their identity only once the final
userspace is actually reached.
2022-03-11 11:34:34 +01:00
Lennart Poettering
3907044ffa kernel-install: add a new $ENTRY_TOKEN variable for naming boot entries
This cleans up naming of boot loader spec boot entries a bit (i.e. the
naming of the .conf snippet files, and the directory in $BOOT where the
kernel images and initrds are placed), and isolates it from the actual machine
ID concept.

Previously there was a sinlge concept for both things, because typically
the entries are just named after the machine ID. However one could also
use a different identifier, i.e. not a 128bit ID in which cases issues
pop up everywhere. For example, the "machine-id" field in the generated
snippets would not be a machine ID anymore, and the newly added
systemd.machine_id= kernel parameter would possibly get passed invalid
data.

Hence clean this up:

$MACHINE_ID → always a valid 128bit ID.

$ENTRY_TOKEN → usually the $MACHINE_ID but can be any other string too.
This is used to name the directory to put kernels/initrds in. It's also
used for naming the *.conf snippets that implement the Boot Loader Type
1 spec.
2022-03-11 11:34:34 +01:00
Lennart Poettering
11ce3ea2f2 kernel-install: don't try to persist used machine ID locally
This reworks the how machine ID used by the boot loader spec snippet
generation logic. Instead of persisting it automatically to /etc/ we'll
append it via systemd.machined_id= to the kernel command line, and thus
persist it in the generated boot loader spec snippets instead. This has
nice benefits:

  1. We do not collide with read-only root
  2. The machine ID remains stable across factory reset, so that we can
     safely recognize the path in $BOOT we drop our kernel images in
     again, i.e. kernel updates will work correctly and safely across
     kernel factory resets.
  3. Previously regular systems had different machine IDs while in
     initrd and after booting into the host system. With this change
     they will now have the same.

This then drops implicit persisting of KERNEL_INSTALL_MACHINE_ID, as its
unnecessary then. The field is still honoured though, for compat
reasons.

This also drops the "Default" fallback previously used, as it actually
is without effect, the randomized ID generation already took precedence
in all cases. This means $MACHNE_ID/KERNEL_INSTALL_MACHINE_ID are now
guaranteed to look like a proper machine ID, which is useful for us,
given you need it that way to be able to pass it to the
systemd.machine_id= kernel command line option.
2022-03-11 11:34:34 +01:00
Lennart Poettering
15e152acd1
Merge pull request #22618 from yuwata/network-safe-string
network: dhcp-server: refuse unsafe filename
2022-03-11 11:33:07 +01:00
Marcel Hellwig
37035235df fix signature of sd_journal_print_with_location in docs 2022-03-11 11:32:20 +01:00
Clyde Byrd III
1015da0930 gitignore: ignore mkosi.installdir 2022-03-11 09:34:04 +00:00
Yu Watanabe
6f4bffb586 lgtm: disable cpp/missing-return
As it does not handle assert_not_reahed() gracefully.
2022-03-11 17:19:32 +09:00
Yu Watanabe
5535484e17 qrcode-util: use u8 literal specifier 2022-03-11 15:59:58 +09:00
Yu Watanabe
e5ba040fb8 hostnamectl: use u8 literal specifier 2022-03-11 15:53:18 +09:00
Yu Watanabe
7fbbec71b1 glyph-util: use u8 literal specifier for special characters 2022-03-11 15:35:47 +09:00
Yu Watanabe
2b2dbcbbeb meson: move to c_std=gnu11
Recently, the kernel communitiy started to discuss to move C11 (gnu11) [1],
and it seems to come near future.
Let's also move to c_std=gnu11. Unlike the kernel, we already uses
gnu99, hence hopefully we can move to C11 without changing anything.

[1] https://lore.kernel.org/lkml/CAHk-=wiyCH7xeHcmiFJ-YgXUy2Jaj7pnkdKpcovt8fYbVFW3TA@mail.gmail.com/
2022-03-11 15:13:29 +09:00
Yu Watanabe
09d09207de network: re-design request queue
This makes Request object takes hash, compare, free, and process functions.

With this change, the logic in networkd-queue.c can be mostly
independent of the type of the request or the object (e.g. Address) assigned
to the request, and it becomes simpler.
2022-03-11 14:20:31 +09:00
Yu Watanabe
4c8b81caa5 network: increment reference counters of Link and Request before processing requests
To prevent the request or link is freed while processing requests.
2022-03-11 14:20:31 +09:00
Yu Watanabe
eb93dc9bde network: merge RequestType and SetLinkOperation
These two enum indicate how we process the request. Hence, it is not
necessary to introduce two separated indicators.
2022-03-11 14:20:31 +09:00
Yu Watanabe
a48ffe47cf network: refuse to configure link properties when in initialized state
The condition should be satisfied only when users request to reconfigure
the link, and in that case, all request will be cancelled. Hence, it is
not necessary to process the request.
2022-03-11 14:20:31 +09:00
Yu Watanabe
e519286407 network: drop unnecessary link_enter_failed()
As returning negative errno makes the link will enter the failed state.
2022-03-11 14:20:31 +09:00
Yu Watanabe
80d62d4f1a network: introduce request_call_netlink_async()
In most netlink handlers, we do the following,
1. decrease the message counter,
2. check the link state,
3. error handling,
4. update link state via e.g. link_check_ready().

The first two steps are mostly common, hence let's extract it.

Moreover, this is not only extracting the common logic, but provide a
strong advantage; `request_call_netlink_async()` assigns the relevant
Request object to the userdata of the netlink slot, and the request object
has full information about the message we sent. Hence, in the future,
netlink handler can print more detailed error message. E.g. when
an address is failed to configure, then currently we only show an
address is failed to configure, but with this commit, potentially we can
show which address is failed explicitly.

This does not change such error handling yet. But let's do that later.
2022-03-11 14:20:31 +09:00
Yu Watanabe
e26d3d407c network: make Request object take Manager*
Previously, even though all Request object are owned by Manager, they
do not have direct reference to Manager, but through Link or NetDev
object. But, as Link or NetDev can be NULL, we need to conditionalize
how to access Manager from Request with the type of the request.
This makes the way simpler, as now Request object has direct reference
to Manager.

This also rename request_drop() -> request_detach(), as in the previous
commit, the reference counter is introduced, so even if a reference of
a Request object from Manager is dropped, the object may still alive.
The naming `request_drop()` sounds the object will freed by the
function. But it may not. And `request_detach()` suggests the object
will not be managed by Manager any more, and I think it is more
appropreate.

This is just a cleanup, and should not change any behavior.
2022-03-11 14:20:31 +09:00
Yu Watanabe
e9ef9a1484 network: introduce reference counter for Request object
Currently, all Request object are always owned by Manager, and freed
when it is processed, especially, soon after a netlink message is sent.
So, it is not necessary to introduce the reference counter.

In a later commit, the Request object will _not_ be freed at the time
when a netlink message is sent, but assigned to the relevant netlink
slot as a userdata, and will be freed when a reply is received. So, the
owner of the Request object is changed in its lifetime. In that case, it
is convenient that the object has reference counter to avoid memleak or
double free.
2022-03-11 14:20:31 +09:00
Yu Watanabe
ff51134c93 network: make request_process_address() and friends take Link and corresponding object
This also renames e.g. request_process_address() -> address_process_request().

Also, this drops type checks such as `assert(req->type == REQUEST_TYPE_ADDRESS)`,
as in the later commits, the function of processing request, e.g.
`address_process_request()`, will be assigned to the Request object when
it is created. And the request type will be used to distinguish and to
avoid deduplicating requests which do not have any assigned objects,
like REQUEST_TYPE_DHCP4_CLIENT. Hence, the type checks in process functions
are mostly not necessary and redundant.

This is mostly cleanups and preparation for later commits, and should
not change any behavior.
2022-03-11 14:16:41 +09:00
Yu Watanabe
54ff39f7ae network: make address_configure() and friends take Request object
This should not change any behavior.
Just a preparation for a later commit which introduces
request_call_netlink_async().
2022-03-11 10:40:59 +09:00
Yu Watanabe
f1eef3675c network: tc: assign netlink handlers into Request object
This should not change any behavior, as req->netlink_handler is always
qdisc_handler or tclass_handler.

This is just a preparation for a later commit which introduces
request_call_netlink_async().
2022-03-11 10:39:05 +09:00
Yu Watanabe
5b25bdd1a3 alloc-util: introduce mfree_func_type_t 2022-03-11 10:24:08 +09:00
Yu Watanabe
6278e42878 network: dhcp: rename NextServer= and Filename= settings
And make the settings configures DHCP option 66 and 67.

Follow-ups for #22615.
Fixes #22661.
2022-03-11 10:14:57 +09:00
Luca Boccassi
0d3c36641d
Merge pull request #22701 from poettering/raise-memlock
pid1/nspawn: raise RLIMIT_MEMLOCK to 8M matching kernel 5.16's new default
2022-03-11 01:09:33 +00:00
Clyde Byrd III
f4ca32a1bc core/dbus-job: Use new way of specifying sd-bus vtable parameter names 2022-03-11 09:00:18 +09:00
Lennart Poettering
0da2bb7414 hostname-util: normalize get_pretty_hostname() call semantics
get_pretty_hostname() so far had semantics not in line with our usual
ones: the return parameter was actually freed before the return string
written into it, because that's what parse_env_file() does. Moreover,
when the value was not set it would return NULL but succeed.

Let's normalize this, and only fill in the return value if there's
something set, and never read from it, like we usually do with return
parameter, and in particular those named "ret_xyz".

The existing callers don't really care about the differences, but it's
nicer to normalize behaviour to minimize surprises.
2022-03-10 23:05:44 +00:00
Luca Boccassi
bed1f67874
Merge pull request #22705 from mrc0mmand/pretty_hostname_specifier
core: introduce %R specifier for pretty hostname
2022-03-10 21:45:34 +00:00
Frantisek Sumsal
217d4a1164 cgls: mangle user-provided unit names
so the CLI interface is now similar to `systemctl`, i.e. if no unit name
suffix is provided, assume `.service`.

Fixes: #20492

Before:
```
$ systemd-cgls --unit user@1000
Failed to query unit control group path: Invalid argument
Failed to list cgroup tree: Invalid argument
```

After:
```
$ build/systemd-cgls --unit user@1000
Unit user@1000.service (/user.slice/user-1000.slice/user@1000.service):
├─session.slice (#4939)
│ ├─pipewire-pulse.service (#5203)
│ │ └─7711 /usr/bin/pipewire-pulse
...
```
2022-03-10 20:47:30 +00:00