Commit Graph
5917 Commits
Author SHA1 Message Date
Adrian Vovk 9e3db91f2f missing_fcntl: Fix RAW_O_LARGEFILE
This value is actually arch-specific, so this commit defines it for all
the arches that set it to some custom value

Fixes https://github.com/systemd/systemd/issues/31417
2024-02-20 15:01:36 -05:00
Adrian Vovk 85f660d46b fd-util: Expose helper to pack fds into 3,4,5,...
This is useful for situations where an array of FDs is to be passed into
a child process (i.e. by passing it through safe_fork). This function
can be called in the child (before calling exec) to pack the FDs to all
be next to each-other starting from SD_LISTEN_FDS_START (i.e. 3)
2024-02-19 11:18:11 +00:00
Luca Boccassi 5ea0da03d4 Merge pull request #31311 from yuwata/journal-user-corruption
journal: fix user journal corruption on rotation
2024-02-16 12:07:50 +00:00
Daan De Meyer 55c2350e85 Merge pull request #31320 from DaanDeMeyer/versioning
meson: Start adding devel and rc suffixes to the project version
2024-02-15 20:15:04 +01:00
Yu Watanabe a6d0cf939c stat-util: introduce {stat,fd}_verify_linked() 2024-02-16 03:48:18 +09:00
Yu Watanabe dd7fa015a6 stat-util: rebreak comment 2024-02-16 03:48:18 +09:00
Yu Watanabe 3900255ac1 Merge pull request #31331 from yuwata/xopenat
tree-wide: several cleanups related to xopenat()
2024-02-16 01:32:21 +09:00
Yu Watanabe e40b11be04 fs-util: rename xopenat() -> xopanat_full() 2024-02-16 00:25:37 +09:00
Yu Watanabe 59a4e17249 chattr-util: fix error code
Follow-up for cf91b9155c.
2024-02-16 00:25:37 +09:00
Yu Watanabe bec1383623 chase: do not wrap xopenat() with RET_NERRNO()
Follow-up for 47f0e1b5e0.
2024-02-16 00:25:37 +09:00
Yu Watanabe e4c094c055 fs-util: readlinkat() supports an empty string
From readlinkat(2):
Since Linux 2.6.39, pathname can be an empty string, in which case the
call operates on the symbolic link referred to by dirfd (which should
have been obtained using open(2) with the O_PATH and O_NOFOLLOW flags).
2024-02-16 00:25:37 +09:00
Mike Yuan 9128fd553c env-util: minor modernization 2024-02-15 19:23:52 +08:00
Yu Watanabe 4dcfdd210c log: reorder arguments of internal macro
To make the order matches with log_internal().

No functional change. Hopefully silence coverity issues like
CID#1534478, CID#1534479, CID#1534480, CID#1534482.
2024-02-15 18:16:33 +09:00
Daan De Meyer ea2a57bee3 meson: Start adding devel and rc suffixes to the project version
Let's make sure that versions generated by meson-vcs-tag.sh always
sort higher than official and stable releases. We achieve this by
immediately updating the meson version in meson.build after a new
release. To make sure this version always sorts lower than future
rcs, we suffix it with "~devel" which will sort lower than "~rcX".

The new release workflow is to update the version in meson.build
for each rc and the official release and to also update the version
number after a new release to the next development version.

The full version is exposed as PROJECT_VERSION_FULL and used where
it makes sense over PROJECT_VERSION.

We also switch to reading the version from a meson.version file in
the repo instead of hardcoding it in meson.build. This makes it
easier to access both inside and outside of the project.

The meson-vcs-tag.sh script is rewritten to query the version from
meson.version instead of passing it in via the command line. This
makes it easier to use outside of systemd since users don't have to
query the version themselves first.
2024-02-14 15:36:34 +01:00
Adrian Vovk c425c8854f hashmap: Add helper to dump sorted keys
Currently, hashmap_dump_sorted sorts by key and then returns the values
in order sorted by key. This commit adds another helper that does the
same but returns the sorted keys instead
2024-02-14 09:35:36 +01:00
Lennart Poettering 64e18af731 Merge pull request #31206 from AdrianVovk/user-record-fields
Added some more user record fields
2024-02-14 09:22:23 +01:00
Adrian Vovk 83b4576195 env-util: Add helper to store current log level
This is useful after a fork but before an exec into a binary that uses
systemd's logging utilities. For example, this should be used in dbus
services that fork off worker processes: currently, the log level set by
the LogControl dbus API will be lost because of the exec, and the worker
process will not have the correct log level set.
2024-02-14 09:21:45 +01:00
Lennart Poettering 2fe27f966f Merge pull request #31297 from AdrianVovk/sha256-util-lib
basic: Add some sha256 helper functions
2024-02-14 09:19:56 +01:00
Adrian Vovk 80d07162e7 format-utils: Expose FORMAT_UID and FORMAT_GID
This pulls this generally useful helper out of sysusers and into the
util lib, and updates the places throughout the codebase where it makes
sense to use it.
2024-02-14 09:14:13 +01:00
Adrian Vovk fa485e8fc5 locale-util: Restrict valid locales
This further restricts the charset of locales to better reflect what
locales actually look like.

