@@ -618,43 +618,7 @@ static int mag_auth(request_rec *req)
618618 }
619619#endif
620620
621- /* output and input are inverted here, this is intentional */
622- maj = gss_init_sec_context (& min , user_cred , & user_ctx , server ,
623- GSS_C_NO_OID , init_flags , 300 ,
624- GSS_C_NO_CHANNEL_BINDINGS , & output ,
625- NULL , & input , NULL , NULL );
626- if (GSS_ERROR (maj )) {
627- ap_log_rerror (APLOG_MARK , APLOG_ERR , 0 , req ,
628- "%s" , mag_error (req , "gss_init_sec_context() "
629- "failed" , maj , min ));
630- goto done ;
631- }
632- }
633-
634- if (auth_type == AUTH_TYPE_NEGOTIATE &&
635- cfg -> allowed_mechs != GSS_C_NO_OID_SET ) {
636- maj = gss_set_neg_mechs (& min , acquired_cred , cfg -> allowed_mechs );
637- if (GSS_ERROR (maj )) {
638- ap_log_rerror (APLOG_MARK , APLOG_ERR , 0 , req , "%s" ,
639- mag_error (req , "gss_set_neg_mechs() failed" ,
640- maj , min ));
641- goto done ;
642- }
643- }
644-
645- maj = gss_accept_sec_context (& min , pctx , acquired_cred ,
646- & input , GSS_C_NO_CHANNEL_BINDINGS ,
647- & client , & mech_type , & output , & flags , & vtime ,
648- & delegated_cred );
649- if (GSS_ERROR (maj )) {
650- ap_log_rerror (APLOG_MARK , APLOG_ERR , 0 , req , "%s" ,
651- mag_error (req , "gss_accept_sec_context() failed" ,
652- maj , min ));
653- goto done ;
654- }
655- if (auth_type == AUTH_TYPE_BASIC ) {
656- while (maj == GSS_S_CONTINUE_NEEDED ) {
657- gss_release_buffer (& min , & input );
621+ do {
658622 /* output and input are inverted here, this is intentional */
659623 maj = gss_init_sec_context (& min , user_cred , & user_ctx , server ,
660624 GSS_C_NO_OID , init_flags , 300 ,
@@ -677,7 +641,32 @@ static int mag_auth(request_rec *req)
677641 " failed" , maj , min ));
678642 goto done ;
679643 }
644+ gss_release_buffer (& min , & input );
645+ } while (maj == GSS_S_CONTINUE_NEEDED );
646+ gss_release_buffer (& min , & output );
647+ goto complete ;
648+ }
649+
650+ if (auth_type == AUTH_TYPE_NEGOTIATE &&
651+ cfg -> allowed_mechs != GSS_C_NO_OID_SET ) {
652+ maj = gss_set_neg_mechs (& min , acquired_cred , cfg -> allowed_mechs );
653+ if (GSS_ERROR (maj )) {
654+ ap_log_rerror (APLOG_MARK , APLOG_ERR , 0 , req , "%s" ,
655+ mag_error (req , "gss_set_neg_mechs() failed" ,
656+ maj , min ));
657+ goto done ;
680658 }
659+ }
660+
661+ maj = gss_accept_sec_context (& min , pctx , acquired_cred ,
662+ & input , GSS_C_NO_CHANNEL_BINDINGS ,
663+ & client , & mech_type , & output , & flags , & vtime ,
664+ & delegated_cred );
665+ if (GSS_ERROR (maj )) {
666+ ap_log_rerror (APLOG_MARK , APLOG_ERR , 0 , req , "%s" ,
667+ mag_error (req , "gss_accept_sec_context() failed" ,
668+ maj , min ));
669+ goto done ;
681670 } else if (maj == GSS_S_CONTINUE_NEEDED ) {
682671 if (!mc ) {
683672 ap_log_rerror (APLOG_MARK , APLOG_ERR , 0 , req ,
@@ -691,6 +680,7 @@ static int mag_auth(request_rec *req)
691680 goto done ;
692681 }
693682
683+ complete :
694684 /* Always set the GSS name in an env var */
695685 maj = gss_display_name (& min , client , & name , NULL );
696686 if (GSS_ERROR (maj )) {
0 commit comments