]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sysext,sysusers: fix wrong error variable in two error paths
authordongshengyuan <545258830@qq.com>
Wed, 17 Jun 2026 03:00:49 +0000 (11:00 +0800)
committerLennart Poettering <lennart@poettering.net>
Wed, 17 Jun 2026 06:32:51 +0000 (08:32 +0200)
sysext: utimensat() failure was logged with stale r (which is 0 after
the preceding successful write_backing_file call). Pass errno instead
so the actual failure reason is recorded and returned.

sysusers: rename() failure in make_backup() returned the raw positive
errno value. All callers check 'if (r < 0)', so the error was silently
ignored, allowing execution to continue after a failed backup. Return
-errno instead.

Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
Co-developed-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
src/sysext/sysext.c
src/sysusers/sysusers.c

index ce2468fafdac09c79ca822ae4be7b06c581a0872..a617bd0f76b493e9279832b97469afb7019fa147 100644 (file)
@@ -1395,7 +1395,7 @@ static int store_info_in_meta(
 
         /* Make sure the top-level dir has an mtime marking the point we established the merge */
         if (utimensat(AT_FDCWD, meta_path, NULL, AT_SYMLINK_NOFOLLOW) < 0)
-                return log_error_errno(r, "Failed to fix mtime of '%s': %m", meta_path);
+                return log_error_errno(errno, "Failed to fix mtime of '%s': %m", meta_path);
 
         return 0;
 }
index c22dbbeda0236f4db944ece43cc4366e338175ff..48d256b15c23bb0bb03d5d510bc990ff6bafc354 100644 (file)
@@ -352,7 +352,7 @@ static int make_backup(const char *target, const char *x) {
                 return r;
 
         if (rename(dst_tmp, backup) < 0)
-                return errno;
+                return -errno;
 
         dst_tmp = mfree(dst_tmp); /* disable the unlink_and_freep() hook now that the file has been renamed */
         return 0;