This allows us to safely join locale names using the `:` character, for
instance, which cannot appear in a locale name and is used by the
`$LANGUAGE` env var
2024-02-13 17:31:36 -05:00
Adrian Vovk 0bac442251 basic: Add some sha256 helper functions
Adds a util function to sha256 an open fd (moved from dissect). Also
adds functions to check if a string contains a valid sha256 hash, and
parse it into a sha256 array.
2024-02-13 13:59:27 -05:00
Lennart Poettering c9cdbaed17 Merge pull request #30380 from keszybz/tmpfiles-dry-run
Make tmpfiles/sysusers nicer with local files and implement tmpfiles --dry-run
2024-02-13 09:45:50 +01:00
Luca Boccassi 27af7c2b4c Merge pull request #31162 from poettering/tint-tweaks
ptyfwd: some tweaks to terminal handling
2024-02-12 16:47:09 +00:00
Lennart Poettering 39d69836ad missing: change our close_range() syscall wrapper to map glibc's
So glibc exposes a close_range() syscall wrapper now, but they decided
to use "unsigned" as type for the fds. Which is a bit weird, because fds
are universally understood to be "int". The kernel internally uses
"unsigned", both for close() and for close_range(), but weirdly,
userspace didn't fix that for close_range() unlike what they did for
close()... Weird.

But anyway, let's follow suit, and make our wrapper match glibc's.

Fixes #31270
2024-02-12 14:07:19 +01:00
Sam Leonard acdef55ef7 basic/namespace-util: add parse_userns_uid_range 2024-02-12 09:46:00 +00:00
Daan De Meyer 23f9af646b Merge pull request #29960 from CodethinkLabs/vmspawn/mkosi-features
vmspawn: add features required by mkosi
2024-02-09 18:39:54 +01:00
Lennart Poettering c80139f078 glyph-util: add colored circle glyphs 2024-02-09 18:27:01 +01:00
Lennart Poettering ddba81d8dd ptyfwd: optionally update window title if we are running a ptyfwd session 2024-02-09 18:27:01 +01:00
Zbigniew Jędrzejewski-Szmek ec3917d282 tmpfiles,sysusers: rework path argument handling
Previously, if given an absolute path, we would open the file, but when given a
relative path, we'd attempt to search the directories. If the user wants to open
a file from the search path, allowing paths is very confusing. E.g. with a path
like 'sysusers/foo.conf', we'd try to open '/etc/sysusers.d/sysusers/foo.conf',
'/run/sysusers.d/sysusers/foo.conf', …, and with '../foo.conf', we'd try to open
'/etc/sysusers.d/../foo.conf', '/run/sysusers.d/../foo.conf', …. This just isn't
useful, and in fact for a scheme like sysusers.d and tmpfiles.d where there we
have a flat directory with config files, only searching for plain names can
result in success. When a user specifies a relative path, it's more likely that
they wanted to open some local file. OTOH, to correctly open a local file, e.g.
one that they're just writing, this interface is also awkward, because something
like '$PWD/file.conf' has to be used to open a file with a relative path.

This patch changes the interface so that any path (i.e. an argument with "/") is
used to open a file directly, and only plain basenames are used for searching.

(Note that tpmfiles and sysusers are somewhat special here: their "config files"
make sense without the other config and users are likely to want to test them
without the other config. I was trying to do just that when writing a spec file
for a package and attempting to convert the existing scripts to sysusers and
tmpfiles. The same logic wouldn't apply for example to units or udev rules,
because they generally can only be interpreted with the whole rest of config
also available.)
2024-02-09 17:57:41 +01:00
Zbigniew Jędrzejewski-Szmek 15d660fb41 sysusers: convert to conf_file_read()
I was annoyed that systemd-sysusers doesn't print any info when it opens a
config file. Its read_config_file() started out the same as the one in tmpfiles,
and then they diverged. The one in tmpfiles has that logging, hence the rework
to use it here too and get better logging. The two programs should provide
similar functionality, so using a common helper will make it easier to extend
them in tandem later.

No functional change apart from the log info.

The userdata argument (Context) is moved to the last position as requested in
the review.
2024-02-09 17:57:41 +01:00
Zbigniew Jędrzejewski-Szmek f6a1346e4e tmpfiles: split out helper to open and read a "config file"
No functional change.

