Patch: Non-unique msgid for abandon in back-<shell,tcl> (ITS#1793)

================
Written by Hallvard B. Furuseth and placed into the public domain.
This software is not subject to any license of the University of Oslo.
			================

Here is a patch which does what I described.  Of course, someone has
to decide if that is the right solution:-)
- Add an "opid:" line to the input to back-shell commands.
- Add an "abandonid: <opid> line to back-shell/abandon input.
- Replace message id with opid in back-tcl arguments.
- Add an abandonid = <opid> argument to back-tcl/abandon.
An opid (operation ID) is a "connection ID/message ID" string.  I
would have liked to use another name to avoid confusion with struct
slap_op->o_opid, but I could not think of another apt word.

This also fixes ITS#1784 and ITS#1792.  Since calling conventions
changed anyway, I fixed back-shell by adding abandonid: and making
opid: always be the ID of the current operation.

Hallvard B. Furuseth <h.b.furuseth@usit.uio.no>, May 2002.
This commit is contained in:
Kurt Zeilenga 2002-05-09 02:11:39 +00:00
parent 2ab8810555
commit 15e6a98bba
20 changed files with 109 additions and 63 deletions

View File

@ -13,6 +13,12 @@ executes external programs to implement operations, and is designed to
make it easy to tie an existing database to the
.B slapd
front-end.
.SH WARNING
.B "This backend's calling conventions have changed since OpenLDAP 2.0."
The operations receive a new "opid:" (operation ID) line, to be used
instead of "msgid:".
The "msgid:" line will be removed in a future version.
Also, abandon now gets a new "abandonid:" line.
.SH CONFIGURATION
These
.B slapd.conf
@ -30,14 +36,17 @@ Each option is followed by the input lines that the program receives:
.B abandon <pathname> <argument>...
.nf
ABANDON
msgid: <message id>
opid: <operation ID>
msgid: <message ID of operation to abandon>
<repeat { "suffix:" <database suffix DN> }>
abandonid: <operation ID of operation to abandon>
.fi
.TP
.B add <pathname> <argument>...
.nf
ADD
msgid: <message id>
opid: <operation ID>
msgid: <message ID>
<repeat { "suffix:" <database suffix DN> }>
<entry in LDIF format>
.fi
@ -45,7 +54,8 @@ msgid: <message id>
.B bind <pathname> <argument>...
.nf
BIND
msgid: <message id>
opid: <operation ID>
msgid: <message ID>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
method: <method number>
@ -56,7 +66,8 @@ cred: <credentials>
.B compare <pathname> <argument>...
.nf
COMPARE
msgid: <message id>
opid: <operation ID>
msgid: <message ID>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
<attribute>: <value>
@ -65,7 +76,8 @@ dn: <DN>
.B delete <pathname> <argument>...
.nf
DELETE
msgid: <message id>
opid: <operation ID>
msgid: <message ID>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
.fi
@ -73,7 +85,8 @@ dn: <DN>
.B modify <pathname> <argument>...
.nf
MODIFY
msgid: <message id>
opid: <operation ID>
msgid: <message ID>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
<repeat {
@ -86,7 +99,8 @@ dn: <DN>
.B modrdn <pathname> <argument>...
.nf
MODRDN
msgid: <message id>
opid: <operation ID>
msgid: <message ID>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
newrdn: <new RDN>
@ -97,7 +111,8 @@ deleteoldrdn: <0 or 1>
.B search <pathname> <argument>...
.nf
SEARCH
msgid: <message id>
opid: <operation ID>
msgid: <message ID>
<repeat { "suffix:" <database suffix DN> }>
base: <base DN>
scope: <0-2, see ldap.h>
@ -112,11 +127,16 @@ attrs: <"all" or space-separated attribute list>
.B unbind <pathname> <argument>...
.nf
UNBIND
msgid: <message id>
opid: <operation ID>
msgid: <message ID>
<repeat { "suffix:" <database suffix DN> }>
dn: <bound DN>
.fi
.LP
An
.I operation ID
is a "connection ID/message ID" string identifying an operation.
.LP
Note that you need only supply configuration lines for those commands you
want the backend to handle.
Operations for which a command is not supplied will be refused with an

View File

@ -14,6 +14,13 @@ interpreter into
Any tcl database section of the configuration file
.BR slapd.conf (5)
must then specify what Tcl script to use.
.SH WARNING
.B "This backend's calling conventions have changed since OpenLDAP 2.0."
Previously, the 2nd argument to the procs was a message ID.
Now they are an "operation ID" string.
Also, proc abandon now gets a new
.B abandonid
argument.
.SH CONFIGURATION
These
.B slapd.conf
@ -57,28 +64,29 @@ So global variables, as well as all the procs, are callable between databases.
If no tclrealm is specified, it is put into the "default" realm.
.SH Variables passed to the procs
.TP
.B abandon { action msgid suffix }
.B abandon { action opid suffix abandonid }
.nf
action - Always equal to ABANDON.
msgid - The msgid of this ldap operation.
suffix - List of suffix(es) associated with the
call. Each one is an entry in a tcl
formatted list (surrounded by {}'s).
action - Always equal to ABANDON.
opid - The opid of this ldap operation.
suffix - List of suffix(es) associated with the
call. Each one is an entry in a tcl
formatted list (surrounded by {}'s).
abandonid - The opid of the operation to abandon.
.fi
.TP
.B add "{ action msgid suffix entry }"
.B add "{ action opid suffix entry }"
.nf
action - Always equal to ADD.
msgid - The msgid of this ldap operation.
opid - The opid of this ldap operation.
suffix - List of suffix(es), as above.
entry - Full entry to add. Each "type: val" is
an element in a tcl formatted list.
.fi
.TP
.B bind "{ action msgid suffix dn method cred_len cred }"
.B bind "{ action opid suffix dn method cred_len cred }"
.nf
action - Always equal to BIND.
msgid - The msgid of this ldap operation.
opid - The opid of this ldap operation.
suffix - List of suffix(es), as above.
dn - DN being bound to.
method - One of the ldap authentication methods.
@ -89,28 +97,28 @@ cred - Credentials being used to authenticate,
bind (??)
.fi
.TP
.B compare "{ action msgid suffix dn ava_type ava_value }"
.B compare "{ action opid suffix dn ava_type ava_value }"
.nf
action - Always equal to COMPARE.
msgid - The msgid of this ldap operation.
opid - The opid of this ldap operation.
suffix - List of suffix(es), as above.
dn - DN for compare.
ava_type - Type for comparison.
ava_value - Value to compare.
.fi
.TP
.B delete "{ action msgid suffix dn }"
.B delete "{ action opid suffix dn }"
.nf
action - Always equal to DELETE.
msgid - The msgid of this ldap operation.
opid - The opid of this ldap operation.
suffix - List of suffix(es), as above.
dn - DN to delete.
.fi
.TP
.B modify "{ action msgid suffix dn mods }"
.B modify "{ action opid suffix dn mods }"
.nf
action - Always equal to MODIFY.
msgid - The msgid of this ldap operation.
opid - The opid of this ldap operation.
suffix - List of suffix(es), as above.
dn - DN to modify.
mods - Tcl list of modifications.
@ -128,10 +136,10 @@ mods - Tcl list of modifications.
(ADD, DELETE, REPLACE).
.fi
.TP
.B modrdn "{ action msgid suffix dn newrdn deleteoldrdn }"
.B modrdn "{ action opid suffix dn newrdn deleteoldrdn }"
.nf
action - Always equal to MODRDN.
msgid - The msgid of this ldap operation.
opid - The opid of this ldap operation.
suffix - List of suffix(es), as above.
dn - DN whose RDN is being renamed.
newrdn - New RDN.
@ -140,11 +148,11 @@ deleteoldrdn - Boolean stating whether or not the
.fi
.TP
.B
search { action msgid suffix base scope deref \
search { action opid suffix base scope deref \
sizelimit timelimit filterstr attrsonly attrlist }
.nf
action - Always equal to SEARCH.
msgid - The msgid of this ldap operation.
opid - The opid of this ldap operation.
suffix - List of suffix(es), as above.
base - Base for this search.
scope - Scope of search, ( 0 | 1 | 2 ).
@ -157,14 +165,19 @@ attrsonly - Boolean for whether to list only the
attrlist - Tcl list if to retrieve.
.fi
.TP
.B unbind "{ action msgid suffix dn }"
.B unbind "{ action opid suffix dn }"
.nf
action - Always equal to UNBIND.
msgid - The msgid of this ldap operation.
opid - The opid of this ldap operation.
suffix - List of suffix(es), as above.
dn - DN to unbind.
.fi
.LP
An
.I opid
(operation ID) is a "connection ID/message ID" string identifying an
operation.
.LP
.SH Return Method and Syntax
There are only 2 return types.
All procs must return a result to show status of the operation.

View File

@ -65,8 +65,10 @@ shell_back_abandon(
/* write out the request to the abandon process */
fprintf( wfp, "ABANDON\n" );
fprintf( wfp, "opid: %ld/%ld\n", op->o_connid, (long) op->o_msgid );
fprintf( wfp, "msgid: %d\n", msgid );
print_suffixes( wfp, be );
fprintf( wfp, "abandonid: %ld/%d\n", op->o_connid, msgid );
fclose( wfp );
/* no result from abandon */

View File

@ -41,6 +41,7 @@ shell_back_add(
/* write out the request to the add process */
fprintf( wfp, "ADD\n" );
fprintf( wfp, "opid: %ld/%ld\n", op->o_connid, (long) op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
ldap_pvt_thread_mutex_lock( &entry2str_mutex );

View File

@ -46,6 +46,7 @@ shell_back_bind(
/* write out the request to the bind process */
fprintf( wfp, "BIND\n" );
fprintf( wfp, "opid: %ld/%ld\n", op->o_connid, (long) op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn->bv_val );

View File

@ -48,6 +48,7 @@ shell_back_compare(
/* write out the request to the compare process */
fprintf( wfp, "COMPARE\n" );
fprintf( wfp, "opid: %ld/%ld\n", op->o_connid, (long) op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn->bv_val );

View File

@ -42,6 +42,7 @@ shell_back_delete(
/* write out the request to the delete process */
fprintf( wfp, "DELETE\n" );
fprintf( wfp, "opid: %ld/%ld\n", op->o_connid, (long) op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn->bv_val );

View File

@ -45,6 +45,7 @@ shell_back_modify(
/* write out the request to the modify process */
fprintf( wfp, "MODIFY\n" );
fprintf( wfp, "opid: %ld/%ld\n", op->o_connid, (long) op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn->bv_val );

View File

@ -60,6 +60,7 @@ shell_back_modrdn(
/* write out the request to the modrdn process */
fprintf( wfp, "MODRDN\n" );
fprintf( wfp, "opid: %ld/%ld\n", op->o_connid, (long) op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn->bv_val );

View File

@ -52,6 +52,7 @@ shell_back_search(
/* write out the request to the search process */
fprintf( wfp, "SEARCH\n" );
fprintf( wfp, "opid: %ld/%ld\n", op->o_connid, (long) op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "base: %s\n", base->bv_val );

View File

@ -36,6 +36,7 @@ shell_back_unbind(
/* write out the request to the unbind process */
fprintf( wfp, "UNBIND\n" );
fprintf( wfp, "opid: %ld/%ld\n", op->o_connid, (long) op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", (conn->c_dn.bv_len ? conn->c_dn.bv_val : "") );

View File

@ -38,9 +38,10 @@ tcl_back_abandon (
}
command = (char *) ch_malloc (ti->ti_abandon.bv_len + suf_tcl.bv_len
+ 20);
sprintf (command, "%s ABANDON {%ld} {%s}",
ti->ti_abandon.bv_val, (long) op->o_msgid, suf_tcl.bv_val);
+ 80);
sprintf (command, "%s ABANDON {%ld/%ld} {%s} {%ld/%d}",
ti->ti_abandon.bv_val, op->o_connid, (long) op->o_msgid,
suf_tcl.bv_val, op->o_connid, msgid);
Tcl_Free (suf_tcl.bv_val);
ldap_pvt_thread_mutex_lock (&tcl_interpreter_mutex);

View File

@ -44,9 +44,9 @@ tcl_back_add (
entrystr = tcl_clean_entry(e);
command = (char *) ch_malloc (ti->ti_add.bv_len + suf_tcl.bv_len +
strlen(entrystr) + 32);
sprintf (command, "%s ADD {%ld} {%s} {%s}",
ti->ti_add.bv_val, (long) op->o_msgid,
strlen(entrystr) + 52);
sprintf (command, "%s ADD {%ld/%ld} {%s} {%s}",
ti->ti_add.bv_val, op->o_connid, (long) op->o_msgid,
suf_tcl.bv_val, entrystr);
Tcl_Free (suf_tcl.bv_val);
free (entrystr);

View File

@ -46,9 +46,10 @@ tcl_back_bind (
}
command = (char *) ch_malloc (ti->ti_bind.bv_len + suf_tcl.bv_len +
dn->bv_len + cred->bv_len + 64);
sprintf (command, "%s BIND {%ld} {%s} {%s} {%d} {%lu} {%s}",
ti->ti_bind.bv_val, (long) op->o_msgid, suf_tcl.bv_val,
dn->bv_len + cred->bv_len + 84);
sprintf (command, "%s BIND {%ld/%ld} {%s} {%s} {%d} {%lu} {%s}",
ti->ti_bind.bv_val, op->o_connid, (long) op->o_msgid,
suf_tcl.bv_val,
dn->bv_val, method, cred->bv_len, cred->bv_val);
Tcl_Free (suf_tcl.bv_val);

View File

@ -45,10 +45,10 @@ tcl_back_compare (
command = (char *) ch_malloc (ti->ti_compare.bv_len +
suf_tcl.bv_len + dn->bv_len + ava->aa_desc->ad_cname.bv_len +
ava->aa_value.bv_len + 64);
sprintf (command, "%s COMPARE {%ld} {%s} {%s} {%s: %s}",
ti->ti_compare.bv_val, (long) op->o_msgid, suf_tcl.bv_val,
dn->bv_val,
ava->aa_value.bv_len + 84);
sprintf (command, "%s COMPARE {%ld/%ld} {%s} {%s} {%s: %s}",
ti->ti_compare.bv_val, op->o_connid, (long) op->o_msgid,
suf_tcl.bv_val, dn->bv_val,
ava->aa_desc->ad_cname.bv_val, ava->aa_value.bv_val);
Tcl_Free (suf_tcl.bv_val);

View File

@ -43,10 +43,10 @@ tcl_back_delete (
}
command = (char *) ch_malloc (ti->ti_delete.bv_len + suf_tcl.bv_len
+ dn->bv_len + 64);
sprintf (command, "%s DELETE {%ld} {%s} {%s}",
ti->ti_delete.bv_val, (long) op->o_msgid, suf_tcl.bv_val,
dn->bv_val);
+ dn->bv_len + 84);
sprintf (command, "%s DELETE {%ld/%ld} {%s} {%s}",
ti->ti_delete.bv_val, op->o_connid, (long) op->o_msgid,
suf_tcl.bv_val, dn->bv_val);
Tcl_Free (suf_tcl.bv_val);
ldap_pvt_thread_mutex_lock (&tcl_interpreter_mutex);

View File

@ -97,11 +97,11 @@ tcl_back_modify (
}
command = (char *) ch_malloc (ti->ti_modify.bv_len + suf_tcl.bv_len
+ dn->bv_len + strlen (tcl_mods) + 64);
+ dn->bv_len + strlen (tcl_mods) + 84);
/* This space is simply for aesthetics--\ */
sprintf (command, "%s MODIFY {%ld} {%s} {%s} { %s}",
ti->ti_modify.bv_val, (long) op->o_msgid, suf_tcl.bv_val,
dn->bv_val, tcl_mods);
sprintf (command, "%s MODIFY {%ld/%ld} {%s} {%s} { %s}",
ti->ti_modify.bv_val, op->o_connid, (long) op->o_msgid,
suf_tcl.bv_val, dn->bv_val, tcl_mods);
Tcl_Free (suf_tcl.bv_val);
free (tcl_mods);

View File

@ -62,10 +62,11 @@ tcl_back_modrdn (
command = (char *) ch_malloc (ti->ti_modrdn.bv_len + suf_tcl.bv_len
+ dn->bv_len + newrdn->bv_len
+ (newSuperior ? newSuperior->bv_len : 0) + 64);
+ (newSuperior ? newSuperior->bv_len : 0) + 84);
if ( newSuperior ) {
sprintf (command, "%s MODRDN {%ld} {%s} {%s} {%s} %d {%s}",
ti->ti_modrdn.bv_val, (long) op->o_msgid,
sprintf (command, "%s MODRDN {%ld/%ld} {%s} {%s} {%s} %d {%s}",
ti->ti_modrdn.bv_val,
op->o_connid, (long) op->o_msgid,
suf_tcl.bv_val, dn->bv_val,
newrdn->bv_val, deleteoldrdn ? 1 : 0,
newSuperior->bv_val );

View File

@ -63,12 +63,12 @@ tcl_back_search (
}
command = (char *) ch_malloc (ti->ti_search.bv_len + suf_tcl.bv_len
+ base->bv_len + 40 + filterstr->bv_len +
+ base->bv_len + 60 + filterstr->bv_len +
(attrs_tcl == NULL ? 5 : strlen (attrs_tcl)) + 72);
sprintf (command,
"%s SEARCH {%ld} {%s} {%s} {%d} {%d} {%d} {%d} {%s} {%d} {%s}",
ti->ti_search.bv_val, (long) op->o_msgid, suf_tcl.bv_val,
base->bv_val, scope, deref,
"%s SEARCH {%ld/%ld} {%s} {%s} {%d} {%d} {%d} {%d} {%s} {%d} {%s}",
ti->ti_search.bv_val, op->o_connid, (long) op->o_msgid,
suf_tcl.bv_val, base->bv_val, scope, deref,
sizelimit, timelimit, filterstr->bv_val, attrsonly ? 1 : 0,
attrs_tcl == NULL ? "{all}" : attrs_tcl);
Tcl_Free (attrs_tcl);

View File

@ -37,10 +37,10 @@ tcl_back_unbind (
}
command = (char *) ch_malloc (ti->ti_unbind.bv_len + suf_tcl.bv_len
+ conn->c_dn.bv_len + 64);
sprintf (command, "%s UNBIND {%ld} {%s} {%s}",
ti->ti_unbind.bv_val, (long) op->o_msgid, suf_tcl.bv_val,
conn->c_dn.bv_val ? conn->c_dn.bv_val : "");
+ conn->c_dn.bv_len + 84);
sprintf (command, "%s UNBIND {%ld/%ld} {%s} {%s}",
ti->ti_unbind.bv_val, op->o_connid, (long) op->o_msgid,
suf_tcl.bv_val, conn->c_dn.bv_val ? conn->c_dn.bv_val : "");
Tcl_Free (suf_tcl.bv_val);
ldap_pvt_thread_mutex_lock (&tcl_interpreter_mutex);