Author: abartlet Date: 2006-03-28 20:59:49 +0000 (Tue, 28 Mar 2006) New Revision: 521
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=lorikeet&rev=521 Log: Another patch from Ronan Waide <[EMAIL PROTECTED]>. In adding plaintext support, we lost NTLM support. Andrew Bartlett Modified: trunk/mod_ntlm_winbind/mod_ntlm_winbind.c Changeset: Modified: trunk/mod_ntlm_winbind/mod_ntlm_winbind.c =================================================================== --- trunk/mod_ntlm_winbind/mod_ntlm_winbind.c 2006-03-28 10:42:08 UTC (rev 520) +++ trunk/mod_ntlm_winbind/mod_ntlm_winbind.c 2006-03-28 20:59:49 UTC (rev 521) @@ -469,7 +469,7 @@ } /* get the current request's auth helper or fork one */ -static int get_auth_helper( request_rec *r, ntlm_config_rec *crec, struct _ntlm_auth_helper *auth_helper, char *cmd, void (*cleanup)(void *)) { +static struct _ntlm_auth_helper *get_auth_helper( request_rec *r, struct _ntlm_auth_helper *auth_helper, char *cmd, void (*cleanup)(void *)) { ntlm_context_t *ctxt = get_connection_context( r->connection ); #ifdef APACHE2 apr_procattr_t *attr; @@ -489,11 +489,11 @@ auth_helper->helper_pid = 0; #ifdef APACHE2 - apr_tokenize_to_argv( crec->ntlm_plaintext_helper, &argv_out, pool ); + apr_tokenize_to_argv( cmd, &argv_out, pool ); #else ap_register_cleanup( pool, auth_helper, cleanup, ap_null_cleanup ); #endif - cld.argv0 = crec->ntlm_plaintext_helper; + cld.argv0 = cmd; cld.r = r; ctxt->ntlm_plaintext_helper = auth_helper; @@ -504,7 +504,7 @@ auth_helper->proc = (apr_proc_t *)apr_pcalloc(pool, sizeof(apr_proc_t)) ; if ( apr_proc_create( auth_helper->proc, argv_out[0], (const char * const *)argv_out, NULL, attr, pool ) != APR_SUCCESS ) { RERROR( errno, "couldn't spawn child ntlm helper process: %s", argv_out[0]); - return HTTP_INTERNAL_SERVER_ERROR; + return NULL; } #else auth_helper->helper_pid = ap_bspawn_child(pool, helper_child, @@ -515,12 +515,12 @@ if (auth_helper->helper_pid == -1) { RERROR( errno, "couldn't spawn child ntlm helper process: %s", cld.argv0); - return HTTP_INTERNAL_SERVER_ERROR; + return NULL; } #endif } - return OK; + return auth_helper; } /* Call winbind to authenticate a (user, password) @@ -533,14 +533,13 @@ char args_from_helper[HUGE_STRING_LEN]; unsigned int bytes_written; int bytes_read; - int retval; #ifdef APACHE2 int exit; apr_exit_why_e why; #endif - if (( retval = get_auth_helper( r, crec, ctxt->ntlm_plaintext_helper, crec->ntlm_plaintext_helper, CLEANUP(cleanup_ntlm_plaintext_helper))) != OK ) { - return retval; + if (( ctxt->ntlm_plaintext_helper = get_auth_helper( r, ctxt->ntlm_plaintext_helper, crec->ntlm_plaintext_helper, CLEANUP(cleanup_ntlm_plaintext_helper))) == NULL ) { + return HTTP_INTERNAL_SERVER_ERROR; } if ( ctxt->connected_user_authenticated == NULL ) { @@ -671,26 +670,24 @@ #endif unsigned int bytes_written; int bytes_read; - int retval; struct _ntlm_auth_helper *auth_helper; /* If this is the first request with this connection, then create * a ntlm_auth_helper entry for it. It will be cleaned up when the * connection is dropped */ - retval = HTTP_INTERNAL_SERVER_ERROR; if (strcmp(auth_type, NEGOTIATE_AUTH_NAME) == 0) { - retval = get_auth_helper( r, crec, ctxt->negotiate_ntlm_auth_helper, crec->negotiate_ntlm_auth_helper, CLEANUP(cleanup_negotiate_ntlm_auth_helper)); - auth_helper = ctxt->negotiate_ntlm_auth_helper; + auth_helper = get_auth_helper( r, ctxt->negotiate_ntlm_auth_helper, crec->negotiate_ntlm_auth_helper, CLEANUP(cleanup_negotiate_ntlm_auth_helper)); + ctxt->negotiate_ntlm_auth_helper = auth_helper; } else if (strcmp(auth_type, NTLM_AUTH_NAME) == 0) { - retval = get_auth_helper( r, crec, ctxt->ntlm_auth_helper, crec->ntlm_auth_helper, CLEANUP(cleanup_ntlm_auth_helper)); - auth_helper = ctxt->ntlm_auth_helper; + auth_helper = get_auth_helper( r, ctxt->ntlm_auth_helper, crec->ntlm_auth_helper, CLEANUP(cleanup_ntlm_auth_helper)); + ctxt->ntlm_auth_helper = auth_helper; } else { auth_helper = NULL; } - if ( retval != OK ) { - return retval; + if ( auth_helper == NULL ) { + return HTTP_INTERNAL_SERVER_ERROR; } if ( ctxt->connected_user_authenticated == NULL ) {
