pam_systemd: fix OSC write failure message appearing in error logs

Create and use new function pam_debug_syslog_errno() instead to ensure the
message only appears when debug mode is enabled. Pass the debug flag to
open_osc_context() and close_osc_context() to support this change.
This commit is contained in:
val4oss
2025-11-20 11:43:01 +01:00
parent bc9dc63f4f
commit 6c32492932
2 changed files with 15 additions and 8 deletions
+8 -1
View File
@@ -35,13 +35,20 @@ int pam_syslog_errno(pam_handle_t *handle, int level, int error, const char *for
int pam_syslog_pam_error(pam_handle_t *handle, int level, int error, const char *format, ...) _printf_(4,5);
/* Call pam_vsyslog if debug is enabled */
/* Call sym_pam_syslog if debug is enabled */
#define pam_debug_syslog(handle, debug, fmt, ...) \
({ \
if (debug) \
sym_pam_syslog(handle, LOG_DEBUG, fmt, ## __VA_ARGS__); \
})
/* Call pam_syslog_errno if debug is enabled */
#define pam_debug_syslog_errno(handle, debug, error, fmt, ...) \
({ \
if (debug) \
pam_syslog_errno(handle, LOG_DEBUG, error, fmt, ## __VA_ARGS__); \
})
static inline int pam_log_oom(pam_handle_t *handle) {
/* This is like log_oom(), but uses PAM logging */
return pam_syslog_errno(handle, LOG_ERR, ENOMEM, "Out of memory.");