Commit Graph

62656 Commits

Author SHA1 Message Date
Yu Watanabe
086234e39b Merge pull request #26491 from dtardon/list-paths
Add systemctl list-paths
2023-02-22 09:29:54 +09:00
mooo
8e46b195e0 po: Translated using Weblate (Lithuanian)
Currently translated at 78.2% (151 of 193 strings)

Co-authored-by: mooo <hazap@hotmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/lt/
Translation: systemd/main
2023-02-22 08:37:52 +09:00
Yu Watanabe
a06f85a073 Merge pull request #26527 from mrc0mmand/more-tests
test: provide coverage for #26467 and #26483
2023-02-22 08:01:07 +09:00
Дамјан Георгиевски
37fe75a2e6 socket-proxyd: support Type=notify
update examples in the man page too
2023-02-21 22:59:04 +00:00
Luca Boccassi
fd4ba8a7db Merge pull request #26349 from yuwata/safe-fork-rearrange-stdio
process-util: introduce FORK_REARRANGE_STDIO
2023-02-21 22:58:52 +00:00
Lennart Poettering
e7906abeb8 pam-systemd: split up weight helper funcs
There are three conditionalizations in the status quo ante function,
which kinda indicates this should not be the same function in the first
place. Hence split this up, simplify it, and have two distinct functions
without conditionalizations.
2023-02-21 22:54:12 +00:00
Lennart Poettering
01e4f03f34 journal: move journal_file_compare_locations() from journal-file.c → sd-journal.c
It's only used from sd-journal.c, and we soon would like to pass in an
sd_journal object, hence let's move this over.

This only moves code, doesn't change behaviour
2023-02-21 21:08:21 +01:00
Aidan Dang
d59025698f Enable TPM by default with SetCredentialEncrypted 2023-02-21 21:07:02 +01:00
Jan Janssen
024951fb22 stub: Fix unaligned read 2023-02-21 21:01:47 +01:00
Zbigniew Jędrzejewski-Szmek
377d36898c Merge pull request #26446 from medhefgo/efi-headers
boot: Provide our own EFI API headers
2023-02-21 20:59:33 +01:00
Zbigniew Jędrzejewski-Szmek
1eca770933 efi: drop executable-stack bit from .elf file
An rpminspect test in Fedora/RHEL is flagging our stub files as having an
executable stack. The check is correct:

$ readelf --wide --program-headers build/src/boot/efi/linuxx64.elf.stub | rg -i stack
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RWE 0x10

It seems to be just an omission in the linker script… None of the objects that
are linked into the stub are marked as requiring an executable stack:

