1 /* config.c - relay backend configuration file routine */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 2004-2006 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.
26 #include "back-relay.h"
36 relay_back_info *ri = (struct relay_back_info *)be->be_private;
39 Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
40 "%s: line %d: relay backend info is null.\n",
45 /* real naming context */
46 if ( strcasecmp( argv[ 0 ], "relay" ) == 0 ) {
47 struct berval dn, ndn, pdn;
53 if ( strcmp( argv[ 2 ], "massage" ) != 0 ) {
54 Log3( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
56 "unknown arg[#2]=\"%s\" "
57 "in \"relay <dn> [massage]\" line\n",
58 fname, lineno, argv[ 2 ] );
62 if ( be->be_nsuffix == NULL ) {
63 Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
65 "\"relay\" directive "
66 "must appear after \"suffix\".\n",
71 if ( !BER_BVISNULL( &be->be_nsuffix[ 1 ] ) ) {
72 Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
74 "relayng of multiple suffix "
75 "database not supported.\n",
85 Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
86 "%s: line %d: missing relay suffix "
87 "in \"relay <dn> [massage]\" line.\n",
92 Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
93 "%s: line %d: extra cruft "
94 "in \"relay <dn> [massage]\" line.\n",
99 if ( !BER_BVISNULL( &ri->ri_realsuffix ) ) {
100 Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
102 "relay dn already specified.\n",
107 dn.bv_val = argv[ 1 ];
108 dn.bv_len = strlen( argv[ 1 ] );
109 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
110 if ( rc != LDAP_SUCCESS ) {
111 Log3( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
113 "relay dn \"%s\" is invalid "
114 "in \"relay <dn> [massage]\" line\n",
115 fname, lineno, argv[ 1 ] );
119 bd = select_backend( &ndn, 0, 1 );
121 Log3( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
123 "cannot find database "
124 "of relay dn \"%s\" "
125 "in \"relay <dn> [massage]\" line\n",
126 fname, lineno, argv[ 1 ] );
130 } else if ( bd->be_private == be->be_private ) {
131 Log3( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
133 "relay dn \"%s\" would call self "
134 "in \"relay <dn> [massage]\" line\n",
135 fname, lineno, pdn.bv_val );
140 ri->ri_realsuffix = ndn;
145 if ( overlay_config( be, "rwm" ) ) {
146 Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
147 "%s: line %d: unable to install "
149 "in \"relay <dn> [massage]\" line\n",
155 cargv[ 0 ] = "rwm-suffixmassage";
156 cargv[ 1 ] = be->be_suffix[0].bv_val;
157 cargv[ 2 ] = pdn.bv_val;
160 rc = be->be_config( be, fname, lineno, 3, cargv );
164 ch_free( pdn.bv_val );
170 return SLAP_CONF_UNKNOWN;