2 ===================================================================
3 --- Makefile.in (.../tags/RELEASE_0_1_0)
4 +++ Makefile.in (.../trunk)
8 -LTLIBRARY_NAME = libsasl.la
9 -LTLIBRARY_SOURCES = sasl.c
10 -LTLIBRARY_SHARED_NAME = sasl.la
11 -LTLIBRARY_SHARED_LIBADD = $(SASL_SHARED_LIBADD)
13 -include $(top_srcdir)/build/dynlib.mk
15 ===================================================================
16 --- sasl.c (.../tags/RELEASE_0_1_0)
17 +++ sasl.c (.../trunk)
19 #define le_conn_name "SASL Connection Context"
22 -/* {{{ sasl_callbacks[]
23 - Global callbacks. These have no per-session context. */
24 -static sasl_callback_t sasl_callbacks[] = {
25 - { SASL_CB_LIST_END, 0, 0 }
28 +PHPAPI ZEND_DECLARE_MODULE_GLOBALS(sasl);
30 +/* SASL Callback Functions */
31 +/* {{{ php_sasl_cb_getopt
33 +static int php_sasl_cb_getopt(void *context, const char *plugin_name,
34 + const char *option, const char **result,
37 + zval *function = context;
40 + int ret = SASL_FAIL;
42 + MAKE_STD_ZVAL(args[0]);
43 + MAKE_STD_ZVAL(args[1]);
44 + MAKE_STD_ZVAL(retval);
46 + ZVAL_STRING(args[0], (plugin_name) ? (char *)plugin_name : "", 1);
47 + ZVAL_STRING(args[1], (char *)option, 1);
49 + if (call_user_function(CG(function_table), NULL, function, retval,
50 + 2, args TSRMLS_CC) == SUCCESS) {
51 + ret = Z_LVAL_P(retval);
52 + *result = estrdup(Z_STRVAL_P(retval));
53 + *len = Z_STRLEN_P(retval);
56 + zval_ptr_dtor(&args[0]);
57 + zval_ptr_dtor(&args[1]);
58 + zval_ptr_dtor(&retval);
63 +/* {{{ php_sasl_cb_log
65 +static int php_sasl_cb_log(void *context, int level, const char *message)
67 + zval *function = context;
70 + int ret = SASL_FAIL;
72 + MAKE_STD_ZVAL(args[0]);
73 + MAKE_STD_ZVAL(args[1]);
74 + MAKE_STD_ZVAL(retval);
76 + ZVAL_LONG(args[0], level);
77 + ZVAL_STRING(args[1], (char *)message, 1);
79 + if (call_user_function(CG(function_table), NULL, function, retval,
80 + 2, args TSRMLS_CC) == SUCCESS) {
81 + ret = Z_LVAL_P(retval);
84 + zval_ptr_dtor(&args[0]);
85 + zval_ptr_dtor(&args[1]);
86 + zval_ptr_dtor(&retval);
91 +/* {{{ php_sasl_cb_getpath
93 +static int php_sasl_cb_getpath(void *context, const char **path)
95 + zval *function = context;
97 + int ret = SASL_FAIL;
99 + MAKE_STD_ZVAL(retval);
101 + if (call_user_function(CG(function_table), NULL, function, retval,
102 + 0, NULL TSRMLS_CC) == SUCCESS) {
103 + ret = Z_LVAL_P(retval);
104 + *path = estrdup(Z_STRVAL_P(retval));
107 + zval_ptr_dtor(&retval);
112 +/* {{{ php_sasl_cb_verifyfile
114 +static int php_sasl_cb_verifyfile(void *context, const char *file,
115 + sasl_verify_type_t type)
117 + zval *function = context;
120 + int ret = SASL_FAIL;
122 + MAKE_STD_ZVAL(args[0]);
123 + MAKE_STD_ZVAL(args[1]);
124 + MAKE_STD_ZVAL(retval);
126 + ZVAL_STRING(args[0], (char *)file, 1);
127 + ZVAL_LONG(args[1], type);
129 + if (call_user_function(CG(function_table), NULL, function, retval,
130 + 2, args TSRMLS_CC) == SUCCESS) {
131 + ret = Z_LVAL_P(retval);
134 + zval_ptr_dtor(&args[0]);
135 + zval_ptr_dtor(&args[1]);
136 + zval_ptr_dtor(&retval);
141 +/* {{{ php_sasl_cb_getconfpath
143 +static int php_sasl_cb_getconfpath(void *context, char **path)
145 + zval *function = context;
147 + int ret = SASL_FAIL;
149 + MAKE_STD_ZVAL(retval);
151 + if (call_user_function(CG(function_table), NULL, function, retval,
152 + 0, NULL TSRMLS_CC) == SUCCESS) {
153 + ret = Z_LVAL_P(retval);
154 + *path = estrdup(Z_STRVAL_P(retval));
157 + zval_ptr_dtor(&retval);
162 +/* {{{ php_sasl_cb_getsimple
164 +static int php_sasl_cb_getsimple(void *context, int id, const char **result,
167 + zval *function = context;
171 + MAKE_STD_ZVAL(args[0]);
172 + MAKE_STD_ZVAL(retval);
174 + ZVAL_LONG(args[0], id);
176 + if (call_user_function(CG(function_table), NULL, function, retval,
177 + 1, args TSRMLS_CC) == SUCCESS) {
178 + *result = estrdup(Z_STRVAL_P(retval));
179 + *len = Z_STRLEN_P(retval);
182 + zval_ptr_dtor(&args[0]);
183 + zval_ptr_dtor(&retval);
188 +/* {{{ php_sasl_cb_getsecret
190 +static int php_sasl_cb_getsecret(sasl_conn_t *conn, void *context, int id,
191 + sasl_secret_t **psecret)
193 + zval *function = context;
197 + MAKE_STD_ZVAL(args[0]);
198 + MAKE_STD_ZVAL(args[1]);
199 + MAKE_STD_ZVAL(retval);
201 + ZVAL_NULL(args[0]);
202 + //ZVAL_RESOURCE(args[0], r);
203 + ZVAL_LONG(args[1], id);
205 + if (call_user_function(CG(function_table), NULL, function, retval,
206 + 2, args TSRMLS_CC) == SUCCESS) {
207 + int len = Z_STRLEN_P(retval);
208 + *psecret = (sasl_secret_t *)emalloc(sizeof(sasl_secret_t) +
209 + (len * sizeof(char)));
211 + (*psecret)->len = len;
212 + memcpy((*psecret)->data, Z_STRVAL_P(retval), len);
216 + zval_ptr_dtor(&args[0]);
217 + zval_ptr_dtor(&args[1]);
218 + zval_ptr_dtor(&retval);
223 +/* {{{ php_sasl_cb_chalprompt
225 +static int php_sasl_cb_chalprompt(void *context, int id, const char *challenge,
226 + const char *prompt, const char *defresult,
227 + const char **result, unsigned *len)
229 + zval *function = context;
233 + MAKE_STD_ZVAL(args[0]);
234 + MAKE_STD_ZVAL(args[1]);
235 + MAKE_STD_ZVAL(args[2]);
236 + MAKE_STD_ZVAL(args[3]);
237 + MAKE_STD_ZVAL(retval);
239 + ZVAL_LONG(args[0], id);
240 + ZVAL_STRING(args[1], (char *)challenge, 1);
241 + ZVAL_STRING(args[2], (char *)prompt, 1);
242 + ZVAL_STRING(args[3], (char *)defresult, 1);
244 + if (call_user_function(CG(function_table), NULL, function, retval,
245 + 4, args TSRMLS_CC) == SUCCESS) {
246 + *result = estrdup(Z_STRVAL_P(retval));
247 + *len = Z_STRLEN_P(retval);
250 + zval_ptr_dtor(&args[0]);
251 + zval_ptr_dtor(&args[1]);
252 + zval_ptr_dtor(&args[2]);
253 + zval_ptr_dtor(&args[3]);
254 + zval_ptr_dtor(&retval);
259 +/* {{{ php_sasl_cb_getrealm
261 +static int php_sasl_cb_getrealm(void *context, int id,
262 + const char **availrealms, const char **result)
264 + zval *function = context;
268 + MAKE_STD_ZVAL(args[0]);
269 + MAKE_STD_ZVAL(args[1]);
270 + MAKE_STD_ZVAL(retval);
272 + ZVAL_LONG(args[0], id);
273 + ZVAL_NULL(args[1]); // TODO: Make an array of available realms
275 + if (call_user_function(CG(function_table), NULL, function, retval,
276 + 2, args TSRMLS_CC) == SUCCESS) {
277 + *result = estrdup(Z_STRVAL_P(retval));
280 + zval_ptr_dtor(&args[0]);
281 + zval_ptr_dtor(&args[1]);
282 + zval_ptr_dtor(&retval);
287 +/* {{{ php_sasl_cb_authorize
289 +static int php_sasl_cb_authorize(sasl_conn_t *conn, void *context,
290 + const char *requested_user, unsigned rlen,
291 + const char *auth_identity, unsigned alen,
292 + const char *def_realm, unsigned urlen,
293 + struct propctx *propctx)
295 + zval *function = context;
298 + int ret = SASL_NOAUTHZ;
301 + MAKE_STD_ZVAL(args[0]);
302 + MAKE_STD_ZVAL(args[1]);
303 + MAKE_STD_ZVAL(retval);
305 + ZVAL_LONG(args[0], id);
306 + ZVAL_NULL(args[1]); // TODO: Make an array of available realms
308 + if (call_user_function(CG(function_table), NULL, function, retval,
309 + 2, args TSRMLS_CC) == SUCCESS) {
310 + *result = estrdup(Z_STRVAL_P(retval));
313 + zval_ptr_dtor(&args[0]);
314 + zval_ptr_dtor(&args[1]);
315 + zval_ptr_dtor(&retval);
321 +/* {{{ php_sasl_cb_userdb_checkpass
323 +static int php_sasl_cb_userdb_checkpass(sasl_conn_t *conn, void *context,
324 + const char *user, const char *pass,
326 + struct propctx *propctx)
328 + zval *function = context;
331 + int ret = SASL_FAIL;
334 + MAKE_STD_ZVAL(args[0]);
335 + MAKE_STD_ZVAL(args[1]);
336 + MAKE_STD_ZVAL(retval);
338 + ZVAL_LONG(args[0], id);
339 + ZVAL_NULL(args[1]); // TODO: Make an array of available realms
341 + if (call_user_function(CG(function_table), NULL, function, retval,
342 + 2, args TSRMLS_CC) == SUCCESS) {
343 + *result = estrdup(Z_STRVAL_P(retval));
346 + zval_ptr_dtor(&args[0]);
347 + zval_ptr_dtor(&args[1]);
348 + zval_ptr_dtor(&retval);
354 +/* {{{ php_sasl_cb_userdb_setpass
356 +static int php_sasl_cb_userdb_setpass(sasl_conn_t *conn, void *context,
357 + const char *user, const char *pass,
359 + struct propctx *propctx, unsigned flags)
361 + zval *function = context;
364 + int ret = SASL_FAIL;
367 + MAKE_STD_ZVAL(args[0]);
368 + MAKE_STD_ZVAL(args[1]);
369 + MAKE_STD_ZVAL(retval);
371 + ZVAL_LONG(args[0], id);
372 + ZVAL_NULL(args[1]); // TODO: Make an array of available realms
374 + if (call_user_function(CG(function_table), NULL, function, retval,
375 + 2, args TSRMLS_CC) == SUCCESS) {
376 + *result = estrdup(Z_STRVAL_P(retval));
379 + zval_ptr_dtor(&args[0]);
380 + zval_ptr_dtor(&args[1]);
381 + zval_ptr_dtor(&retval);
387 +/* {{{ php_sasl_cb_canon_user
389 +static int php_sasl_cb_canon_user(sasl_conn_t *conn, void *context,
390 + const char *in, unsigned inlen,
391 + unsigned flags, const char *user_realm,
392 + char *out, unsigned out_max,
395 + zval *function = context;
398 + int ret = SASL_FAIL;
401 + MAKE_STD_ZVAL(args[0]);
402 + MAKE_STD_ZVAL(args[1]);
403 + MAKE_STD_ZVAL(retval);
405 + ZVAL_LONG(args[0], id);
406 + ZVAL_NULL(args[1]); // TODO: Make an array of available realms
408 + if (call_user_function(CG(function_table), NULL, function, retval,
409 + 2, args TSRMLS_CC) == SUCCESS) {
410 + *result = estrdup(Z_STRVAL_P(retval));
413 + zval_ptr_dtor(&args[0]);
414 + zval_ptr_dtor(&args[1]);
415 + zval_ptr_dtor(&retval);
422 +/* {{{ sasl_callback_function_t php_sasl_get_callback_function(unsigned long id)
424 +typedef int (*sasl_callback_function_t)();
425 +static sasl_callback_function_t php_sasl_get_callback_function(unsigned long id)
428 + case SASL_CB_GETOPT: return php_sasl_cb_getopt;
429 + case SASL_CB_LOG: return php_sasl_cb_log;
430 + case SASL_CB_GETPATH: return php_sasl_cb_getpath;
431 + case SASL_CB_VERIFYFILE: return php_sasl_cb_verifyfile;
432 + case SASL_CB_GETCONFPATH: return php_sasl_cb_getconfpath;
433 + case SASL_CB_USER: return php_sasl_cb_getsimple;
434 + case SASL_CB_AUTHNAME: return php_sasl_cb_getsimple;
435 + case SASL_CB_LANGUAGE: return php_sasl_cb_getsimple;
436 + case SASL_CB_CNONCE: return php_sasl_cb_getsimple;
437 + case SASL_CB_PASS: return php_sasl_cb_getsecret;
438 + case SASL_CB_ECHOPROMPT: return php_sasl_cb_chalprompt;
439 + case SASL_CB_NOECHOPROMPT: return php_sasl_cb_chalprompt;
440 + case SASL_CB_GETREALM: return php_sasl_cb_getrealm;
441 + case SASL_CB_PROXY_POLICY: return php_sasl_cb_authorize;
442 + case SASL_CB_SERVER_USERDB_CHECKPASS: return php_sasl_cb_userdb_checkpass;
443 + case SASL_CB_SERVER_USERDB_SETPASS: return php_sasl_cb_userdb_setpass;
444 + case SASL_CB_CANON_USER: return php_sasl_cb_canon_user;
450 +/* {{{ php_sasl_create_callbacks(HashTable *ht)
452 +static int php_sasl_create_callbacks(HashTable *ht, sasl_callback_t *callbacks)
460 + * Start by counting the number of legitimate callbacks that exist in
461 + * the array. This allows us to appropriately size our callback array.
463 + zend_hash_internal_pointer_reset(ht);
464 + while (zend_hash_get_current_data(ht, (void **)&entry) == SUCCESS) {
465 + switch (zend_hash_get_current_key(ht, &string_key, &num_key, 0)) {
466 + case HASH_KEY_IS_LONG:
467 + if (php_sasl_get_callback_function(num_key)) {
472 + zend_hash_move_forward(ht);
476 + * Now that we know how many callbacks we have, allocate the array. We
477 + * include an additional entry for the final SASL_CB_LIST_END sentinel.
479 + callbacks = (sasl_callback_t *)emalloc(sizeof(sasl_callback_t) * (n + 1));
482 + /* Assign the sentinel to the last entry in the callback array. */
483 + callbacks[n].id = SASL_CB_LIST_END;
486 + * Now we iterate through the array again, except this time we will
487 + * actually create the callback entries.
491 + zend_hash_internal_pointer_reset(ht);
492 + while (zend_hash_get_current_data(ht, (void **)&entry) == SUCCESS) {
493 + sasl_callback_t *cb = &callbacks[n];
495 + switch (zend_hash_get_current_key(ht, &string_key, &num_key, 0)) {
496 + case HASH_KEY_IS_LONG:
498 + cb->proc = php_sasl_get_callback_function(num_key);
501 + cb->context = *entry;
507 + zend_hash_move_forward(ht);
515 /* {{{ php_sasl_error(int level, int reason)
517 static void php_sasl_error(int level, int code TSRMLS_DC)
519 "%s", sasl_errstring(code, NULL, NULL));
522 +/* {{{ php_sasl_rinit_globals(TSRMLS_D)
524 +static void php_sasl_rinit_globals(TSRMLS_D)
526 + SASLG(client_callbacks) = NULL;
527 + SASLG(server_callbacks) = NULL;
530 +/* {{{ php_sasl_rshutdown_globals(TSRMLS_D)
532 +static void php_sasl_rshutdown_globals(TSRMLS_D)
534 + if (SASLG(client_callbacks)) {
535 + efree(SASLG(client_callbacks));
536 + SASLG(client_callbacks) = NULL;
539 + if (SASLG(server_callbacks)) {
540 + efree(SASLG(server_callbacks));
541 + SASLG(server_callbacks) = NULL;
545 /* {{{ php_sasl_destroy_conn(zend_rsrc_list_entry *rsrc TSRMLS_DC)
547 static void php_sasl_destroy_conn(zend_rsrc_list_entry *rsrc TSRMLS_DC)
550 /* {{{ sasl_functions[]
552 -function_entry sasl_functions[] = {
553 +zend_function_entry sasl_functions[] = {
554 /* Common Functions */
555 - PHP_FE(sasl_version, NULL)
556 - PHP_FE(sasl_errstring, NULL)
557 + PHP_FE(sasl_version, NULL)
558 + PHP_FE(sasl_errstring, NULL)
559 #if SASL_VERSION_MAJOR >= 2
560 - PHP_FE(sasl_errdetail, NULL)
561 + PHP_FE(sasl_errdetail, NULL)
562 + PHP_FE(sasl_seterror, NULL)
564 - PHP_FE(sasl_encode, NULL)
565 - PHP_FE(sasl_decode, NULL)
566 + PHP_FE(sasl_encode, NULL)
567 + PHP_FE(sasl_decode, NULL)
569 /* Client Functions */
570 - PHP_FE(sasl_client_init, NULL)
571 - PHP_FE(sasl_client_new, NULL)
572 - PHP_FE(sasl_client_start, NULL)
573 - PHP_FE(sasl_client_step, NULL)
574 + PHP_FE(sasl_client_init, NULL)
575 + PHP_FE(sasl_client_new, NULL)
576 + PHP_FE(sasl_client_start, NULL)
577 + PHP_FE(sasl_client_step, NULL)
579 /* Server Functions */
580 - PHP_FE(sasl_server_init, NULL)
581 - PHP_FE(sasl_server_new, NULL)
582 - PHP_FE(sasl_server_start, NULL)
583 - PHP_FE(sasl_server_step, NULL)
584 - PHP_FE(sasl_listmech, NULL)
585 - PHP_FE(sasl_checkpass, NULL)
586 + PHP_FE(sasl_server_init, NULL)
587 + PHP_FE(sasl_server_new, NULL)
588 + PHP_FE(sasl_server_start, NULL)
589 + PHP_FE(sasl_server_step, NULL)
590 + PHP_FE(sasl_listmech, NULL)
591 + PHP_FE(sasl_checkpass, NULL)
595 @@ -102,10 +606,10 @@
602 + PHP_RSHUTDOWN(sasl),
606 STANDARD_MODULE_PROPERTIES
610 SASL_CONSTANT(SASL_SEC_MAXIMUM);
613 + /* SASL callback identifiers */
614 + SASL_CONSTANT(SASL_CB_GETOPT);
615 + SASL_CONSTANT(SASL_CB_LOG);
616 + SASL_CONSTANT(SASL_CB_GETPATH);
617 + SASL_CONSTANT(SASL_CB_VERIFYFILE);
618 + SASL_CONSTANT(SASL_CB_GETCONFPATH);
619 + SASL_CONSTANT(SASL_CB_USER);
620 + SASL_CONSTANT(SASL_CB_AUTHNAME);
621 + SASL_CONSTANT(SASL_CB_LANGUAGE);
622 + SASL_CONSTANT(SASL_CB_CNONCE);
623 + SASL_CONSTANT(SASL_CB_PASS);
624 + SASL_CONSTANT(SASL_CB_ECHOPROMPT);
625 + SASL_CONSTANT(SASL_CB_NOECHOPROMPT);
626 + SASL_CONSTANT(SASL_CB_GETREALM);
627 + SASL_CONSTANT(SASL_CB_PROXY_POLICY);
628 + SASL_CONSTANT(SASL_CB_SERVER_USERDB_CHECKPASS);
629 + SASL_CONSTANT(SASL_CB_SERVER_USERDB_SETPASS);
630 + SASL_CONSTANT(SASL_CB_CANON_USER);
632 + /* SASL_CB_VERIFYFILE flags */
633 + SASL_CONSTANT(SASL_VRFY_PLUGIN);
634 + SASL_CONSTANT(SASL_VRFY_CONF);
635 + SASL_CONSTANT(SASL_VRFY_PASSWD);
636 + SASL_CONSTANT(SASL_VRFY_OTHER);
645 +/* {{{ PHP_RINIT_FUNCTION
647 +PHP_RINIT_FUNCTION(sasl)
649 + php_sasl_rinit_globals(TSRMLS_C);
653 +/* {{{ PHP_RSHUTDOWN_FUNCTION
655 +PHP_RSHUTDOWN_FUNCTION(sasl)
657 + php_sasl_rshutdown_globals(TSRMLS_C);
661 /* {{{ PHP_MINFO_FUNCTION
663 PHP_MINFO_FUNCTION(sasl)
665 php_info_print_table_row(2, "SASL Support", "enabled");
666 php_info_print_table_row(2, "SASL API Version", api_version);
667 php_info_print_table_row(2, "SASL Library Version", lib_version);
668 - php_info_print_table_row(2, "Extension Version", "$Revision$");
669 + php_info_print_table_row(2, "Extension Version", PHP_SASL_VERSION);
670 + php_info_print_table_row(2, "CVS Revision", "$Revision$");
671 php_info_print_table_end();
675 libsasl_step = libsasl_version & 0xFFFF;
678 - snprintf(version, 64, "%u.%u.%u (%s)",
679 + snprintf(version, sizeof(version), "%u.%u.%u (%s)",
680 libsasl_major, libsasl_minor, libsasl_step, sasl_implementation);
682 RETURN_STRING(version, 1);
684 Returns the string translation of the given error code. */
685 PHP_FUNCTION(sasl_errstring)
689 char *languages = NULL;
693 RETURN_STRING((char *)sasl_errstring(code, languages, NULL), 1);
696 +/* {{{ proto void sasl_seterror(resource conn, string message)
697 + Set the error string which will be returned by sasl_errdetail. */
698 +#if SASL_VERSION_MAJOR >= 2
699 +PHP_FUNCTION(sasl_seterror)
706 + if (zend_parse_parameters(2 TSRMLS_CC, "rs",
707 + &rsrc, &message, &message_len) == FAILURE) {
711 + ZEND_FETCH_RESOURCE(conn, sasl_conn_t *, &rsrc, -1, le_conn_name, le_conn);
713 + sasl_seterror(conn, 0, message);
717 /* {{{ proto string sasl_encode(resource conn, string input)
718 Encodes a block of data for tranmission using the security layer. */
719 PHP_FUNCTION(sasl_encode)
720 @@ -345,10 +912,25 @@
721 Initializes the SASL client drivers. */
722 PHP_FUNCTION(sasl_client_init)
724 - if (sasl_client_init(NULL) != SASL_OK) {
727 + if (zend_parse_parameters(1 TSRMLS_CC, "a", &array) == FAILURE) {
732 + * Convert the supplied array into a set of callback functions. We
733 + * don't bother spending any time validating its contents because the
734 + * sasl_client_init() function will do that for us (and return an error
735 + * if it encounters something that it doesn't like).
737 + php_sasl_create_callbacks(Z_ARRVAL_P(array), SASLG(client_callbacks));
739 + if (sasl_client_init(SASLG(client_callbacks)) != SASL_OK) {
740 + /* XXX: Free the callbacks? */
749 ZEND_REGISTER_RESOURCE(return_value, conn, le_conn);
752 -/* {{{ proto bool sasl_client_start(resource conn, string mechlist [, string &$output [, string &$mech]])
753 +/* {{{ proto int sasl_client_start(resource conn, string mechlist [, string &$output [, string &$mech]])
754 Starts an authentication session. */
755 PHP_FUNCTION(sasl_client_start)
757 @@ -421,10 +1003,13 @@
758 r = sasl_client_start(conn, mechlist, NULL, &data, &data_len, &chosenmech);
761 - /* Print a warning and return false if we receive an unexpected result. */
763 + * Issue a warning and return the error code if we receive an unexpected
766 if ((r != SASL_OK) && (r != SASL_CONTINUE)) {
767 php_sasl_error(E_WARNING, r TSRMLS_CC);
772 /* Store the output in the "output" parameter (by reference). */
774 /* Store the chosen mechanism in the "mech" parameter (by reference). */
775 ZVAL_STRING(mech, (char *)chosenmech, 1);
781 /* {{{ proto int sasl_client_step(resource conn, string input, string &$output)
782 @@ -483,14 +1068,25 @@
783 Initializes the session and loads the shared authentication mechanisms. */
784 PHP_FUNCTION(sasl_server_init)
790 - if (zend_parse_parameters(1 TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
791 + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "as",
792 + &array, &name, &name_len) == FAILURE) {
796 - if (sasl_server_init(NULL, name) != SASL_OK) {
798 + * Convert the supplied array into a set of callback functions. We
799 + * don't bother spending any time validating its contents because the
800 + * sasl_client_init() function will do that for us (and return an error
801 + * if it encounters something that it doesn't like).
803 + php_sasl_create_callbacks(Z_ARRVAL_P(array), SASLG(server_callbacks));
805 + if (sasl_server_init(SASLG(server_callbacks), name) != SASL_OK) {
806 + /* XXX: Free the callbacks? */
811 Property changes on: sasl.c
812 ___________________________________________________________________
813 Modified: cvs2svn:cvs-rev
816 \ No newline at end of property
818 \ No newline at end of property
820 ===================================================================
821 --- config.m4 (.../tags/RELEASE_0_1_0)
822 +++ config.m4 (.../trunk)
825 if test "$PHP_SASL" != "no"; then
826 SEARCH_DIRS="/usr/local /usr"
827 - SEARCH_SUBS="sasl sasl1 sasl2"
828 + SEARCH_SUBS="sasl2 sasl sasl1"
829 SEARCH_LIBS="sasl2 sasl"
831 if test -r $PHP_SASL; then
835 AC_MSG_RESULT(found in $i)
842 AC_MSG_CHECKING(for SASL library in $SASL_DIR/lib)
843 for i in $SEARCH_LIBS; do
844 - if test -r $SASL_DIR/lib/lib$i.a; then
845 + if test -r $SASL_DIR/lib/lib$i.a -o -r $SASL_DIR/lib/lib$i.$SHLIB_SUFFIX_NAME; then
847 AC_MSG_RESULT(found -l$i)
853 Property changes on: config.m4
854 ___________________________________________________________________
855 Modified: cvs2svn:cvs-rev
858 \ No newline at end of property
860 \ No newline at end of property
861 Index: docs/guide.txt
862 ===================================================================
863 --- docs/guide.txt (.../tags/RELEASE_0_1_0)
864 +++ docs/guide.txt (.../trunk)
866 +============================
867 + The SASL Extension for PHP
868 +============================
870 +--------------------
872 +--------------------
875 +:Contact: jon@php.net
877 +:Revision: $Revision$
879 +.. contents:: Contents
880 +.. section-numbering::
882 +Frequently Asked Questions
883 +--------------------------
885 +How does the SASL extension relate to the Auth_SASL PEAR package?
886 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
887 +The `Auth_SASL`_ PEAR package provides native PHP implementations of many of
888 +the SASL authentication mechanisms. In theory, those methods could call out
889 +to the SASL extension to compute those strings using the native C library, but
890 +I'm not sure the effort is worth it. I wouldn't object to the idea if someone
891 +did the work, though.
893 +.. _Auth_SASL: http://pear.php.net/Auth_SASL
895 +Does saslauthd need to be running locally?
896 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
897 +``saslauthd`` needs to be running on the same machine as the SASL client (the
898 +PHP process, in your case). The libsasl library (that the SASL extension
899 +wraps) will communicate with the ``saslauthd`` process via a local Unix domain
902 +Can saslauthd be used to authenticate against a remote server?
903 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
905 +The ``saslauthd`` process loads the SASL authentication modules and performs
906 +the actual authentication. This may involve contacting a foreign machine
907 +(such as a remote Kerberos or LDAP server).
909 +To complicate things even further, ``saslauthd`` can use `PAM`_ as its
910 +authentication backend, which opens up even more authentication possibilities
911 +(many of which may involve other hosts).
913 +.. _PAM: http://www.freebsd.org/doc/en_US.ISO8859-1/articles/pam/
915 +.. vim: tabstop=4 shiftwidth=4 softtabstop=4 expandtab textwidth=78 ft=rst:
917 Property changes on: docs/guide.txt
918 ___________________________________________________________________
919 Added: cvs2svn:cvs-rev
922 \ No newline at end of property
926 \ No newline at end of property
929 +Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
930 \ No newline at end of property
934 \ No newline at end of property
936 ===================================================================
937 Cannot display: file marked as a binary type.
938 svn:mime-type = application/xml
940 ===================================================================
941 --- package.xml (.../tags/RELEASE_0_1_0)
942 +++ package.xml (.../trunk)
944 Property changes on: package.xml
945 ___________________________________________________________________
946 Modified: cvs2svn:cvs-rev
949 \ No newline at end of property
951 \ No newline at end of property
952 Deleted: svn:mime-type
955 \ No newline at end of property
957 ===================================================================
958 --- php_sasl.h (.../tags/RELEASE_0_1_0)
959 +++ php_sasl.h (.../trunk)
961 extern zend_module_entry sasl_module_entry;
962 #define phpext_sasl_ptr &sasl_module_entry
964 +#define PHP_SASL_VERSION "0.2.0-dev"
967 #define PHP_SASL_API __declspec(dllexport)
971 PHP_MINIT_FUNCTION(sasl);
972 PHP_MSHUTDOWN_FUNCTION(sasl);
973 +PHP_RINIT_FUNCTION(sasl);
974 +PHP_RSHUTDOWN_FUNCTION(sasl);
975 PHP_MINFO_FUNCTION(sasl);
977 /* Common Functions */
979 PHP_FUNCTION(sasl_errstring);
980 #if SASL_VERSION_MAJOR >= 2
981 PHP_FUNCTION(sasl_errdetail);
982 +PHP_FUNCTION(sasl_seterror);
984 PHP_FUNCTION(sasl_encode);
985 PHP_FUNCTION(sasl_decode);
987 PHP_FUNCTION(sasl_listmech);
988 PHP_FUNCTION(sasl_checkpass);
991 +/* Global Variables */
992 +ZEND_BEGIN_MODULE_GLOBALS(sasl)
993 + sasl_callback_t *client_callbacks;
994 + sasl_callback_t *server_callbacks;
995 +ZEND_END_MODULE_GLOBALS(sasl)
998 #define SASLG(v) TSRMG(sasl_globals_id, zend_sasl_globals *, v)
1000 #define SASLG(v) (sasl_globals.v)
1004 #endif /* PHP_SASL_H */
1006 Property changes on: php_sasl.h
1007 ___________________________________________________________________
1008 Modified: cvs2svn:cvs-rev
1011 \ No newline at end of property
1013 \ No newline at end of property
1015 ===================================================================
1016 --- package.php (.../tags/RELEASE_0_1_0)
1017 +++ package.php (.../trunk)
1021 +require_once 'PEAR/PackageFileManager2.php';
1022 +PEAR::setErrorHandling(PEAR_ERROR_DIE);
1025 +SASL is the Simple Authentication and Security Layer (as defined by RFC 2222). It provides a system for adding plugable authenticating support to connection-based protocols. The SASL Extension for PHP makes the Cyrus SASL library functions available to PHP. It aims to provide a 1-to-1 wrapper around the SASL library to provide the greatest amount of implementation flexibility. To that end, it is possible to build both a client-side and server-side SASL implementation entirely in PHP.
1028 +$version = '0.2.0';
1030 +- The build system now searches for both static and shared versions of the SASL library. (Bug #13097)
1033 +$package = new PEAR_PackageFileManager2();
1035 +$result = $package->setOptions(array(
1036 + 'filelistgenerator' => 'svn',
1037 + 'changelogoldtonew' => false,
1038 + 'simpleoutput' => true,
1039 + 'baseinstalldir' => '/',
1040 + 'packagefile' => 'package.xml',
1041 + 'packagedirectory' => '.',
1042 + 'clearcontents' => true,
1043 + 'ignore' => array('package.php', 'package.xml'),
1044 + 'dir_roles' => array(
1046 + 'tests' => 'test',
1050 +if (PEAR::isError($result)) {
1051 + echo $result->getMessage();
1055 +$package->clearDeps();
1056 +$package->setPackage('sasl');
1057 +$package->setPackageType('extsrc');
1058 +$package->setSummary('Cyrus SASL Extensions');
1059 +$package->setDescription($desc);
1060 +$package->setChannel('pecl.php.net');
1061 +$package->setLicense('PHP License');
1062 +$package->addMaintainer('lead', 'jon', 'Jon Parise', 'jon@php.net');
1064 +$package->addRelease();
1065 +$package->setProvidesExtension('sasl');
1066 +$package->setAPIVersion('0.6.0');
1067 +$package->setAPIStability('alpha');
1068 +$package->setReleaseVersion($version);
1069 +$package->setReleaseStability('alpha');
1070 +$package->setNotes($notes);
1071 +$package->setPhpDep('5.3.0');
1072 +$package->setPearInstallerDep('1.4.3');
1074 +$package->generateContents();
1076 +if (isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] == 'commit') {
1077 + $result = $package->writePackageFile();
1079 + $result = $package->debugPackageFile();
1082 +if (PEAR::isError($result)) {
1083 + echo $result->getMessage();
1087 Property changes on: package.php
1088 ___________________________________________________________________
1089 Added: cvs2svn:cvs-rev
1092 \ No newline at end of property
1095 +Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
1096 \ No newline at end of property
1097 Added: svn:eol-style
1100 \ No newline at end of property
1101 Index: tests/sasl_version.phpt
1102 ===================================================================
1103 --- tests/sasl_version.phpt (.../tags/RELEASE_0_1_0)
1104 +++ tests/sasl_version.phpt (.../trunk)
1106 <?php if (!extension_loaded("sasl")) die('skip'); ?>
1109 +echo sasl_version();
1111 -$version = sasl_version();
1112 -if (strlen($version) > 0) {
1119 +\d+\.\d+\.\d+ \(.*\)
1121 Property changes on: tests/sasl_version.phpt
1122 ___________________________________________________________________
1123 Modified: cvs2svn:cvs-rev
1126 \ No newline at end of property
1128 \ No newline at end of property
1130 ===================================================================
1131 --- tests (.../tags/RELEASE_0_1_0)
1132 +++ tests (.../trunk)
1134 Property changes on: tests
1135 ___________________________________________________________________
1143 ===================================================================
1144 --- . (.../tags/RELEASE_0_1_0)
1147 Property changes on: .
1148 ___________________________________________________________________
1180 +scan_makefile_in.awk