]> git.sur5r.net Git - openldap/commitdiff
don't allow multiple relay lines (ITS#4322)
authorPierangelo Masarati <ando@openldap.org>
Tue, 10 Jan 2006 20:30:35 +0000 (20:30 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 10 Jan 2006 20:30:35 +0000 (20:30 +0000)
servers/slapd/back-relay/config.c

index 83b9719877a35610e25f76db647179fecbc3df27..c893be6d5315c3343895d676987298af1ed8c584 100644 (file)
@@ -31,14 +31,14 @@ relay_back_db_config(
        const char      *fname,
        int             lineno,
        int             argc,
-       char            **argv
-)
+       char            **argv )
 {
        relay_back_info *ri = (struct relay_back_info *)be->be_private;
 
        if ( ri == NULL ) {
-               fprintf( stderr, "%s: line %d: relay backend info is null!\n",
-                   fname, lineno );
+               Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
+                       "%s: line %d: relay backend info is null.\n",
+                       fname, lineno );
                return 1;
        }
 
@@ -49,15 +49,24 @@ relay_back_db_config(
                BackendDB       *bd;
 
                if ( argc < 2 ) {
-                       fprintf( stderr,
-       "%s: line %d: missing relay suffix in \"relay <dn> [massage]\" line\n",
-                           fname, lineno );
+                       Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
+                               "%s: line %d: missing relay suffix "
+                               "in \"relay <dn> [massage]\" line.\n",
+                               fname, lineno );
                        return 1;
 
                } else if ( argc > 3 ) {
-                       fprintf( stderr,
-       "%s: line %d: too many args in \"relay <dn> [massage]\" line\n",
-                           fname, lineno );
+                       Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
+                               "%s: line %d: extra cruft in \"relay <dn> [massage]\" line.\n",
+                               fname, lineno );
+                       return 1;
+               }
+
+               if ( !BER_BVISNULL( &ri->ri_realsuffix ) ) {
+                       Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
+                               "%s: line %d: "
+                               "relay dn already specified.\n",
+                               fname, lineno );
                        return 1;
                }
 
@@ -65,37 +74,41 @@ relay_back_db_config(
                dn.bv_len = strlen( argv[ 1 ] );
                rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
                if ( rc != LDAP_SUCCESS ) {
-                       fprintf( stderr, "%s: line %d: "
-                                       "relay dn \"%s\" is invalid "
-                                       "in \"relay <dn> [massage]\" line\n",
-                                       fname, lineno, argv[ 1 ] );
+                       Log3( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
+                               "%s: line %d: "
+                               "relay dn \"%s\" is invalid "
+                               "in \"relay <dn> [massage]\" line\n",
+                               fname, lineno, argv[ 1 ] );
                        return 1;
                }
 
                bd = select_backend( &ndn, 0, 1 );
                if ( bd == NULL ) {
-                       fprintf( stderr, "%s: line %d: "
-                                       "cannot find database "
-                                       "of relay dn \"%s\" "
-                                       "in \"relay <dn> [massage]\" line\n",
-                                       fname, lineno, argv[ 1 ] );
+                       Log3( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
+                               "%s: line %d: "
+                               "cannot find database "
+                               "of relay dn \"%s\" "
+                               "in \"relay <dn> [massage]\" line\n",
+                               fname, lineno, argv[ 1 ] );
                        return 1;
 
                } else if ( bd == be ) {
-                       fprintf( stderr, "%s: line %d: "
-                                       "relay dn \"%s\" would call self "
-                                       "in \"relay <dn> [massage]\" line\n",
-                                       fname, lineno, pdn.bv_val );
+                       Log3( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
+                               "%s: line %d: "
+                               "relay dn \"%s\" would call self "
+                               "in \"relay <dn> [massage]\" line\n",
+                               fname, lineno, pdn.bv_val );
                        return 1;
                }
 
                ri->ri_realsuffix = ndn;
 
                if ( overlay_config( be, "rwm" ) ) {
-                       fprintf( stderr, "%s: line %d: unable to install "
-                                       "rwm overlay "
-                                       "in \"relay <dn> [massage]\" line\n",
-                                       fname, lineno );
+                       Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
+                               "%s: line %d: unable to install "
+                               "rwm overlay "
+                               "in \"relay <dn> [massage]\" line\n",
+                               fname, lineno );
                        return 1;
                }
 
@@ -103,10 +116,11 @@ relay_back_db_config(
                        char    *cargv[ 4 ];
 
                        if ( strcmp( argv[2], "massage" ) != 0 ) {
-                               fprintf( stderr, "%s: line %d: "
+                               Log3( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
+                                       "%s: line %d: "
                                        "unknown directive \"%s\" "
                                        "in \"relay <dn> [massage]\" line\n",
-                                       fname, lineno, argv[2] );
+                                       fname, lineno, argv[ 2 ] );
                                return 1;
                        }