]> git.sur5r.net Git - openldap/blob - servers/slapd/back-shell/modrdn.c
Add OpenLDAP RCSid to *.[ch] in clients, libraries, and servers.
[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        *newrdn,
34     int         deleteoldrdn,
35     char        *newSuperior
36 )
37 {
38         struct shellinfo        *si = (struct shellinfo *) be->be_private;
39         FILE                    *rfp, *wfp;
40
41         if ( si->si_modrdn == NULL ) {
42                 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
43                     "modrdn not implemented", NULL, NULL );
44                 return( -1 );
45         }
46
47         if ( (op->o_private = (void *) forkandexec( si->si_modrdn, &rfp, &wfp ))
48             == (void *) -1 ) {
49                 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
50                     "could not fork/exec", NULL, NULL );
51                 return( -1 );
52         }
53
54         /* write out the request to the modrdn process */
55         fprintf( wfp, "MODRDN\n" );
56         fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
57         print_suffixes( wfp, be );
58         fprintf( wfp, "dn: %s\n", dn );
59         fprintf( wfp, "newrdn: %s\n", newrdn );
60         fprintf( wfp, "deleteoldrdn: %d\n", deleteoldrdn ? 1 : 0 );
61         if (newSuperior != NULL) {
62                 fprintf( wfp, "newSuperior: %s\n", newSuperior );
63         }
64         fclose( wfp );
65
66         /* read in the results and send them along */
67         read_and_send_results( be, conn, op, rfp, NULL, 0 );
68         fclose( rfp );
69         return( 0 );
70 }