From: dongshengyuan <545258830@qq.com> Date: Wed, 17 Jun 2026 03:00:49 +0000 (+0800) Subject: sysext,sysusers: fix wrong error variable in two error paths X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51d63dadd026e135d3fd8ace66fdda625587d3b1;p=thirdparty%2Fsystemd.git sysext,sysusers: fix wrong error variable in two error paths 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 Co-developed-by: Claude Opus 4.8 (1M context) --- diff --git a/src/sysext/sysext.c b/src/sysext/sysext.c index ce2468fafda..a617bd0f76b 100644 --- a/src/sysext/sysext.c +++ b/src/sysext/sysext.c @@ -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; } diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index c22dbbeda02..48d256b15c2 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -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;