summaryrefslogtreecommitdiff
path: root/libavformat/libssh.c
diff options
context:
space:
mode:
authorFlorian Jacob <projects+ffmpeg@florianjacob.de>2015-03-11 01:13:44 +0100
committerLukasz Marek <lukasz.m.luki2@gmail.com>2015-03-11 01:34:37 +0100
commitc5c4ca6bc88135f5e819dd707fee68a01c9ffe08 (patch)
treea208625d3f9ce3fa24abbca23448b8b101f41c34 /libavformat/libssh.c
parent48df30d36c3ca360c407d84f96749888d1fbe853 (diff)
downloadffmpeg-c5c4ca6bc88135f5e819dd707fee68a01c9ffe08.tar.gz
lavf/libssh: support reading config from ~/.ssh/config
libssh provides a function for parsing ~/.ssh/config for ssh connection parameters like user, hostname, identity file and port. This patch makes ffmpeg use this function to take parameters from the config file for everything that's not explicitely set in the url. It also supports host aliases, i.e. using a shorthand in the url and replacing it with the hostname / IP address specified for the shorthand in the config file. Signed-off-by: Florian Jacob <projects+ffmpeg@florianjacob.de> Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
Diffstat (limited to 'libavformat/libssh.c')
-rw-r--r--libavformat/libssh.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/libavformat/libssh.c b/libavformat/libssh.c
index 3ec60cb8f4..fac6114210 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_WARNING, "Could not parse the config file.\n");
+ }
+
if (ssh_connect(libssh->session) != SSH_OK) {
av_log(libssh, AV_LOG_ERROR, "Connection failed: %s\n", ssh_get_error(libssh->session));
return AVERROR(EIO);
@@ -187,7 +191,7 @@ static av_cold int libssh_open(URLContext *h, const char *url, int flags)
{
LIBSSHContext *libssh = h->priv_data;
char proto[10], path[MAX_URL_SIZE], hostname[1024], credencials[1024];
- int port = 22, ret;
+ int port, ret;
const char *user = NULL, *pass = NULL;
char *end = NULL;
@@ -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;
if ((ret = libssh_create_ssh_session(libssh, hostname, port)) < 0)
goto fail;