Commit Graph
623 Commits
Author SHA1 Message Date
Lennart Poettering f5452477d4 tree-wide: fix lseek() parameter order
The offset must be specified first, 'whence' second. Fix that.

Except for one case this fix doesn't actually fix any real bug, since
SEEK_SET is defined as 0 anyway, hence the swapped arguments have no
effect.

The one exception is the MTD smartmedia code, which I guess indicates
that noone has been using that hw anymore in a long time?
2025-11-13 14:19:29 +01:00
Yu Watanabe 242088e98b meson: drop redundant HAVE_ZLIB check
ENABLE_IMPORTD requires HAVE_ZLIB, and it is already checked at the very
beginning of the file.
2025-11-09 05:42:21 +09:00
Lennart Poettering 729e1f24c5 pull-job: port .payload field to struct iovec
struct iovec is really how we should encode any form of arbitrary blob
data
2025-11-08 09:28:50 +01:00
Lennart Poettering 33f49312f8 pull-job: use http_status_etag_exists() at a second place 2025-11-08 09:28:50 +01:00
Lennart Poettering f56531c25c pull: there's no need to keep the downloaded image in memory, except for the sha256sums/gpg file
This seems to be a mistake, in place since the first commit: we only
want the downloaded data in memory if this is a sha256sums or gpg file,
which we need to prorcess ourselves.
2025-11-08 09:28:50 +01:00
Lennart Poettering 7aa847933f pull: use ASSERT_PTR() to shorten code a tiny bit 2025-11-08 09:28:50 +01:00
Lennart Poettering 5bba33f5e9 pull: now that PullJob can verify expected digests, let's rely on it for tar/raw pulling
Instead of authenticating the downloaded image explicity in the tar and
in the raw downloader, we can now rely on the checksum checking in the
generic PullJob code. Hence do so: drop tep the checksum field from
TarPull and RawPull, and just initialized the ->expected_checksum in the
relevant PullJob instead.
2025-11-08 09:28:50 +01:00
Lennart Poettering 6f16ab4893 pull-job: optionally store an expected checksum in PullJob object 2025-11-08 09:28:50 +01:00
Lennart Poettering e825635af6 import: rework pull logic to store download digests in binary form rather than string
We generally want to store data in parsed form, not formatted form,
hence let's follow our own rules on this, and store the message digest
as "struct iovec" rather than as string. This is generally more
efficient and safer, simply because of case issues.
2025-11-08 09:28:50 +01:00
Lennart Poettering cb1caab98e pull-job: optionally take expected content length and compare it with what we are downloading 2025-11-08 09:27:46 +01:00
Lennart Poettering bf51a545a4 pull-job: always implicitly NUL terminate downloaded payload stored in memory
Just as a safety measure, let's always NUL terminate what we are
downloading, maybe future code will parse it as string, and is sloppy by
accident.

