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