$ readelf --wide --sections build/src/boot/efi/*.c.o \
  /usr/lib/gnuefi/x64/libgnuefi.a \
  /usr/lib/gnuefi/x64/libefi.a \
  /usr/lib/gcc/x86_64-redhat-linux/12/libgcc.a \
  | rg '.note.GNU-stack.*X'
(nothing)

On aarch64 we end up with a nonexecutable stack, but on ia32 and x64 we get one,
so this might be just a matter of defaults in the linker. It doesn't matter
greatly, but let's mark the stack as non-executable to avoid the warning.

Note: '-Wl,-z' is not needed, things work with just '-z'.
2023-02-21 20:51:47 +01:00
David Tardon
6269ffe7ee logind-session: make stopping of idle session visible to admins 2023-02-21 20:50:24 +01:00
Mike Yuan
e0b3a70fab sleep: check if we're on AC power before checking battery capacity
Before this commit, battery_is_low() returns
true if there's no battery on the system.
It's now modified to check if the system is
on AC power first, and returns false early
if that's the case.

Fixes #26492
2023-02-21 20:48:33 +01:00
Frantisek Sumsal
adae3552f0 test: add coverage for #26483 2023-02-21 19:39:52 +01:00
Frantisek Sumsal
4190124b3c test: add coverage for #26467 2023-02-21 19:39:52 +01:00
David Tardon
f8979e8698 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
2023-02-21 18:39:07 +00:00
David Tardon
a2ceb88005 test: add a minimal test for list-paths 2023-02-21 19:03:26 +01:00
David Tardon
7336968488 shell-completion: add systemctl list-paths 2023-02-21 19:03:26 +01:00
David Tardon
160b8e981b man: document systemctl list-paths 2023-02-21 19:03:26 +01:00
David Tardon
5fb5f49bec systemctl: add list-paths verb
Fixes #6054.
2023-02-21 19:03:24 +01:00
Daan De Meyer
6c53840958 Merge pull request #26518 from DaanDeMeyer/mkosi-stuff
mkosi: Drop build script workarounds
2023-02-21 18:23:06 +01:00
Lennart Poettering
c56be2c294 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.
2023-02-21 18:19:38 +01:00
Lennart Poettering
b469b969f3 Merge pull request #26265 from poettering/journal-refresh-fixes
journal: journal file header IDs refresh fixes and corrections
2023-02-21 18:19:12 +01:00
David Tardon
f748b2d01a systemctl: prepend machine ID to unit ID in list-sockets
We do it that way in all other list-* functions, so let's be consistent.
2023-02-21 17:15:12 +01:00
David Tardon
ac1405960a systemctl: extract common code to a function 2023-02-21 17:15:12 +01:00
David Tardon
f4384e199d systemctl: use table_add_triggered 2023-02-21 17:15:12 +01:00
David Tardon
531a45f35a systemctl: extract code to a helper function
It will be used more in subsequent commits.
2023-02-21 17:15:12 +01:00
Daan De Meyer
1ad84c9af8 mkosi: Reduce postinst script indentation 2023-02-21 15:23:15 +01:00
Daan De Meyer
d2a0ca2440 mkosi: Simplify BUILDDIR/SRCDIR handling a bit 2023-02-21 15:20:20 +01:00
Daan De Meyer
01a0756427 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.
2023-02-21 15:20:18 +01:00
Daan De Meyer
fff772bee8 mkosi: Remove preset workaround
A "disable *" preset is already shipped on debian so no need to add
one ourselves.
2023-02-21 14:57:29 +01:00
Daan De Meyer
03d319a45f mkosi: Add more debugging 2023-02-21 13:51:59 +00:00
Jan Janssen
5080a60a71 boot: Provide our own EFI API headers
We want to get away from gnu-efi and the only really usable source of
EFI headers would be EDK2, which is somewhat impractical to use and
quite large to require to be around just for some headers.

As a bonus point, the new headers are safe to be included in userspace
code.

This should not have any behavior changes as it is mostly changing
header includes. There are some renames to conform to standard names
and a few minor device path fixups as the struct is defined slightly
different.

Of note is that this removes usage of uchar.h and wchar.h as they are
not guaranteed to be available in a freestanding environment. Instead
efi.h will provide the needed types.
2023-02-21 14:46:02 +01:00
Jan Janssen
a409607489 boot: Query EFI var size before fetching them 2023-02-21 14:44:53 +01:00
Jan Janssen
b3e2557629 boot: Use C escape sequence for control chars
This makes things less magical by emphasizing that these are just
regular ascii/unicode chars.
2023-02-21 14:44:53 +01:00
Jan Janssen
65d40db7de boot: Drop use of efigpt.h 2023-02-21 14:44:48 +01:00
Daan De Meyer
a1cfe39000 mkosi: Use 4 space indentation for scripts
mkosi scripts are shell scripts and for shell scripts we use 4 space
indentation.
2023-02-21 14:22:52 +01:00
Lennart Poettering
464ec1dec7 homectl: add missing break 2023-02-21 13:35:12 +01:00
Daan De Meyer
bfe6bd1789 mkosi: Drop opensuse workaround 2023-02-21 13:11:52 +01:00
Daan De Meyer
51c31ed7d7 mkosi: Drop bootctl workaround in postinst script 2023-02-21 13:11:37 +01:00
Daan De Meyer
046607bb5f 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.
2023-02-21 13:01:30 +01:00
Daan De Meyer
f88f720a8b mkosi: Drop ld workaround
Build scripts will always run in an environment with /etc/ available
now, so we don't need this workaround anymore.
2023-02-21 13:01:30 +01:00
Daan De Meyer
8d8337da5e mkosi: Update to latest 2023-02-21 13:01:22 +01:00
Yu Watanabe
a2275dcb9d 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).
2023-02-21 11:11:03 +01:00
Lennart Poettering
f010478168 docs: document the new HEADER_COMPATIBLE_TAIL_ENTRY_BOOT_ID flag 2023-02-21 10:47:53 +01:00
Lennart Poettering
ced1196802 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.
2023-02-21 10:47:53 +01:00
Lennart Poettering
07f1c7aa9d 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.)
2023-02-21 10:47:53 +01:00
Lennart Poettering
51ab0afed4 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.
2023-02-21 10:47:53 +01:00
Lennart Poettering
8e64ec0470 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.
2023-02-21 10:47:53 +01:00
Lennart Poettering
9204fc642a 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.
2023-02-21 10:47:53 +01:00