]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
2 years agotest: add coverage for #26483 26527/head
Frantisek Sumsal [Tue, 21 Feb 2023 18:30:58 +0000 (19:30 +0100)] 
test: add coverage for #26483

2 years agotest: add coverage for #26467
Frantisek Sumsal [Tue, 21 Feb 2023 18:15:13 +0000 (19:15 +0100)] 
test: add coverage for #26467

2 years agoinstall: fail early if specifier expansion failed
David Tardon [Tue, 21 Feb 2023 13:10:33 +0000 (14:10 +0100)] 
install: fail early if specifier expansion failed

Before:

systemd[1]: Assertion 'path' failed at src/shared/install.c:288, function install_changes_add(). Aborting.
systemd[1]: Caught <ABRT> from our own process.
systemd[1]: Caught <ABRT>, dumped core as pid 2525.
systemd[1]: Freezing execution

After:

Failed to enable unit: Invalid specifier in user-%J.service

Fixes #26467.

Follow-up for: f5a0162

2 years agoMerge pull request #26518 from DaanDeMeyer/mkosi-stuff
Daan De Meyer [Tue, 21 Feb 2023 17:23:06 +0000 (18:23 +0100)] 
Merge pull request #26518 from DaanDeMeyer/mkosi-stuff

mkosi: Drop build script workarounds

2 years agobootctl: add new --print-root-device option
Lennart Poettering [Mon, 20 Feb 2023 16:25:14 +0000 (17:25 +0100)] 
bootctl: add new --print-root-device option

We already have this nice code in system that determines the block
device backing the root file system, but it's only used internally in
systemd-gpt-generator. Let's make this more accessible and expose it
directly in bootctl.

It doesn't fit immediately into the topic of bootctl, but I think it's
close enough and behaves very similar to the existing "bootctl
--print-boot-path" and "--print-esp-path" tools.

If --print-root-device (or -R) is specified once, will show the block device
backing the root fs, and if specified twice (probably easier: -RR) it
will show the whole block device that block device belongs to in case it
is a partition block device.

Suggested use:

        # cfdisk `bootctl -RR`

To get access to the partition table, behind the OS install, for
whatever it might be.

2 years agoMerge pull request #26265 from poettering/journal-refresh-fixes
Lennart Poettering [Tue, 21 Feb 2023 17:19:12 +0000 (18:19 +0100)] 
Merge pull request #26265 from poettering/journal-refresh-fixes

journal: journal file header IDs refresh fixes and corrections

2 years agomkosi: Reduce postinst script indentation 26518/head
Daan De Meyer [Tue, 21 Feb 2023 14:23:15 +0000 (15:23 +0100)] 
mkosi: Reduce postinst script indentation

2 years agomkosi: Simplify BUILDDIR/SRCDIR handling a bit
Daan De Meyer [Tue, 21 Feb 2023 14:19:06 +0000 (15:19 +0100)] 
mkosi: Simplify BUILDDIR/SRCDIR handling a bit

2 years agomkosi: Move more logic to the postinst script
Daan De Meyer [Tue, 21 Feb 2023 14:09:38 +0000 (15:09 +0100)] 
mkosi: Move more logic to the postinst script

Let's move stuff that only applies to the final image to the
postinst script. Let's also move out some of the static files to
mkosi.extra/ instead of hardcoding them in scripts.

2 years agomkosi: Remove preset workaround
Daan De Meyer [Tue, 21 Feb 2023 13:57:29 +0000 (14:57 +0100)] 
mkosi: Remove preset workaround

A "disable *" preset is already shipped on debian so no need to add
one ourselves.

2 years agomkosi: Add more debugging
Daan De Meyer [Thu, 16 Feb 2023 09:23:01 +0000 (10:23 +0100)] 
mkosi: Add more debugging

2 years agomkosi: Use 4 space indentation for scripts
Daan De Meyer [Tue, 21 Feb 2023 13:22:52 +0000 (14:22 +0100)] 
mkosi: Use 4 space indentation for scripts

mkosi scripts are shell scripts and for shell scripts we use 4 space
indentation.

2 years agohomectl: add missing break
Lennart Poettering [Fri, 17 Feb 2023 21:24:10 +0000 (22:24 +0100)] 
homectl: add missing break

2 years agomkosi: Drop opensuse workaround
Daan De Meyer [Tue, 21 Feb 2023 12:03:36 +0000 (13:03 +0100)] 
mkosi: Drop opensuse workaround