(We have similar logic in read_full_file(), and I think it's a really
good rule, to always implicitly NUL terminate blobs we acquire that
might very well be used as text later on)
2025-11-08 09:27:46 +01:00
Lennart Poettering 78a738f4cf tar-util: squash high UIDs in user mode 2025-11-04 14:12:39 +01:00
Lennart Poettering 2348c56367 import: make sure image mangling works unpriv too 2025-10-30 22:57:43 +01:00
Lennart Poettering 7912b1ebe5 import-common: rework import_mangle_os_tree() to operate based on fd to tree 2025-10-30 22:56:19 +01:00
Lennart Poettering 96d03f8e41 importd: port export-tar code to use the one systemd-dissect already uses (#39405)
Split out of #38728.

(Testcase is part of that PR)
2025-10-30 22:15:34 +01:00
Lennart Poettering 90305bd17a pull: add pretty progress bar to systemd-pull too
This already exists in systemd-import, but let's add it for systemd-pull
too.
2025-10-29 13:09:57 +01:00
Lennart Poettering 3780a0b446 export-tar: port to common libarchive tar generation code 2025-10-29 10:09:44 +01:00
Lennart Poettering ee327e086e discover-image: imply that hidden images are read-only
Marking a whole directory tree OS image as read-only is difficult
privilege-wise, because so far we rely on the FS_IMMUTABLE_FL which is
not accessible to unpriv clients.

One fundamental place where we currently rely on marking images
read-only is for keeping pristine copies of the originally downloaded
image around, which we place in "hidden" image directories. This is
probably the most relevant usecase for the read-only flag. And moreover,
the only usecase for the hidden images are these read-only pristine
copies.

Hence, let's make this work reasonably in the unpriv case, and simply
imply the read-only flag for hidden images. This is strictly speaking a
change in behaviour, but effectively it shouldn't be, because for nspawn
containers that are executed we insist on names that are hostname
compatible, and hidden names aren't (because they start with a dot).
2025-10-24 17:51:00 +02:00
Lennart Poettering 25dbf586b2 importd: downgrade log message about bound capability set dropping + netns
An unprivileged process cannot reduce its own capability bounding set,
hence, while it is nice to reduce the set, let's not log about it
loudly, in case we are invoked unpriv (which we explicity support these
days after all).

An unpriv process also cannot detach from its netns, hence also
downgrade the warning to a debug message.
2025-10-21 23:09:50 +02:00
Lennart Poettering 1be8caa6be importd: support unpacking tarballs to foreign UID range
When invoked unprivileged, let's use a transiently allocated userns, so
that we can properly untar UIDs/GIDs so that the trees appear owned by
the foreign UID/GID range.
2025-10-21 23:09:50 +02:00
Lennart Poettering d9c10bf1d2 importd: clean up how we determine image root in importd backends
Let's introduce a single helper that determines where to download images
to, taking all three primary parameters into account: the image class,
the runtime scope and whether to do runtime or persistency.

Then port everything over to this.

This not only cleans things up, but makes sure the importd backends
actually properly can deal with per-user downloads, as before we never
took the runtime scope into account for determining download location.
2025-10-21 23:09:50 +02:00
Lennart Poettering 0960b905bc importctl: add --user/--system switches 2025-10-21 23:09:50 +02:00
Lennart Poettering f7c72e8725 importd: properly support operation in per-user mode 2025-10-21 23:09:50 +02:00
Lennart Poettering b76a76ac15 importd: teach all backends --system/--user mode
The runtime scope logic is internally already in place, let's expose
this via getopt() command line too. This way importd later can propagate
the invocation scope down to the backends.
2025-10-21 23:09:50 +02:00
Lennart Poettering b0c6d129a5 two small varlink additions (#39323)
Split out of #39293, but make a ton of sense on their own.
2025-10-16 17:42:57 +02:00
Daan De Meyer f102bc3e5f tree-wide: Introduce sd-forward.h and shared-forward.h headers
Let's not leak details from src/shared and src/libsystemd into
src/basic, even though you can't actually do anything useful with
just forward declarations from src/shared.

The sd-forward.h header is put in src/libsystemd/sd-common as we
don't have a directory for shared internal headers for libsystemd
yet.

Let's also rename forward.h to basic-forward.h to keep things
self-explanatory.
2025-10-16 17:00:29 +02:00
Lennart Poettering 78a135f567 varlink: move definition of varlink_hash_ops into common code
This is truly useful whenever we have to deal with multiple varlink
connections.
2025-10-16 16:24:29 +02:00
Zbigniew Jędrzejewski-Szmek 1929f43199 test-tar-extract: add a binary wrapping tar_x() for manual testing
We'll probably want to turn this into a test in the integration tests.
2025-10-16 08:22:33 +02:00
Lennart Poettering a7c8f92d1f importd: port untarring logic over to libarchive
This way we have can expose identical behaviour everywhere, can make use
of our atomic replacement calls, and openat() logic, and later apply
additional tracks while unpacking, such as putting limits on UID ranges
and similar.
2025-10-14 11:56:45 +02:00
David Tardon 188049d38c tree-wide: combine DUMP_STRING_TABLE() and return 2025-10-02 16:19:03 +02:00
David Tardon 854789543b export: use table to parse --format= 2025-09-29 16:04:12 +02:00
Lennart Poettering b7f6bdbbd3 service-util: add generic parser for runtime scope 2025-09-25 22:43:59 +02:00
Daan De Meyer 9adb4685df tree-wide: Remove unused includes 2025-09-19 14:46:55 +02:00
Daan De Meyer 1403faeb15 tree-wide: Fix two curl warnings 2025-09-19 11:32:04 +02:00
Yu Watanabe 8835034df8 importd: some minor tweaks (#39008) 2025-09-19 15:48:14 +09:00
Lennart Poettering 625c2e10c6 importd: port to PidRef 2025-09-19 15:45:46 +09:00
Lennart Poettering f26a805a9f import: always use the same buffer size
Let's synchronize the buffer sizes used when passing around the disk
images, i.e. size both our internal buffers and the pipe buffers the
same (so that we can always write()/read() everything in one gone -
except for the noise compression inserts).

Let's also increase the buffer sizes from 16K to 128K, which made a
difference for me, because it reduces the number of syscalls quite a
bit.
2025-09-18 15:43:13 +02:00
Lennart Poettering 0ba1d9f6db export-tar: refuse to write tar to a TTY 2025-09-18 15:40:41 +02:00
Lennart Poettering f20508da71 pull-job: fix include order 2025-09-18 15:29:42 +02:00
Lennart Poettering acd4943528 copy: calculate bytes per second while copying, and pass to progress info
Also, show it in import-fs/repart.
2025-09-17 19:48:08 +01:00
Lennart Poettering aa7574417b pull: fix SHA256SUMS fallback for file:// URLs
For file:// there's no http error code 404, but there's
CURLE_FILE_COULDNT_READ_FILE hence call ->on_not_found() in that case
too.

Follow-up for: c456862f87
2025-09-17 14:35:10 +02:00
Antonio Alvarez Feijoo 3eb590f2b0 tree-wide: avoid logging 2 error messages if table_print_with_pager() fails
`table_print_with_pager()` already calls `table_log_print_error()` internally if
there is an error.
2025-08-28 14:09:50 +02:00
Lennart Poettering 06de39b3bd import-generator: disable timeout for downloaded images
Downloading images can take arbitrary amounts of time, hence disable the
timeout for it.

Inspired by https://github.com/systemd/particleos/issues/80
2025-08-26 15:23:41 +02:00
Luca Boccassi 9ce6d08196 import-generator: fix crash with no remote string in systemd.pull=
SYSTEMD_PROC_CMDLINE=rd.systemd.pull=raw,machine,blockdev,bootorigin:rootdisk systemd-import-generator

Follow-up for 0c892214f7
2025-08-25 19:08:25 +01:00
Lennart Poettering 265386ba35 importd: accept a single space as SHA256SUMS separator
The SHA256SUMS files provided by https://images.linuxcontainers.org/
are slightly non-conforming, insted of using " *" or "  " as separator
between hash and file name they use " ". Let's accept that too, in the
interest of maximizing compatibility.
2025-08-19 11:49:19 +01:00
Yu Watanabe 2633ed01ca import: add a debugging log of importing blob
This should be helpful for debugging issue #38524.
2025-08-13 23:44:58 +09:00
Yu Watanabe defac931c0 import: align table 2025-08-13 23:44:58 +09:00
Yu Watanabe 00085ba6c2 import,sysupdate: make notify event processed before SIGCHLD of worker processes
This fixes the following warning:
```
[    5.628796] TEST-13-NSPAWN.sh[299]: + importctl import-raw --class=confext /var/tmp/importtest
(snip)
[    5.638894] systemd-importd[302]: (transfer1) Operation completed successfully.
[    5.640760] TEST-13-NSPAWN.sh[318]: ^MTotal:   0%^MTotal:  40%
[    5.638902] systemd-importd[302]: (transfer1) Exiting.
[    5.638931] systemd-importd[302]: Got percentage from client: 40%
[    5.638956] systemd-importd[302]: Transfer process succeeded.
[    5.638988] systemd-importd[302]: Got notification datagram from unexpected peer, ignoring.
```
2025-08-13 23:44:58 +09:00
Yu Watanabe 7f6086d530 tree-wide: do not use %m with SYNTHETIC_ERRNO() 2025-07-22 03:05:54 +09:00
Yu Watanabe 5918ba9c69 tree-wide: fix log messages: "Failed VERB" -> "Failed to VERB" 2025-07-22 03:05:33 +09:00