]> git.sur5r.net Git - openldap/blob - servers/slapd/back-shell/bind.c
Per ITS#419, don't require SLAPD_RLOOKUPS when HAVE_TCPD
[openldap] / servers / slapd / back-shell / bind.c
1 /* bind.c - shell backend bind function */
2 /* $OpenLDAP$ */
3
4 #include "portable.h"
5
6 #include <stdio.h>
7
8 #include <ac/socket.h>
9 #include <ac/string.h>
10
11 #include "slap.h"
12 #include "shell.h"
13
14 int
15 shell_back_bind(
16     Backend             *be,
17     Connection          *conn,
18     Operation           *op,
19     char                *dn,
20     char                *ndn,
21     int                 method,
22         char            *mech,
23     struct berval       *cred,
24         char            **edn
25 )
26 {
27         struct shellinfo        *si = (struct shellinfo *) be->be_private;
28         FILE                    *rfp, *wfp;
29         int                     rc;
30
31         *edn = NULL;
32
33         if ( si->si_bind == NULL ) {
34                 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
35                     "bind not implemented", NULL, NULL );
36                 return( -1 );
37         }
38
39         if ( (op->o_private = (void *) forkandexec( si->si_bind, &rfp, &wfp ))
40             == (void *) -1 ) {
41                 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
42                     "could not fork/exec", NULL, NULL );
43                 return( -1 );
44         }
45
46         /* write out the request to the bind process */
47         fprintf( wfp, "BIND\n" );
48         fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
49         print_suffixes( wfp, be );
50         fprintf( wfp, "dn: %s\n", dn );
51         fprintf( wfp, "method: %d\n", method );
52         fprintf( wfp, "credlen: %lu\n", cred->bv_len );
53         fprintf( wfp, "cred: %s\n", cred->bv_val ); /* XXX */
54         fclose( wfp );
55
56         /* read in the results and send them along */
57         rc = read_and_send_results( be, conn, op, rfp, NULL, 0 );
58         fclose( rfp );
59
60         return( rc );
61 }