]> git.sur5r.net Git - openldap/blob - servers/slapd/back-shell/modrdn.c
Per ITS#419, don't require SLAPD_RLOOKUPS when HAVE_TCPD
[openldap] / servers / slapd / back-shell / modrdn.c
1 /* modrdn.c - shell backend modrdn function */
2 /* $OpenLDAP$ */
3
4 /*
5  * LDAP v3 newSuperior support.
6  *
7  * Copyright 1999, Juan C. Gomez, All rights reserved.
8  * This software is not subject to any license of Silicon Graphics 
9  * Inc. or Purdue University.
10  *
11  * Redistribution and use in source and binary forms are permitted
12  * without restriction or fee of any kind as long as this notice
13  * is preserved.
14  *
15  */
16
17 #include "portable.h"
18
19 #include <stdio.h>
20
21 #include <ac/socket.h>
22 #include <ac/string.h>
23
24 #include "slap.h"
25 #include "shell.h"
26
27 int
28 shell_back_modrdn(
29     Backend     *be,
30     Connection  *conn,
31     Operation   *op,
32     char        *dn,
33     char        *ndn,
34     char        *newrdn,
35     int         deleteoldrdn,
36     char        *newSuperior
37 )
38 {
39         struct shellinfo        *si = (struct shellinfo *) be->be_private;
40         FILE                    *rfp, *wfp;
41
42         if ( si->si_modrdn == NULL ) {
43                 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
44                     "modrdn not implemented", NULL, NULL );
45                 return( -1 );
46         }
47
48         if ( (op->o_private = (void *) forkandexec( si->si_modrdn, &rfp, &wfp ))
49             == (void *) -1 ) {
50                 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
51                     "could not fork/exec", NULL, NULL );
52                 return( -1 );
53         }
54
55         /* write out the request to the modrdn process */
56         fprintf( wfp, "MODRDN\n" );
57         fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
58         print_suffixes( wfp, be );
59         fprintf( wfp, "dn: %s\n", dn );
60         fprintf( wfp, "newrdn: %s\n", newrdn );
61         fprintf( wfp, "deleteoldrdn: %d\n", deleteoldrdn ? 1 : 0 );
62         if (newSuperior != NULL) {
63                 fprintf( wfp, "newSuperior: %s\n", newSuperior );
64         }
65         fclose( wfp );
66
67         /* read in the results and send them along */
68         read_and_send_results( be, conn, op, rfp, NULL, 0 );
69         fclose( rfp );
70         return( 0 );
71 }