]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
kernel-install: move staging area to /var/tmp/
authorLennart Poettering <lennart@poettering.net>
Sun, 2 Nov 2025 08:32:16 +0000 (09:32 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 3 Nov 2025 08:01:44 +0000 (09:01 +0100)
The generated files (UKIs...) can potentially be huge, hence create them
in /var/tmp/, rather than /tmp/.

src/kernel-install/kernel-install.c
src/kernel-install/test-kernel-install.sh

index a636a91dd2b9881c07305a755a8c559130fc9ab7..97c4b3a352bc271b599a7a57f207eb39f5f9de86 100644 (file)
@@ -810,7 +810,6 @@ static int context_ensure_layout(Context *c) {
 }
 
 static int context_set_up_staging_area(Context *c) {
-        static const char *template = "/tmp/kernel-install.staging.XXXXXX";
         int r;
 
         assert(c);
@@ -818,12 +817,19 @@ static int context_set_up_staging_area(Context *c) {
         if (c->staging_area)
                 return 0;
 
-        if (c->action == ACTION_INSPECT) {
+        const char *d;
+        r = var_tmp_dir(&d);
+        if (r < 0)
+                return log_error_errno(r, "Failed to determine temporary directory location: %m");
+
+        _cleanup_free_ char *template = path_join(d, "kernel-install.staging.XXXXXX");
+        if (!template)
+                return log_oom();
+
+        if (c->action == ACTION_INSPECT)
                 /* This is only used for display. The directory will not be created. */
-                c->staging_area = strdup(template);
-                if (!c->staging_area)
-                        return log_oom();
-        } else {
+                c->staging_area = TAKE_PTR(template);
+        else {
                 r = mkdtemp_malloc(template, &c->staging_area);
                 if (r < 0)
                         return log_error_errno(r, "Failed to create staging area: %m");
index e904ee53758fd6daa3a028d4224dd6f4b978a63b..922c593e6008c54c55eed82ea182c047d395415e 100755 (executable)
@@ -318,7 +318,7 @@ diff -u <(echo "$output") - >&2 <<EOF
                "KERNEL_INSTALL_LAYOUT=other",
                "KERNEL_INSTALL_INITRD_GENERATOR=none",
                "KERNEL_INSTALL_UKI_GENERATOR=",
-               "KERNEL_INSTALL_STAGING_AREA=/tmp/kernel-install.staging.XXXXXX"
+               "KERNEL_INSTALL_STAGING_AREA=/var/tmp/kernel-install.staging.XXXXXX"
        ]
 }
 EOF