| 43 | } LIBSSHContext; |
| 44 | |
| 45 | static av_cold int libssh_create_ssh_session(LIBSSHContext *libssh, const char* hostname, unsigned int port) |
| 46 | { |
| 47 | static const int verbosity = SSH_LOG_NOLOG; |
| 48 | |
| 49 | if (!(libssh->session = ssh_new())) { |
| 50 | av_log(libssh, AV_LOG_ERROR, "SSH session creation failed: %s\n", ssh_get_error(libssh->session)); |
| 51 | return AVERROR(ENOMEM); |
| 52 | } |
| 53 | ssh_options_set(libssh->session, SSH_OPTIONS_HOST, hostname); |
| 54 | ssh_options_set(libssh->session, SSH_OPTIONS_PORT, &port); |
| 55 | ssh_options_set(libssh->session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity); |
| 56 | if (libssh->rw_timeout > 0) { |
| 57 | long timeout = libssh->rw_timeout * 1000; |
| 58 | ssh_options_set(libssh->session, SSH_OPTIONS_TIMEOUT_USEC, &timeout); |
| 59 | } |
| 60 | |
| 61 | if (ssh_options_parse_config(libssh->session, NULL) < 0) { |
| 62 | av_log(libssh, AV_LOG_WARNING, "Could not parse the config file.\n"); |
| 63 | } |
| 64 | |
| 65 | if (ssh_connect(libssh->session) != SSH_OK) { |
| 66 | av_log(libssh, AV_LOG_ERROR, "Connection failed: %s\n", ssh_get_error(libssh->session)); |
| 67 | return AVERROR(EIO); |
| 68 | } |
| 69 | |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | static av_cold int libssh_authentication(LIBSSHContext *libssh, const char *user, const char *password) |
| 74 | { |
no test coverage detected