]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/config.c
Use defined Root DSE attributes.
[openldap] / servers / slapd / config.c
index f20979649e9ef35a147ac6257fa660a805167063..6c0c130378c35df67afa660baf2019836a999dde 100644 (file)
 #include <ac/string.h>
 #include <ac/ctype.h>
 #include <ac/socket.h>
+#include <ac/errno.h>
 
 #include "lutil.h"
 #include "ldap_pvt.h"
 #include "slap.h"
 
-#define MAXARGS        200
+#define MAXARGS        500
 
 /*
  * defaults for various global variables
@@ -85,16 +86,21 @@ read_config( const char *fname )
 
        if ( (fp = fopen( fname, "r" )) == NULL ) {
                ldap_syslog = 1;
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "config", LDAP_LEVEL_ENTRY, "read_config: "
+                       "could not open config file \"%s\": %s (%d)\n",
+                   fname, strerror(errno), errno ));
+#else
                Debug( LDAP_DEBUG_ANY,
-                   "could not open config file \"%s\" - absolute path?\n",
-                   fname, 0, 0 );
-               perror( fname );
+                   "could not open config file \"%s\": %s (%d)\n",
+                   fname, strerror(errno), errno );
+#endif
                return 1;
        }
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "config", LDAP_LEVEL_ENTRY,
-                  "read_config: reading config file %s\n", fname ));
+               "read_config: reading config file %s\n", fname ));
 #else
        Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
 #endif
@@ -1827,6 +1833,34 @@ read_config( const char *fname )
                                replogfile = ch_strdup( cargv[1] );
                        }
 
+               /* file from which to read additional rootdse attrs */
+               } else if ( strcasecmp( cargv[0], "rootdse" ) == 0) {
+                       if ( cargc < 2 ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
+                                       "missing filename in \"rootDSEfile <filename>\" line.\n",
+                                       fname, lineno ));
+#else
+                               Debug( LDAP_DEBUG_ANY, "%s: line %d: "
+                                       "missing filename in \"rootDSEfile <filename>\" line.\n",
+                                   fname, lineno, 0 );
+#endif
+                               return 1;
+                       }
+
+                       if( read_root_dse_file( cargv[1] ) ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
+                                       "could not read \"rootDSEfile <filename>\" line.\n",
+                                       fname, lineno ));
+#else
+                               Debug( LDAP_DEBUG_ANY, "%s: line %d: "
+                                       "could not read \"rootDSEfile <filename>\" line\n",
+                                   fname, lineno, 0 );
+#endif
+                               return 1;
+                       }
+
                /* maintain lastmodified{by,time} attributes */
                } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
                        if ( cargc < 2 ) {
@@ -2221,7 +2255,9 @@ fp_getline( FILE *fp, int *lineno )
        }
 
        while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
+               /* trim off \r\n or \n */
                if ( (p = strchr( buf, '\n' )) != NULL ) {
+                       if( p > buf && p[-1] == '\r' ) --p;
                        *p = '\0';
                }
                if ( ! isspace( (unsigned char) buf[0] ) ) {