|
|
4c04d8 |
From 177faf2c7080d3476798d305451e8ee19ea47f8d Mon Sep 17 00:00:00 2001
|
|
|
e79480 |
From: Mark Reynolds <mreynolds@redhat.com>
|
|
|
e79480 |
Date: Wed, 7 Aug 2019 16:57:17 -0400
|
|
|
e79480 |
Subject: [PATCH] Issue 50536 - Audit log heading written to log after every
|
|
|
e79480 |
update
|
|
|
e79480 |
|
|
|
e79480 |
Bug Description: Once the audit log is rotated the log "title" is incorrectly
|
|
|
e79480 |
written to the log after every single update. This happened
|
|
|
e79480 |
becuase when we udpated the state of the log it was applied
|
|
|
e79480 |
to a local variable, and not the log info structure itself.
|
|
|
e79480 |
|
|
|
e79480 |
Fix Description: After writting the "title", update the state of the log using
|
|
|
e79480 |
a pointer to the log info structure.
|
|
|
e79480 |
|
|
|
e79480 |
relates: https://pagure.io/389-ds-base/issue/50536
|
|
|
e79480 |
|
|
|
e79480 |
Reviewed by: lkrispenz(Thanks!)
|
|
|
e79480 |
---
|
|
|
e79480 |
ldap/servers/slapd/log.c | 14 +++++++-------
|
|
|
e79480 |
ldap/servers/slapd/proto-slap.h | 2 +-
|
|
|
e79480 |
2 files changed, 8 insertions(+), 8 deletions(-)
|
|
|
e79480 |
|
|
|
e79480 |
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
|
|
|
e79480 |
index 2456abf1e..f308a4813 100644
|
|
|
e79480 |
--- a/ldap/servers/slapd/log.c
|
|
|
e79480 |
+++ b/ldap/servers/slapd/log.c
|
|
|
e79480 |
@@ -2073,11 +2073,11 @@ slapd_log_audit(
|
|
|
e79480 |
int retval = LDAP_SUCCESS;
|
|
|
e79480 |
int lbackend = loginfo.log_backend; /* We copy this to make these next checks atomic */
|
|
|
e79480 |
|
|
|
e79480 |
- int state = 0;
|
|
|
e79480 |
+ int *state;
|
|
|
e79480 |
if (sourcelog == SLAPD_AUDIT_LOG) {
|
|
|
e79480 |
- state = loginfo.log_audit_state;
|
|
|
e79480 |
+ state = &loginfo.log_audit_state;
|
|
|
e79480 |
} else if (sourcelog == SLAPD_AUDITFAIL_LOG) {
|
|
|
e79480 |
- state = loginfo.log_auditfail_state;
|
|
|
e79480 |
+ state = &loginfo.log_auditfail_state;
|
|
|
e79480 |
} else {
|
|
|
e79480 |
/* How did we even get here! */
|
|
|
e79480 |
return 1;
|
|
|
e79480 |
@@ -2106,9 +2106,9 @@ int
|
|
|
e79480 |
slapd_log_audit_internal(
|
|
|
e79480 |
char *buffer,
|
|
|
e79480 |
int buf_len,
|
|
|
e79480 |
- int state)
|
|
|
e79480 |
+ int *state)
|
|
|
e79480 |
{
|
|
|
e79480 |
- if ((state & LOGGING_ENABLED) && (loginfo.log_audit_file != NULL)) {
|
|
|
e79480 |
+ if ((*state & LOGGING_ENABLED) && (loginfo.log_audit_file != NULL)) {
|
|
|
e79480 |
LOG_AUDIT_LOCK_WRITE();
|
|
|
e79480 |
if (log__needrotation(loginfo.log_audit_fdes,
|
|
|
e79480 |
SLAPD_AUDIT_LOG) == LOG_ROTATE) {
|
|
|
e79480 |
@@ -2122,9 +2122,9 @@ slapd_log_audit_internal(
|
|
|
e79480 |
loginfo.log_audit_rotationsyncclock += PR_ABS(loginfo.log_audit_rotationtime_secs);
|
|
|
e79480 |
}
|
|
|
e79480 |
}
|
|
|
e79480 |
- if (state & LOGGING_NEED_TITLE) {
|
|
|
e79480 |
+ if (*state & LOGGING_NEED_TITLE) {
|
|
|
e79480 |
log_write_title(loginfo.log_audit_fdes);
|
|
|
e79480 |
- state &= ~LOGGING_NEED_TITLE;
|
|
|
e79480 |
+ *state &= ~LOGGING_NEED_TITLE;
|
|
|
e79480 |
}
|
|
|
e79480 |
LOG_WRITE_NOW_NO_ERR(loginfo.log_audit_fdes, buffer, buf_len, 0);
|
|
|
e79480 |
LOG_AUDIT_UNLOCK_WRITE();
|
|
|
e79480 |
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
|
|
|
e79480 |
index a0648ca3c..e37f702ea 100644
|
|
|
e79480 |
--- a/ldap/servers/slapd/proto-slap.h
|
|
|
e79480 |
+++ b/ldap/servers/slapd/proto-slap.h
|
|
|
e79480 |
@@ -777,7 +777,7 @@ int slapi_log_access(int level, char *fmt, ...)
|
|
|
e79480 |
;
|
|
|
e79480 |
#endif
|
|
|
e79480 |
int slapd_log_audit(char *buffer, int buf_len, int sourcelog);
|
|
|
e79480 |
-int slapd_log_audit_internal(char *buffer, int buf_len, int state);
|
|
|
e79480 |
+int slapd_log_audit_internal(char *buffer, int buf_len, int *state);
|
|
|
e79480 |
int slapd_log_auditfail(char *buffer, int buf_len);
|
|
|
e79480 |
int slapd_log_auditfail_internal(char *buffer, int buf_len);
|
|
|
e79480 |
void log_access_flush(void);
|
|
|
e79480 |
--
|
|
|
e79480 |
2.21.0
|
|
|
e79480 |
|