2 years agomkosi: Drop bootctl workaround in postinst script
Daan De Meyer [Tue, 21 Feb 2023 12:11:37 +0000 (13:11 +0100)] 
mkosi: Drop bootctl workaround in postinst script

2 years agomkosi: Drop locale workaround
Daan De Meyer [Tue, 21 Feb 2023 11:51:28 +0000 (12:51 +0100)] 
mkosi: Drop locale workaround

mkosi will always run all commands with the C.UTF-8 locale so we
don't need a workaround in the build script anymore.

2 years agomkosi: Drop ld workaround
Daan De Meyer [Tue, 21 Feb 2023 11:25:43 +0000 (12:25 +0100)] 
mkosi: Drop ld workaround

Build scripts will always run in an environment with /etc/ available
now, so we don't need this workaround anymore.

2 years agomkosi: Update to latest
Daan De Meyer [Tue, 21 Feb 2023 12:01:22 +0000 (13:01 +0100)] 
mkosi: Update to latest

2 years agocore/manager: falling back to execute generators without sandboxing
Yu Watanabe [Sat, 18 Feb 2023 17:42:52 +0000 (02:42 +0900)] 
core/manager: falling back to execute generators without sandboxing

When running in a container, like podman, docker or so, creating new mount
namespace may be disabled.

Fixes #26474.
Fixes RHBZ#2165004 (https://bugzilla.redhat.com/show_bug.cgi?id=2165004).

2 years agodocs: document the new HEADER_COMPATIBLE_TAIL_ENTRY_BOOT_ID flag 26265/head
Lennart Poettering [Tue, 31 Jan 2023 15:09:58 +0000 (16:09 +0100)] 
docs: document the new HEADER_COMPATIBLE_TAIL_ENTRY_BOOT_ID flag

2 years agojournal-file: drop checking if files are from the future at time of open
Lennart Poettering [Thu, 26 Jan 2023 16:24:15 +0000 (17:24 +0100)] 
journal-file: drop checking if files are from the future at time of open

We nowadays check for ordering anyway at time of writing entries, hence
we don't have to do that at moment of opening, too.

Benefit of dropping this check: we can safely archive files from the
future instead of marking them as broken.

2 years agojournal-file: allow opening journal files for write when machine ID is not initialized
Lennart Poettering [Wed, 1 Feb 2023 11:23:54 +0000 (12:23 +0100)] 
journal-file: allow opening journal files for write when machine ID is not initialized

We allow reading them, and we allow creating them, but we so far did not
allow opening existing ones for write – if the machine ID is not
initialized.

Let's fix that.

(This is just to fix an asymmetry. I have no immediate use for this. But
test code should in theory be able to use this, if it runs in an
incompletely initialized environment.)

2 years agojournal-file: lazily fill in machine ID into journal header, if needed
Lennart Poettering [Tue, 31 Jan 2023 12:37:12 +0000 (13:37 +0100)] 
journal-file: lazily fill in machine ID into journal header, if needed

Previously, if we ran in an environment where /etc/machine-id was
not defined, we'd never bother to write it ever again. So it would stay
at all zeroes till the end of times.

Let's make this more robust: whenever we try to append an entry, let's
try to refresh it from the status quo if not initialized yet. Moreover,
when copying records from a different journal file, let's propagate the
machine ID from there.

This should make things more robust and systematic, and match how we
propagate the boot ID and the seqnum ID to some level.

2 years agojournal-file: write machine ID when create the file, not when we open it for writing
Lennart Poettering [Thu, 26 Jan 2023 16:12:25 +0000 (17:12 +0100)] 
journal-file: write machine ID when create the file, not when we open it for writing

This doesn't actually change much, but makes the code less surprising.

Status quo ante:

1. Open a journal file
2. If newly created set header machine ID to zero
3. If existing and open for write check if machine ID in header matches
   local one, if not, refuse.
4. if open for writing, now refresh the machine ID from the local system

Of course, step 4 is pretty much pointless for existing files, as the
check in 3 made sure it is already in order or we'd refuse operating on
it anyway. With this patch this is simplified to:

1. Open a journal file
2. If newly created initialized machine ID to local machine ID
3. If existing, compare machine ID in header with local one, if not
   matching refuse.

Outcome is the same.

2 years agojournal-file: don't update boot_id in journal header on open
Lennart Poettering [Thu, 26 Jan 2023 15:49:36 +0000 (16:49 +0100)] 
journal-file: don't update boot_id in journal header on open

