Subject: Re: [PATCH] Support for exit-signal messages

Re: [PATCH] Support for exit-signal messages

From: Tommy Lindgren <tommy.lindgren_at_gmail.com>
Date: Sat, 02 Oct 2010 11:50:53 +0200

Simon Josefsson <simon_at_josefsson.org> writes:

> Tommy Lindgren <tommy.lindgren_at_gmail.com> writes:
>
>> On 2010-10-01 16:29, Simon Josefsson wrote:
>>> Tommy Lindgren<tommy.lindgren_at_gmail.com> writes:
>>>
>>>> Hi,
>>>>
>>>> I've implemented rudimentary support for exit-signal messages (see RFC
>>>> 4254 section 6.10) which I'd like to see included in libssh2, please
>>>> see attached patch. The patch only adds support for retrieving the
>>>> signal name, I skipped the part about the (optional) error message.
>>>
>>> It looks good to me, thanks for this! However a question: why skip the
>>> error message part?
>>
>> Simply because the error message didn't seem to get set in my test
>> cases, so I didn't bother to write code for it.
>
> I think it would be an improvement if the API was modified to make it
> possible for a future libssh2 to supply the error message to the
> application, when someone improves the protocol parser.

Any opinion on how that modification should look? Personally I think it
looks nicer with a separate function for retrieving the error message
(and language tag). But if we are extending the new function I guess the
signature could look something like

LIBSSH2_API const char *
libssh2_channel_get_exit_signal(LIBSSH2_CHANNEL *channel, char *errmsg,
                                char **langtag)

or possibly

LIBSSH2_API const char *
libssh2_channel_get_exit_signal(LIBSSH2_CHANNEL *channel, char *errmsg,
                                int *errmsg_len, char **langtag, int *langtag_len)

Thoughts?

> Btw, shouldn't the return value of the API use a 'const' qualifier? The
> string should not be modifiable by the application.

True, fixed. I'm not really a C coder, I just pretend to be one.

Attached new patch with const fix and modified ssh2_exec.c example. The
patch can be tested with:

$ example/ssh2_exec host user pass "kill -TERM \$\$"

Regards,
Tommy

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

Received on 2010-10-02