Yu Watanabe [Wed, 7 Aug 2024 03:01:45 +0000 (12:01 +0900)]
sd-journal: fix sd_journal_seek_monotonic_usec()
This fixes the following issues:
- We have a journal file, which contains entries of boot A and B. Let T
be the timestamp of the _last_ entry of boot A.
If sd_journal_seek_monotonic_usec() is called for boot A with a timestamp
_after_ T, following sd_journal_next() will provide the _first_ entry of
boot A, rather than the first entry of boot B.
- We have two journal files X and Y. The file X contains entries of boot A.
Let T be the timestamp of the _last_ entry of boot A in file X. The file Y
contains entries of boot A after timestamp T.
If sd_journal_seek_monotonic_usec() is called for boot A with a
timestamp _after_ T, following sd_journal_next() will provide the
_first_ entry of boot A, whose timestamp is of course earlier than T.
I don't particularly favor the duplicated strstrip()
and such, so let's ensure if we get fixed data it's
only trimmed once. Subsequently we can benefit more
by making all copies reflinks.
Mike Yuan [Sun, 11 Aug 2024 13:41:30 +0000 (15:41 +0200)]
edit-util: do not try to recreate temp file if missing
We initially read from temp file, then strip it, and write
back to it. If the file suddenly disappeared during the process,
it indicates someone else is touching our temp file
behind our back. Let's not silently continue.
Mike Yuan [Sun, 7 Jul 2024 15:21:08 +0000 (17:21 +0200)]
edit-util: clean up run_editor() a bit
- Add missing assertions
- Close all fds before spawning editor
- Use FOREACH_STRING() + empty_to_null() where appropriate
Note that this slightly changes the behavior, in that
empty envvars would be treated as unset and we'd try
the next candidate. But the new behavior is better IMO.
Luca Boccassi [Sun, 11 Aug 2024 13:33:07 +0000 (14:33 +0100)]
mkosi: update debian commit reference
* 6e0f4f74ba Update changelog for 256.4-3 release
* 4b142f9c37 Depend on new linux-bpf-dev package where available
* f5fe5ecf4d autopkgtest: use hint-testsuite-triggers to ensure other packages changes trigger our testsuite
* 407932845d autopkgtest: run upstream test last
* 31458d03c2 Stop installing legaly pkla file in upstream CI too
* 484643291a Use d/not-installed instead of manual removals
* 752bb4c34c Stop shipping empty /etc/init.d directory
* 174603ffc2 Use debian/clean instead of override in d/rules
* 9a355e5a51 Drop redundant pot build
* 3d249c88cb Update changelog for 256.4-2 release
Ivan Shapovalov [Wed, 7 Aug 2024 08:02:45 +0000 (10:02 +0200)]
core/exec-invoke: call setpriority() after sched_setattr()
The nice value is part of struct sched_attr, and consequently invoking
sched_setattr() after setpriority() would clobber the nice value with
the default (as we are not setting it in struct sched_attr).
It would be best to combine both calls, but for now simply invoke
setpriority() after sched_setattr() to make sure Nice= remains effective
when used together with CPUSchedulingPolicy=.
Nick Rosbrook [Wed, 7 Aug 2024 22:18:06 +0000 (18:18 -0400)]
core/unit: do not use unit path cache in unit_need_daemon_reload()
When unit_need_daemon_reload() calls unit_find_dropin_paths() to check
for new drop-in configs, the manager's unit path cache is used to limit
which directories are considered. If a new drop-in directory is created,
it may not be in the unit path cache, and hence unit_need_daemon_reload()
may return false, despite a new drop-in being present. However, if a
unit path cache is not given to unit_file_find_dropin_paths() at all,
then it behaves as if the target path was found in the unit path cache.
So, to fix this, adapt unit_find_dropin_paths() to take a boolean
argument indicating whether or not to pass along the unit path cache.
Set this to false in unit_need_daemon_reload().
Daan De Meyer [Wed, 7 Aug 2024 18:44:38 +0000 (20:44 +0200)]
crash-handler: Call vhangup on /dev/console before spawning crash shell
When pid 1 crashes, the getty unit for the console will happily keep
running which means we end up with two shells competing for the same
tty. Let's call vhangup on /dev/console to kill every other process
attached to the console before we spawn the crash shell. The getty
units have Restart=always but lucky for us, pid 1 just crashed in fire
and flames so it isn't actually able to restart the getty unit.
gcc15 has -Wunterminated-string-initialization in -Wextra and
warns about string constants that are not null terminated even though
the functions do do out of bounds access.
Silence the warnings by simply not providing an explicit size.
Daan De Meyer [Tue, 6 Aug 2024 09:08:33 +0000 (11:08 +0200)]
nspawn: Allow specifying custom init program
This allows for example forcing to use /sbin/init instead of always
using /usr/lib/systemd/systemd if it exists. Or it allows using a
different path altogether.
Nick Rosbrook [Tue, 6 Aug 2024 00:43:15 +0000 (20:43 -0400)]
sysusers: check if requested group name matches user name in queue
When creating a user, check if the requested group name matches a user
name in the queue. If that matched user name is also going to be a group
name, then use it for the new user too. In other words, allow the
following:
Yu Watanabe [Sun, 4 Aug 2024 05:09:53 +0000 (14:09 +0900)]
systemctl: gracefully adjust bus transport and runtime scope when --boot-loader-entry=help
This fixes the following assertion:
===
SYSTEMD_LOG_LEVEL=debug systemctl --user -H foo --boot-loader-entry=help
Assertion 'transport != BUS_TRANSPORT_REMOTE || runtime_scope == RUNTIME_SCOPE_SYSTEM' failed at src/shared/bus-util.c:284, function bus_connect_transport(). Ignoring.
Failed to connect to bus: Operation not supported
===
The PrepareForShutdownWithMetadata signal was added via e4aab5cf1a00bbb73f325f4f785dd4171ccdae77 but a corresponding property
was not. A property has to be a single type, so the bool needs to be
one of the key/value pairs as 'ba{sv}' is not a valid property.
Daan De Meyer [Mon, 5 Aug 2024 13:37:46 +0000 (15:37 +0200)]
mkosi: Prevent busybox from getting pulled into opensuse images
OpenSUSE's busybox has a bunch of Provides for basic tools that cause
it to get pulled into images unless the corresponding tool is explicitly
installed so let's add explicit tools to make sure we don't get busybox.
Daan De Meyer [Fri, 2 Aug 2024 14:25:03 +0000 (16:25 +0200)]
test: Add a way to quickly iterate on an integration test
Rebuilding the integration test every time is very slow. Let's
introduce a way to iterate on an integration test without rebuilding
the image every time. By making a btrfs snapshot before we run the
integration test, we can then systemctl soft-reboot after running
the test to restore the rootfs to a pristine state before running
the test again.
As /run/nextroot will get nuked on reboot or soft-reboot, we introduce
a tmpfiles snippet to make sure it is recreated every (soft-)reboot
and adapt the existing tests to deal with this new symlink.
Daan De Meyer [Fri, 2 Aug 2024 14:22:37 +0000 (16:22 +0200)]
mkosi: Enable Autologin= again on Debian
Debian uses /usr/bin/login from the shadow package instead of util-linux
which doesn't support credentials. Let's enable autologin the old
fashioned way for now.
Daan De Meyer [Fri, 2 Aug 2024 13:18:45 +0000 (15:18 +0200)]
docs: Update upgrade commands in HACKING.md
- Add the required options to make the package managers non interactive
- Use apt-get instead of apt
- Remove --reinstall from apt-get command so we only install newer packages
- Add --needed to pacman command so we only install newer packages
Yu Watanabe [Mon, 5 Aug 2024 05:18:21 +0000 (14:18 +0900)]
journal: set flushed flag even if we fail to open runtime journals
As at this stage, a persistent journal file has been already opened, and
saved seqnum has been reset, and any later journal entries will be stored
to the file. Hence we should not open the runtime journal file by
server_system_journal_open() again.
Yu Watanabe [Mon, 5 Aug 2024 05:56:11 +0000 (14:56 +0900)]
journal: do not rotate journal when MaxRetentionSec= is set
The setting is about vacuuming archived journal files. It is not
necessary to rotate the current journal. Note, journal file rotation is
controlled by MaxFileSec=.