The header of the journal file contains a boot ID field that is
currently updated whenever we open the journal file. This is not ideal:
pretty often we want to archive a journal file, and need to open it for
that. Archiving a foreign journal file should not mark it as ours, it
should just change the status flag in the file header.

The boot ID in the header is aleady rewritten whenever we write a
journal entry to the file anyway, hence all this patch effectively does
is slightly "delay" when the boot ID in the header is updated: instead
of immediately on open it is updated on the first entry that is written.

Net effect: archived journal files don't all look like they were written
to on a boot newer then they actually were

And more importantly: the "tail_entry_monotonic" field suddenly becomes
useful, since we know which boot it belongs to. Generally, monotonic
timestamps without boot ID information are useless, and this fixes it.

A new (compatible) header flag marks file where the boot_id can be
understood this way. This can be used by code that wants to make use of
the "tail_entry_monotonic" field to ensure it actually can do so safely.

This also renames the structure definition in journal-def accordingly,
to indicate we now follow the stricter semantics for it.

2 years agoupdate TODO
Lennart Poettering [Tue, 21 Feb 2023 08:49:30 +0000 (09:49 +0100)] 
update TODO

2 years agoman: add DefaultStartupMemoryLow= as term in term list
Steve Ramage [Mon, 20 Feb 2023 21:49:29 +0000 (13:49 -0800)] 
man: add DefaultStartupMemoryLow= as term in term list

2 years agomeson: adjust whitespace handling in jinja2 rendering
Zbigniew Jędrzejewski-Szmek [Mon, 20 Feb 2023 14:07:44 +0000 (15:07 +0100)] 
meson: adjust whitespace handling in jinja2 rendering

In 6abe882bae1bb12827ef395c60f21ab8bb1bc61b the renderer was made to
unconditionally append a newline to output. This works, but is ugly. A nicer
solution is to tell jinja2 to not strip the newline in the first place, via
keep_trailing_newline=True. It seems that the result is unchanged because all
our source files have exactly one trailing newline.

