Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ssh2.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ PHP_FUNCTION(ssh2_auth_pubkey_file)
{
LIBSSH2_SESSION *session;
zval *zsession;
zend_string *username, *pubkey, *privkey, *passphrase;
zend_string *username, *pubkey, *privkey, *passphrase = NULL;
#ifndef PHP_WIN32
zend_string *newpath;
struct passwd *pws;
Expand Down Expand Up @@ -689,7 +689,7 @@ PHP_FUNCTION(ssh2_auth_pubkey_file)
#endif

/* TODO: Support passphrase callback */
if (libssh2_userauth_publickey_fromfile_ex(session, ZSTR_VAL(username), ZSTR_LEN(username), ZSTR_VAL(pubkey), ZSTR_VAL(privkey), ZSTR_VAL(passphrase))) {
if (libssh2_userauth_publickey_fromfile_ex(session, ZSTR_VAL(username), ZSTR_LEN(username), ZSTR_VAL(pubkey), ZSTR_VAL(privkey), passphrase ? ZSTR_VAL(passphrase) : NULL)) {
char *buf;
int len;
libssh2_session_last_error(session, &buf, &len, 0);
Expand All @@ -709,15 +709,15 @@ PHP_FUNCTION(ssh2_auth_pubkey)
{
LIBSSH2_SESSION *session;
zval *zsession;
zend_string *username, *pubkey, *privkey, *passphrase;
zend_string *username, *pubkey, *privkey, *passphrase = NULL;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "rSSS|S", &zsession, &username, &pubkey, &privkey, &passphrase) == FAILURE) {
return;
}

SSH2_FETCH_NONAUTHENTICATED_SESSION(session, zsession);

if (libssh2_userauth_publickey_frommemory(session, ZSTR_VAL(username), ZSTR_LEN(username), ZSTR_VAL(pubkey), ZSTR_LEN(pubkey), ZSTR_VAL(privkey), ZSTR_LEN(privkey), ZSTR_VAL(passphrase))) {
if (libssh2_userauth_publickey_frommemory(session, ZSTR_VAL(username), ZSTR_LEN(username), ZSTR_VAL(pubkey), ZSTR_LEN(pubkey), ZSTR_VAL(privkey), ZSTR_LEN(privkey), passphrase ? ZSTR_VAL(passphrase) : NULL)) {
char *buf;
int len;
libssh2_session_last_error(session, &buf, &len, 0);
Expand Down
Loading