diff --git a/ssheven-constants.r b/ssheven-constants.r index 019db72..104b0e4 100644 --- a/ssheven-constants.r +++ b/ssheven-constants.r @@ -71,6 +71,10 @@ #define DLOG_KEY_PASSWORD 138 #define DITL_KEY_PASSWORD 138 +/* alert for key file read failure */ +#define ALRT_FILE_FAIL 139 +#define DITL_FILE_FAIL 139 + /* menus */ #define MBAR_SSHEVEN 128 #define MENU_APPLE 128 diff --git a/ssheven.c b/ssheven.c index 97a8de9..986b120 100644 --- a/ssheven.c +++ b/ssheven.c @@ -23,9 +23,12 @@ enum { WAIT, READ, EXIT } read_thread_command = WAIT; enum { UNINTIALIZED, OPEN, CLEANUP, DONE } read_thread_state = UNINTIALIZED; enum { KEY_LOGIN, PASSWORD_LOGIN } login_type = PASSWORD_LOGIN; +// pascal strings char hostname[512] = {0}; char username[256] = {0}; char password[256] = {0}; + +// malloc'd c strings char* pubkey_path = NULL; char* privkey_path = NULL; @@ -847,7 +850,8 @@ void* read_thread(void* arg) } else { - if (rc == LIBSSH2_ERROR_AUTHENTICATION_FAILED) StopAlert(ALRT_PW_FAIL, nil); + if (rc == LIBSSH2_ERROR_AUTHENTICATION_FAILED && login_type == PASSWORD_LOGIN) StopAlert(ALRT_PW_FAIL, nil); + if (rc == LIBSSH2_ERROR_FILE) StopAlert(ALRT_FILE_FAIL, nil); printf_i("failure: %s\r\n", libssh2_error_string(rc)); ok = 0; } diff --git a/ssheven.r b/ssheven.r index 2277014..fc706ba 100644 --- a/ssheven.r +++ b/ssheven.r @@ -308,6 +308,30 @@ resource 'ALRT' (ALRT_PRIVKEY, purgeable) { alertPositionMainScreen }; +resource 'DITL' (DITL_FILE_FAIL) { + { + { 50, 260, 70, 340 }, + Button { enabled, "OK" }; + + { 10, 70, 30, 340 }, + StaticText { enabled, "Couldn't load key files!" }; + } +}; + +resource 'ALRT' (ALRT_FILE_FAIL, purgeable) { + { 50, 100, 50+80, 100+350 }, + DITL_FILE_FAIL, + + /* OK means draw default border on first button */ + { + OK, visible, silent, + OK, visible, silent, + OK, visible, silent, + OK, visible, silent + }, + alertPositionMainScreen +}; + #include "Processes.r" resource 'SIZE' (-1) {