diff options
author | Russ Allbery <rra@stanford.edu> | 2011-09-26 16:13:21 -0700 |
---|---|---|
committer | Russ Allbery <rra@stanford.edu> | 2011-09-26 16:13:21 -0700 |
commit | ea436286dc6e916d9f881db187bfe52c666a4ba2 (patch) | |
tree | 98352a576d22d84b6e137c01b4c7230904f4f517 /php | |
parent | 593aa068813178c6be07833a49fb4d3f759ef63a (diff) |
Add remctl_set_ccache interface to the PHP bindings
Diffstat (limited to 'php')
-rw-r--r-- | php/php_remctl.c | 25 | ||||
-rw-r--r-- | php/php_remctl.h.in | 1 | ||||
-rw-r--r-- | php/tests/005.phpt | 38 |
3 files changed, 64 insertions, 0 deletions
diff --git a/php/php_remctl.c b/php/php_remctl.c index a7af9a8..7bedcf8 100644 --- a/php/php_remctl.c +++ b/php/php_remctl.c @@ -31,6 +31,7 @@ static int le_remctl_internal; static zend_function_entry remctl_functions[] = { ZEND_FE(remctl, NULL) ZEND_FE(remctl_new, NULL) + ZEND_FE(remctl_set_ccache, NULL) ZEND_FE(remctl_set_source_ip, NULL) ZEND_FE(remctl_open, NULL) ZEND_FE(remctl_close, NULL) @@ -215,6 +216,30 @@ ZEND_FUNCTION(remctl_new) /* + * Set the credential cache for subsequent connections with remctl_open. + */ +ZEND_FUNCTION(remctl_set_ccache) +{ + struct remctl *r; + zval *zrem; + char *ccache; + int clen, status; + + status = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &zrem, + &ccache, &clen); + if (status == FAILURE) { + zend_error(E_WARNING, "remctl_set_ccache: invalid parameters\n"); + RETURN_FALSE; + } + ZEND_FETCH_RESOURCE(r, struct remctl *, &zrem, -1, PHP_REMCTL_RES_NAME, + le_remctl_internal); + if (!remctl_set_ccache(r, ccache)) + RETURN_FALSE; + RETURN_TRUE; +} + + +/* * Set the source IP for subsequent connections with remctl_open. */ ZEND_FUNCTION(remctl_set_source_ip) diff --git a/php/php_remctl.h.in b/php/php_remctl.h.in index 9b69ed8..26f7f89 100644 --- a/php/php_remctl.h.in +++ b/php/php_remctl.h.in @@ -20,6 +20,7 @@ PHP_MINIT_FUNCTION(remctl); PHP_FUNCTION(remctl); PHP_FUNCTION(remctl_new); +PHP_FUNCTION(remctl_set_ccache); PHP_FUNCTION(remctl_set_source_ip); PHP_FUNCTION(remctl_open); PHP_FUNCTION(remctl_command); diff --git a/php/tests/005.phpt b/php/tests/005.phpt new file mode 100644 index 0000000..3fac294 --- /dev/null +++ b/php/tests/005.phpt @@ -0,0 +1,38 @@ +--TEST-- +Check setting credential cache +--ENV-- +KRB5CCNAME=nonexistent-file +LD_LIBRARY_PATH=../client/.libs +--SKIPIF-- +<?php + if (!file_exists("remctl-test.pid")) + echo "skip remctld not running"; +?> +--FILE-- +<?php + $fh = fopen("remctl-test.princ", "r"); + $principal = rtrim(fread($fh, filesize("remctl-test.princ"))); + $r = remctl_new(); + if ($r == null) { + echo "remctl_new failed\n"; + exit(2); + } + echo "Created object\n"; + if (remctl_open($r, "127.0.0.1", 14373, $principal)) { + echo "remctl_open succeeded unexpectedly\n"; + exit(2); + } + echo "remctl_open failed without credential cache\n"; + if (remctl_set_ccache($r, "remctl-test.cache")) { + if (!remctl_open($r, "127.0.0.1", 14373, $principal)) { + echo "remctl_open failed\n"; + exit (2); + } + } + echo "Success or expected failure\n"; + remctl_close($r); +?> +--EXPECT-- +Created object +remctl_open failed without credential cache +Success or expected failure |