1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
1999-02-18 10:18:39 +08:00
|
|
|
/* unbind.c - tcl unbind routines
|
1999-02-15 03:20:14 +08:00
|
|
|
*
|
|
|
|
* Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms are permitted only
|
|
|
|
* as authorized by the OpenLDAP Public License. A copy of this
|
|
|
|
* license is available at http://www.OpenLDAP.org/license.html or
|
|
|
|
* in file LICENSE in the top-level directory of the distribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "slap.h"
|
|
|
|
#include "tcl_back.h"
|
|
|
|
|
1999-02-18 10:18:39 +08:00
|
|
|
int
|
|
|
|
tcl_back_unbind (
|
2003-03-30 17:03:54 +08:00
|
|
|
Operation * op,
|
|
|
|
SlapReply * rs
|
1999-02-15 03:20:14 +08:00
|
|
|
)
|
|
|
|
{
|
2002-04-08 17:43:22 +08:00
|
|
|
char *command, *results;
|
|
|
|
struct berval suf_tcl;
|
|
|
|
int code, err = 0;
|
2003-03-30 17:03:54 +08:00
|
|
|
struct tclinfo *ti = (struct tclinfo *) op->o_bd->be_private;
|
1999-02-15 03:20:14 +08:00
|
|
|
|
2002-04-08 17:43:22 +08:00
|
|
|
if (ti->ti_unbind.bv_len == 0) {
|
1999-02-19 15:55:20 +08:00
|
|
|
return (-1);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
if (tcl_merge_bvlist (op->o_bd->be_suffix, &suf_tcl) == NULL) {
|
2002-04-08 17:43:22 +08:00
|
|
|
return (-1);
|
|
|
|
}
|
1999-02-15 03:20:14 +08:00
|
|
|
|
2002-04-08 17:43:22 +08:00
|
|
|
command = (char *) ch_malloc (ti->ti_unbind.bv_len + suf_tcl.bv_len
|
2003-03-30 17:03:54 +08:00
|
|
|
+ op->o_conn->c_dn.bv_len + 84);
|
2002-05-09 10:11:39 +08:00
|
|
|
sprintf (command, "%s UNBIND {%ld/%ld} {%s} {%s}",
|
|
|
|
ti->ti_unbind.bv_val, op->o_connid, (long) op->o_msgid,
|
2003-03-30 17:03:54 +08:00
|
|
|
suf_tcl.bv_val, op->o_conn->c_dn.bv_val ? op->o_conn->c_dn.bv_val : "");
|
2002-04-08 17:43:22 +08:00
|
|
|
Tcl_Free (suf_tcl.bv_val);
|
1999-02-15 03:20:14 +08:00
|
|
|
|
1999-02-18 10:18:39 +08:00
|
|
|
ldap_pvt_thread_mutex_lock (&tcl_interpreter_mutex);
|
|
|
|
code = Tcl_GlobalEval (ti->ti_ii->interp, command);
|
1999-02-19 15:55:20 +08:00
|
|
|
results = (char *) ch_strdup (ti->ti_ii->interp->result);
|
1999-02-18 10:18:39 +08:00
|
|
|
ldap_pvt_thread_mutex_unlock (&tcl_interpreter_mutex);
|
|
|
|
free (command);
|
1999-02-15 03:20:14 +08:00
|
|
|
|
|
|
|
if (code != TCL_OK) {
|
1999-02-28 13:55:48 +08:00
|
|
|
Debug (LDAP_DEBUG_SHELL, "tcl_unbind_error: %s\n", results,
|
1999-02-18 10:18:39 +08:00
|
|
|
0, 0);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|
1999-02-18 10:18:39 +08:00
|
|
|
|
1999-02-19 15:55:20 +08:00
|
|
|
free (results);
|
1999-02-18 10:18:39 +08:00
|
|
|
return (err);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|