]> git.sur5r.net Git - openldap/blob - servers/slapd/back-shell/modrdn.c
Minor cleanup
[openldap] / servers / slapd / back-shell / modrdn.c
1 /* modrdn.c - shell backend modrdn function */
2
3 #include <stdio.h>
4 #include <string.h>
5 #include <sys/types.h>
6 #include <sys/socket.h>
7 #include "slap.h"
8 #include "shell.h"
9
10 void
11 shell_back_modrdn(
12     Backend     *be,
13     Connection  *conn,
14     Operation   *op,
15     char        *dn,
16     char        *newrdn,
17     int         deleteoldrdn
18 )
19 {
20         struct shellinfo        *si = (struct shellinfo *) be->be_private;
21         FILE                    *rfp, *wfp;
22
23         if ( si->si_modrdn == NULL ) {
24                 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
25                     "modrdn not implemented" );
26                 return;
27         }
28
29         if ( (op->o_private = forkandexec( si->si_modrdn, &rfp, &wfp ))
30             == -1 ) {
31                 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
32                     "could not fork/exec" );
33                 return;
34         }
35
36         /* write out the request to the modrdn process */
37         fprintf( wfp, "MODRDN\n" );
38         fprintf( wfp, "msgid: %d\n", op->o_msgid );
39         print_suffixes( wfp, be );
40         fprintf( wfp, "dn: %s\n", dn );
41         fprintf( wfp, "newrdn: %s\n", newrdn );
42         fprintf( wfp, "deleteoldrdn: %d\n", deleteoldrdn ? 1 : 0 );
43         fclose( wfp );
44
45         /* read in the results and send them along */
46         read_and_send_results( be, conn, op, rfp, NULL, 0 );
47         fclose( rfp );
48 }