]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9713 log fatal config errors at LDAP_DEBUG_ANY
authorHoward Chu <hyc@openldap.org>
Thu, 7 Oct 2021 16:11:53 +0000 (17:11 +0100)
committerHoward Chu <hyc@openldap.org>
Thu, 7 Oct 2021 16:11:53 +0000 (17:11 +0100)
and make sure logfile_only doesn't mute failures to open logfile

servers/slapd/config.c
servers/slapd/logging.c
servers/slapd/slapcommon.c

index 8b9ec0f5f09d326223a9e134bc0b0e6d2ccf0c0e..85a8eda5ec862a010b7c9e0cd0cea6eb3549451d 100644 (file)
@@ -383,7 +383,7 @@ int config_set_vals(ConfigTable *Conf, ConfigArgs *c) {
                        if ( !c->cr_msg[0] ) {
                                snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> handler exited with %d",
                                        c->argv[0], rc );
-                               Debug(LDAP_DEBUG_CONFIG, "%s: %s!\n",
+                               Debug( LDAP_DEBUG_ANY, "%s: %s!\n",
                                        c->log, c->cr_msg );
                        }
                        return(ARG_BAD_CONF);
@@ -398,7 +398,7 @@ int config_set_vals(ConfigTable *Conf, ConfigArgs *c) {
                else {
                        snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> offset is missing base pointer",
                                c->argv[0] );
-                       Debug(LDAP_DEBUG_CONFIG, "%s: %s!\n",
+                       Debug( LDAP_DEBUG_ANY, "%s: %s!\n",
                                c->log, c->cr_msg );
                        return(ARG_BAD_CONF);
                }
index cb0fe6f9747249f0d2b6516d8a9a687e9f57e52f..ce2d292b04433c151ef377a30ee57ed8fb5a2bb8 100644 (file)
@@ -118,22 +118,28 @@ int
 logfile_open( const char *path )
 {
        struct stat st;
-       int fd;
+       int fd, saved_errno;
 
        fd = open( path, O_CREAT|O_WRONLY, 0640 );
-       if ( fd < 0 )
-               return errno;
+       if ( fd < 0 ) {
+               saved_errno = errno;
+fail:
+               logfile_only = 0;       /* make sure something gets output */
+               return saved_errno;
+       }
 
        if ( fstat( fd, &st ) ) {
-               int saved_errno = errno;
+               saved_errno = errno;
                close( fd );
-               return saved_errno;
+               goto fail;
        }
 
        if ( !logfile_path[0] ) {
                logpathlen = strlen( path );
-               if ( logpathlen >= sizeof(logfile_path) )
-                       return ENAMETOOLONG;
+               if ( logpathlen >= sizeof(logfile_path) ) {
+                       saved_errno = ENAMETOOLONG;
+                       goto fail;
+               }
                strcpy( logfile_path, path );
                strcpy( logpaths[0], path );
                strcpy( logpaths[1], path );
index 8f471d27d105373607b15679e44887a0d5a50ac1..031962b132b13012c6ec0cb33ce287085cb0dda1 100644 (file)
@@ -574,6 +574,7 @@ slap_tool_init(
                        break;
                }
        }
+       slap_debug_orig = slap_debug;
 
 #if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG)
        if ( start_syslog ) {