Also, enable lstrip_blocks=True. This would cause whitespace on the line before
an {%if block to be automatically stripped. It seems reasonable to enable that
if trim_blocks=True.

Overall, no change is expected, though I didn't test combinations of
configurations, so there might be a change in some cases. But now the rules of
rendering are more logical, e.g. we should be able to indent nested conditional
statements without getting unexpected whitespace in the output.

2 years agoMerge pull request #26506 from keszybz/tiny-cleanups
Yu Watanabe [Mon, 20 Feb 2023 21:41:01 +0000 (06:41 +0900)] 
Merge pull request #26506 from keszybz/tiny-cleanups

Various trivial cleanups and follow-ups

2 years agoMerge pull request #26499 from mrc0mmand/assorted-tweaks
Yu Watanabe [Mon, 20 Feb 2023 20:55:37 +0000 (05:55 +0900)] 
Merge pull request #26499 from mrc0mmand/assorted-tweaks

A couple of test tweaks for recent CI fails

2 years agoukify: Set fast_load option when parsing PE files
Daan De Meyer [Mon, 20 Feb 2023 13:45:19 +0000 (14:45 +0100)] 
ukify: Set fast_load option when parsing PE files

Let's skip parsing of some irrelevant information that we don't use
to speed up building UKIs with large initrds from +-15s to less than
1s.

2 years agoMerge pull request #26508 from poettering/cap-fixes
Lennart Poettering [Mon, 20 Feb 2023 18:04:13 +0000 (19:04 +0100)] 
Merge pull request #26508 from poettering/cap-fixes

various fixes to capability handling

2 years agocapability-util: use UINT32_MAX as shortcut where appropriatea 26508/head
Lennart Poettering [Mon, 20 Feb 2023 15:26:46 +0000 (16:26 +0100)] 
capability-util: use UINT32_MAX as shortcut where appropriatea

2 years agocapability-util: add macro for largest cap we're willing to accept
Lennart Poettering [Mon, 20 Feb 2023 15:21:25 +0000 (16:21 +0100)] 
capability-util: add macro for largest cap we're willing to accept

Let's hide the hard to grasp 62 behind a name.

2 years agocapability-util: add CAP_MASK_ALL + CAP_MASK_UNSET macros
Lennart Poettering [Mon, 20 Feb 2023 11:53:26 +0000 (12:53 +0100)] 
capability-util: add CAP_MASK_ALL + CAP_MASK_UNSET macros

We should be more careful with distinguishing the cases "all bits set in
caps mask" from "cap mask invalid". We so far mostly used UINT64_MAX for
both, which is not correct though (as it would mean
AmbientCapabilities=~0 followed by AmbientCapabilities=0) would result
in capability 63 to be set (which we don't really allow, since that
means unset).

2 years agocap-list: make sure never to accidentally return more than 63 caps
Lennart Poettering [Mon, 20 Feb 2023 10:30:56 +0000 (11:30 +0100)] 
cap-list: make sure never to accidentally return more than 63 caps

The rest of our codebase stores caps masks in a uint64_t, and also
assumes UINT64_MAX was a suitable value for "unset mask". Hence refuse
any caps outside of 0…62.

(right now the kernel knows 40 caps, hence 22 more to go before we have
to reconsider our life's choices.)

2 years agocap-list: rework capability_set_to_string()
Lennart Poettering [Mon, 20 Feb 2023 10:45:07 +0000 (11:45 +0100)] 
cap-list: rework capability_set_to_string()

Let's use strextend_with_separator() and CAPABILITY_TO_STRING().

2 years agocap-list: add CAPABILITY_TO_STRING() macro using compound initialization to allocate...
Lennart Poettering [Mon, 20 Feb 2023 10:43:13 +0000 (11:43 +0100)] 
cap-list: add CAPABILITY_TO_STRING() macro using compound initialization to allocate fallback buffer

Let's add a helper that can return a numeric string in case we don't
recognize a name for a capability.

2 years agocap-list: refuse parsing numeric capability 63
Lennart Poettering [Mon, 20 Feb 2023 11:26:46 +0000 (12:26 +0100)] 
cap-list: refuse parsing numeric capability 63

We refuse it otherwise currently, simply because we cannot store it in a
uint64_t caps mask value anymore while retaining the ability to use
UINT64_MAX as "unset" marker.

The check actually was in place already, just one off.

2 years agocap-list: modernize capability_set_from_string() a bit
Lennart Poettering [Mon, 20 Feb 2023 11:25:44 +0000 (12:25 +0100)] 
cap-list: modernize capability_set_from_string() a bit

Make return parameter optional. And return whether there were any caps
we didn't recognize via 0/1 return value.

2 years agocap-list: rename capability_set_to_string_alloc() → capability_set_to_string()
Lennart Poettering [Mon, 20 Feb 2023 10:33:48 +0000 (11:33 +0100)] 
cap-list: rename capability_set_to_string_alloc() → capability_set_to_string()

We typically don't use the _alloc() suffix anymore for anything, hence
drop it here too.

2 years agoMerge pull request #26437 from DaanDeMeyer/repart-exclude
Daan De Meyer [Mon, 20 Feb 2023 14:49:29 +0000 (15:49 +0100)] 
Merge pull request #26437 from DaanDeMeyer/repart-exclude

repart: Add ExcludeFiles= option

2 years agoTODO: add entry for time-based glob cleanup 26506/head
Zbigniew Jędrzejewski-Szmek [Mon, 20 Feb 2023 14:25:39 +0000 (15:25 +0100)] 
TODO: add entry for time-based glob cleanup

2 years agoman/tmpfiles.d: adjust the table in synopsis, improve spelling
Zbigniew Jędrzejewski-Szmek [Mon, 20 Feb 2023 14:21:54 +0000 (15:21 +0100)] 
man/tmpfiles.d: adjust the table in synopsis, improve spelling

r and R take globs, so let's name the argument appropriately in the tl;dr listing.

Also, use 'clean-up' in the file name where it represents the verb "clean up",
and other minor spelling adjustments.

2 years agoshared/hwdb-util: drop "variable" with a single use
Zbigniew Jędrzejewski-Szmek [Mon, 20 Feb 2023 13:19:41 +0000 (14:19 +0100)] 
shared/hwdb-util: drop "variable" with a single use

In 6a34639e76b8b59233a97533b13836d5a44e8d4a arg_hwdb_bin_dir was replaced by
default_hwdb_bin_dir, which is constant. Generally we'd use a #define instead,
but since there's just one use, let's just avoid the indirection altogether.

2 years agoman: document DefaultStartupMemoryLow=
Luca Boccassi [Mon, 20 Feb 2023 12:52:33 +0000 (12:52 +0000)] 
man: document DefaultStartupMemoryLow=

Fixes https://github.com/systemd/systemd/issues/26493

2 years agoMerge pull request #26465 from DaanDeMeyer/openat-helpers
Daan De Meyer [Mon, 20 Feb 2023 12:58:59 +0000 (13:58 +0100)] 
Merge pull request #26465 from DaanDeMeyer/openat-helpers

Add more openat() helpers of utility functions

2 years agorepart: Add ExcludeFiles= option 26437/head
Daan De Meyer [Thu, 16 Feb 2023 12:23:47 +0000 (13:23 +0100)] 
repart: Add ExcludeFiles= option

2 years agoefi/measure: adjust formatting
Zbigniew Jędrzejewski-Szmek [Wed, 8 Feb 2023 14:42:49 +0000 (15:42 +0100)] 
efi/measure: adjust formatting

2 years agomeasure: wrap long lines and avoid one cast
Zbigniew Jędrzejewski-Szmek [Wed, 8 Feb 2023 12:43:59 +0000 (13:43 +0100)] 
measure: wrap long lines and avoid one cast

2 years agosleep: use shared constant for freeze timeout
Zbigniew Jędrzejewski-Szmek [Thu, 2 Feb 2023 12:01:24 +0000 (13:01 +0100)] 
sleep: use shared constant for freeze timeout

Let's keep all the timeout definitions in one place.

2 years agosmack-util: Add renameat_and_apply_smack_floor_label() 26465/head
Daan De Meyer [Thu, 22 Dec 2022 13:28:27 +0000 (14:28 +0100)] 
smack-util: Add renameat_and_apply_smack_floor_label()

Also add mac_smack_apply_at() as its a requirement for
renameat_and_apply_smack_floor_label().

2 years agotmpfile-util-label: Add fopen_temporary_at_label()
Daan De Meyer [Thu, 22 Dec 2022 13:27:57 +0000 (14:27 +0100)] 
tmpfile-util-label: Add fopen_temporary_at_label()

2 years agocopy: Add copy_file_at()
Daan De Meyer [Thu, 22 Dec 2022 13:27:26 +0000 (14:27 +0100)] 
copy: Add copy_file_at()

2 years agoenv-file: Add write_env_file_at()
Daan De Meyer [Thu, 22 Dec 2022 13:26:29 +0000 (14:26 +0100)] 
env-file: Add write_env_file_at()

2 years agoudev-node: make stack_directory_read_one() accept NULL for devnode
Yu Watanabe [Mon, 20 Feb 2023 05:43:58 +0000 (14:43 +0900)] 
udev-node: make stack_directory_read_one() accept NULL for devnode

No functional change, as currently the function is always called with
non-NULL argument. Just a preparation for #26048 or #25839.

2 years agoMerge pull request #26479 from yuwata/exec-util-misc
Lennart Poettering [Mon, 20 Feb 2023 10:17:58 +0000 (11:17 +0100)] 
Merge pull request #26479 from yuwata/exec-util-misc

exec-util: several cleanups

2 years agoudev-node: drop unnecessary initialization
Yu Watanabe [Sat, 18 Feb 2023 22:15:02 +0000 (07:15 +0900)] 
udev-node: drop unnecessary initialization

The priority of device node symlink can be negative. So the
initialization is confusing.

Fortunately, this changes no functionality, as we only compare the
priorities of symlinks only when we parsed at least one device node and
its priority.

2 years agotest: ignore missing coverage in TEST-78 26499/head
Frantisek Sumsal [Mon, 20 Feb 2023 09:50:06 +0000 (10:50 +0100)] 
test: ignore missing coverage in TEST-78

gcov is incompatible with DynamicUser=true without additional tweaks, so
let's ignore its complaints in this test, as working around it is not
worth it (in this case).

2 years agotest: disable pipefail when testing interactive firstboot
Frantisek Sumsal [Wed, 1 Feb 2023 12:54:21 +0000 (13:54 +0100)] 
test: disable pipefail when testing interactive firstboot

Otherwise we might get unexpected test fails due to SIGPIPE:

```
[   14.334917] testsuite-74.sh[565]: + grep -q '^root:.*:0:0:.*:/bin/fooshell$' test-root/etc/passwd
[   14.335670] testsuite-74.sh[681]: + systemd-firstboot --root=test-root --prompt-root-shell
[   14.336382] testsuite-74.sh[680]: + echo -ne '\n/bin/barshell\n'
[   14.336980] testsuite-74.sh[680]: .//usr/lib/systemd/tests/testdata/units/testsuite-74.firstboot.sh: line 166: echo: write error: Broken pipe
```

2 years agocore: permit sending augmented enable/disable methods
Ronan Pigott [Sat, 18 Feb 2023 23:50:22 +0000 (16:50 -0700)] 
core: permit sending augmented enable/disable methods

systemctl disable some.service fails to acquire interactive permission
because the DisableUnitFilesWithFlagsAndInstallInto method isn't permitted

2 years agoexec-util: use TAKE_FD() 26479/head
Yu Watanabe [Sat, 18 Feb 2023 17:09:22 +0000 (02:09 +0900)] 
exec-util: use TAKE_FD()

2 years agoexec-util: propagate error in wait_for_terminate_and_check()
Yu Watanabe [Sat, 18 Feb 2023 16:55:28 +0000 (01:55 +0900)] 
exec-util: propagate error in wait_for_terminate_and_check()

Then, the two error handlings becomes consistent with the one in
execute_directories().

2 years agoprocess-util: show requested process name in the log
Yu Watanabe [Sat, 18 Feb 2023 16:26:39 +0000 (01:26 +0900)] 
process-util: show requested process name in the log

This is useful for debugging issues like #26474.

2 years agosystemctl: edit: fix double free of instanced name
Ronan Pigott [Sat, 18 Feb 2023 20:03:07 +0000 (13:03 -0700)] 
systemctl: edit: fix double free of instanced name

There is a double free of unit_name when an instance is used, causing
systemctl --user edit service@instance to abort.

2 years agojournalctl: fix output when --lines is used with --grep
Mike Yuan [Sat, 18 Feb 2023 13:49:21 +0000 (21:49 +0800)] 
journalctl: fix output when --lines is used with --grep

Previously, we skip the entries before arg_lines
unconditionally, which doesn't behave correctly
when used with --grep. After this commit, when
a pattern is specified, we don't skip the entries
early, but rely on the count of the lines shown
to tell us when to stop. To achieve that we would
have to search backwards instead.

Fixes #25147

2 years agoloop-util: fix error condition and return value
Yu Watanabe [Sat, 18 Feb 2023 06:35:41 +0000 (15:35 +0900)] 
loop-util: fix error condition and return value

Fixes a bug introduced by da4fd28871227d23d4719e30da03af5a71f47e5a.

2 years agoshared: move psi-util.[ch] to basic/ so that we can use it in sd-event
Lennart Poettering [Tue, 14 Feb 2023 15:10:21 +0000 (16:10 +0100)] 
shared: move psi-util.[ch] to basic/ so that we can use it in sd-event

2 years agoutil: move mallinfo compat glue from selinux code into generic code
Lennart Poettering [Fri, 10 Feb 2023 15:55:06 +0000 (16:55 +0100)] 
util: move mallinfo compat glue from selinux code into generic code

2 years agohashmap: fix build with valgrind
Yu Watanabe [Fri, 17 Feb 2023 21:56:02 +0000 (06:56 +0900)] 
hashmap: fix build with valgrind

Follow-up for a2b052b29f8bc141e94a4af95d1653a38a57eaeb.

2 years agoCorrect journal misspell
Winterhuman [Fri, 17 Feb 2023 21:19:51 +0000 (21:19 +0000)] 
Correct journal misspell

2 years agoMerge pull request #26443 from poettering/mempool-fixes
Lennart Poettering [Fri, 17 Feb 2023 16:15:35 +0000 (17:15 +0100)] 
Merge pull request #26443 from poettering/mempool-fixes

mempool tweaks

2 years agotests: add test for mempool logic 26443/head
Lennart Poettering [Tue, 14 Feb 2023 12:49:17 +0000 (13:49 +0100)] 
tests: add test for mempool logic

2 years agomempool: rework mempool_cleanup() to only release freed tiles
Lennart Poettering [Tue, 14 Feb 2023 12:44:51 +0000 (13:44 +0100)] 
mempool: rework mempool_cleanup() to only release freed tiles

This substantially reworks mempool_cleanup() so that it releases pools
with all freed tiles only, but keeps all pools with still-allocated
tiles around.

This is more correct, as the previous implementation just released all
pools regardless if anything was still used or not. This would make
valgrind shut up but would just hide memory leaks altogether. Moreover
if called during regular runtime of a program would result in bad memory
accesses all over.

Hence, let's add a proper implementation and only trim pools we really
know are empty.

This way we can safely call these functions later, when under memory
pressure, at any time.

2 years agomempool: make mempool_free_tile() return NULL
Lennart Poettering [Tue, 14 Feb 2023 12:42:03 +0000 (13:42 +0100)] 
mempool: make mempool_free_tile() return NULL

To match how we usually do this current allocation code.

(Also, make it accept a NULL pointer, also in order to match behaviour
in the rest of our codebase)

2 years agomempool: introduce new helper pool_ptr()
Lennart Poettering [Tue, 14 Feb 2023 12:40:40 +0000 (13:40 +0100)] 
mempool: introduce new helper pool_ptr()

This new helper returns the beginning of the usable area of the pool
object.

For now this is only used once, a later commit will use it more.

2 years agotpm2: simplify tpm2_seal() blob creation
Dan Streetman [Mon, 19 Dec 2022 14:58:05 +0000 (09:58 -0500)] 
tpm2: simplify tpm2_seal() blob creation

TPM2 marshalling will never increase the total size, only possibly decrease.
There is no need for checking for insufficient size if the buffer size
is set to the sizeof both objects to be marshalled.

2 years agomempool: rename local variable to match current coding style
Lennart Poettering [Tue, 14 Feb 2023 12:38:18 +0000 (13:38 +0100)] 
mempool: rename local variable to match current coding style

2 years agomempool: use size_t for all memory object sizes and counts
Lennart Poettering [Tue, 14 Feb 2023 12:37:20 +0000 (13:37 +0100)] 
mempool: use size_t for all memory object sizes and counts

2 years agohashmap: expose helper for releasing memory pools independently of valgrind
Lennart Poettering [Wed, 8 Feb 2023 17:03:27 +0000 (18:03 +0100)] 
hashmap: expose helper for releasing memory pools independently of valgrind

Let's clean this up and export this always, so that we can later call
when we are under memory pressure.

2 years agodissect-image: Return mount point fd if requested
Daan De Meyer [Thu, 22 Dec 2022 12:00:31 +0000 (13:00 +0100)] 
dissect-image: Return mount point fd if requested

2 years agoprocess-util: add helper get_process_threads()
Lennart Poettering [Wed, 8 Feb 2023 17:01:26 +0000 (18:01 +0100)] 
process-util: add helper get_process_threads()

Let's add a proper helper for querying the number of threads in a
process.

2 years agoMerge pull request #26463 from DaanDeMeyer/hacking
Luca Boccassi [Fri, 17 Feb 2023 11:58:13 +0000 (11:58 +0000)] 
Merge pull request #26463 from DaanDeMeyer/hacking

Hacking

2 years agosync-util: port fsync_directory_of_file() to fd_is_opath()
Lennart Poettering [Fri, 17 Feb 2023 09:32:18 +0000 (10:32 +0100)] 
sync-util: port fsync_directory_of_file() to fd_is_opath()

As suggested here:

https://github.com/systemd/systemd/pull/26450#pullrequestreview-1302922404

2 years agoMerge pull request #26438 from poettering/event-source-shorten
Lennart Poettering [Fri, 17 Feb 2023 11:46:55 +0000 (12:46 +0100)] 
Merge pull request #26438 from poettering/event-source-shorten

sd-event: reduce memory use of sd_event_source objects

2 years agoMerge pull request #26341 from DaanDeMeyer/chase-fixes
Luca Boccassi [Fri, 17 Feb 2023 11:44:47 +0000 (11:44 +0000)] 
Merge pull request #26341 from DaanDeMeyer/chase-fixes

chase-symlinks fixes

2 years agoMerge pull request #26447 from poettering/sigqueue
Lennart Poettering [Fri, 17 Feb 2023 09:51:58 +0000 (10:51 +0100)] 
Merge pull request #26447 from poettering/sigqueue

pid1/systemctl: add ability to enqueue POSIX RT sigs with associated value to service processes

2 years agosocket-util: make connect_unix_path() work with a NULL path
Lennart Poettering [Fri, 10 Feb 2023 15:43:58 +0000 (16:43 +0100)] 
socket-util: make connect_unix_path() work with a NULL path

2 years agoMerge pull request #26343 from DaanDeMeyer/bus-debug
Lennart Poettering [Fri, 17 Feb 2023 09:50:19 +0000 (10:50 +0100)] 
Merge pull request #26343 from DaanDeMeyer/bus-debug

Bus debug

2 years agoMerge pull request #26450 from yuwata/fd-is-opath
Lennart Poettering [Fri, 17 Feb 2023 09:28:32 +0000 (10:28 +0100)] 
Merge pull request #26450 from yuwata/fd-is-opath

util: introduce fd_is_opath() and use it in xsetxattr()

2 years agosd-event: allocate event source objects with the actually needed size 26438/head
Lennart Poettering [Fri, 10 Feb 2023 16:56:48 +0000 (17:56 +0100)] 
sd-event: allocate event source objects with the actually needed size

Currently we allocate fixed-size memory for event sources: the largest
any of the event source type needs. Discrepancy in the sizes needed for
the various event sources is quite major however: it's 144 bytes on
x86_64, i.e. more than two cache lines.

hence, let's be a tiny bit more careful, and allocate exactly as much as
we need, but not more.

2 years agomacro: add macro for determining size of struct with trailing union
Lennart Poettering [Fri, 10 Feb 2023 16:56:30 +0000 (17:56 +0100)] 
macro: add macro for determining size of struct with trailing union

2 years agotest: add test for new "systemctl --kill-value=" functionality 26447/head
Lennart Poettering [Thu, 16 Feb 2023 15:31:02 +0000 (16:31 +0100)] 
test: add test for new "systemctl --kill-value=" functionality

(as side-effect this also tests the new systemd-notify --exec switch)

2 years agoman: document new --exec switch for systemd-notify
Lennart Poettering [Thu, 16 Feb 2023 15:30:09 +0000 (16:30 +0100)] 
man: document new --exec switch for systemd-notify

2 years agonotify: add new --exec switch for chaining other commands to systemd-notify
Lennart Poettering [Thu, 16 Feb 2023 14:42:49 +0000 (15:42 +0100)] 
notify: add new --exec switch for chaining other commands to systemd-notify

This is useful in tests, so that we can first send a READY message and
then continue doing something else without changing PID.

2 years agostrv: add strv_copy_n() helper for copying part of a n strv
Lennart Poettering [Thu, 16 Feb 2023 14:41:55 +0000 (15:41 +0100)] 
strv: add strv_copy_n() helper for copying part of a n strv

2 years agoman: document new --kill-value= switch to systemctl
Lennart Poettering [Thu, 16 Feb 2023 15:20:48 +0000 (16:20 +0100)] 
man: document new --kill-value= switch to systemctl

2 years agosystemctl: add --kill-value= argument to systemctl
Lennart Poettering [Wed, 15 Feb 2023 09:51:33 +0000 (10:51 +0100)] 
systemctl: add --kill-value= argument to systemctl

This allows accompanying a signal with a value (as supported for Linux
Realtime signals). This is particularly useful as it allows us to do
stuff like this:

   systemctl kill --kill-whom=main --kill-value=0x300 systemd-journald

In order to ask journald to flush its allocation caches and compact
memory.

2 years agopid1: add a new D-Bus method for enquing POSIX signals with values to unit processes
Lennart Poettering [Wed, 15 Feb 2023 09:25:51 +0000 (10:25 +0100)] 
pid1: add a new D-Bus method for enquing POSIX signals with values to unit processes

This augments the existing KillUnit() + Kill() methods with
QueueSignalUnit() + QueueSignal(), which are what sigqueue() is to
kill().

This is useful for sending our new SIGRTMIN+18 control signals to system
services.

2 years agotest-execute: also mount tmpfs on /dev/shm
Yu Watanabe [Fri, 17 Feb 2023 01:21:58 +0000 (10:21 +0900)] 
test-execute: also mount tmpfs on /dev/shm

Otherwise, if /dev/shm has a directory that cannot be accessible by
unprivileged user, then we cannot pick a dynamic user, and test service
may fail with unexpected error code:
---
Failed to enter shared memory directory /dev/shm/systemd-watch-bind-BqAGlN: Permission denied
exec-dynamicuser-supplementarygroups.service: Failed to update dynamic user credentials: Device or resource busy
exec-dynamicuser-supplementarygroups.service: Failed at step USER spawning /bin/sh: Device or resource busy
src/test/test-execute.c:885:test_exec_dynamicuser: exec-dynamicuser-supplementarygroups.service: can_unshare=no: exit status 217, expected 216
---

Follow-up for 4e032f654b94c2544ccf937209303766dfa66c24.