]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
import: try to capture tar exit codes on failure 42081/head
authorLuca Boccassi <luca.boccassi@gmail.com>
Wed, 13 May 2026 17:39:06 +0000 (18:39 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 13 May 2026 17:39:24 +0000 (18:39 +0100)
TEST-13-NSPAWN.machined occasionally fails with a tar error, and it's hard
to say what the problem is at the exit code is lost. Try to capture it.

[ 34.054] systemd-importd[504]: (transfer18) Imported 92%.
[ 34.118] systemd-importd[504]: (transfer18) Failed to decode and write: Broken pipe
[ 34.119] systemd-importd[504]: (transfer18) Exiting.
[ 34.121] systemd-importd[504]: (transfer18) Failed to allocate transient user namespace: Operation not permitted
[ 34.121] systemd-importd[504]: Transfer process failed with exit code 1.

Follow-up for b6e676ce41508e2aeea22202fc8f234126177f52

src/import/import-tar.c

index 4bd59788008e947f74b16b6355d13e826c79ba5a..06ee56bd78f90c8f59729031fb53c67d46c03119 100644 (file)
@@ -368,6 +368,17 @@ static int tar_import_process(TarImport *i) {
         r = decompressor_push(i->compress, i->buffer, i->buffer_size, tar_import_write, i);
         if (r < 0) {
                 log_error_errno(r, "Failed to decode and write: %m");
+
+                /* Try to check the actual exit code from the child process, to make debugging easier */
+                if (r == -EPIPE && pidref_is_set(&i->tar_pid)) {
+                        int q = pidref_wait_for_terminate_and_check("tar", &i->tar_pid, WAIT_LOG);
+                        pidref_done(&i->tar_pid);
+                        if (q < 0)
+                                r = q;
+                        else if (q != EXIT_SUCCESS)
+                                r = -EPROTO;
+                }
+
                 goto finish;
         }