All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Ashijeet Acharya <ashijeetacharya@gmail.com>
Cc: Max Reitz <mreitz@redhat.com>,
	"Richard W.M. Jones" <rjones@redhat.com>,
	jcody@redhat.com, Eric Blake <eblake@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	"Daniel P. Berrange" <berrange@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [v2 2/5] block/ssh: Add InetSocketAddress and accept it
Date: Mon, 17 Oct 2016 17:53:07 +0200	[thread overview]
Message-ID: <20161017155307.GH4821@noname.redhat.com> (raw)
In-Reply-To: <CAC2QTZYbdG24e2zGL7YRumsOvsc4fNyH5dLBeqEh_Fae60gdDA@mail.gmail.com>

Am 17.10.2016 um 17:44 hat Ashijeet Acharya geschrieben:
> On Mon, Oct 17, 2016 at 6:27 PM, Kevin Wolf <kwolf@redhat.com> wrote:
> > Am 17.10.2016 um 14:33 hat Ashijeet Acharya geschrieben:
> >> On Sun, Oct 16, 2016 at 4:00 AM, Max Reitz <mreitz@redhat.com> wrote:
> >> > On 15.10.2016 11:04, Ashijeet Acharya wrote:
> >> >> Add InetSocketAddress compatibility to SSH driver.
> >> >>
> >> >> Add a new option "server" to the SSH block driver which then accepts
> >> >> a InetSocketAddress.
> >> >>
> >> >> "host" and "port" are supported as legacy options and are mapped to
> >> >> their InetSocketAddress representation.
> >> >>
> >> >> Signed-off-by: Ashijeet Acharya <ashijeetacharya@gmail.com>
> >> >> ---
> >> >>  block/ssh.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
> >> >>  1 file changed, 74 insertions(+), 9 deletions(-)
> >> >>
> >> >>
> >> >>      /* Open the socket and connect. */
> >> >>      s->sock = inet_connect(s->hostport, errp);
> >> >> @@ -634,7 +698,8 @@ static int connect_to_ssh(BDRVSSHState *s, QDict *options,
> >> >>      }
> >> >>
> >> >>      /* Check the remote host's key against known_hosts. */
> >> >> -    ret = check_host_key(s, host, port, host_key_check, errp);
> >> >> +    ret = check_host_key(s, s->inet->host, port, host_key_check,
> >> >
> >> > But then you're still using the port here... And I can't come up with a
> >> > way (not even a bad one) to get the numeric port. Maybe interpret the
> >> > addrinfo in inet_connect_saddr()? But getting that information out would
> >> > be ugly, if even possible...
> >> >
> >> > So maybe the best is to keep it this way and put a FIXME above the
> >> > atoi() call. :-/
> >>
> >> Kevin, I believe (after talking with Max) that regarding the atoi()
> >> issue, I can't use any string to integer function since it won't
> >> succeed for cases like port = 'ssh' and putting a FIXME over it seems
> >> to be the only option. But Max did warn me, though, to get everybody's
> >> opinion before I do so. So I am awaiting your response on this one.
> >> Much better will be if you have a workaround solution in mind!! :-)
> >
> > The integer port is only needed for libssh2_knownhost_checkp(). One
> > option could be to consider passing -1 instead:
> >
> >     port is the port number used by the host (or a negative number to
> >     check the generic host). If the port number is given, libssh2 will
> >     check the key for the specific host + port number combination in
> >     addition to the plain host name only check.
> >
> > In 99% of the cases, this shouldn't make any difference.
> 
> I think, its better to keep using atoi() and check if it returns a '0'
>  value and display the error to the user to give the input as numeric.
> This is possible since this will not clash with the possibility that
> user gives the port input as port = '0' for no such port number exists
> as far as I know. Will this work?

It's fair enough. We will have a little inconsistency between ssh and
other users of SocketAddress, but the driver never supported service
names, so it isn't a regression either.

Kevin

> Ashijeet
> > Alternatively it could be possible to use getservbyname() to get the
> > port number from the name, but maybe that's a bit too much for a feature
> > that most people don't even know of.
> >
> > I'm also not completely opposed to simply requiring a numeric argument
> > for SSH. There is no real use to support service names here other than
> > being consistent with other places in qemu.
> >
> > Kevin

  reply	other threads:[~2016-10-17 15:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-15  9:04 [Qemu-devel] [v2 0/5] Allow blockdev-add for SSH Ashijeet Acharya
2016-10-15  9:04 ` [Qemu-devel] [v2 1/5] block/ssh: Add ssh_has_filename_options_conflict() Ashijeet Acharya
2016-10-15 21:28   ` Max Reitz
2016-10-15  9:04 ` [Qemu-devel] [v2 2/5] block/ssh: Add InetSocketAddress and accept it Ashijeet Acharya
2016-10-15 22:30   ` Max Reitz
2016-10-16  8:53     ` Ashijeet Acharya
2016-10-16  9:10       ` Ashijeet Acharya
2016-10-17 11:27     ` Kevin Wolf
2016-10-17 12:33     ` Ashijeet Acharya
2016-10-17 12:57       ` Kevin Wolf
2016-10-17 15:44         ` Ashijeet Acharya
2016-10-17 15:53           ` Kevin Wolf [this message]
2016-10-17 15:56             ` Ashijeet Acharya
2016-10-17 15:59           ` Eric Blake
2016-10-17 16:08             ` Ashijeet Acharya
2016-10-15  9:04 ` [Qemu-devel] [v2 3/5] block/ssh: Use inet_connect_saddr() to establish socket connection Ashijeet Acharya
2016-10-15 22:34   ` Max Reitz
2016-10-15  9:04 ` [Qemu-devel] [v2 4/5] block/ssh: Use InetSocketAddress options Ashijeet Acharya
2016-10-15 22:37   ` Max Reitz
2016-10-15  9:04 ` [Qemu-devel] [v2 5/5] qapi: allow blockdev-add for ssh Ashijeet Acharya
2016-10-15 22:43   ` Max Reitz
2016-10-15  9:25 ` [Qemu-devel] [v2 0/5] Allow blockdev-add for SSH no-reply
2016-10-17 11:29 ` Kevin Wolf
2016-10-17 12:33   ` Ashijeet Acharya

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161017155307.GH4821@noname.redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=ashijeetacharya@gmail.com \
    --cc=berrange@redhat.com \
    --cc=eblake@redhat.com \
    --cc=jcody@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rjones@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.