]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tmpfile-util: make sure errno is left untouched by CLEANUP_TMPFILE_AT()
authorLennart Poettering <lennart@poettering.net>
Tue, 11 Nov 2025 10:35:45 +0000 (11:35 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 17 Nov 2025 15:53:31 +0000 (16:53 +0100)
This mimics how rm_rf_physical_and_free() operate, and we should do the
same here, and make clean-up error paths not touch errno needlessly.

src/basic/tmpfile-util.c

index c145e02221f5b4a32070138c46217ef0d19ba818..7eabc9c9007b8346782252c31948037366acd218 100644 (file)
@@ -447,7 +447,9 @@ void cleanup_tmpfile_data_done(struct cleanup_tmpfile_data *d) {
             !*d->filename)
                 return;
 
-        (void) unlinkat(*d->dir_fd, *d->filename, 0);
+        PROTECT_ERRNO;
+
+        (void) unlinkat(*d->dir_fd, *d->filename, /* flags= */ 0);
         d->dir_fd = NULL;
         d->filename = NULL;
 }