Note that this function will be modified in subsequent commits, and the API
will change.
2024-02-09 17:57:41 +01:00
Luca Boccassi c505275476 Merge pull request #31243 from YHNdnzj/systemctl-disable-now-template
systemctl: support disable/mask --now with unit template
2024-02-09 14:29:50 +00:00
Sam Leonard fd1cd4a843 path-lookup: add runtime_directory for resolving $RUNTIME_DIRECTORY 2024-02-09 11:43:18 +00:00
Frantisek Sumsal 8632590278 Merge pull request #31230 from mrc0mmand/test-seccomp
process-util: use only the least significant byte from personality()
2024-02-09 10:39:23 +01:00
Mike Yuan 8749b09390 basic/unit-name: introduce unit_name_replace_instance_full
that optionally accepts a globbed instance
2024-02-09 16:17:59 +08:00
Mike Yuan 09d7952a67 basic/unit-name: include param name in function prototype 2024-02-09 16:10:41 +08:00
mille-feuille baa90b4b81 detect-virt: fix Google Compute Engine support
Follow-up for 9b0688f491
2024-02-09 12:12:33 +09:00
Frantisek Sumsal 14ce9b4ed8 process-util: unify the hex value format a bit
And fix the man page reference as well.
2024-02-07 19:29:53 +01:00
Frantisek Sumsal 3dc51ab2cf process-util: use only the least significant byte from personality()
The personality() syscall returns a 32-bit value where the top three
bytes are reserved for flags that emulate historical or architectural
quirks, and only the least significant byte reflects the actual
personality we're interested in (in opinionated_personality()).

Use the newly defined mask in the corresponding test as well, otherwise
the test fails on some more "exotic" architectures that set some of the
"quirk" flags:

~# uname -m
armv7l
~# build/test-seccomp
...
/* test_lock_personality */
current personality=0x0
safe_personality(PERSONALITY_INVALID)=0x800000
Assertion '(unsigned long) safe_personality(current) == current' failed at src/test/test-seccomp.c:970, function test_lock_personality(). Aborting.
lockpersonalityseccomp terminated by signal ABRT.
Assertion 'wait_for_terminate_and_check("lockpersonalityseccomp", pid, WAIT_LOG) == EXIT_SUCCESS' failed at src/test/test-seccomp.c:996, function test_lock_personality(). Aborting.
Aborted (core dumped)

See: personality(2) and comments in sys/personality.h
2024-02-07 19:29:53 +01:00
Luca Boccassi d50f58d641 Merge pull request #31210 from poettering/chdir-hardening
WorkingDirectory= hardening
2024-02-06 12:41:43 +00:00
Luca Boccassi 33d7fedca9 Merge pull request #31205 from YHNdnzj/path-is-mount-point
mountpoint-util: expose root and flags as path_is_mount_point_full
2024-02-06 12:37:20 +00:00
Mike Yuan c90335403c process-util: minor follow-up for pidfd_spawn 2024-02-06 12:26:38 +00:00
Lennart Poettering 0fb08bd5e3 mountpoint-util: add small helper that checks if a path is below the API VFS hierarchies 2024-02-06 11:13:28 +01:00
Mike Yuan b409aacb0a mountpoint-util: introduce path_is_mount_point_full 2024-02-06 15:09:28 +08:00
Luca Boccassi 2e106312e2 core: add support for pidfd_spawn
Added in glibc 2.39, allows cloning into a cgroup and to get
a pid fd back instead of a pid. Removes race conditions for
both changing cgroups and getting a reliable reference for the
child process.

Fixes https://github.com/systemd/systemd/pull/18843
Replaces https://github.com/systemd/systemd/pull/16706
2024-02-05 21:52:36 +00:00
Luca Boccassi 9ca13d60db executor: really set POSIX_SPAWN_SETSIGDEF for posix_spawn
posix_spawnattr_setflags() doesn't OR the input to the current set of flags,
it overwrites them, so we are currently losing POSIX_SPAWN_SETSIGDEF.

Follow-up for: 6ecdfe7d10
2024-02-05 16:26:01 +00:00
Vladimir Stoiakin 85686b37b0 cryptenroll: allow to use a public key on a token
This patch allows systemd-cryptenroll to enroll directly with a public key if a certificate is missing on a token.

Fixes: #30675
2024-02-03 03:00:51 +09:00
Yu Watanabe d282d55d4f cgroup-util: fix typo
Follow-up for 677e6c14b1.
2024-02-02 09:11:42 +09:00
Yu Watanabe a4f1a3087a user-util: fix typo
Follow-up for 75673cd8ae.
2024-02-02 09:10:02 +09:00
Luca Boccassi 556d2bc4a1 core: use PidRef in exec_spawn 2024-02-01 21:06:14 +00:00