1998-08-08 20:43:13 -04:00
|
|
|
/* unbind.c - shell backend unbind function */
|
1999-09-08 15:06:24 -04:00
|
|
|
/* $OpenLDAP$ */
|
2000-05-15 12:35:48 -04:00
|
|
|
/*
|
2003-01-03 15:20:47 -05:00
|
|
|
* Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
|
2000-05-15 12:35:48 -04:00
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
|
*/
|
1998-08-08 20:43:13 -04:00
|
|
|
|
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"
|
|
|
|
|
|
1999-02-05 04:03:47 -05:00
|
|
|
int
|
1998-08-08 20:43:13 -04:00
|
|
|
shell_back_unbind(
|
2003-03-30 04:03:54 -05:00
|
|
|
Operation *op,
|
|
|
|
|
SlapReply *rs
|
1998-08-08 20:43:13 -04:00
|
|
|
)
|
|
|
|
|
{
|
2003-03-30 04:03:54 -05:00
|
|
|
struct shellinfo *si = (struct shellinfo *) op->o_bd->be_private;
|
1998-08-08 20:43:13 -04:00
|
|
|
FILE *rfp, *wfp;
|
|
|
|
|
|
2002-10-10 16:28:36 -04:00
|
|
|
if ( si->si_unbind == NULL ) {
|
1999-02-05 04:03:47 -05:00
|
|
|
return 0;
|
1998-08-08 20:43:13 -04:00
|
|
|
}
|
|
|
|
|
|
1999-01-25 23:32:26 -05:00
|
|
|
if ( (op->o_private = (void *) forkandexec( si->si_unbind, &rfp, &wfp ))
|
|
|
|
|
== (void *) -1 ) {
|
1999-02-05 04:03:47 -05:00
|
|
|
return 0;
|
1998-08-08 20:43:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* write out the request to the unbind process */
|
|
|
|
|
fprintf( wfp, "UNBIND\n" );
|
1999-09-02 04:05:17 -04:00
|
|
|
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
|
2003-03-30 04:03:54 -05: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-08 20:43:13 -04:00
|
|
|
fclose( wfp );
|
|
|
|
|
|
|
|
|
|
/* no response to unbind */
|
|
|
|
|
fclose( rfp );
|
1999-02-05 04:03:47 -05:00
|
|
|
|
|
|
|
|
return 0;
|
1998-08-08 20:43:13 -04:00
|
|
|
}
|