mirror of
https://github.com/libssh2/libssh2.git
synced 2025-07-04 09:22:28 +03:00
tidy-up: avoid exclamations, prefer single quotes, in outputs
Closes #1079
This commit is contained in:
@ -187,9 +187,9 @@ test_script:
|
|||||||
if((Get-Process -Name "sshd" -ErrorAction SilentlyContinue).Count -gt 1) {
|
if((Get-Process -Name "sshd" -ErrorAction SilentlyContinue).Count -gt 1) {
|
||||||
$env:DOCKER_HOST = "tcp://127.0.0.1:2375"
|
$env:DOCKER_HOST = "tcp://127.0.0.1:2375"
|
||||||
[System.Environment]::SetEnvironmentVariable("DOCKER_HOST", $env:DOCKER_HOST)
|
[System.Environment]::SetEnvironmentVariable("DOCKER_HOST", $env:DOCKER_HOST)
|
||||||
Write-Host "... ready!"
|
Write-Host "... ready."
|
||||||
} else {
|
} else {
|
||||||
Write-Host "... failed!"
|
Write-Host "... failed."
|
||||||
}
|
}
|
||||||
if($env:CRYPTO_BACKEND -eq "WinCNG") {
|
if($env:CRYPTO_BACKEND -eq "WinCNG") {
|
||||||
$env:FIXTURE_TRACE_ALL_CONNECT = "1"
|
$env:FIXTURE_TRACE_ALL_CONNECT = "1"
|
||||||
|
@ -105,10 +105,10 @@ case "${use_crypto}" in
|
|||||||
m4_set_map([crypto_backends], [LIBSSH2_CHECK_CRYPTO])
|
m4_set_map([crypto_backends], [LIBSSH2_CHECK_CRYPTO])
|
||||||
;;
|
;;
|
||||||
yes|"")
|
yes|"")
|
||||||
crypto_errors="No crypto backend specified!"
|
crypto_errors="No crypto backend specified."
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
crypto_errors="Unknown crypto backend '${use_crypto}' specified!"
|
crypto_errors="Unknown crypto backend '${use_crypto}' specified."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ if test "$use_libz" != no; then
|
|||||||
AC_MSG_NOTICE([Cannot find libz, disabling compression])
|
AC_MSG_NOTICE([Cannot find libz, disabling compression])
|
||||||
found_libz="disabled; no libz found"
|
found_libz="disabled; no libz found"
|
||||||
else
|
else
|
||||||
libz_errors="No libz found!
|
libz_errors="No libz found.
|
||||||
Try --with-libz-prefix=PATH if you know that you have it."
|
Try --with-libz-prefix=PATH if you know that you have it."
|
||||||
AS_MESSAGE([ERROR: $libz_errors])
|
AS_MESSAGE([ERROR: $libz_errors])
|
||||||
fi
|
fi
|
||||||
@ -365,7 +365,7 @@ if test "$found_crypto" = "none"; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if test $missing_required_deps = 1; then
|
if test $missing_required_deps = 1; then
|
||||||
AC_MSG_ERROR([Required dependencies are missing!])
|
AC_MSG_ERROR([Required dependencies are missing.])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AM_CONDITIONAL([HAVE_WINDRES],
|
AM_CONDITIONAL([HAVE_WINDRES],
|
||||||
|
@ -25,7 +25,7 @@ To make sure you run with the correct libssh2 version:
|
|||||||
|
|
||||||
.nf
|
.nf
|
||||||
if(!libssh2_version(LIBSSH2_VERSION_NUM)) {
|
if(!libssh2_version(LIBSSH2_VERSION_NUM)) {
|
||||||
fprintf(stderr, \&"Runtime libssh2 version too old!\&");
|
fprintf(stderr, \&"Runtime libssh2 version too old.\&");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
.fi
|
.fi
|
||||||
|
@ -104,26 +104,26 @@ int main(int argc, char *argv[])
|
|||||||
/* Connect to SSH server */
|
/* Connect to SSH server */
|
||||||
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to open socket!\n");
|
fprintf(stderr, "failed to open socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
sin.sin_family = AF_INET;
|
sin.sin_family = AF_INET;
|
||||||
sin.sin_addr.s_addr = inet_addr(server_ip);
|
sin.sin_addr.s_addr = inet_addr(server_ip);
|
||||||
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
||||||
fprintf(stderr, "inet_addr: Invalid IP address \"%s\"\n", server_ip);
|
fprintf(stderr, "inet_addr: Invalid IP address '%s'\n", server_ip);
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "Failed to connect to %s!\n", inet_ntoa(sin.sin_addr));
|
fprintf(stderr, "Failed to connect to %s.\n", inet_ntoa(sin.sin_addr));
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if(auth & AUTH_PASSWORD) {
|
if(auth & AUTH_PASSWORD) {
|
||||||
if(libssh2_userauth_password(session, username, password)) {
|
if(libssh2_userauth_password(session, username, password)) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,7 +175,7 @@ int main(int argc, char *argv[])
|
|||||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||||
pubkey, privkey,
|
pubkey, privkey,
|
||||||
password)) {
|
password)) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -183,14 +183,14 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "No supported authentication methods found!\n");
|
fprintf(stderr, "No supported authentication methods found.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
listensock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
listensock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
if(listensock == LIBSSH2_INVALID_SOCKET) {
|
if(listensock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to open listen socket!\n");
|
fprintf(stderr, "failed to open listen socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons((unsigned short)local_listenport);
|
sin.sin_port = htons((unsigned short)local_listenport);
|
||||||
sin.sin_addr.s_addr = inet_addr(local_listenip);
|
sin.sin_addr.s_addr = inet_addr(local_listenip);
|
||||||
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
||||||
fprintf(stderr, "failed in inet_addr()!\n");
|
fprintf(stderr, "failed in inet_addr().\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
sockopt = 1;
|
sockopt = 1;
|
||||||
@ -206,11 +206,11 @@ int main(int argc, char *argv[])
|
|||||||
sizeof(sockopt));
|
sizeof(sockopt));
|
||||||
sinlen = sizeof(sin);
|
sinlen = sizeof(sin);
|
||||||
if(-1 == bind(listensock, (struct sockaddr *)&sin, sinlen)) {
|
if(-1 == bind(listensock, (struct sockaddr *)&sin, sinlen)) {
|
||||||
fprintf(stderr, "failed to bind()!\n");
|
fprintf(stderr, "failed to bind().\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
if(-1 == listen(listensock, 2)) {
|
if(-1 == listen(listensock, 2)) {
|
||||||
fprintf(stderr, "failed to listen()!\n");
|
fprintf(stderr, "failed to listen().\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
forwardsock = accept(listensock, (struct sockaddr *)&sin, &sinlen);
|
forwardsock = accept(listensock, (struct sockaddr *)&sin, &sinlen);
|
||||||
if(forwardsock == LIBSSH2_INVALID_SOCKET) {
|
if(forwardsock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to accept forward socket!\n");
|
fprintf(stderr, "failed to accept forward socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,8 +232,8 @@ int main(int argc, char *argv[])
|
|||||||
channel = libssh2_channel_direct_tcpip_ex(session, remote_desthost,
|
channel = libssh2_channel_direct_tcpip_ex(session, remote_desthost,
|
||||||
remote_destport, shost, sport);
|
remote_destport, shost, sport);
|
||||||
if(!channel) {
|
if(!channel) {
|
||||||
fprintf(stderr, "Could not open the direct-tcpip channel!\n"
|
fprintf(stderr, "Could not open the direct-tcpip channel.\n"
|
||||||
"(Note that this can be a problem at the server!"
|
"(Note that this can be a problem at the server."
|
||||||
" Please review the server logs.)\n");
|
" Please review the server logs.)\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
@ -248,17 +248,17 @@ int main(int argc, char *argv[])
|
|||||||
tv.tv_usec = 100000;
|
tv.tv_usec = 100000;
|
||||||
rc = select((int)(forwardsock + 1), &fds, NULL, NULL, &tv);
|
rc = select((int)(forwardsock + 1), &fds, NULL, NULL, &tv);
|
||||||
if(-1 == rc) {
|
if(-1 == rc) {
|
||||||
fprintf(stderr, "failed to select()!\n");
|
fprintf(stderr, "failed to select().\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
if(rc && FD_ISSET(forwardsock, &fds)) {
|
if(rc && FD_ISSET(forwardsock, &fds)) {
|
||||||
len = recv(forwardsock, buf, sizeof(buf), 0);
|
len = recv(forwardsock, buf, sizeof(buf), 0);
|
||||||
if(len < 0) {
|
if(len < 0) {
|
||||||
fprintf(stderr, "failed to recv()!\n");
|
fprintf(stderr, "failed to recv().\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
else if(len == 0) {
|
else if(len == 0) {
|
||||||
fprintf(stderr, "The client at %s:%d disconnected!\n", shost,
|
fprintf(stderr, "The client at %s:%d disconnected.\n", shost,
|
||||||
sport);
|
sport);
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
@ -289,13 +289,13 @@ int main(int argc, char *argv[])
|
|||||||
while(wr < len) {
|
while(wr < len) {
|
||||||
ssize_t nsent = send(forwardsock, buf + wr, len - wr, 0);
|
ssize_t nsent = send(forwardsock, buf + wr, len - wr, 0);
|
||||||
if(nsent <= 0) {
|
if(nsent <= 0) {
|
||||||
fprintf(stderr, "failed to send()!\n");
|
fprintf(stderr, "failed to send().\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
wr += nsent;
|
wr += nsent;
|
||||||
}
|
}
|
||||||
if(libssh2_channel_eof(channel)) {
|
if(libssh2_channel_eof(channel)) {
|
||||||
fprintf(stderr, "The server at %s:%d disconnected!\n",
|
fprintf(stderr, "The server at %s:%d disconnected.\n",
|
||||||
remote_desthost, remote_destport);
|
remote_desthost, remote_destport);
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,14 +88,14 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = hostaddr;
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ int main(int argc, char *argv[])
|
|||||||
if(auth_pw) {
|
if(auth_pw) {
|
||||||
/* We could authenticate via password */
|
/* We could authenticate via password */
|
||||||
if(libssh2_userauth_password(session, username, password)) {
|
if(libssh2_userauth_password(session, username, password)) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ int main(int argc, char *argv[])
|
|||||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||||
pubkey, privkey,
|
pubkey, privkey,
|
||||||
password)) {
|
password)) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,14 +142,14 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = hostaddr;
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ int main(int argc, char *argv[])
|
|||||||
while((rc = libssh2_userauth_password(session, username, password)) ==
|
while((rc = libssh2_userauth_password(session, username, password)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN);
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,7 +198,7 @@ int main(int argc, char *argv[])
|
|||||||
password)) ==
|
password)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN);
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,7 +208,7 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Request a file via SCP */
|
/* Request a file via SCP */
|
||||||
fprintf(stderr, "libssh2_scp_recv2()!\n");
|
fprintf(stderr, "libssh2_scp_recv2().\n");
|
||||||
do {
|
do {
|
||||||
channel = libssh2_scp_recv2(session, scppath, &fileinfo);
|
channel = libssh2_scp_recv2(session, scppath, &fileinfo);
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while(!channel);
|
} while(!channel);
|
||||||
fprintf(stderr, "libssh2_scp_recv() is done, now receive data!\n");
|
fprintf(stderr, "libssh2_scp_recv() is done, now receive data.\n");
|
||||||
|
|
||||||
while(got < fileinfo.st_size) {
|
while(got < fileinfo.st_size) {
|
||||||
char mem[1024 * 24];
|
char mem[1024 * 24];
|
||||||
|
@ -91,7 +91,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,14 +99,14 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = hostaddr;
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ int main(int argc, char *argv[])
|
|||||||
if(auth_pw) {
|
if(auth_pw) {
|
||||||
/* We could authenticate via password */
|
/* We could authenticate via password */
|
||||||
if(libssh2_userauth_password(session, username, password)) {
|
if(libssh2_userauth_password(session, username, password)) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,7 +143,7 @@ int main(int argc, char *argv[])
|
|||||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||||
pubkey, privkey,
|
pubkey, privkey,
|
||||||
password)) {
|
password)) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,14 +134,14 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = hostaddr;
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ int main(int argc, char *argv[])
|
|||||||
while((rc = libssh2_userauth_password(session, username, password)) ==
|
while((rc = libssh2_userauth_password(session, username, password)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN);
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ int main(int argc, char *argv[])
|
|||||||
password)) ==
|
password)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN);
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,14 +144,14 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = hostaddr;
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ int main(int argc, char *argv[])
|
|||||||
if(auth_pw & 1) {
|
if(auth_pw & 1) {
|
||||||
/* We could authenticate via password */
|
/* We could authenticate via password */
|
||||||
if(libssh2_userauth_password(session, username, password)) {
|
if(libssh2_userauth_password(session, username, password)) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,7 +219,7 @@ int main(int argc, char *argv[])
|
|||||||
if(libssh2_userauth_keyboard_interactive(session, username,
|
if(libssh2_userauth_keyboard_interactive(session, username,
|
||||||
&kbd_callback) ) {
|
&kbd_callback) ) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Authentication by keyboard-interactive failed!\n");
|
"Authentication by keyboard-interactive failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -232,7 +232,7 @@ int main(int argc, char *argv[])
|
|||||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||||
pubkey, privkey,
|
pubkey, privkey,
|
||||||
password)) {
|
password)) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -240,12 +240,12 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "No supported authentication methods found!\n");
|
fprintf(stderr, "No supported authentication methods found.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_init()!\n");
|
fprintf(stderr, "libssh2_sftp_init().\n");
|
||||||
sftp_session = libssh2_sftp_init(session);
|
sftp_session = libssh2_sftp_init(session);
|
||||||
|
|
||||||
if(!sftp_session) {
|
if(!sftp_session) {
|
||||||
@ -253,7 +253,7 @@ int main(int argc, char *argv[])
|
|||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_open()!\n");
|
fprintf(stderr, "libssh2_sftp_open().\n");
|
||||||
/* Request a file via SFTP */
|
/* Request a file via SFTP */
|
||||||
sftp_handle = libssh2_sftp_open(sftp_session, sftppath,
|
sftp_handle = libssh2_sftp_open(sftp_session, sftppath,
|
||||||
LIBSSH2_FXF_READ, 0);
|
LIBSSH2_FXF_READ, 0);
|
||||||
@ -263,13 +263,13 @@ int main(int argc, char *argv[])
|
|||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_open() is done, now receive data!\n");
|
fprintf(stderr, "libssh2_sftp_open() is done, now receive data.\n");
|
||||||
do {
|
do {
|
||||||
char mem[1024];
|
char mem[1024];
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
|
|
||||||
/* loop until we fail */
|
/* loop until we fail */
|
||||||
fprintf(stderr, "libssh2_sftp_read()!\n");
|
fprintf(stderr, "libssh2_sftp_read().\n");
|
||||||
nread = libssh2_sftp_read(sftp_handle, mem, sizeof(mem));
|
nread = libssh2_sftp_read(sftp_handle, mem, sizeof(mem));
|
||||||
if(nread > 0) {
|
if(nread > 0) {
|
||||||
write(1, mem, nread);
|
write(1, mem, nread);
|
||||||
|
@ -116,7 +116,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,14 +124,14 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = htonl(0x7F000001);
|
sin.sin_addr.s_addr = htonl(0x7F000001);
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ int main(int argc, char *argv[])
|
|||||||
while((rc = libssh2_userauth_password(session, username, password)) ==
|
while((rc = libssh2_userauth_password(session, username, password)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN);
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ int main(int argc, char *argv[])
|
|||||||
password)) ==
|
password)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN);
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -218,7 +218,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
} while(!sftp_handle);
|
} while(!sftp_handle);
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_open() is done, now receive data!\n");
|
fprintf(stderr, "libssh2_sftp_open() is done, now receive data.\n");
|
||||||
do {
|
do {
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
do {
|
do {
|
||||||
@ -321,7 +321,7 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while(1);
|
} while(1);
|
||||||
fprintf(stderr, "SFTP upload done!\n");
|
fprintf(stderr, "SFTP upload done.\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "SFTP failed to open destination path: %s\n",
|
fprintf(stderr, "SFTP failed to open destination path: %s\n",
|
||||||
|
@ -98,7 +98,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,14 +106,14 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = hostaddr;
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ int main(int argc, char *argv[])
|
|||||||
if(auth_pw) {
|
if(auth_pw) {
|
||||||
/* We could authenticate via password */
|
/* We could authenticate via password */
|
||||||
if(libssh2_userauth_password(session, username, password)) {
|
if(libssh2_userauth_password(session, username, password)) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,12 +153,12 @@ int main(int argc, char *argv[])
|
|||||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||||
pubkey, privkey,
|
pubkey, privkey,
|
||||||
password)) {
|
password)) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_init()!\n");
|
fprintf(stderr, "libssh2_sftp_init().\n");
|
||||||
sftp_session = libssh2_sftp_init(session);
|
sftp_session = libssh2_sftp_init(session);
|
||||||
|
|
||||||
if(!sftp_session) {
|
if(!sftp_session) {
|
||||||
@ -166,7 +166,7 @@ int main(int argc, char *argv[])
|
|||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_open() for READ and WRITE!\n");
|
fprintf(stderr, "libssh2_sftp_open() for READ and WRITE.\n");
|
||||||
/* Request a file via SFTP */
|
/* Request a file via SFTP */
|
||||||
sftp_handle = libssh2_sftp_open(sftp_session, sftppath,
|
sftp_handle = libssh2_sftp_open(sftp_session, sftppath,
|
||||||
LIBSSH2_FXF_WRITE |
|
LIBSSH2_FXF_WRITE |
|
||||||
@ -196,7 +196,7 @@ int main(int argc, char *argv[])
|
|||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_open() is done, now send data!\n");
|
fprintf(stderr, "libssh2_sftp_open() is done, now send data.\n");
|
||||||
do {
|
do {
|
||||||
nread = fread(mem, 1, sizeof(mem), local);
|
nread = fread(mem, 1, sizeof(mem), local);
|
||||||
if(nread <= 0) {
|
if(nread <= 0) {
|
||||||
|
@ -81,7 +81,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,14 +89,14 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = hostaddr;
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ int main(int argc, char *argv[])
|
|||||||
if(auth_pw) {
|
if(auth_pw) {
|
||||||
/* We could authenticate via password */
|
/* We could authenticate via password */
|
||||||
if(libssh2_userauth_password(session, username, password)) {
|
if(libssh2_userauth_password(session, username, password)) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ int main(int argc, char *argv[])
|
|||||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||||
pubkey, privkey,
|
pubkey, privkey,
|
||||||
password)) {
|
password)) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,14 +89,14 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = hostaddr;
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ int main(int argc, char *argv[])
|
|||||||
if(auth_pw) {
|
if(auth_pw) {
|
||||||
/* We could authenticate via password */
|
/* We could authenticate via password */
|
||||||
if(libssh2_userauth_password(session, username, password)) {
|
if(libssh2_userauth_password(session, username, password)) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ int main(int argc, char *argv[])
|
|||||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||||
pubkey, privkey,
|
pubkey, privkey,
|
||||||
password)) {
|
password)) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,14 +143,14 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = hostaddr;
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ int main(int argc, char *argv[])
|
|||||||
while((rc = libssh2_userauth_password(session, username, password)) ==
|
while((rc = libssh2_userauth_password(session, username, password)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN);
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,14 +200,14 @@ int main(int argc, char *argv[])
|
|||||||
password)) ==
|
password)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN);
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
libssh2_trace(session, LIBSSH2_TRACE_CONN);
|
libssh2_trace(session, LIBSSH2_TRACE_CONN);
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr, "libssh2_sftp_init()!\n");
|
fprintf(stderr, "libssh2_sftp_init().\n");
|
||||||
do {
|
do {
|
||||||
sftp_session = libssh2_sftp_init(session);
|
sftp_session = libssh2_sftp_init(session);
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
} while(!sftp_session);
|
} while(!sftp_session);
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_open()!\n");
|
fprintf(stderr, "libssh2_sftp_open().\n");
|
||||||
/* Request a file via SFTP */
|
/* Request a file via SFTP */
|
||||||
do {
|
do {
|
||||||
sftp_handle = libssh2_sftp_open(sftp_session, sftppath,
|
sftp_handle = libssh2_sftp_open(sftp_session, sftppath,
|
||||||
@ -241,7 +241,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
} while(!sftp_handle);
|
} while(!sftp_handle);
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_open() is done, now receive data!\n");
|
fprintf(stderr, "libssh2_sftp_open() is done, now receive data.\n");
|
||||||
do {
|
do {
|
||||||
char mem[1024 * 24];
|
char mem[1024 * 24];
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
|
@ -97,7 +97,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,14 +105,14 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = hostaddr;
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ int main(int argc, char *argv[])
|
|||||||
if(auth_pw) {
|
if(auth_pw) {
|
||||||
/* We could authenticate via password */
|
/* We could authenticate via password */
|
||||||
if(libssh2_userauth_password(session, username, password)) {
|
if(libssh2_userauth_password(session, username, password)) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,12 +152,12 @@ int main(int argc, char *argv[])
|
|||||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||||
pubkey, privkey,
|
pubkey, privkey,
|
||||||
password)) {
|
password)) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_init()!\n");
|
fprintf(stderr, "libssh2_sftp_init().\n");
|
||||||
sftp_session = libssh2_sftp_init(session);
|
sftp_session = libssh2_sftp_init(session);
|
||||||
|
|
||||||
if(!sftp_session) {
|
if(!sftp_session) {
|
||||||
@ -165,7 +165,7 @@ int main(int argc, char *argv[])
|
|||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_open()!\n");
|
fprintf(stderr, "libssh2_sftp_open().\n");
|
||||||
/* Request a file via SFTP */
|
/* Request a file via SFTP */
|
||||||
sftp_handle = libssh2_sftp_open(sftp_session, sftppath,
|
sftp_handle = libssh2_sftp_open(sftp_session, sftppath,
|
||||||
LIBSSH2_FXF_WRITE |
|
LIBSSH2_FXF_WRITE |
|
||||||
@ -181,7 +181,7 @@ int main(int argc, char *argv[])
|
|||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_open() is done, now send data!\n");
|
fprintf(stderr, "libssh2_sftp_open() is done, now send data.\n");
|
||||||
do {
|
do {
|
||||||
nread = fread(mem, 1, sizeof(mem), local);
|
nread = fread(mem, 1, sizeof(mem), local);
|
||||||
if(nread <= 0) {
|
if(nread <= 0) {
|
||||||
|
@ -131,7 +131,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,14 +139,14 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = hostaddr;
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ int main(int argc, char *argv[])
|
|||||||
while((rc = libssh2_userauth_password(session, username, password)) ==
|
while((rc = libssh2_userauth_password(session, username, password)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN);
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,12 +191,12 @@ int main(int argc, char *argv[])
|
|||||||
password)) ==
|
password)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN);
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_init()!\n");
|
fprintf(stderr, "libssh2_sftp_init().\n");
|
||||||
do {
|
do {
|
||||||
sftp_session = libssh2_sftp_init(session);
|
sftp_session = libssh2_sftp_init(session);
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
} while(!sftp_session);
|
} while(!sftp_session);
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_open()!\n");
|
fprintf(stderr, "libssh2_sftp_open().\n");
|
||||||
/* Request a file via SFTP */
|
/* Request a file via SFTP */
|
||||||
do {
|
do {
|
||||||
sftp_handle = libssh2_sftp_open(sftp_session, sftppath,
|
sftp_handle = libssh2_sftp_open(sftp_session, sftppath,
|
||||||
@ -226,7 +226,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
} while(!sftp_handle);
|
} while(!sftp_handle);
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_open() is done, now send data!\n");
|
fprintf(stderr, "libssh2_sftp_open() is done, now send data.\n");
|
||||||
start = time(NULL);
|
start = time(NULL);
|
||||||
do {
|
do {
|
||||||
nread = fread(mem, 1, sizeof(mem), local);
|
nread = fread(mem, 1, sizeof(mem), local);
|
||||||
|
@ -132,7 +132,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,14 +140,14 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = hostaddr;
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ int main(int argc, char *argv[])
|
|||||||
while((rc = libssh2_userauth_password(session, username, password)) ==
|
while((rc = libssh2_userauth_password(session, username, password)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN);
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -192,12 +192,12 @@ int main(int argc, char *argv[])
|
|||||||
password)) ==
|
password)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN);
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_init()!\n");
|
fprintf(stderr, "libssh2_sftp_init().\n");
|
||||||
do {
|
do {
|
||||||
sftp_session = libssh2_sftp_init(session);
|
sftp_session = libssh2_sftp_init(session);
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
} while(!sftp_session);
|
} while(!sftp_session);
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_open()!\n");
|
fprintf(stderr, "libssh2_sftp_open().\n");
|
||||||
/* Request a file via SFTP */
|
/* Request a file via SFTP */
|
||||||
do {
|
do {
|
||||||
sftp_handle = libssh2_sftp_open(sftp_session, sftppath,
|
sftp_handle = libssh2_sftp_open(sftp_session, sftppath,
|
||||||
@ -227,7 +227,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
} while(!sftp_handle);
|
} while(!sftp_handle);
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_open() is done, now send data!\n");
|
fprintf(stderr, "libssh2_sftp_open() is done, now send data.\n");
|
||||||
start = time(NULL);
|
start = time(NULL);
|
||||||
memuse = 0; /* it starts blank */
|
memuse = 0; /* it starts blank */
|
||||||
do {
|
do {
|
||||||
|
@ -109,7 +109,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,14 +117,14 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = hostaddr;
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ int main(int argc, char *argv[])
|
|||||||
if(auth_pw & 1) {
|
if(auth_pw & 1) {
|
||||||
/* We could authenticate via password */
|
/* We could authenticate via password */
|
||||||
if(libssh2_userauth_password(session, username, password)) {
|
if(libssh2_userauth_password(session, username, password)) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,7 +189,7 @@ int main(int argc, char *argv[])
|
|||||||
if(libssh2_userauth_keyboard_interactive(session, username,
|
if(libssh2_userauth_keyboard_interactive(session, username,
|
||||||
&kbd_callback) ) {
|
&kbd_callback) ) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Authentication by keyboard-interactive failed!\n");
|
"Authentication by keyboard-interactive failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -202,7 +202,7 @@ int main(int argc, char *argv[])
|
|||||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||||
pubkey, privkey,
|
pubkey, privkey,
|
||||||
password)) {
|
password)) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -210,12 +210,12 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "No supported authentication methods found!\n");
|
fprintf(stderr, "No supported authentication methods found.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_init()!\n");
|
fprintf(stderr, "libssh2_sftp_init().\n");
|
||||||
sftp_session = libssh2_sftp_init(session);
|
sftp_session = libssh2_sftp_init(session);
|
||||||
|
|
||||||
if(!sftp_session) {
|
if(!sftp_session) {
|
||||||
@ -226,7 +226,7 @@ int main(int argc, char *argv[])
|
|||||||
/* Since we have not set non-blocking, tell libssh2 we are blocking */
|
/* Since we have not set non-blocking, tell libssh2 we are blocking */
|
||||||
libssh2_session_set_blocking(session, 1);
|
libssh2_session_set_blocking(session, 1);
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_opendir()!\n");
|
fprintf(stderr, "libssh2_sftp_opendir().\n");
|
||||||
/* Request a dir listing via SFTP */
|
/* Request a dir listing via SFTP */
|
||||||
sftp_handle = libssh2_sftp_opendir(sftp_session, sftppath);
|
sftp_handle = libssh2_sftp_opendir(sftp_session, sftppath);
|
||||||
if(!sftp_handle) {
|
if(!sftp_handle) {
|
||||||
@ -234,7 +234,7 @@ int main(int argc, char *argv[])
|
|||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_opendir() is done, now receive listing!\n");
|
fprintf(stderr, "libssh2_sftp_opendir() is done, now receive listing.\n");
|
||||||
do {
|
do {
|
||||||
char mem[512];
|
char mem[512];
|
||||||
char longentry[512];
|
char longentry[512];
|
||||||
|
@ -88,7 +88,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,14 +96,14 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = hostaddr;
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ int main(int argc, char *argv[])
|
|||||||
while((rc = libssh2_userauth_password(session, username, password)) ==
|
while((rc = libssh2_userauth_password(session, username, password)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN);
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -148,12 +148,12 @@ int main(int argc, char *argv[])
|
|||||||
password)) ==
|
password)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN);
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_init()!\n");
|
fprintf(stderr, "libssh2_sftp_init().\n");
|
||||||
do {
|
do {
|
||||||
sftp_session = libssh2_sftp_init(session);
|
sftp_session = libssh2_sftp_init(session);
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
} while(!sftp_session);
|
} while(!sftp_session);
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_opendir()!\n");
|
fprintf(stderr, "libssh2_sftp_opendir().\n");
|
||||||
/* Request a dir listing via SFTP */
|
/* Request a dir listing via SFTP */
|
||||||
do {
|
do {
|
||||||
sftp_handle = libssh2_sftp_opendir(sftp_session, sftppath);
|
sftp_handle = libssh2_sftp_opendir(sftp_session, sftppath);
|
||||||
@ -176,7 +176,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
} while(!sftp_handle);
|
} while(!sftp_handle);
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_opendir() is done, now receive listing!\n");
|
fprintf(stderr, "libssh2_sftp_opendir() is done, now receive listing.\n");
|
||||||
do {
|
do {
|
||||||
char mem[512];
|
char mem[512];
|
||||||
LIBSSH2_SFTP_ATTRIBUTES attrs;
|
LIBSSH2_SFTP_ATTRIBUTES attrs;
|
||||||
|
@ -102,7 +102,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
rc = 1;
|
rc = 1;
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ int main(int argc, char *argv[])
|
|||||||
inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), username);
|
inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), username);
|
||||||
|
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ int main(int argc, char *argv[])
|
|||||||
if(auth_pw & 1) {
|
if(auth_pw & 1) {
|
||||||
/* We could authenticate via password */
|
/* We could authenticate via password */
|
||||||
if(libssh2_userauth_password(session, username, password)) {
|
if(libssh2_userauth_password(session, username, password)) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -194,7 +194,7 @@ int main(int argc, char *argv[])
|
|||||||
if(libssh2_userauth_keyboard_interactive(session, username,
|
if(libssh2_userauth_keyboard_interactive(session, username,
|
||||||
&kbd_callback) ) {
|
&kbd_callback) ) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Authentication by keyboard-interactive failed!\n");
|
"Authentication by keyboard-interactive failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -227,7 +227,7 @@ int main(int argc, char *argv[])
|
|||||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||||
fn1, fn2,
|
fn1, fn2,
|
||||||
password)) {
|
password)) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
free(fn2);
|
free(fn2);
|
||||||
free(fn1);
|
free(fn1);
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
@ -239,7 +239,7 @@ int main(int argc, char *argv[])
|
|||||||
free(fn1);
|
free(fn1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "No supported authentication methods found!\n");
|
fprintf(stderr, "No supported authentication methods found.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
rc = 1;
|
rc = 1;
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
@ -81,14 +81,14 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = hostaddr;
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ int main(int argc, char *argv[])
|
|||||||
if(userauthlist) {
|
if(userauthlist) {
|
||||||
fprintf(stderr, "Authentication methods: %s\n", userauthlist);
|
fprintf(stderr, "Authentication methods: %s\n", userauthlist);
|
||||||
if(!strstr(userauthlist, "publickey")) {
|
if(!strstr(userauthlist, "publickey")) {
|
||||||
fprintf(stderr, "\"publickey\" authentication is not supported\n");
|
fprintf(stderr, "'publickey' authentication is not supported\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if(libssh2_agent_userauth(agent, username, identity)) {
|
if(libssh2_agent_userauth(agent, username, identity)) {
|
||||||
fprintf(stderr, "Authentication with username %s and "
|
fprintf(stderr, "Authentication with username %s and "
|
||||||
"public key %s failed!\n",
|
"public key %s failed.\n",
|
||||||
username, identity->comment);
|
username, identity->comment);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -113,7 +113,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,14 +121,14 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = hostaddr;
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if(libssh2_agent_userauth(agent, username, identity)) {
|
if(libssh2_agent_userauth(agent, username, identity)) {
|
||||||
fprintf(stderr, "Authentication with username %s and "
|
fprintf(stderr, "Authentication with username %s and "
|
||||||
"public key %s failed!\n",
|
"public key %s failed.\n",
|
||||||
username, identity->comment);
|
username, identity->comment);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -212,7 +212,7 @@ int main(int argc, char *argv[])
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stdout, "Agent forwarding request succeeded!\n");
|
fprintf(stdout, "Agent forwarding request succeeded.\n");
|
||||||
}
|
}
|
||||||
while((rc = libssh2_channel_exec(channel, commandline)) ==
|
while((rc = libssh2_channel_exec(channel, commandline)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN) {
|
LIBSSH2_ERROR_EAGAIN) {
|
||||||
|
@ -111,7 +111,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,14 +119,14 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = hostaddr;
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ int main(int argc, char *argv[])
|
|||||||
while((rc = libssh2_userauth_password(session, username, password)) ==
|
while((rc = libssh2_userauth_password(session, username, password)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN);
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,14 +125,14 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = hostaddr;
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ int main(int argc, char *argv[])
|
|||||||
while((rc = libssh2_userauth_password(session, username, password)) ==
|
while((rc = libssh2_userauth_password(session, username, password)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN);
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ int main(int argc, char *argv[])
|
|||||||
password)) ==
|
password)) ==
|
||||||
LIBSSH2_ERROR_EAGAIN);
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if(rc) {
|
if(rc) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ static ssize_t netconf_read_until(LIBSSH2_CHANNEL *channel, const char *endtag,
|
|||||||
/* read more data until we see a rpc-reply closing tag followed by
|
/* read more data until we see a rpc-reply closing tag followed by
|
||||||
* the special sequence ]]>]]> */
|
* the special sequence ]]>]]> */
|
||||||
|
|
||||||
/* really, this MUST be replaced with proper XML parsing! */
|
/* really, this MUST be replaced with proper XML parsing. */
|
||||||
|
|
||||||
endreply = strstr(buf, endtag);
|
endreply = strstr(buf, endtag);
|
||||||
if(endreply)
|
if(endreply)
|
||||||
@ -82,8 +82,8 @@ static ssize_t netconf_read_until(LIBSSH2_CHANNEL *channel, const char *endtag,
|
|||||||
} while(!specialsequence && rd < buflen);
|
} while(!specialsequence && rd < buflen);
|
||||||
|
|
||||||
if(!specialsequence) {
|
if(!specialsequence) {
|
||||||
fprintf(stderr, "netconf_read_until(): ]]>]]> not found!"
|
fprintf(stderr, "netconf_read_until(): ]]>]]> not found."
|
||||||
" read buffer too small?\n");
|
" Read buffer too small?\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,26 +133,26 @@ int main(int argc, char *argv[])
|
|||||||
/* Connect to SSH server */
|
/* Connect to SSH server */
|
||||||
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to open socket!\n");
|
fprintf(stderr, "failed to open socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
sin.sin_family = AF_INET;
|
sin.sin_family = AF_INET;
|
||||||
sin.sin_addr.s_addr = inet_addr(server_ip);
|
sin.sin_addr.s_addr = inet_addr(server_ip);
|
||||||
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
||||||
fprintf(stderr, "inet_addr: Invalid IP address \"%s\"\n", server_ip);
|
fprintf(stderr, "inet_addr: Invalid IP address '%s'\n", server_ip);
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
sin.sin_port = htons(830);
|
sin.sin_port = htons(830);
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "Failed to connect to %s!\n", inet_ntoa(sin.sin_addr));
|
fprintf(stderr, "Failed to connect to %s.\n", inet_ntoa(sin.sin_addr));
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if(auth & AUTH_PASSWORD) {
|
if(auth & AUTH_PASSWORD) {
|
||||||
if(libssh2_userauth_password(session, username, password)) {
|
if(libssh2_userauth_password(session, username, password)) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ int main(int argc, char *argv[])
|
|||||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||||
pubkey, privkey,
|
pubkey, privkey,
|
||||||
password)) {
|
password)) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -212,7 +212,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "No supported authentication methods found!\n");
|
fprintf(stderr, "No supported authentication methods found.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,16 +220,16 @@ int main(int argc, char *argv[])
|
|||||||
/* open a channel */
|
/* open a channel */
|
||||||
channel = libssh2_channel_open_session(session);
|
channel = libssh2_channel_open_session(session);
|
||||||
if(!channel) {
|
if(!channel) {
|
||||||
fprintf(stderr, "Could not open the channel!\n"
|
fprintf(stderr, "Could not open the channel.\n"
|
||||||
"(Note that this can be a problem at the server!"
|
"(Note that this can be a problem at the server."
|
||||||
" Please review the server logs.)\n");
|
" Please review the server logs.)\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* execute the subsystem on our channel */
|
/* execute the subsystem on our channel */
|
||||||
if(libssh2_channel_subsystem(channel, "netconf")) {
|
if(libssh2_channel_subsystem(channel, "netconf")) {
|
||||||
fprintf(stderr, "Could not execute the \"netconf\" subsystem!\n"
|
fprintf(stderr, "Could not execute the 'netconf' subsystem.\n"
|
||||||
"(Note that this can be a problem at the server!"
|
"(Note that this can be a problem at the server."
|
||||||
" Please review the server logs.)\n");
|
" Please review the server logs.)\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
@ -102,26 +102,26 @@ int main(int argc, char *argv[])
|
|||||||
/* Connect to SSH server */
|
/* Connect to SSH server */
|
||||||
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to open socket!\n");
|
fprintf(stderr, "failed to open socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
sin.sin_family = AF_INET;
|
sin.sin_family = AF_INET;
|
||||||
sin.sin_addr.s_addr = inet_addr(server_ip);
|
sin.sin_addr.s_addr = inet_addr(server_ip);
|
||||||
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
||||||
fprintf(stderr, "inet_addr: Invalid IP address \"%s\"\n", server_ip);
|
fprintf(stderr, "inet_addr: Invalid IP address '%s'\n", server_ip);
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "Failed to connect to %s!\n", inet_ntoa(sin.sin_addr));
|
fprintf(stderr, "Failed to connect to %s.\n", inet_ntoa(sin.sin_addr));
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a session instance */
|
/* Create a session instance */
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if(auth & AUTH_PASSWORD) {
|
if(auth & AUTH_PASSWORD) {
|
||||||
if(libssh2_userauth_password(session, username, password)) {
|
if(libssh2_userauth_password(session, username, password)) {
|
||||||
fprintf(stderr, "Authentication by password failed!\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,7 +173,7 @@ int main(int argc, char *argv[])
|
|||||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||||
pubkey, privkey,
|
pubkey, privkey,
|
||||||
password)) {
|
password)) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -181,7 +181,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "No supported authentication methods found!\n");
|
fprintf(stderr, "No supported authentication methods found.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -192,8 +192,8 @@ int main(int argc, char *argv[])
|
|||||||
listener = libssh2_channel_forward_listen_ex(session, remote_listenhost,
|
listener = libssh2_channel_forward_listen_ex(session, remote_listenhost,
|
||||||
remote_wantport, &remote_listenport, 1);
|
remote_wantport, &remote_listenport, 1);
|
||||||
if(!listener) {
|
if(!listener) {
|
||||||
fprintf(stderr, "Could not start the tcpip-forward listener!\n"
|
fprintf(stderr, "Could not start the tcpip-forward listener.\n"
|
||||||
"(Note that this can be a problem at the server!"
|
"(Note that this can be a problem at the server."
|
||||||
" Please review the server logs.)\n");
|
" Please review the server logs.)\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
@ -204,8 +204,8 @@ int main(int argc, char *argv[])
|
|||||||
fprintf(stderr, "Waiting for remote connection\n");
|
fprintf(stderr, "Waiting for remote connection\n");
|
||||||
channel = libssh2_channel_forward_accept(listener);
|
channel = libssh2_channel_forward_accept(listener);
|
||||||
if(!channel) {
|
if(!channel) {
|
||||||
fprintf(stderr, "Could not accept connection!\n"
|
fprintf(stderr, "Could not accept connection.\n"
|
||||||
"(Note that this can be a problem at the server!"
|
"(Note that this can be a problem at the server."
|
||||||
" Please review the server logs.)\n");
|
" Please review the server logs.)\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
@ -215,7 +215,7 @@ int main(int argc, char *argv[])
|
|||||||
local_destip, local_destport);
|
local_destip, local_destport);
|
||||||
forwardsock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
forwardsock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
if(forwardsock == LIBSSH2_INVALID_SOCKET) {
|
if(forwardsock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to open forward socket!\n");
|
fprintf(stderr, "failed to open forward socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,11 +223,11 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_port = htons((unsigned short)local_destport);
|
sin.sin_port = htons((unsigned short)local_destport);
|
||||||
sin.sin_addr.s_addr = inet_addr(local_destip);
|
sin.sin_addr.s_addr = inet_addr(local_destip);
|
||||||
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
||||||
fprintf(stderr, "failed in inet_addr()!\n");
|
fprintf(stderr, "failed in inet_addr().\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
if(-1 == connect(forwardsock, (struct sockaddr *)&sin, sinlen)) {
|
if(-1 == connect(forwardsock, (struct sockaddr *)&sin, sinlen)) {
|
||||||
fprintf(stderr, "failed to connect()!\n");
|
fprintf(stderr, "failed to connect().\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,18 +244,18 @@ int main(int argc, char *argv[])
|
|||||||
tv.tv_usec = 100000;
|
tv.tv_usec = 100000;
|
||||||
rc = select((int)(forwardsock + 1), &fds, NULL, NULL, &tv);
|
rc = select((int)(forwardsock + 1), &fds, NULL, NULL, &tv);
|
||||||
if(-1 == rc) {
|
if(-1 == rc) {
|
||||||
fprintf(stderr, "failed to select()!\n");
|
fprintf(stderr, "failed to select().\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
if(rc && FD_ISSET(forwardsock, &fds)) {
|
if(rc && FD_ISSET(forwardsock, &fds)) {
|
||||||
ssize_t nwritten;
|
ssize_t nwritten;
|
||||||
len = recv(forwardsock, buf, sizeof(buf), 0);
|
len = recv(forwardsock, buf, sizeof(buf), 0);
|
||||||
if(len < 0) {
|
if(len < 0) {
|
||||||
fprintf(stderr, "failed to recv()!\n");
|
fprintf(stderr, "failed to recv().\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
else if(len == 0) {
|
else if(len == 0) {
|
||||||
fprintf(stderr, "The local server at %s:%d disconnected!\n",
|
fprintf(stderr, "The local server at %s:%d disconnected.\n",
|
||||||
local_destip, local_destport);
|
local_destip, local_destport);
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
@ -284,13 +284,13 @@ int main(int argc, char *argv[])
|
|||||||
while(wr < len) {
|
while(wr < len) {
|
||||||
nsent = send(forwardsock, buf + wr, len - wr, 0);
|
nsent = send(forwardsock, buf + wr, len - wr, 0);
|
||||||
if(nsent <= 0) {
|
if(nsent <= 0) {
|
||||||
fprintf(stderr, "failed to send()!\n");
|
fprintf(stderr, "failed to send().\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
wr += nsent;
|
wr += nsent;
|
||||||
}
|
}
|
||||||
if(libssh2_channel_eof(channel)) {
|
if(libssh2_channel_eof(channel)) {
|
||||||
fprintf(stderr, "The remote client at %s:%d disconnected!\n",
|
fprintf(stderr, "The remote client at %s:%d disconnected.\n",
|
||||||
remote_listenhost, remote_listenport);
|
remote_listenhost, remote_listenport);
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ static void x11_callback(LIBSSH2_SESSION *session, LIBSSH2_CHANNEL *channel,
|
|||||||
ptr = strrchr(display, ':');
|
ptr = strrchr(display, ':');
|
||||||
temp_buff = (char *)calloc(strlen(ptr + 1) + 1, sizeof(char));
|
temp_buff = (char *)calloc(strlen(ptr + 1) + 1, sizeof(char));
|
||||||
if(!temp_buff) {
|
if(!temp_buff) {
|
||||||
fprintf(stderr, "failed to calloc()!\n");
|
fprintf(stderr, "failed to calloc().\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memcpy(temp_buff, ptr + 1, strlen(ptr + 1));
|
memcpy(temp_buff, ptr + 1, strlen(ptr + 1));
|
||||||
@ -311,7 +311,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to open socket!\n");
|
fprintf(stderr, "failed to open socket.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ int main(int argc, char *argv[])
|
|||||||
sin.sin_addr.s_addr = hostaddr;
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
|
|
||||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||||
fprintf(stderr, "Failed to established connection!\n");
|
fprintf(stderr, "Failed to established connection.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* Open a session */
|
/* Open a session */
|
||||||
|
@ -2617,7 +2617,7 @@ static int channel_wait_eof(LIBSSH2_CHANNEL *channel)
|
|||||||
else if(rc < 0) {
|
else if(rc < 0) {
|
||||||
channel->wait_eof_state = libssh2_NB_state_idle;
|
channel->wait_eof_state = libssh2_NB_state_idle;
|
||||||
return _libssh2_error(session, rc,
|
return _libssh2_error(session, rc,
|
||||||
"_libssh2_transport_read() bailed out!");
|
"_libssh2_transport_read() bailed out");
|
||||||
}
|
}
|
||||||
} while(1);
|
} while(1);
|
||||||
|
|
||||||
|
@ -4165,7 +4165,7 @@ LIBSSH2_API int libssh2_session_supported_algs(LIBSSH2_SESSION* session,
|
|||||||
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||||
"Memory allocation failed");
|
"Memory allocation failed");
|
||||||
}
|
}
|
||||||
/* Past this point *algs must be deallocated in case of an error!! */
|
/* Past this point *algs must be deallocated in case of an error! */
|
||||||
|
|
||||||
/* copy non-NULL pointers only */
|
/* copy non-NULL pointers only */
|
||||||
for(i = 0, j = 0; mlist[i] && j < ialg; i++) {
|
for(i = 0, j = 0; mlist[i] && j < ialg; i++) {
|
||||||
|
@ -1271,7 +1271,7 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename,
|
|||||||
|
|
||||||
if(LIBSSH2_FX_OK == sftp->last_errno) {
|
if(LIBSSH2_FX_OK == sftp->last_errno) {
|
||||||
_libssh2_debug((session, LIBSSH2_TRACE_SFTP,
|
_libssh2_debug((session, LIBSSH2_TRACE_SFTP,
|
||||||
"got HANDLE FXOK!"));
|
"got HANDLE FXOK"));
|
||||||
|
|
||||||
LIBSSH2_FREE(session, data);
|
LIBSSH2_FREE(session, data);
|
||||||
|
|
||||||
@ -3379,7 +3379,7 @@ static int sftp_mkdir(LIBSSH2_SFTP *sftp, const char *path,
|
|||||||
LIBSSH2_FREE(session, data);
|
LIBSSH2_FREE(session, data);
|
||||||
|
|
||||||
if(retcode == LIBSSH2_FX_OK) {
|
if(retcode == LIBSSH2_FX_OK) {
|
||||||
_libssh2_debug((session, LIBSSH2_TRACE_SFTP, "OK!"));
|
_libssh2_debug((session, LIBSSH2_TRACE_SFTP, "OK"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -887,7 +887,7 @@ int _libssh2_transport_send(LIBSSH2_SESSION *session,
|
|||||||
debugdump(session, "libssh2_transport_write plain2", data2, data2_len);
|
debugdump(session, "libssh2_transport_write plain2", data2, data2_len);
|
||||||
|
|
||||||
/* FIRST, check if we have a pending write to complete. send_existing
|
/* FIRST, check if we have a pending write to complete. send_existing
|
||||||
only sanity-check data and data_len and not data2 and data2_len!! */
|
only sanity-check data and data_len and not data2 and data2_len! */
|
||||||
rc = send_existing(session, data, data_len, &ret);
|
rc = send_existing(session, data, data_len, &ret);
|
||||||
if(rc)
|
if(rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -45,7 +45,7 @@ int main(int argc, char **argv)
|
|||||||
/* Call the fuzzer with the data. */
|
/* Call the fuzzer with the data. */
|
||||||
LLVMFuzzerTestOneInput(buffer, buffer_len);
|
LLVMFuzzerTestOneInput(buffer, buffer_len);
|
||||||
|
|
||||||
printf("complete !!");
|
printf("complete.");
|
||||||
|
|
||||||
/* Free the buffer as it's no longer needed. */
|
/* Free the buffer as it's no longer needed. */
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
@ -69,7 +69,7 @@ int main(void)
|
|||||||
++retry > retries) {
|
++retry > retries) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "Test failed (%d)! Retrying... %d / %d\n",
|
fprintf(stderr, "Test failed (%d). Retrying... %d / %d\n",
|
||||||
rc, retry, retries);
|
rc, retry, retries);
|
||||||
} while(1);
|
} while(1);
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(sock == LIBSSH2_INVALID_SOCKET) {
|
if(sock == LIBSSH2_INVALID_SOCKET) {
|
||||||
fprintf(stderr, "failed to create socket!\n");
|
fprintf(stderr, "failed to create socket.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
session = libssh2_session_init();
|
session = libssh2_session_init();
|
||||||
if(!session) {
|
if(!session) {
|
||||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
fprintf(stderr, "Could not initialize SSH session.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ int main(int argc, char *argv[])
|
|||||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||||
pubkey, privkey,
|
pubkey, privkey,
|
||||||
password)) {
|
password)) {
|
||||||
fprintf(stderr, "Authentication by public key failed!\n");
|
fprintf(stderr, "Authentication by public key failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -199,7 +199,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "No supported authentication methods found!\n");
|
fprintf(stderr, "No supported authentication methods found.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user