openldap/servers/slapd/back-shell/modrdn.c

52 lines
1.1 KiB
C
Raw Normal View History

1998-08-08 20:43:13 -04:00
/* modrdn.c - shell backend modrdn function */
1998-10-24 21:41:42 -04:00
#include "portable.h"
1998-08-08 20:43:13 -04:00
#include <stdio.h>
1998-10-24 21:41:42 -04:00
#include <ac/socket.h>
#include <ac/string.h>
1998-08-08 20:43:13 -04:00
#include "slap.h"
#include "shell.h"
void
shell_back_modrdn(
Backend *be,
Connection *conn,
Operation *op,
char *dn,
char *newrdn,
int deleteoldrdn
)
{
struct shellinfo *si = (struct shellinfo *) be->be_private;
FILE *rfp, *wfp;
if ( si->si_modrdn == NULL ) {
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
"modrdn not implemented" );
return;
}
if ( (op->o_private = forkandexec( si->si_modrdn, &rfp, &wfp ))
== -1 ) {
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
"could not fork/exec" );
return;
}
/* write out the request to the modrdn process */
fprintf( wfp, "MODRDN\n" );
fprintf( wfp, "msgid: %d\n", op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn );
fprintf( wfp, "newrdn: %s\n", newrdn );
fprintf( wfp, "deleteoldrdn: %d\n", deleteoldrdn ? 1 : 0 );
fclose( wfp );
/* read in the results and send them along */
read_and_send_results( be, conn, op, rfp, NULL, 0 );
fclose( rfp );
}