exec-invoke: fix wrong errno in log_error_errno for setenv failure
When setenv("CREDENTIALS_DIRECTORY") fails, log_error_errno() was
called with the stale return value of exec_context_get_credential_directory()
(which is >= 0 on success) instead of errno.
The %m in the format string correctly expands from libc's errno, so
the human-readable log message was unaffected. However, the structured
journal field ERRNO= received an incorrect value (0 or positive),
making automated log analysis and alerting on this failure unreliable.
Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
This commit is contained in:
@@ -1090,7 +1090,7 @@ static int ask_password_conv(
|
||||
|
||||
if (creds_dir) {
|
||||
if (setenv("CREDENTIALS_DIRECTORY", creds_dir, /* overwrite= */ true) < 0)
|
||||
return log_error_errno(r, "Failed to set $CREDENTIALS_DIRECTORY: %m");
|
||||
return log_error_errno(errno, "Failed to set $CREDENTIALS_DIRECTORY: %m");
|
||||
} else
|
||||
(void) unsetenv("CREDENTIALS_DIRECTORY");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user