Commit Graph

6746 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
75d51d77da basic/glyph-util: introduce optional_glyph() to wrap emoji_enabled() 2025-03-15 14:40:52 +01:00
Zbigniew Jędrzejewski-Szmek
1ae9b0cfa8 basic/glyph-util: rename "special glyph" to just "glyph"
Admittedly, some of our glyphs _are_ special, e.g. "O=" for SPECIAL_GLYPH_TOUCH ;)
But we don't need this in the name. The very long names make some invocations
very wordy, e.g. special_glyph(SPECIAL_GLYPH_SLIGHTLY_UNHAPPY_SMILEY).
Also, I want to add GLYPH_SPACE, which is not special at all.
2025-03-15 14:40:39 +01:00
Lennart Poettering
d810815ed4 firstboot: welcome user with emoji in firstboot wizard 🧙 2025-03-15 05:12:12 +09:00
Lennart Poettering
da65941c3e coredump,analyze: use read_full_file() for reading various top-level /proc/ files
Kernel API file systems typically use either "raw" or "seq_file" to
implement their various interface files. The former are really simple
(to point I'd call them broken), in that they have no understanding of
file offsets, and return their contents again and again on every read(),
and thus EOF is indicated by a short read, not by a zero read. The
latter otoh works like a typical file: you read until you get a
zero-sized read back.

We have read_virtual_file() to read the "raw" files, and can use regular
read_full_file() to read the "seq_file" ones.

Apparently all files in the top-level /proc/ directory use 'seq_file'.
but we accidentally used read_virtual_file() for them. Fix that.

Also clarify in a comment what the rules are.

Fixes: #36131
2025-03-13 14:18:46 +01:00
Lennart Poettering
af9c45d5b6 hostname: support that /etc/hostname contains ??? as wildcards to be replaced by hash value from /etc/machine-id 2025-03-11 18:01:42 +01:00
Lennart Poettering
98b7c5e2f2 basic: move gethostname_full() from basic/hostname-util.c → shared/hostname-setup.c
In one of the next commits we'd like to introduce a concept of
optionally hashing the hostname from the machine ID. For that we we need
to optionally back gethostname_full() by code involving sd-id128, hence
let's move it from src/basic/ to src/shared/, since only there we are
allowed to use our public APIs.
2025-03-11 17:54:44 +01:00
Lennart Poettering
a9178dbdd9 cgroup-util: Handle capsule@ paths like user@ paths (#36664)
The capsule instances are related to user instances, so treat them
equally to user@.service when handling cgroup paths. This also saves us
from polluting public libsystemd API with variant for capsules too.

Fix: https://github.com/systemd/systemd/issues/36098
2025-03-11 12:03:57 +01:00
Michal Koutný
6c5703f9bc cgroup-util: Handle capsule@ paths like user@ paths
The capsule instances are related to user instances, so treat them
equally to user@.service when handling cgroup paths. This also saves us
from polluting public libsystemd API with variant for capsules too.

Fix: #36098
2025-03-11 10:37:19 +01:00
Michal Koutný
afffd9ee26 capsule-util: Move from shared/ to basic/
...so that other code in basic can use it too (basic ⊆ shared).
2025-03-07 18:07:51 +01:00
Lennart Poettering
600e135a0b virt: detect "linux,dummy-virt" devicetree VMs
So apparently "linux,dummy-virt" is a devicetree in popular use by
various hypervisors, including crosvm:

e5d7a64d37/aarch64/src/fdt.rs (L692)

and qemu:

98c7362b1e/hw/arm/virt.c (L283)

and that's because the kernel ships support for that natively:

https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/linux%2Cdummy-virt.yaml

It's explicitly for using in virtualization. Hence it's suitable for
detecting it as generic fallback.

This hence adds the check, similar to how we already look for one other
qemu-specific devicetree.

I ran into this while playing around with the new Pixel "Linux Terminal"
app from google which runs a Debian in a crosvm apparently. So far
systemd didn't recognize execution in it at all. Let's at least
recognize it as VM at all, even if this doesn't recognize it as
crosvm.
2025-03-07 15:18:08 +01:00
Lennart Poettering
4d53d76f5e virt: some modernizations
Reduce scope of certain allocations, add more debug logging, and improve
some log messages.
2025-03-07 15:11:09 +01:00
Lennart Poettering
4efd46c44b terminal-util: during terminal reset clear from beginning of line to end of screen
tianocore does some weird shit with its terminal emulation and regular
fills half the terminal with grey background and then invokes us with
this not cleared up. Hence let us clear this up for it: as part of the
ansi sequence based reset let's position the cursor explicitly at the
beginning of the current line, and erase everything till the end of the
screen. This makes boot output in tianocore vms much much cleaner.

Note that this does *not* erase any terminal output *before* the cursor
position where we take over, because that typically contains valuable
information still we should not erase.
2025-03-06 22:32:32 +00:00
Yu Watanabe
5c9feb2d6e tree-wide: drop unnecessary break in default branch 2025-03-06 11:42:20 +01:00
Mike Yuan
33db9f214b missing_syscall: drop raw_getpid()
This used to be relevant since in old versions of glibc an internal
cache is maintained, while we might sidestep their invalidation
with raw_clone(). After glibc 2.25 getpid() is a trivial wrapper
for the syscall, and hence there's no need to have a separate
raw_getpid().
2025-03-04 23:03:24 +01:00
Mike Yuan
c133fcd5c0 locale-util: modernize is_locale_utf8() a bit 2025-03-04 23:03:23 +01:00
Mike Yuan
87838420aa basic/sys/mount: sort includes 2025-03-04 23:02:39 +01:00
Mike Yuan
c74380cceb missing_fs: drop FS_KEY_DESCRIPTOR_SIZE
We now directly import linux/fscrypt.h, so this def is duplicate
2025-03-04 23:02:37 +01:00
Yu Watanabe
c4eef17990 dirent-util: add several assertions in posix_getdents()
Follow-up for e86a492ff0.
2025-03-04 22:54:01 +01:00
Lennart Poettering
4f4c37bc07 log: explicitly size log_target_max_level()
We always validate that the target value is below _LOG_TARGET_SINGLE_MAX
before acessing it, but we don't actually size the array like that.
let's fix that.

This doesn#t effectively change anything, but it makes things more
explicit what the limit here is.
2025-03-04 18:07:00 +01:00
Daan De Meyer
5abf819a5f basic: remove unnecessary definition in missing_xyz.h (#36565) 2025-03-04 08:41:14 +01:00
Yu Watanabe
f342c2420a chattr-util: two trivial cleanups (#36593) 2025-03-04 13:13:25 +09:00
Yu Watanabe
42f6a96e6c fileio: move call of label_ops_post() before error handling of creating files
Fixes CID#1563946.
2025-03-04 05:18:15 +09:00
Yu Watanabe
e86a492ff0 dirent-util: introduce simple wrapper of posix_getdents()
glibc exports getdents64 syscall as is, but musl exports it as
posix_getdents(). Let's introduce a simple wrapper of posix_getdents().

Note, our baseline for glibc is 2.31. Hence, we can assume getdents64()
always defined when building with glibc.
2025-03-04 04:23:57 +09:00
Yu Watanabe
ec32732043 basic: introduce our own sys/mount.h implementation
To resolve conflict with sys/mount.h and linux/mount.h or linux/fs.h.

The conflict between sys/mount.h and linux/mount.h is resolved in
glibc-2.37 (774058d72942249f71d74e7f2b639f77184160a6), but our baseline
is still glibc-2.31. Also, even with the version or newer, still
sys/mount.h conflicts with linux/fs.h, which is included by
linux/btrfs.h.

This introduces our own implementation of sys/mount.h, that can be
simultaneously included with linux/mount.h and linux/fs.h. This also
imports linux/fs.h, linux/mount.h, and several other dependent headers.
The introduced sys/mount.h header itself may not be enough simple, but
by using the header, we can drop most of workarounds in other source files.
2025-03-04 02:24:49 +09:00
Yu Watanabe
bc2bb59bdd missing_audit: AUDIT_NLGRP_READLOG is defined since kernel v3.16
More specifically, since 451f921639fea4600dfb9ab2889332bdcc7b48d3.
Now, our kernel baseline is 5.4. Hence, we can drop the definition.
2025-03-04 02:24:49 +09:00
Yu Watanabe
aa14f19398 basic/linux: import capability.h from kernel 6.14-rc4 2025-03-04 02:24:49 +09:00
Yu Watanabe
b9b006c504 missing_wait: add short comment about P_PIDFD 2025-03-04 02:24:49 +09:00
Yu Watanabe
003b845cb2 missing_timerfd: TFD_TIMER_CANCEL_ON_SET is defined since glibc-2.26 2025-03-04 02:24:49 +09:00
Yu Watanabe
e75372958d missing_threads.h: threads.h exists since glibc-2.28 2025-03-04 02:24:49 +09:00
Yu Watanabe
75b101718c missing_socket: drop unnecessary definitions
All removed definitions are in glibc-2.31
2025-03-04 02:24:49 +09:00
Yu Watanabe
2c2d832eb0 missing_securebits: remove unnecessary header
Our kernel baseline is 5.4, hence all entries in the headers are defined
in linux/securebits.h.
2025-03-04 02:24:49 +09:00
Yu Watanabe
a7cb43d8d1 missing_resource.h: RLIMIT_RTTIME is defined since glibc-2.14
Now our baseline is glibc-2.31.
2025-03-04 02:24:49 +09:00
Yu Watanabe
8e091ec420 basic/linux: import prctl.h from linux 6.14-rc4 2025-03-04 02:24:49 +09:00
Yu Watanabe
6e338c25d8 missing_network: drop unnecessary definitions
They are already defined in glibc-2.31.
2025-03-04 02:24:49 +09:00
Yu Watanabe
b4ea2e7249 missing_namespace: drop unnecessary entries
Our kernel baseline is 5.4.
2025-03-04 02:24:49 +09:00
Yu Watanabe
dc1a78a462 basic/linux: import loop.h from kernel 6.14-rc4, and drop missing_loop.h 2025-03-04 02:24:49 +09:00
Yu Watanabe
fa716b6fc7 missing_keyctl: import keyctl.h from kernel 6.14-rc4 2025-03-04 02:24:49 +09:00
Yu Watanabe
e7e91769e8 basic/linux: import ioprio.h from kernel 6.14-rc4
This also fixes the maximum allowed ioprio class: 8 -> 7
2025-03-04 02:24:49 +09:00
Yu Watanabe
87fb62f598 missing_input: replace the header with genuine linux header 2025-03-04 02:24:49 +09:00
Yu Watanabe
4dbaa211b5 basic/linux: import hidraw.h and hid.h from linux-6.14-rc4 2025-03-04 02:24:49 +09:00
Yu Watanabe
1b8f8a2d30 missing_fs: drop unnecessary entries
Now our kernel baseline is 5.4.
2025-03-04 02:24:49 +09:00
Yu Watanabe
c5cba760cf missing_fcntl: drop definitions covered by glibc-2.31
Note, this also fixes the definition for O_TMPFILE for parisc and hppa,
it should be 040000000 (seven zeros) rather than 0400000000 (eight zeros).
2025-03-04 02:24:49 +09:00
Yu Watanabe
883360f63a missing_type: char16_t and char32_t are always defined in uchar.h since C11
Now, we use C17, hence the fallback definitions can be dropped.
2025-03-04 02:24:49 +09:00
Yu Watanabe
905497c86d missing_stdlib: secure_getenv() exists since glibc-2.17 2025-03-04 02:24:49 +09:00
Yu Watanabe
e79d88320a alloc-util: reallocarray() exists since glibc-2.26 2025-03-04 02:24:49 +09:00
Yu Watanabe
6b557580fe missing_syscall: drop unnecessary definition of AT_EMPTY_PATH
It is defined since glibc-2.14 (46998f745736b3c8df5901a27b6c2a19f5cc5e98),
and the value was never changed.
2025-03-04 02:24:49 +09:00
Yu Watanabe
1d917ba421 missing_syscall: drop unnecessary ifdefs for syscall number
Nowadays, we define syscall numbers for newer syscalls.
Hence the conditions are not necessary.

This also adds several comments about when syscalls are introduced.
2025-03-04 02:24:49 +09:00
Yu Watanabe
2a6e117ddb missing_syscall: drop unnecessary syscall number definitions 2025-03-04 02:24:49 +09:00
Yu Watanabe
fbfe09ccd0 missing_syscall: drop unused rt_sigqueueinfo wrapper
The syscall is unused since 19e1a908b5.
2025-03-04 02:24:49 +09:00
Yu Watanabe
177f168f43 missing_syscall: copy_file_range is supported by glibc since 2.27
Now our baseline of glibc is 2.31, hence it is OK to drop our
definition.
2025-03-04 02:24:49 +09:00