1998-08-09 08:43:13 +08:00
|
|
|
/* unbind.c - shell backend unbind function */
|
1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
2000-05-16 00:35:48 +08:00
|
|
|
/*
|
2003-01-04 04:20:47 +08:00
|
|
|
* Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
|
2000-05-16 00:35:48 +08:00
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
*/
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#include "portable.h"
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
#include <stdio.h>
|
1998-10-25 09:41:42 +08:00
|
|
|
|
|
|
|
#include <ac/socket.h>
|
|
|
|
#include <ac/string.h>
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
#include "slap.h"
|
|
|
|
#include "shell.h"
|
|
|
|
|
1999-02-05 17:03:47 +08:00
|
|
|
int
|
1998-08-09 08:43:13 +08:00
|
|
|
shell_back_unbind(
|
2003-03-30 17:03:54 +08:00
|
|
|
Operation *op,
|
|
|
|
SlapReply *rs
|
1998-08-09 08:43:13 +08:00
|
|
|
)
|
|
|
|
{
|
2003-03-30 17:03:54 +08:00
|
|
|
struct shellinfo *si = (struct shellinfo *) op->o_bd->be_private;
|
1998-08-09 08:43:13 +08:00
|
|
|
FILE *rfp, *wfp;
|
|
|
|
|
2002-10-11 04:28:36 +08:00
|
|
|
if ( si->si_unbind == NULL ) {
|
1999-02-05 17:03:47 +08:00
|
|
|
return 0;
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
|
2003-06-04 01:31:25 +08:00
|
|
|
if ( forkandexec( si->si_unbind, &rfp, &wfp ) == (pid_t)-1 ) {
|
1999-02-05 17:03:47 +08:00
|
|
|
return 0;
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* write out the request to the unbind process */
|
|
|
|
fprintf( wfp, "UNBIND\n" );
|
1999-09-02 16:05:17 +08:00
|
|
|
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
|
2003-03-30 17:03:54 +08:00
|
|
|
print_suffixes( wfp, op->o_bd );
|
|
|
|
fprintf( wfp, "dn: %s\n", (op->o_conn->c_dn.bv_len ? op->o_conn->c_dn.bv_val : "") );
|
1998-08-09 08:43:13 +08:00
|
|
|
fclose( wfp );
|
|
|
|
|
|
|
|
/* no response to unbind */
|
|
|
|
fclose( rfp );
|
1999-02-05 17:03:47 +08:00
|
|
|
|
|
|
|
return 0;
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|