1 /* config.c - relay backend configuration file routine */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 2003-2004 The OpenLDAP Foundation.
5 * Portions Copyright 2004 Pierangelo Masarati.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
17 * This work was initially developed by Pierangelo Masaratifor inclusion
18 * in OpenLDAP Software.
25 #include <ac/string.h>
26 #include <ac/socket.h>
29 #include "back-relay.h"
41 relay_back_info *ri = (struct relay_back_info *)be->be_private;
44 fprintf( stderr, "%s: line %d: relay backend info is null!\n",
49 /* real naming context */
50 if ( strcasecmp( argv[0], "relay" ) == 0 ) {
51 struct berval dn, ndn, pdn;
57 "%s: line %d: missing relay suffix in \"relay <dn>\" line\n",
62 dn.bv_val = argv[ 1 ];
63 dn.bv_len = strlen( argv[ 1 ] );
64 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
65 if ( rc != LDAP_SUCCESS ) {
66 fprintf( stderr, "%s: line %d: "
67 "relay dn \"%s\" is invalid\n",
68 fname, lineno, argv[ 1 ] );
72 ri->ri_bd = select_backend( &ndn, 0, 1 );
73 if ( ri->ri_bd == NULL ) {
74 fprintf( stderr, "%s: line %d: "
75 "cannot find database "
76 "of relay dn \"%s\"\n",
77 fname, lineno, argv[ 1 ] );
80 } else if ( ri->ri_bd == be ) {
81 fprintf( stderr, "%s: line %d: "
82 "relay dn \"%s\" would call self\n",
83 fname, lineno, pdn.bv_val );
87 if ( overlay_config( be, "rewrite-remap" ) ) {
88 fprintf( stderr, "unable to install "
89 "rewrite-remap overlay "
90 "in back-relay \"%s\" => \"%s\"\n",
91 be->be_suffix[0].bv_val,
92 ri->ri_bd->be_suffix[0].bv_val ?
93 ri->ri_bd->be_suffix[0].bv_val : "<unknown>" );
97 cargv[ 0 ] = "suffixmassage";
98 cargv[ 1 ] = be->be_suffix[0].bv_val;
99 cargv[ 2 ] = ri->ri_bd->be_suffix[0].bv_val;
102 if ( be->be_config( be, "back-relay", 1, 3, cargv ) ) {
108 return SLAP_CONF_UNKNOWN;