Skip to content

Commit

Permalink
Allow hardcoded string passwords, fixes #26
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Apr 3, 2019
1 parent f0d19bb commit 6b5b321
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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){
Expand Down

0 comments on commit 6b5b321

Please sign in to comment.