messeing around with libssh
This commit is contained in:
parent
7acd21695f
commit
5fd1c5b2a5
3 changed files with 42 additions and 0 deletions
|
|
@ -30,6 +30,10 @@ set_property(CACHE ARCHEUS_STD_INPUT_BACKEND PROPERTY STRINGS NONE SDL2 GLFW)
|
||||||
set(ARCHEUS_STD_GRAPHICS_BACKEND "NONE" CACHE STRING "Graphics Backend to build with")
|
set(ARCHEUS_STD_GRAPHICS_BACKEND "NONE" CACHE STRING "Graphics Backend to build with")
|
||||||
set_property(CACHE ARCHEUS_STD_GRAPHICS_BACKEND PROPERTY STRINGS NONE SDL2 OPENGL)
|
set_property(CACHE ARCHEUS_STD_GRAPHICS_BACKEND PROPERTY STRINGS NONE SDL2 OPENGL)
|
||||||
|
|
||||||
|
set(ARCHEUS_STD_SSH_BACKEND "NONE" CACHE STRING "SSH Backend to build with")
|
||||||
|
set_property(CACHE ARCHEUS_STD_GRAPHICS_BACKEND PROPERTY STRINGS NONE LIBSSH)
|
||||||
|
|
||||||
|
|
||||||
# ~ INIT VARIABLES ~ #
|
# ~ INIT VARIABLES ~ #
|
||||||
set(ARCHEUS_STD_FLAGS "")
|
set(ARCHEUS_STD_FLAGS "")
|
||||||
set(ARCHEUS_STD_LIBRARIES "")
|
set(ARCHEUS_STD_LIBRARIES "")
|
||||||
|
|
@ -98,6 +102,10 @@ opengl_check_and_init_needed(ARCHEUS_STD_FLAGS ARCHEUS_STD_SOURCES ${ARCHEUS_STD
|
||||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/archeus_glfw.cmake)
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/archeus_glfw.cmake)
|
||||||
glfw_check_and_init_needed(ARCHEUS_STD_FLAGS ARCHEUS_STD_SOURCES ${ARCHEUS_STD_WINDOW_BACKEND} ${ARCHEUS_STD_INPUT_BACKEND})
|
glfw_check_and_init_needed(ARCHEUS_STD_FLAGS ARCHEUS_STD_SOURCES ${ARCHEUS_STD_WINDOW_BACKEND} ${ARCHEUS_STD_INPUT_BACKEND})
|
||||||
|
|
||||||
|
# ~ LIBSSH ~ #
|
||||||
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/archeus_libssh.cmake)
|
||||||
|
libssh_check_and_init_needed(ARCHEUS_STD_FLAGS ARCHEUS_STD_SOURCES ${ARCHEUS_STD_SSH_BACKEND})
|
||||||
|
|
||||||
#if(ARCHEUS_STD_GLEW)
|
#if(ARCHEUS_STD_GLEW)
|
||||||
# string(APPEND ARCHEUS_STD_FLAGS "-DARC_GLEW ")
|
# string(APPEND ARCHEUS_STD_FLAGS "-DARC_GLEW ")
|
||||||
#endif()
|
#endif()
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
set(ARCHEUS_STD_LIBSSH_SSH_SOURCES
|
||||||
|
packages/networking/libssh/ssh.c
|
||||||
|
)
|
||||||
|
|
||||||
|
function(libssh_check_and_init_needed _ARCHEUS_STD_FLAGS _ARCHEUS_STD_SOURCES ARCHEUS_STD_SSH_BACKEND)
|
||||||
|
#add matching files for the selected backends
|
||||||
|
if(${ARCHEUS_STD_SSH_BACKEND} STREQUAL "LIBSSH")
|
||||||
|
string(APPEND ${_ARCHEUS_STD_FLAGS} "-lssh ")
|
||||||
|
list(APPEND ${_ARCHEUS_STD_SOURCES} ${ARCHEUS_STD_LIBSSH_SSH_SOURCES})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(${_ARCHEUS_STD_FLAGS} ${${_ARCHEUS_STD_FLAGS}} PARENT_SCOPE)
|
||||||
|
set(${_ARCHEUS_STD_SOURCES} ${${_ARCHEUS_STD_SOURCES}} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
@ -129,6 +129,24 @@ void ARC_Ssh_Create(ARC_Ssh **ssh, char *host, char *user, char *password){
|
||||||
*ssh = NULL;
|
*ssh = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if no password is provided try to connect with a public key
|
||||||
|
if(password == NULL){
|
||||||
|
returnCode = ssh_userauth_publickey_auto((*ssh)->session, NULL, NULL);
|
||||||
|
if(returnCode != SSH_AUTH_SUCCESS){
|
||||||
|
arc_errno = ARC_ERRNO_CONNECTION;
|
||||||
|
ARC_DEBUG_LOG(arc_errno, "ARC_Ssh_Create(ssh), ssh failed to authenticate with password: %s\n", ssh_get_error((*ssh)->session));
|
||||||
|
ssh_disconnect((*ssh)->session);
|
||||||
|
ssh_free((*ssh)->session);
|
||||||
|
free(*ssh);
|
||||||
|
*ssh = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ssh_send_ignore((*ssh)->session, "mpv https://youtu.be/1P5BSm_oFJg --input-ipc-server=/tmp/mpvsocket --no-terminal & disown");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//try connecting with password
|
||||||
returnCode = ssh_userauth_password((*ssh)->session, NULL, password);
|
returnCode = ssh_userauth_password((*ssh)->session, NULL, password);
|
||||||
if(returnCode != SSH_AUTH_SUCCESS){
|
if(returnCode != SSH_AUTH_SUCCESS){
|
||||||
arc_errno = ARC_ERRNO_CONNECTION;
|
arc_errno = ARC_ERRNO_CONNECTION;
|
||||||
|
|
@ -201,6 +219,8 @@ void ARC_Ssh_ExecStrInNewSession(ARC_Ssh *ssh, char *command){
|
||||||
ARC_DEBUG_LOG(arc_errno, "ARC_Ssh_RunInSession(ssh, sessionFn), ssh failed when executing command with error code: %d\n", returnCode);
|
ARC_DEBUG_LOG(arc_errno, "ARC_Ssh_RunInSession(ssh, sessionFn), ssh failed when executing command with error code: %d\n", returnCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sleep(1);
|
||||||
|
|
||||||
ssh_channel_send_eof(channel);
|
ssh_channel_send_eof(channel);
|
||||||
ssh_channel_close(channel);
|
ssh_channel_close(channel);
|
||||||
ssh_channel_free(channel);
|
ssh_channel_free(channel);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue