فهرست منبع

Ticket 47968 - Fix for issues with multiple log backends

Bug Description:

* Did not correctly use str formats in the output to journald_print
* Due to a change strcmp api, the values were not checked properly
* The default template did not have the correct backend value

Fix Description:
* Correctly use string formats to avoid compilation errors
* Fix the check for values of strcmp
* Fix the template to include dirsrv-log
* The rpm spec to include the correct systemd libraries

https://fedorahosted.org/389/ticket/47968

Author: wibrown

Review by: nhosoi (Thanks!)
William Brown 9 سال پیش
والد
کامیت
ef53e0c70c
3فایلهای تغییر یافته به همراه19 افزوده شده و 16 حذف شده
  1. 1 1
      ldap/ldif/template-dse.ldif.in
  2. 13 15
      ldap/servers/slapd/log.c
  3. 5 0
      rpm/389-ds-base.spec.in

+ 1 - 1
ldap/ldif/template-dse.ldif.in

@@ -62,7 +62,7 @@ nsslapd-ndn-cache-enabled: on
 nsslapd-sasl-mapping-fallback: off
 nsslapd-dynamic-plugins: off
 nsslapd-allow-hashed-passwords: off
-nsslapd-logging-backend: 1
+nsslapd-logging-backend: dirsrv-log
 
 dn: cn=features,cn=config
 objectclass: top

+ 13 - 15
ldap/servers/slapd/log.c

@@ -393,21 +393,18 @@ log_set_logging(const char *attrname, char *value, int logtype, char *errorbuf,
 int
 log_set_backend(const char *attrname, char *value, int logtype, char *errorbuf, int apply) {
 
-    int retval = LDAP_SUCCESS;
     int backend = 0;
     char *backendstr = NULL; /* The backend we are looking at */
     char *token = NULL; /* String to tokenise, need to dup value */
     char *next = NULL; /* The next value */
 
-
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
 
     /* We don't need to bother checking log type ... */
-    if ( !apply || !value || !*value ) {
-        return retval;
+    if ( !value || !*value ) {
+        return LDAP_OPERATIONS_ERROR;
     }
 
-
     /* We have a comma seperated list. So split it up */
     token = slapi_ch_strdup(value);
     for (backendstr = ldap_utf8strtok_r(token, ",", &next);
@@ -417,12 +414,12 @@ log_set_backend(const char *attrname, char *value, int logtype, char *errorbuf,
         if(strlen(backendstr) == 0) {
             /* Probably means someone did ",,"*/
             continue;
-        } else if (slapi_UTF8NCASECMP(backendstr, "dirsrv-log", 10) ) {
+        } else if (slapi_UTF8NCASECMP(backendstr, "dirsrv-log", 10) == 0 ) {
             backend |= LOGGING_BACKEND_INTERNAL;
-        } else if (slapi_UTF8NCASECMP(backendstr, "syslog", 6) ) {
+        } else if (slapi_UTF8NCASECMP(backendstr, "syslog", 6) == 0) {
             backend |= LOGGING_BACKEND_SYSLOG;
 #ifdef WITH_SYSTEMD
-        } else if (slapi_UTF8NCASECMP(backendstr, "journald", 8) ) {
+        } else if (slapi_UTF8NCASECMP(backendstr, "journald", 8) == 0 ) {
             backend |= LOGGING_BACKEND_JOURNALD;
 #endif
         }
@@ -436,20 +433,21 @@ log_set_backend(const char *attrname, char *value, int logtype, char *errorbuf,
 #endif
        ) {
         /* There is probably a better error here .... */
-        retval = LDAP_OPERATIONS_ERROR;
-    } else {
+        return LDAP_OPERATIONS_ERROR;
+    }
+    if ( apply ) {
         /* We have a valid backend, set it */
         /*
          * We just need to use any lock here, doesn't matter which. 
          */
-		LOG_ACCESS_LOCK_WRITE( );
+        LOG_ACCESS_LOCK_WRITE( );
         loginfo.log_backend = backend;
         slapi_ch_free_string(&(slapdFrontendConfig->logging_backend));
         slapdFrontendConfig->logging_backend = slapi_ch_strdup(value);
-		LOG_ACCESS_UNLOCK_WRITE( );
+        LOG_ACCESS_UNLOCK_WRITE( );
     }
 
-    return retval;
+    return LDAP_SUCCESS;
 }
 /******************************************************************************
 * Tell me  the access log file name inc path
@@ -1985,7 +1983,7 @@ slapd_log_audit (
     }
 #ifdef WITH_SYSTEMD
     if (lbackend & LOGGING_BACKEND_JOURNALD) {
-        retval = sd_journal_print(LOG_NOTICE, buffer);
+        retval = sd_journal_print(LOG_NOTICE, "%s", buffer);
     }
 #endif
     return retval;
@@ -2044,7 +2042,7 @@ slapd_log_auditfail (
     }
 #ifdef WITH_SYSTEMD
     if (lbackend & LOGGING_BACKEND_JOURNALD) {
-        retval = sd_journal_print(LOG_NOTICE, buffer);
+        retval = sd_journal_print(LOG_NOTICE, "%s", buffer);
     }
 #endif
     return retval;

+ 5 - 0
rpm/389-ds-base.spec.in

@@ -78,6 +78,7 @@ BuildRequires:    tcp_wrappers
 # the following is for the pam passthru auth plug-in
 BuildRequires:    pam-devel
 BuildRequires:    systemd-units
+BuildRequires:    systemd-devel
 
 # this is needed for using semanage from our setup scripts
 Requires:         policycoreutils-python
@@ -122,6 +123,7 @@ Requires:         perl-Socket6
 Requires:         perl-Socket
 %endif
 Requires:         perl-NetAddr-IP
+Requires:         systemd-libs
 
 Source0:          http://port389.org/sources/%{name}-%{version}%{?prerel}.tar.bz2
 # 389-ds-git.sh should be used to generate the source tarball from git
@@ -169,6 +171,7 @@ BuildRequires:    /usr/bin/xsltproc
 BuildRequires:    valgrind-devel
 %endif
 %endif
+BuildRequires:    systemd-devel
 
 %description      libs
 Core libraries for the 389 Directory Server base package.  These libraries
@@ -193,6 +196,8 @@ Requires:         libtalloc
 Requires:         libevent
 Requires:         libtevent
 %endif
+Requires:         systemd-libs
+
 
 %description      devel
 Development Libraries and headers for the 389 Directory Server base package.