[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Shell backend: read_and_send_results

[Rearranging a little]
Timur Izhbulatov writes:

> After some investigation it appeared that the problem is in the way
> how the str2result function (servers/slapd/result.c) works. It uses
> the luitl_atoix function (libraries/libutil/utils.c) in which:
>         i = strtol( s, &next, x );
>         if ( next == s || next[ 0 ] != '\0' ) {
>                 return -1;
>         }
> If "code: <integer>" is the second line, as the man page says, next[ 0
> ] contains '\n' (the first non-digit character after the integer) and
> lutil_atoix fails to convert the code value. That is why it fails if
> there are any trailing characters after the value.

You are right.  That was introduced in servers/slapd/result.c rev 1.276.
			if ( c != NULL && lutil_atoi( code, c ) != 0 ) {
				goto bailout;
with the previous code
			if ( c != NULL ) {
				*code = atoi( c );
and it should work.

And I figured out the weird "space instead of newline" in the log which
originally confused us: It's syslog which does the substitution.  I was
looking at the 'slap -d shell' output instead:-( Sorry about sending you
off with an error report in the wrong direction.

Which leaves one problem: The current (broken) code should have returned
an error for me.  Maybe one bug hid another.  I'll check later.

>>> We find problem. Return code must be LAST string in backend output
>> Yes.  As 'man slapd-shell' says: "The search RESULT should be preceded
>> by the entries in LDIF format, each entry followed by a blank line."
>> Maybe that needs to be clarified - if so, what should it say?
> The slapd-shell man page says:
>        The commands - except unbind - should output:
>               RESULT
>               code: <integer>
>               matched: <matched DN>
>               info: <text>
>        where only RESULT is mandatory.
> But the order matters.

Yes.  That's what the next sentence after the one you quoted says.
(The one I quoted.)  Anyway, I've swapped those texts in the manpage
now, hopefully it's clearer that way.