Subject: Re: [Netconf] xml start directive with ssh

From: Shikhar <[email-masked]>
Date: Tue, 14 Jul 2009 22:36:00 +0530

On Thu, Jun 25, 2009 at 11:42 PM, David Reid<[email-masked]> wrote:
> From rfc4742 page 3:
>
>   Once the SSH session has been established, the user (or application)
>   will invoke NETCONF as an SSH subsystem called "netconf".  Subsystem
>   support is a feature of SSH version 2 (SSHv2) and is not included in
>   SSHv1.  Running NETCONF as an SSH subsystem avoids the need for the
>   script to recognize shell prompts or skip over extraneous
>   information, such as a system message that is sent at shell start-up.
>   However, even when a subsystem is used, some extraneous messages may
>   be printed by the user's start-up scripts.  Implementations MUST skip
>   over these messages by searching for an 'xml' start directive, which
>   MUST be followed by a <hello> element in the 'NETCONF' namespace.
>
>
> I want to make sure I understand this correctly. Does this mean:
>
> Both the netconf client and server MUST send an xml start directive before
> the <hello> message and MAY send an xml start directive before any other
> message when running over SSH.
>
> When not running over SSH, the xml start directive is always optional.
>
> Anything sent by either the client or server before the xml start directive
> MUST be ignored when running over SSH.
>
> When not running over SSH, any extraneous data results in a parse error.

I think the below text from section 6.5 of [1] offers a clue as to the
motivation of the requirement:

"[..] As the user's shell is usually used to execute the subsystem, it
is advisable for the subsystem protocol to have a "magic cookie" at
the beginning of the protocol transaction to distinguish it from
arbitrary output generated by shell initialization scripts, etc."

Shikhar

[1] RFC 4254, SSH Connection Protocol

> -David Reid
> _______________________________________________
> Netconf mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netconf
>

---

From: Shikhar <[email-masked]>
Date: Tue, 14 Jul 2009 22:56:35 +0530

> arbitrary output generated by shell initialization scripts, etc."

More context in this thread [1] where some SECSH WG members were in
favor of dropping above requirement.

Shikhar

[1] http://osdir.com/ml/ietf.secsh/2001-01/msg00062.html

---

From: Phil Shafer <[email-masked]>
Date: Tue, 14 Jul 2009 15:05:14 -0400

>arbitrary output generated by shell initialization scripts, etc."

This is not correct.  The user's shell is not used to execute
the subsystem.  It is exec'd directly.

Thanks,
 Phil

---

From: Andy Bierman <[email-masked]>
Date: Tue, 14 Jul 2009 13:33:08 -0700

> the subsystem.  It is exec'd directly.

Yes.

Here is an incomplete code snippet for the libssh2 library:

    /* Request a shell */
    mscb->channel = libssh2_channel_open_session(mscb->session);
    if (!mscb->channel) {
	if (LOGINFO) {
	    log_info("\nmgr_ses: SSH2 channel open failed");
	}
	return ERR_NCX_SESSION_FAILED;
    }

    /* Connect to the NETCONF subsystem */
    ret = libssh2_channel_subsystem(mscb->channel, "netconf");
    if (ret) {
	if (LOGINFO) {
	    log_info("\nmgr_ses: Unable to request netconf subsystem");
	}
	return ERR_NCX_SESSION_FAILED;
    }

Notice how there is no reason to send garbage, or magic cookies,
or anything other than a proper <hello> message at this point?
I sort of remember all that text going into the RFC at the time,
but it was mostly ignored at the time.
Now I think it is all wrong, and should be changed.

>  Phil

Andy