]> git.sur5r.net Git - openldap/blob - servers/slapd/back-shell/delete.c
Per ITS#419, don't require SLAPD_RLOOKUPS when HAVE_TCPD
[openldap] / servers / slapd / back-shell / delete.c
1 /* delete.c - shell backend delete 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_delete(
16     Backend     *be,
17     Connection  *conn,
18     Operation   *op,
19     char        *dn,
20     char        *ndn
21 )
22 {
23         struct shellinfo        *si = (struct shellinfo *) be->be_private;
24         FILE                    *rfp, *wfp;
25
26         if ( si->si_delete == NULL ) {
27                 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
28                     "delete not implemented", NULL, NULL );
29                 return( -1 );
30         }
31
32         if ( (op->o_private = (void *) forkandexec( si->si_delete, &rfp, &wfp ))
33             == (void *) -1 ) {
34                 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
35                     "could not fork/exec", NULL, NULL );
36                 return( -1 );
37         }
38
39         /* write out the request to the delete process */
40         fprintf( wfp, "DELETE\n" );
41         fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
42         print_suffixes( wfp, be );
43         fprintf( wfp, "dn: %s\n", dn );
44         fclose( wfp );
45
46         /* read in the results and send them along */
47         read_and_send_results( be, conn, op, rfp, NULL, 0 );
48         fclose( rfp );
49         return( 0 );
50 }