ITS#9713 log fatal config errors at LDAP_DEBUG_ANY

and make sure logfile_only doesn't mute failures to open logfile
This commit is contained in:
Howard Chu 2021-10-07 17:11:53 +01:00
parent 2995da7e8d
commit 7c20ca922f
3 changed files with 16 additions and 9 deletions

View file

@ -383,7 +383,7 @@ int config_set_vals(ConfigTable *Conf, ConfigArgs *c) {
if ( !c->cr_msg[0] ) { if ( !c->cr_msg[0] ) {
snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> handler exited with %d", snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> handler exited with %d",
c->argv[0], rc ); c->argv[0], rc );
Debug(LDAP_DEBUG_CONFIG, "%s: %s!\n", Debug( LDAP_DEBUG_ANY, "%s: %s!\n",
c->log, c->cr_msg ); c->log, c->cr_msg );
} }
return(ARG_BAD_CONF); return(ARG_BAD_CONF);
@ -398,7 +398,7 @@ int config_set_vals(ConfigTable *Conf, ConfigArgs *c) {
else { else {
snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> offset is missing base pointer", snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> offset is missing base pointer",
c->argv[0] ); c->argv[0] );
Debug(LDAP_DEBUG_CONFIG, "%s: %s!\n", Debug( LDAP_DEBUG_ANY, "%s: %s!\n",
c->log, c->cr_msg ); c->log, c->cr_msg );
return(ARG_BAD_CONF); return(ARG_BAD_CONF);
} }

View file

@ -118,22 +118,28 @@ int
logfile_open( const char *path ) logfile_open( const char *path )
{ {
struct stat st; struct stat st;
int fd; int fd, saved_errno;
fd = open( path, O_CREAT|O_WRONLY, 0640 ); fd = open( path, O_CREAT|O_WRONLY, 0640 );
if ( fd < 0 ) if ( fd < 0 ) {
return errno; saved_errno = errno;
fail:
logfile_only = 0; /* make sure something gets output */
return saved_errno;
}
if ( fstat( fd, &st ) ) { if ( fstat( fd, &st ) ) {
int saved_errno = errno; saved_errno = errno;
close( fd ); close( fd );
return saved_errno; goto fail;
} }
if ( !logfile_path[0] ) { if ( !logfile_path[0] ) {
logpathlen = strlen( path ); logpathlen = strlen( path );
if ( logpathlen >= sizeof(logfile_path) ) if ( logpathlen >= sizeof(logfile_path) ) {
return ENAMETOOLONG; saved_errno = ENAMETOOLONG;
goto fail;
}
strcpy( logfile_path, path ); strcpy( logfile_path, path );
strcpy( logpaths[0], path ); strcpy( logpaths[0], path );
strcpy( logpaths[1], path ); strcpy( logpaths[1], path );

View file

@ -574,6 +574,7 @@ slap_tool_init(
break; break;
} }
} }
slap_debug_orig = slap_debug;
#if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG) #if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG)
if ( start_syslog ) { if ( start_syslog ) {