From 21f449f1164507962bfceaa456c30186f97737f6 Mon Sep 17 00:00:00 2001 From: Noriko Hosoi Date: Fri, 13 Mar 2009 20:35:37 +0000 Subject: Resolves: #490027 Summary: log module issues unnecessary/inaccurate syslog errors Description: 1) don't log "Exceeded max number of logs allowed" in syslog messages. It's an info level log, which is not appropriate to log in syslog messages. 2) when deleting an error log file failed, a wrong file name (audit log) was printed. I also added the error code and the message why the deletion failed. --- ldap/servers/slapd/log.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'ldap/servers/slapd/log.c') diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c index bf39e356..cb23748c 100644 --- a/ldap/servers/slapd/log.c +++ b/ldap/servers/slapd/log.c @@ -3104,7 +3104,6 @@ log__delete_error_logfile(int locked) */ if (++numoflogs > loginfo.log_error_maxnumlogs) { logstr = "Exceeded max number of logs allowed"; - syslog(LOG_ERR, "%s\n", logstr); goto delete_logfile; } @@ -3184,6 +3183,8 @@ delete_logfile: return 0; } } + memset(tbuf, 0, sizeof(tbuf)); + log_convert_time (delete_logp->l_ctime, tbuf, 1 /*short */); if (!locked) { /* if locked, we should not call LDAPDebug, which tries to get a lock internally. */ @@ -3201,14 +3202,15 @@ delete_logfile: } /* Delete the error file */ - log_convert_time (delete_logp->l_ctime, tbuf, 1 /*short */); PR_snprintf (buffer, sizeof(buffer), "%s.%s", loginfo.log_error_file, tbuf); if (PR_Delete(buffer) != PR_SUCCESS) { + PRErrorCode prerr = PR_GetError(); /* This function could be called in the ERROR WRITE LOCK, * which causes the self deadlock if you call LDAPDebug for logging. * Thus, instead of LDAPDebug, call log__error_emergency with locked == 1. */ - PR_snprintf(buffer, sizeof(buffer), "LOGINFO:Unable to remove file:%s.%s\n", - loginfo.log_audit_file, tbuf); + PR_snprintf(buffer, sizeof(buffer), + "LOGINFO:Unable to remove file:%s.%s error %d (%s)\n", + loginfo.log_error_file, tbuf, prerr, slapd_pr_strerror(prerr)); log__error_emergency(buffer, 0, locked); } slapi_ch_free((void**)&delete_logp); -- cgit