Blame SOURCES/mod_auth_kerb-5.4-delegation.patch

b2b3b1
b2b3b1
https://bugzilla.redhat.com/show_bug.cgi?id=688210
b2b3b1
b2b3b1
--- mod_auth_kerb-5.4/src/mod_auth_kerb.c.delegation
b2b3b1
+++ mod_auth_kerb-5.4/src/mod_auth_kerb.c
b2b3b1
@@ -209,6 +209,7 @@ typedef struct krb5_conn_data {
b2b3b1
 	char *authline;
b2b3b1
 	char *user;
b2b3b1
 	char *mech;
b2b3b1
+	char *ccname;
b2b3b1
 	int  last_return;
b2b3b1
 } krb5_conn_data;
b2b3b1
 
b2b3b1
@@ -875,7 +876,7 @@ create_krb5_ccache(krb5_context kcontext
b2b3b1
    int ret;
b2b3b1
    krb5_ccache tmp_ccache = NULL;
b2b3b1
 
b2b3b1
-   ccname = apr_psprintf(r->pool, "FILE:%s/krb5cc_apache_XXXXXX", P_tmpdir);
b2b3b1
+   ccname = apr_psprintf(r->connection->pool, "FILE:%s/krb5cc_apache_XXXXXX", P_tmpdir);
b2b3b1
    fd = mkstemp(ccname + strlen("FILE:"));
b2b3b1
    if (fd < 0) {
b2b3b1
       log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
b2b3b1
@@ -905,7 +906,7 @@ create_krb5_ccache(krb5_context kcontext
b2b3b1
    }
b2b3b1
 
b2b3b1
    apr_table_setn(r->subprocess_env, "KRB5CCNAME", ccname);
b2b3b1
-   apr_pool_cleanup_register(r->pool, ccname, krb5_cache_cleanup,
b2b3b1
+   apr_pool_cleanup_register(r->connection->pool, ccname, krb5_cache_cleanup,
b2b3b1
 	 		     apr_pool_cleanup_null);
b2b3b1
 
b2b3b1
    *ccache = tmp_ccache;
b2b3b1
@@ -1866,10 +1868,15 @@ already_succeeded(request_rec *r, char *
b2b3b1
    if (apr_pool_userdata_get((void**)&conn_data, keyname, r->connection->pool) != 0)
b2b3b1
 	return NULL;
b2b3b1
 
b2b3b1
-   if(conn_data) {
b2b3b1
-	if(strcmp(conn_data->authline, auth_line) == 0) {
b2b3b1
-		log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "matched previous auth request");
b2b3b1
-		return conn_data;
b2b3b1
+   if(conn_data && conn_data->ccname != NULL) {
b2b3b1
+       apr_finfo_t finfo;
b2b3b1
+
b2b3b1
+       if (apr_stat(&finfo, conn_data->ccname + strlen("FILE:"), 
b2b3b1
+                    APR_FINFO_NORM, r->pool) == APR_SUCCESS
b2b3b1
+           && (finfo.valid & APR_FINFO_TYPE)
b2b3b1
+           && finfo.filetype == APR_REG) {
b2b3b1
+           log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "matched previous auth request");
b2b3b1
+           return conn_data;
b2b3b1
 	}
b2b3b1
    }
b2b3b1
    return NULL;
b2b3b1
@@ -2001,6 +2008,8 @@ kerb_authenticate_user(request_rec *r)
b2b3b1
 	ret = prevauth->last_return;
b2b3b1
 	MK_USER = prevauth->user;
b2b3b1
 	MK_AUTH_TYPE = prevauth->mech;
b2b3b1
+	if (prevauth->ccname)
b2b3b1
+		apr_table_setn(r->subprocess_env, "KRB5CCNAME", prevauth->ccname);
b2b3b1
    }
b2b3b1
 
b2b3b1
    /*
b2b3b1
@@ -2011,6 +2020,7 @@ kerb_authenticate_user(request_rec *r)
b2b3b1
        prevauth->user = apr_pstrdup(r->connection->pool, MK_USER);
b2b3b1
        prevauth->authline = apr_pstrdup(r->connection->pool, auth_line);
b2b3b1
        prevauth->mech = apr_pstrdup(r->connection->pool, auth_type);
b2b3b1
+       prevauth->ccname = apr_pstrdup(r->connection->pool, apr_table_get(r->subprocess_env, "KRB5CCNAME"));
b2b3b1
        prevauth->last_return = ret;
b2b3b1
        snprintf(keyname, sizeof(keyname) - 1,
b2b3b1
            "mod_auth_kerb::connection::%s::%ld",