]> git.pld-linux.org Git - packages/php-pecl-sasl.git/blob - branch.diff
add module load test
[packages/php-pecl-sasl.git] / branch.diff
1 Index: Makefile.in
2 ===================================================================
3 --- Makefile.in (.../tags/RELEASE_0_1_0)
4 +++ Makefile.in (.../trunk)
5 @@ -1,8 +0,0 @@
6 -# $Id$
7 -
8 -LTLIBRARY_NAME        = libsasl.la
9 -LTLIBRARY_SOURCES     = sasl.c
10 -LTLIBRARY_SHARED_NAME = sasl.la
11 -LTLIBRARY_SHARED_LIBADD  = $(SASL_SHARED_LIBADD)
12 -
13 -include $(top_srcdir)/build/dynlib.mk
14 Index: sasl.c
15 ===================================================================
16 --- sasl.c      (.../tags/RELEASE_0_1_0)
17 +++ sasl.c      (.../trunk)
18 @@ -41,13 +41,493 @@
19  #define le_conn_name "SASL Connection Context"
20  static int le_conn;
21  
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 }
26 -};
27 -/* }}}*/
28 +PHPAPI ZEND_DECLARE_MODULE_GLOBALS(sasl);
29  
30 +/* SASL Callback Functions */
31 +/* {{{ php_sasl_cb_getopt
32 + */
33 +static int php_sasl_cb_getopt(void *context, const char *plugin_name,
34 +                                                         const char *option, const char **result,
35 +                                                         unsigned *len)
36 +{
37 +       zval *function = context;
38 +       zval *args[2];
39 +       zval *retval;
40 +       int ret = SASL_FAIL;
41 +
42 +       MAKE_STD_ZVAL(args[0]);
43 +       MAKE_STD_ZVAL(args[1]);
44 +       MAKE_STD_ZVAL(retval);
45 +
46 +       ZVAL_STRING(args[0], (plugin_name) ? (char *)plugin_name : "", 1);
47 +       ZVAL_STRING(args[1], (char *)option, 1);
48 +
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);
54 +       }
55 +
56 +       zval_ptr_dtor(&args[0]);
57 +       zval_ptr_dtor(&args[1]);
58 +       zval_ptr_dtor(&retval);
59 +
60 +       return ret;
61 +}
62 +/* }}} */
63 +/* {{{ php_sasl_cb_log
64 + */
65 +static int php_sasl_cb_log(void *context, int level, const char *message)
66 +{
67 +       zval *function = context;
68 +       zval *args[2];
69 +       zval *retval;
70 +       int ret = SASL_FAIL;
71 +
72 +       MAKE_STD_ZVAL(args[0]);
73 +       MAKE_STD_ZVAL(args[1]);
74 +       MAKE_STD_ZVAL(retval);
75 +
76 +       ZVAL_LONG(args[0], level);
77 +       ZVAL_STRING(args[1], (char *)message, 1);
78 +
79 +       if (call_user_function(CG(function_table), NULL, function, retval,
80 +                                                  2, args TSRMLS_CC) == SUCCESS) {
81 +               ret = Z_LVAL_P(retval);
82 +       }
83 +
84 +       zval_ptr_dtor(&args[0]);
85 +       zval_ptr_dtor(&args[1]);
86 +       zval_ptr_dtor(&retval);
87 +
88 +       return ret;
89 +}
90 +/* }}} */
91 +/* {{{ php_sasl_cb_getpath
92 + */
93 +static int php_sasl_cb_getpath(void *context, const char **path)
94 +{
95 +       zval *function = context;
96 +       zval *retval;
97 +       int ret = SASL_FAIL;
98 +
99 +       MAKE_STD_ZVAL(retval);
100 +
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));
105 +       }
106 +
107 +       zval_ptr_dtor(&retval);
108 +
109 +       return ret;
110 +}
111 +/* }}} */
112 +/* {{{ php_sasl_cb_verifyfile
113 + */
114 +static int php_sasl_cb_verifyfile(void *context, const char *file,
115 +                                                                 sasl_verify_type_t type)
116 +{
117 +       zval *function = context;
118 +       zval *args[2];
119 +       zval *retval;
120 +       int ret = SASL_FAIL;
121 +
122 +       MAKE_STD_ZVAL(args[0]);
123 +       MAKE_STD_ZVAL(args[1]);
124 +       MAKE_STD_ZVAL(retval);
125 +
126 +       ZVAL_STRING(args[0], (char *)file, 1);
127 +       ZVAL_LONG(args[1], type);
128 +
129 +       if (call_user_function(CG(function_table), NULL, function, retval,
130 +                                                  2, args TSRMLS_CC) == SUCCESS) {
131 +               ret = Z_LVAL_P(retval);
132 +       }
133 +
134 +       zval_ptr_dtor(&args[0]);
135 +       zval_ptr_dtor(&args[1]);
136 +       zval_ptr_dtor(&retval);
137 +
138 +       return ret;
139 +}
140 +/* }}} */
141 +/* {{{ php_sasl_cb_getconfpath
142 + */
143 +static int php_sasl_cb_getconfpath(void *context, char **path)
144 +{
145 +       zval *function = context;
146 +       zval *retval;
147 +       int ret = SASL_FAIL;
148 +
149 +       MAKE_STD_ZVAL(retval);
150 +
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));
155 +       }
156 +
157 +       zval_ptr_dtor(&retval);
158 +
159 +       return ret;
160 +}
161 +/* }}} */
162 +/* {{{ php_sasl_cb_getsimple
163 + */
164 +static int php_sasl_cb_getsimple(void *context, int id, const char **result,
165 +                                                                unsigned *len)
166 +{
167 +       zval *function = context;
168 +       zval *args[1];
169 +       zval *retval;
170 +
171 +       MAKE_STD_ZVAL(args[0]);
172 +       MAKE_STD_ZVAL(retval);
173 +
174 +       ZVAL_LONG(args[0], id);
175 +
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);
180 +       }
181 +
182 +       zval_ptr_dtor(&args[0]);
183 +       zval_ptr_dtor(&retval);
184 +
185 +       return SASL_OK;
186 +}
187 +/* }}} */
188 +/* {{{ php_sasl_cb_getsecret
189 + */
190 +static int php_sasl_cb_getsecret(sasl_conn_t *conn, void *context, int id,
191 +                                                                sasl_secret_t **psecret)
192 +{
193 +       zval *function = context;
194 +       zval *args[2];
195 +       zval *retval;
196 +
197 +       MAKE_STD_ZVAL(args[0]);
198 +       MAKE_STD_ZVAL(args[1]);
199 +       MAKE_STD_ZVAL(retval);
200 +
201 +       ZVAL_NULL(args[0]);
202 +       //ZVAL_RESOURCE(args[0], r);
203 +       ZVAL_LONG(args[1], id);
204 +
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)));
210 +               if (*psecret) {
211 +                       (*psecret)->len = len;
212 +                       memcpy((*psecret)->data, Z_STRVAL_P(retval), len);
213 +               }
214 +       }
215 +
216 +       zval_ptr_dtor(&args[0]);
217 +       zval_ptr_dtor(&args[1]);
218 +       zval_ptr_dtor(&retval);
219 +
220 +       return SASL_OK;
221 +}
222 +/* }}} */
223 +/* {{{ php_sasl_cb_chalprompt
224 + */
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)
228 +{
229 +       zval *function = context;
230 +       zval *args[4];
231 +       zval *retval;
232 +
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);
238 +
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);
243 +
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);
248 +       }
249 +
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);
255 +
256 +       return SASL_OK;
257 +}
258 +/* }}} */
259 +/* {{{ php_sasl_cb_getrealm
260 + */
261 +static int php_sasl_cb_getrealm(void *context, int id,
262 +                                                               const char **availrealms, const char **result)
263 +{
264 +       zval *function = context;
265 +       zval *args[2];
266 +       zval *retval;
267 +
268 +       MAKE_STD_ZVAL(args[0]);
269 +       MAKE_STD_ZVAL(args[1]);
270 +       MAKE_STD_ZVAL(retval);
271 +
272 +       ZVAL_LONG(args[0], id);
273 +       ZVAL_NULL(args[1]); // TODO: Make an array of available realms
274 +
275 +       if (call_user_function(CG(function_table), NULL, function, retval,
276 +                                                  2, args TSRMLS_CC) == SUCCESS) {
277 +               *result = estrdup(Z_STRVAL_P(retval));
278 +       }
279 +
280 +       zval_ptr_dtor(&args[0]);
281 +       zval_ptr_dtor(&args[1]);
282 +       zval_ptr_dtor(&retval);
283 +
284 +       return SASL_OK;
285 +}
286 +/* }}} */
287 +/* {{{ php_sasl_cb_authorize
288 + */
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)
294 +{
295 +       zval *function = context;
296 +       zval *args[2];
297 +       zval *retval;
298 +       int ret = SASL_NOAUTHZ;
299 +
300 +#if 0
301 +       MAKE_STD_ZVAL(args[0]);
302 +       MAKE_STD_ZVAL(args[1]);
303 +       MAKE_STD_ZVAL(retval);
304 +
305 +       ZVAL_LONG(args[0], id);
306 +       ZVAL_NULL(args[1]); // TODO: Make an array of available realms
307 +
308 +       if (call_user_function(CG(function_table), NULL, function, retval,
309 +                                                  2, args TSRMLS_CC) == SUCCESS) {
310 +               *result = estrdup(Z_STRVAL_P(retval));
311 +       }
312 +
313 +       zval_ptr_dtor(&args[0]);
314 +       zval_ptr_dtor(&args[1]);
315 +       zval_ptr_dtor(&retval);
316 +#endif
317 +
318 +       return ret;
319 +}
320 +/* }}} */
321 +/* {{{ php_sasl_cb_userdb_checkpass
322 + */
323 +static int php_sasl_cb_userdb_checkpass(sasl_conn_t *conn, void *context,
324 +                                                                               const char *user, const char *pass,
325 +                                                                               unsigned passlen,
326 +                                                                               struct propctx *propctx)
327 +{
328 +       zval *function = context;
329 +       zval *args[2];
330 +       zval *retval;
331 +       int ret = SASL_FAIL;
332 +
333 +#if 0
334 +       MAKE_STD_ZVAL(args[0]);
335 +       MAKE_STD_ZVAL(args[1]);
336 +       MAKE_STD_ZVAL(retval);
337 +
338 +       ZVAL_LONG(args[0], id);
339 +       ZVAL_NULL(args[1]); // TODO: Make an array of available realms
340 +
341 +       if (call_user_function(CG(function_table), NULL, function, retval,
342 +                                                  2, args TSRMLS_CC) == SUCCESS) {
343 +               *result = estrdup(Z_STRVAL_P(retval));
344 +       }
345 +
346 +       zval_ptr_dtor(&args[0]);
347 +       zval_ptr_dtor(&args[1]);
348 +       zval_ptr_dtor(&retval);
349 +#endif
350 +
351 +       return ret;
352 +}
353 +/* }}} */
354 +/* {{{ php_sasl_cb_userdb_setpass
355 + */
356 +static int php_sasl_cb_userdb_setpass(sasl_conn_t *conn, void *context,
357 +                                                                         const char *user, const char *pass,
358 +                                                                         unsigned passlen,
359 +                                                                         struct propctx *propctx, unsigned flags)
360 +{
361 +       zval *function = context;
362 +       zval *args[2];
363 +       zval *retval;
364 +       int ret = SASL_FAIL;
365 +
366 +#if 0
367 +       MAKE_STD_ZVAL(args[0]);
368 +       MAKE_STD_ZVAL(args[1]);
369 +       MAKE_STD_ZVAL(retval);
370 +
371 +       ZVAL_LONG(args[0], id);
372 +       ZVAL_NULL(args[1]); // TODO: Make an array of available realms
373 +
374 +       if (call_user_function(CG(function_table), NULL, function, retval,
375 +                                                  2, args TSRMLS_CC) == SUCCESS) {
376 +               *result = estrdup(Z_STRVAL_P(retval));
377 +       }
378 +
379 +       zval_ptr_dtor(&args[0]);
380 +       zval_ptr_dtor(&args[1]);
381 +       zval_ptr_dtor(&retval);
382 +#endif
383 +
384 +       return ret;
385 +}
386 +/* }}} */
387 +/* {{{ php_sasl_cb_canon_user
388 + */
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,
393 +                                                                 unsigned *out_len)
394 +{
395 +       zval *function = context;
396 +       zval *args[2];
397 +       zval *retval;
398 +       int ret = SASL_FAIL;
399 +
400 +#if 0
401 +       MAKE_STD_ZVAL(args[0]);
402 +       MAKE_STD_ZVAL(args[1]);
403 +       MAKE_STD_ZVAL(retval);
404 +
405 +       ZVAL_LONG(args[0], id);
406 +       ZVAL_NULL(args[1]); // TODO: Make an array of available realms
407 +
408 +       if (call_user_function(CG(function_table), NULL, function, retval,
409 +                                                  2, args TSRMLS_CC) == SUCCESS) {
410 +               *result = estrdup(Z_STRVAL_P(retval));
411 +       }
412 +
413 +       zval_ptr_dtor(&args[0]);
414 +       zval_ptr_dtor(&args[1]);
415 +       zval_ptr_dtor(&retval);
416 +#endif
417 +
418 +       return ret;
419 +}
420 +/* }}} */
421 +
422 +/* {{{ sasl_callback_function_t php_sasl_get_callback_function(unsigned long id)
423 + */
424 +typedef int (*sasl_callback_function_t)();
425 +static sasl_callback_function_t php_sasl_get_callback_function(unsigned long id)
426 +{
427 +       switch (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;
445 +       }
446 +
447 +       return NULL;
448 +}
449 +/* }}} */
450 +/* {{{ php_sasl_create_callbacks(HashTable *ht)
451 + */
452 +static int php_sasl_create_callbacks(HashTable *ht, sasl_callback_t *callbacks)
453 +{
454 +       int n = 0;
455 +       zval **entry;
456 +       char *string_key;
457 +       long num_key;
458 +
459 +       /*
460 +        * Start by counting the number of legitimate callbacks that exist in
461 +        * the array.  This allows us to appropriately size our callback array.
462 +        */
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)) {
468 +                                       n++;
469 +                               }
470 +                               break;
471 +               }
472 +               zend_hash_move_forward(ht);
473 +       }
474 +
475 +       /*
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.
478 +        */
479 +       callbacks = (sasl_callback_t *)emalloc(sizeof(sasl_callback_t) * (n + 1));
480 +
481 +       if (callbacks) {
482 +               /* Assign the sentinel to the last entry in the callback array. */
483 +               callbacks[n].id = SASL_CB_LIST_END;
484 +
485 +               /*
486 +                * Now we iterate through the array again, except this time we will
487 +                * actually create the callback entries.
488 +                */
489 +               n = 0;
490 +
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];
494 +
495 +                       switch (zend_hash_get_current_key(ht, &string_key, &num_key, 0)) {
496 +                               case HASH_KEY_IS_LONG:
497 +                                       {
498 +                                               cb->proc = php_sasl_get_callback_function(num_key);
499 +                                               if (cb->proc) {
500 +                                                       cb->id = num_key;
501 +                                                       cb->context = *entry;
502 +                                                       n++;
503 +                                               }
504 +                                       }
505 +                                       break;
506 +                       }
507 +                       zend_hash_move_forward(ht);
508 +               }
509 +       }
510 +
511 +       return n;
512 +}
513 +/* }}} */
514 +
515  /* {{{ php_sasl_error(int level, int reason)
516   */
517  static void php_sasl_error(int level, int code TSRMLS_DC)
518 @@ -56,6 +536,29 @@
519                                          "%s", sasl_errstring(code, NULL, NULL));
520  }
521  /* }}} */
522 +/* {{{ php_sasl_rinit_globals(TSRMLS_D)
523 + */
524 +static void php_sasl_rinit_globals(TSRMLS_D)
525 +{
526 +       SASLG(client_callbacks) = NULL;
527 +       SASLG(server_callbacks) = NULL;
528 +}
529 +/* }}} */
530 +/* {{{ php_sasl_rshutdown_globals(TSRMLS_D)
531 + */
532 +static void php_sasl_rshutdown_globals(TSRMLS_D)
533 +{
534 +       if (SASLG(client_callbacks)) {
535 +               efree(SASLG(client_callbacks));
536 +               SASLG(client_callbacks) = NULL;
537 +       }
538 +
539 +       if (SASLG(server_callbacks)) {
540 +               efree(SASLG(server_callbacks));
541 +               SASLG(server_callbacks) = NULL;
542 +       }
543 +}
544 +/* }}} */
545  /* {{{ php_sasl_destroy_conn(zend_rsrc_list_entry *rsrc TSRMLS_DC)
546   */
547  static void php_sasl_destroy_conn(zend_rsrc_list_entry *rsrc TSRMLS_DC)
548 @@ -67,29 +570,30 @@
549  
550  /* {{{ sasl_functions[]
551   */
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)
563  #endif
564 -       PHP_FE(sasl_encode,                     NULL)
565 -       PHP_FE(sasl_decode,                     NULL)
566 +       PHP_FE(sasl_encode,                             NULL)
567 +       PHP_FE(sasl_decode,                             NULL)
568  
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)
578  
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)
592  
593         {NULL, NULL, NULL}
594  };
595 @@ -102,10 +606,10 @@
596         sasl_functions,
597         PHP_MINIT(sasl),
598         PHP_MSHUTDOWN(sasl),
599 -       NULL,
600 -       NULL,
601 +       PHP_RINIT(sasl),
602 +       PHP_RSHUTDOWN(sasl),
603         PHP_MINFO(sasl),
604 -       NO_VERSION_YET,
605 +       PHP_SASL_VERSION,
606         STANDARD_MODULE_PROPERTIES
607  };
608  
609 @@ -173,6 +677,31 @@
610         SASL_CONSTANT(SASL_SEC_MAXIMUM);
611  #endif
612  
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);
631 +
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);
637 +
638         return SUCCESS;
639  }
640  /* }}} */
641 @@ -185,6 +714,22 @@
642         return SUCCESS;
643  }
644  /* }}} */
645 +/* {{{ PHP_RINIT_FUNCTION
646 + */
647 +PHP_RINIT_FUNCTION(sasl)
648 +{
649 +       php_sasl_rinit_globals(TSRMLS_C);
650 +       return SUCCESS;
651 +}
652 +/* }}} */
653 +/* {{{ PHP_RSHUTDOWN_FUNCTION
654 + */
655 +PHP_RSHUTDOWN_FUNCTION(sasl)
656 +{
657 +       php_sasl_rshutdown_globals(TSRMLS_C);
658 +       return SUCCESS;
659 +}
660 +/* }}} */
661  /* {{{ PHP_MINFO_FUNCTION
662   */
663  PHP_MINFO_FUNCTION(sasl)
664 @@ -214,7 +759,8 @@
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();
672  }
673  /* }}} */
674 @@ -239,7 +785,7 @@
675         libsasl_step = libsasl_version & 0xFFFF;
676  #endif
677  
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);
681  
682         RETURN_STRING(version, 1);
683 @@ -267,7 +813,7 @@
684     Returns the string translation of the given error code. */
685  PHP_FUNCTION(sasl_errstring)
686  {
687 -       long code; 
688 +       long code;
689         char *languages = NULL;
690         int languages_len;
691  
692 @@ -279,6 +825,27 @@
693         RETURN_STRING((char *)sasl_errstring(code, languages, NULL), 1);
694  }
695  /* }}} */
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)
700 +{
701 +       zval *rsrc;
702 +       sasl_conn_t *conn;
703 +       char *message;
704 +       int message_len;
705 +
706 +       if (zend_parse_parameters(2 TSRMLS_CC, "rs",
707 +                                                         &rsrc, &message, &message_len) == FAILURE) {
708 +               return;
709 +       }
710 +
711 +       ZEND_FETCH_RESOURCE(conn, sasl_conn_t *, &rsrc, -1, le_conn_name, le_conn);
712 +
713 +       sasl_seterror(conn, 0, message);
714 +}
715 +#endif
716 +/* }}} */
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)
723  {
724 -       if (sasl_client_init(NULL) != SASL_OK) {
725 +       zval *array;
726 +
727 +       if (zend_parse_parameters(1 TSRMLS_CC, "a", &array) == FAILURE) {
728 +               return;
729 +       }
730 +
731 +       /*
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).
736 +        */
737 +       php_sasl_create_callbacks(Z_ARRVAL_P(array), SASLG(client_callbacks));
738 +
739 +       if (sasl_client_init(SASLG(client_callbacks)) != SASL_OK) {
740 +               /* XXX: Free the callbacks? */
741                 RETURN_FALSE;
742         }
743 -       
744 +
745         RETURN_TRUE;
746  }
747  /* }}} */
748 @@ -384,7 +966,7 @@
749         ZEND_REGISTER_RESOURCE(return_value, conn, le_conn);
750  }
751  /* }}} */
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)
756  {
757 @@ -421,10 +1003,13 @@
758         r = sasl_client_start(conn, mechlist, NULL, &data, &data_len, &chosenmech);
759  #endif
760  
761 -       /* Print a warning and return false if we receive an unexpected result. */
762 +       /*
763 +        * Issue a warning and return the error code if we receive an unexpected
764 +        * result code.
765 +        */
766         if ((r != SASL_OK) && (r != SASL_CONTINUE)) {
767                 php_sasl_error(E_WARNING, r TSRMLS_CC);
768 -               RETURN_FALSE;
769 +               RETURN_LONG(r);
770         }
771  
772         /* Store the output in the "output" parameter (by reference). */
773 @@ -434,7 +1019,7 @@
774         /* Store the chosen mechanism in the "mech" parameter (by reference). */
775         ZVAL_STRING(mech, (char *)chosenmech, 1);
776  
777 -       RETURN_TRUE;
778 +       RETURN_LONG(r);
779  }
780  /* }}} */
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)
785  {
786 +       zval *array;
787         char *name;
788         int name_len;
789  
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) {
793                 return;
794         }
795  
796 -       if (sasl_server_init(NULL, name) != SASL_OK) {
797 +       /*
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).
802 +        */
803 +       php_sasl_create_callbacks(Z_ARRVAL_P(array), SASLG(server_callbacks));
804 +
805 +       if (sasl_server_init(SASLG(server_callbacks), name) != SASL_OK) {
806 +               /* XXX: Free the callbacks? */
807                 RETURN_FALSE;
808         }
809  
810
811 Property changes on: sasl.c
812 ___________________________________________________________________
813 Modified: cvs2svn:cvs-rev
814 ## -1 +1 ##
815 -1.3
816 \ No newline at end of property
817 +1.6
818 \ No newline at end of property
819 Index: config.m4
820 ===================================================================
821 --- config.m4   (.../tags/RELEASE_0_1_0)
822 +++ config.m4   (.../trunk)
823 @@ -6,7 +6,7 @@
824  
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"
830  
831    if test -r $PHP_SASL; then
832 @@ -19,6 +19,7 @@
833                SASL_DIR=$i
834                SASL_SUB=$j
835                AC_MSG_RESULT(found in $i)
836 +              break
837             fi
838          done
839       done
840 @@ -31,9 +32,10 @@
841  
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
846        SASL_LIB=$i
847        AC_MSG_RESULT(found -l$i)
848 +      break
849      fi
850    done
851  
852
853 Property changes on: config.m4
854 ___________________________________________________________________
855 Modified: cvs2svn:cvs-rev
856 ## -1 +1 ##
857 -1.2
858 \ No newline at end of property
859 +1.4
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)
865 @@ -0,0 +1,50 @@
866 +============================
867 + The SASL Extension for PHP
868 +============================
869 +
870 +--------------------
871 + User Documentation
872 +--------------------
873 +
874 +:Author:        Jon Parise
875 +:Contact:       jon@php.net
876 +:Date:          $Date$
877 +:Revision:      $Revision$
878 +
879 +.. contents:: Contents
880 +.. section-numbering::
881 +
882 +Frequently Asked Questions
883 +--------------------------
884 +
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.
892 +
893 +.. _Auth_SASL: http://pear.php.net/Auth_SASL
894 +
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
900 +socket.
901 +
902 +Can saslauthd be used to authenticate against a remote server?
903 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
904 +
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).                     
908 +
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).
912 +
913 +.. _PAM: http://www.freebsd.org/doc/en_US.ISO8859-1/articles/pam/
914 +
915 +.. vim: tabstop=4 shiftwidth=4 softtabstop=4 expandtab textwidth=78 ft=rst:
916
917 Property changes on: docs/guide.txt
918 ___________________________________________________________________
919 Added: cvs2svn:cvs-rev
920 ## -0,0 +1 ##
921 +1.1
922 \ No newline at end of property
923 Added: svn:mime-type
924 ## -0,0 +1 ##
925 +text/plain
926 \ No newline at end of property
927 Added: svn:keywords
928 ## -0,0 +1 ##
929 +Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
930 \ No newline at end of property
931 Added: svn:eol-style
932 ## -0,0 +1 ##
933 +native
934 \ No newline at end of property
935 Index: package.xml
936 ===================================================================
937 Cannot display: file marked as a binary type.
938 svn:mime-type = application/xml
939 Index: package.xml
940 ===================================================================
941 --- package.xml (.../tags/RELEASE_0_1_0)
942 +++ package.xml (.../trunk)
943
944 Property changes on: package.xml
945 ___________________________________________________________________
946 Modified: cvs2svn:cvs-rev
947 ## -1 +1 ##
948 -1.3
949 \ No newline at end of property
950 +1.5
951 \ No newline at end of property
952 Deleted: svn:mime-type
953 ## -1 +0,0 ##
954 -application/xml
955 \ No newline at end of property
956 Index: php_sasl.h
957 ===================================================================
958 --- php_sasl.h  (.../tags/RELEASE_0_1_0)
959 +++ php_sasl.h  (.../trunk)
960 @@ -26,6 +26,8 @@
961  extern zend_module_entry sasl_module_entry;
962  #define phpext_sasl_ptr &sasl_module_entry
963  
964 +#define PHP_SASL_VERSION "0.2.0-dev"
965 +
966  #ifdef PHP_WIN32
967  #define PHP_SASL_API __declspec(dllexport)
968  #else
969 @@ -38,6 +40,8 @@
970  
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);
976  
977  /* Common Functions */
978 @@ -45,6 +49,7 @@
979  PHP_FUNCTION(sasl_errstring);
980  #if SASL_VERSION_MAJOR >= 2
981  PHP_FUNCTION(sasl_errdetail);
982 +PHP_FUNCTION(sasl_seterror);
983  #endif
984  PHP_FUNCTION(sasl_encode);
985  PHP_FUNCTION(sasl_decode);
986 @@ -63,12 +68,16 @@
987  PHP_FUNCTION(sasl_listmech);
988  PHP_FUNCTION(sasl_checkpass);
989  
990 -#if 0
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)
996 +
997  #ifdef ZTS
998  #define SASLG(v) TSRMG(sasl_globals_id, zend_sasl_globals *, v)
999  #else
1000  #define SASLG(v) (sasl_globals.v)
1001  #endif
1002 -#endif
1003  
1004  #endif /* PHP_SASL_H */
1005
1006 Property changes on: php_sasl.h
1007 ___________________________________________________________________
1008 Modified: cvs2svn:cvs-rev
1009 ## -1 +1 ##
1010 -1.2
1011 \ No newline at end of property
1012 +1.4
1013 \ No newline at end of property
1014 Index: package.php
1015 ===================================================================
1016 --- package.php (.../tags/RELEASE_0_1_0)
1017 +++ package.php (.../trunk)
1018 @@ -0,0 +1,67 @@
1019 +<?php
1020 +
1021 +require_once 'PEAR/PackageFileManager2.php';
1022 +PEAR::setErrorHandling(PEAR_ERROR_DIE);
1023 +
1024 +$desc = <<<EOT
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.
1026 +EOT;
1027 +
1028 +$version = '0.2.0';
1029 +$notes = <<<EOT
1030 +- The build system now searches for both static and shared versions of the SASL library. (Bug #13097)
1031 +EOT;
1032 +
1033 +$package = new PEAR_PackageFileManager2();
1034 +
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(
1045 +         'docs'                 => 'doc',
1046 +         'tests'                => 'test',
1047 +    ),
1048 +));
1049 +
1050 +if (PEAR::isError($result)) {
1051 +    echo $result->getMessage();
1052 +    die();
1053 +}
1054 +
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');
1063 +
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');
1073 +
1074 +$package->generateContents();
1075 +
1076 +if (isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] == 'commit') {
1077 +    $result = $package->writePackageFile();
1078 +} else {
1079 +    $result = $package->debugPackageFile();
1080 +}
1081 +
1082 +if (PEAR::isError($result)) {
1083 +    echo $result->getMessage();
1084 +    die();
1085 +}
1086
1087 Property changes on: package.php
1088 ___________________________________________________________________
1089 Added: cvs2svn:cvs-rev
1090 ## -0,0 +1 ##
1091 +1.3
1092 \ No newline at end of property
1093 Added: svn:keywords
1094 ## -0,0 +1 ##
1095 +Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
1096 \ No newline at end of property
1097 Added: svn:eol-style
1098 ## -0,0 +1 ##
1099 +native
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)
1105 @@ -4,11 +4,7 @@
1106  <?php if (!extension_loaded("sasl")) die('skip'); ?>
1107  --FILE--
1108  <?php
1109 +echo sasl_version();
1110  
1111 -$version = sasl_version();
1112 -if (strlen($version) > 0) {
1113 -       echo "OK";
1114 -}
1115 -
1116 ---EXPECT--
1117 -OK
1118 +--EXPECTREGEX--
1119 +\d+\.\d+\.\d+ \(.*\)
1120
1121 Property changes on: tests/sasl_version.phpt
1122 ___________________________________________________________________
1123 Modified: cvs2svn:cvs-rev
1124 ## -1 +1 ##
1125 -1.2
1126 \ No newline at end of property
1127 +1.3
1128 \ No newline at end of property
1129 Index: tests
1130 ===================================================================
1131 --- tests       (.../tags/RELEASE_0_1_0)
1132 +++ tests       (.../trunk)
1133
1134 Property changes on: tests
1135 ___________________________________________________________________
1136 Added: svn:ignore
1137 ## -0,0 +1,4 ##
1138 +*.diff
1139 +*.exp
1140 +*.log
1141 +*.out
1142 Index: .
1143 ===================================================================
1144 --- .   (.../tags/RELEASE_0_1_0)
1145 +++ .   (.../trunk)
1146
1147 Property changes on: .
1148 ___________________________________________________________________
1149 Added: svn:ignore
1150 ## -0,0 +1,32 ##
1151 +.deps
1152 +Makefile
1153 +*.lo
1154 +*.la
1155 +.libs
1156 +libs.mk
1157 +Makefile.fragments
1158 +Makefile.global
1159 +Makefile.objects
1160 +autom4te.cache
1161 +acinclude.m4
1162 +aclocal.m4
1163 +build
1164 +config.cache
1165 +config.guess
1166 +config.h
1167 +config.h.in
1168 +config.log
1169 +config.nice
1170 +config.status
1171 +config.sub
1172 +configure
1173 +configure.in
1174 +install-sh
1175 +libtool
1176 +ltmain.sh
1177 +missing
1178 +mkinstalldirs
1179 +modules
1180 +scan_makefile_in.awk
1181 +conftest*
1182 +*.tgz
This page took 0.26075 seconds and 3 git commands to generate.