From 395207029b103f7790046b231dfb02e84c10a1f4 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Thu, 14 Jul 2005 18:03:29 +0000 Subject: [PATCH] need a regular file (ITS#3865) --- servers/slapd/config.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 9a0c798429..fa3a2c2e24 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -34,6 +34,10 @@ #include #include +#include +#include +#include + #include "slap.h" #ifdef LDAP_SLAPI #include "slapi/slapi.h" @@ -549,6 +553,7 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft) ConfigTable *ct; ConfigArgs *c; int rc; + struct stat s; c = ch_calloc( 1, sizeof( ConfigArgs ) ); if ( c == NULL ) { @@ -567,6 +572,22 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft) c->fname = fname; init_config_argv( c ); + if ( stat( fname, &s ) != 0 ) { + ldap_syslog = 1; + Debug(LDAP_DEBUG_ANY, + "could not stat config file \"%s\": %s (%d)\n", + fname, strerror(errno), errno); + return(1); + } + + if ( !S_ISREG( s.st_mode ) ) { + ldap_syslog = 1; + Debug(LDAP_DEBUG_ANY, + "regular file expected, got \"%s\"\n", + fname, 0, 0 ); + return(1); + } + fp = fopen( fname, "r" ); if ( fp == NULL ) { ldap_syslog = 1;