add error alert if keys failed to load

This commit is contained in:
cy384 2020-09-15 21:33:00 -04:00
parent 749b6a3a22
commit 7f2779c9ba
3 changed files with 33 additions and 1 deletions

View File

@ -71,6 +71,10 @@
#define DLOG_KEY_PASSWORD 138 #define DLOG_KEY_PASSWORD 138
#define DITL_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 */ /* menus */
#define MBAR_SSHEVEN 128 #define MBAR_SSHEVEN 128
#define MENU_APPLE 128 #define MENU_APPLE 128

View File

@ -23,9 +23,12 @@ enum { WAIT, READ, EXIT } read_thread_command = WAIT;
enum { UNINTIALIZED, OPEN, CLEANUP, DONE } read_thread_state = UNINTIALIZED; enum { UNINTIALIZED, OPEN, CLEANUP, DONE } read_thread_state = UNINTIALIZED;
enum { KEY_LOGIN, PASSWORD_LOGIN } login_type = PASSWORD_LOGIN; enum { KEY_LOGIN, PASSWORD_LOGIN } login_type = PASSWORD_LOGIN;
// pascal strings
char hostname[512] = {0}; char hostname[512] = {0};
char username[256] = {0}; char username[256] = {0};
char password[256] = {0}; char password[256] = {0};
// malloc'd c strings
char* pubkey_path = NULL; char* pubkey_path = NULL;
char* privkey_path = NULL; char* privkey_path = NULL;
@ -847,7 +850,8 @@ void* read_thread(void* arg)
} }
else 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)); printf_i("failure: %s\r\n", libssh2_error_string(rc));
ok = 0; ok = 0;
} }

View File

@ -308,6 +308,30 @@ resource 'ALRT' (ALRT_PRIVKEY, purgeable) {
alertPositionMainScreen 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" #include "Processes.r"
resource 'SIZE' (-1) { resource 'SIZE' (-1) {