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