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