#50537 Issue 50536 - Audit log heading written to log after every update
Closed 3 years ago by spichugi. Opened 4 years ago by mreynolds.
mreynolds/389-ds-base cockpit-logging  into  master

file modified
+7 -7
@@ -2071,11 +2071,11 @@ 

      int retval = LDAP_SUCCESS;

      int lbackend = loginfo.log_backend; /* We copy this to make these next checks atomic */

  

-     int state = 0;

+     int *state;

      if (sourcelog == SLAPD_AUDIT_LOG) {

-         state = loginfo.log_audit_state;

+         state = &loginfo.log_audit_state;

      } else if (sourcelog == SLAPD_AUDITFAIL_LOG) {

-         state = loginfo.log_auditfail_state;

+         state = &loginfo.log_auditfail_state;

      } else {

          /* How did we even get here! */

          return 1;
@@ -2104,9 +2104,9 @@ 

  slapd_log_audit_internal(

      char *buffer,

      int buf_len,

-     int state)

+     int *state)

  {

-     if ((state & LOGGING_ENABLED) && (loginfo.log_audit_file != NULL)) {

+     if ((*state & LOGGING_ENABLED) && (loginfo.log_audit_file != NULL)) {

          LOG_AUDIT_LOCK_WRITE();

          if (log__needrotation(loginfo.log_audit_fdes,

                                SLAPD_AUDIT_LOG) == LOG_ROTATE) {
@@ -2120,9 +2120,9 @@ 

                  loginfo.log_audit_rotationsyncclock += PR_ABS(loginfo.log_audit_rotationtime_secs);

              }

          }

-         if (state & LOGGING_NEED_TITLE) {

+         if (*state & LOGGING_NEED_TITLE) {

              log_write_title(loginfo.log_audit_fdes);

-             state &= ~LOGGING_NEED_TITLE;

+             *state &= ~LOGGING_NEED_TITLE;

          }

          LOG_WRITE_NOW_NO_ERR(loginfo.log_audit_fdes, buffer, buf_len, 0);

          LOG_AUDIT_UNLOCK_WRITE();

@@ -791,7 +791,7 @@ 

      ;

  #endif

  int slapd_log_audit(char *buffer, int buf_len, int sourcelog);

- int slapd_log_audit_internal(char *buffer, int buf_len, int state);

+ int slapd_log_audit_internal(char *buffer, int buf_len, int *state);

  int slapd_log_auditfail(char *buffer, int buf_len);

  int slapd_log_auditfail_internal(char *buffer, int buf_len);

  void log_access_flush(void);

@@ -521,7 +521,7 @@ 

              <label for="nsslapd-accesslog-logrotationtime" class="ds-config-sub-label" title="Access log rotation time settings (nsslapd-accesslog-logrotationtime).">Create New Log Every...</label><input

                class="ds-input" type="text" id="nsslapd-accesslog-logrotationtime" size="40"/> <select class="btn btn-default dropdown" id="nsslapd-accesslog-logrotationtimeunit">

                  <option>minute</option>

-                 <option>hours</option>

+                 <option>hour</option>

                  <option>day</option>

                  <option>week</option>

                  <option>month</option>
@@ -610,7 +610,7 @@ 

            <label for="nsslapd-auditlog-logrotationtime" class="ds-config-sub-label" title="Audit log rotation time settings (nsslapd-auditlog-logrotationtime).">Create New Log Every...</label><input

              class="ds-input" type="text" id="nsslapd-auditlog-logrotationtime" size="40"/> <select class="btn btn-default dropdown" id="nsslapd-auditlog-logrotationtimeunit">

                <option>minute</option>

-               <option>hours</option>

+               <option>hour</option>

                <option>day</option>

                <option>week</option>

                <option>month</option>
@@ -669,7 +669,7 @@ 

            <label for="nsslapd-auditfaillog-logrotationtime" class="ds-config-sub-label" title="Audit failure log rotation time settings (nsslapd-auditlog-logrotationtime).">Create New Log Every...</label><input

              class="ds-input" type="text" id="nsslapd-auditfaillog-logrotationtime" size="40"/> <select class="btn btn-default dropdown" id="nsslapd-auditfaillog-logrotationtimeunit">

                <option>minute</option>

-               <option>hours</option>

+               <option>hour</option>

                <option>day</option>

                <option>week</option>

                <option>month</option>
@@ -726,7 +726,7 @@ 

            <label for="nsslapd-errorlog-logrotationtime" class="ds-config-sub-label" title="Errors log rotation time settings (nsslapd-errorlog-logrotationtime).">Create New Log Every...</label><input

              class="ds-input" type="text" id="nsslapd-errorlog-logrotationtime" size="40"/> <select class="btn btn-default dropdown" id="nsslapd-errorlog-logrotationtimeunit">

                <option>minute</option>

-               <option>hours</option>

+               <option>hour</option>

                <option>day</option>

                <option>week</option>

                <option>month</option>

Bug Description:

Once the audit log is rotated the log "title" is incorrectly written to the log after every single update. This happened because when we updated the state of the log it was applied to a local variable, and not the log info structure itself.

Fix Description:

After writing the "title", update the state of the log using a pointer to the log info structure.

relates: https://pagure.io/389-ds-base/issue/50536

rebased onto 71d7ca0

4 years ago

Pull-Request has been merged by mreynolds

4 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/3593

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago