diff --git a/src/session.c b/src/session.c index a2fe627..be3fc9f 100644 --- a/src/session.c +++ b/src/session.c @@ -41,7 +41,7 @@ static void assert_or_disconnect(int rc, const char * what, ssh_session ssh){ static int password_cb(SEXP rpass, const char * prompt, char *buf, int buflen, const char *user){ if(Rf_isString(rpass) && Rf_length(rpass)){ strncpy(buf, CHAR(STRING_ELT(rpass, 0)), buflen); - return Rf_length(STRING_ELT(rpass, 0)); + return SSH_OK; } else if(Rf_isFunction(rpass)){ int err; if(strcmp(prompt, "Passphrase") == 0) //nicer wording @@ -63,9 +63,8 @@ static int password_cb(SEXP rpass, const char * prompt, char *buf, int buflen, c return SSH_ERROR; } -static int my_auth_callback(const char *prompt, char *buf, size_t len, int echo, int verify, void *userdata){ - SEXP rpass = (SEXP) userdata; - return password_cb(rpass, prompt, buf, len, ""); +static int my_auth_callback(const char *prompt, char *buf, size_t len, int echo, int verify, void *rpass){ + return password_cb((SEXP) rpass, prompt, buf, len, ""); } static int auth_password(ssh_session ssh, SEXP rpass, const char *user){