cvs: pecl /ssh2 config.m4 ssh2.c
| From: | Sara Golemon | Date: | Mon, 14 Feb 2005 06:07:48 +0000 |
| Subject: | cvs: pecl /ssh2 config.m4 ssh2.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-2560@lists.php.net to get a copy of this message | ||
pollita Mon Feb 14 01:07:48 2005 EDT
Modified files:
/pecl/ssh2 config.m4 ssh2.c
Log:
Add support for libssh2-0.7's hostbased auth method
http://cvs.php.net/diff.php/pecl/ssh2/config.m4?r1=1.4&r2=1.5&ty=u
Index: pecl/ssh2/config.m4
diff -u pecl/ssh2/config.m4:1.4 pecl/ssh2/config.m4:1.5
--- pecl/ssh2/config.m4:1.4 Wed Feb 9 14:44:21 2005
+++ pecl/ssh2/config.m4 Mon Feb 14 01:07:45 2005
@@ -1,4 +1,4 @@
-dnl $Id: config.m4,v 1.4 2005/02/09 19:44:21 pollita Exp $
+dnl $Id: config.m4,v 1.5 2005/02/14 06:07:45 pollita Exp $
dnl config.m4 for extension ssh2
PHP_ARG_WITH(ssh2, for ssh2 support,
@@ -45,6 +45,13 @@
],[
AC_MSG_WARN([libssh2 <= 0.4, remote forwarding not enabled])
])
+
+ PHP_CHECK_LIBRARY($LIBNAME,libssh2_userauth_hostbased_fromfile_ex,
+ [
+ AC_DEFINE(PHP_SSH2_HOSTBASED_AUTH, 1, [Have libssh2 with hostbased authentication])
+ ],[
+ AC_MSG_WARN([libssh2 <= 0.6, hostbased authentication not enabled])
+ ])
PHP_SUBST(SSH2_SHARED_LIBADD)
http://cvs.php.net/diff.php/pecl/ssh2/ssh2.c?r1=1.5&r2=1.6&ty=u
Index: pecl/ssh2/ssh2.c
diff -u pecl/ssh2/ssh2.c:1.5 pecl/ssh2/ssh2.c:1.6
--- pecl/ssh2/ssh2.c:1.5 Sun Feb 13 00:24:58 2005
+++ pecl/ssh2/ssh2.c Mon Feb 14 01:07:45 2005
@@ -15,7 +15,7 @@
| Author: Sara Golemon <pollita@php.net> |
+----------------------------------------------------------------------+
- $Id: ssh2.c,v 1.5 2005/02/13 05:24:58 pollita Exp $
+ $Id: ssh2.c,v 1.6 2005/02/14 06:07:45 pollita Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -652,6 +652,58 @@
}
/* }}} */
+#ifdef PHP_SSH2_HOSTBASED_AUTH
+/* {{{ proto bool ssh2_auth_hostbased_file(resource session, string username, string
local_hostname, string pubkeyfile, string privkeyfile[, string passphrase[, string local_username]])
+ * Authenticate using a hostkey
+ */
+PHP_FUNCTION(ssh2_auth_hostbased_file)
+{
+ LIBSSH2_SESSION *session;
+ zval *zsession;
+ char *username, *hostname, *pubkey, *privkey, *passphrase = NULL, *local_username = NULL;
+ int username_len, hostname_len, pubkey_len, privkey_len, passphrase_len, local_username_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rssss|s!s!",
&zsession, &username, &username_len,
+ &hostname, &hostname_len,
+ &pubkey, &pubkey_len,
+ &privkey, &privkey_len,
+ &passphrase, &passphrase_len,
+ &local_username, &local_username_len) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ if (PG(safe_mode) && !php_checkuid(pubkey, NULL, CHECKUID_CHECK_FILE_AND_DIR)) {
+ RETURN_FALSE;
+ }
+ if (PG(safe_mode) && !php_checkuid(privkey, NULL, CHECKUID_CHECK_FILE_AND_DIR)) {
+ RETURN_FALSE;
+ }
+
+ if (php_check_open_basedir(pubkey TSRMLS_CC)) {
+ RETURN_FALSE;
+ }
+ if (php_check_open_basedir(privkey TSRMLS_CC)) {
+ RETURN_FALSE;
+ }
+
+ ZEND_FETCH_RESOURCE(session, LIBSSH2_SESSION*, &zsession, -1, PHP_SSH2_SESSION_RES_NAME,
le_ssh2_session);
+
+ if (!local_username) {
+ local_username = username;
+ local_username_len = username_len;
+ }
+
+ /* TODO: Support passphrase callback */
+ if (libssh2_userauth_hostbased_fromfile_ex(session, username, username_len, pubkey, privkey,
passphrase, hostname, hostname_len, local_username, local_username_len)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Authentication failed for %s using hostbased
public key", username);
+ RETURN_FALSE;
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+#endif /* PHP_SSH2_HOSTBASED_AUTH */
+
#ifdef PHP_SSH2_REMOTE_FORWARDING
/* {{{ proto resource ssh2_forward_listen(resource session, int port[, string host[, long
max_connections]])
* Bind a port on the remote server and listen for connections
@@ -846,6 +898,9 @@
PHP_FE(ssh2_auth_none, NULL)
PHP_FE(ssh2_auth_password, NULL)
PHP_FE(ssh2_auth_pubkey_file, NULL)
+#ifdef PHP_SSH2_HOSTBASED_AUTH
+ PHP_FE(ssh2_auth_hostbased_file, NULL)
+#endif /* PHP_SSH2_HOSTBASED_AUTH */
#ifdef PHP_SSH2_REMOTE_FORWARDING
PHP_FE(ssh2_forward_listen, NULL)