[FFmpeg-devel] [PATCH] sftp: support reading config from ~/.ssh/config

Florian Jacob projects+ffmpeg at florianjacob.de
Wed Mar 11 00:53:09 CET 2015


> >   libavformat/libssh.c | 11 ++++++++---
> >   1 file changed, 8 insertions(+), 3 deletions(-)
> > 
> > diff --git a/libavformat/libssh.c b/libavformat/libssh.c
> > index 3ec60cb..1ed1d72 100644
> > --- a/libavformat/libssh.c
> > +++ b/libavformat/libssh.c
> > @@ -55,6 +55,10 @@ static av_cold int
> > libssh_create_ssh_session(LIBSSHContext *libssh, const char*> 
> >           ssh_options_set(libssh->session, SSH_OPTIONS_TIMEOUT_USEC,
> >           &timeout);
> >       
> >       }
> > 
> > +    if (ssh_options_parse_config(libssh->session, NULL) < 0) {
> > +        av_log(libssh, AV_LOG_ERROR, "Could not parse the config
> > file.\n");

> This should be a warning (not an error), or return with error code from
> here. A warning is probably better.
Of course, excuse me. I'll correct it.

> > @@ -198,8 +202,9 @@ static av_cold int libssh_open(URLContext *h, const
> > char *url, int flags)> 
> >                    path, sizeof(path),
> >                    url);
> > 
> > -    if (port <= 0 || port > 65535)
> > -        port = 22;
> > +    // a port of 0 will use a port from ~/.ssh/config or the default
> > value 22 +    if (port < 0 || port > 65535)
> > +        port = 0;

> Is this really required? Port will be overwritten if present in config
> either way?
It is required. In my first version without that change, I wondered why 
everything worked besides the port which was still set to 22. The reason is 
that if the port is set != 0, libssh treats it as port that is explicitely set 
by the user, and therefore doesn't overwrite it with the port specified in the 
config file.


> I will test later, thanks.
Thanks in advance. :)


More information about the ffmpeg-devel mailing list