Skip to content

Commit eb8ed98

Browse files
frasertweedalesimo5
authored andcommitted
Add option to set alternative ccname env var
In some cases (e.g. if you want to convey the ccname over AJP) the request environment variable name "KRB5CCNAME" is not appropriate. Add the GssapiDelegCcacheEnvVar option that allows the env var name to be changed. Fixes: https://github.com/modauthgssapi/mod_auth_gssapi/issues/123 Reviewed-by: Simo Sorce <simo@redhat.com> Closes #124 Closes #123
1 parent 3ae63e3 commit eb8ed98

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

README

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ options like keytab location, client_keytab location, ccache location etc.
176176
If delegation of credentials is desired credentials can be exported in a
177177
private directory accessible by the Apache process.
178178
The delegated credentials will be stored in a file named after the client
179-
principal and the subprocess environment variable KRB5CCNAME will be set
180-
to point to that file.
179+
principal and a request environment variable (`KRB5CCNAME` by default) will be
180+
set to point to that file.
181181

182182
#### Example
183183
GssapiDelegCcacheDir /var/run/httpd/clientcaches
@@ -199,6 +199,16 @@ in the contrib directory.
199199
#### Example
200200
GssapiDelegCcacheUnique On
201201

202+
203+
### GssapiDelegCcacheEnvVar
204+
205+
Set the name of the request environment variable that will receive the
206+
credential cache name. If unspecified, defaults to `KRB5CCNAME`.
207+
208+
#### Example
209+
GssapiDelegCcacheEnvVar AJP_KRB5CCNAME
210+
211+
202212
### GssapiUseS4U2Proxy
203213

204214
Enables the use of the s4u2Proxy Kerberos extension also known as

src/environ.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ static void mag_set_name_attributes(request_rec *req, struct mag_conn *mc)
243243
}
244244
}
245245

246-
static void mag_set_KRB5CCNAME(request_rec *req, struct mag_config *cfg,
247-
struct mag_conn *mc)
246+
static void mag_set_ccname_envvar(request_rec *req, struct mag_config *cfg,
247+
struct mag_conn *mc)
248248
{
249249
apr_status_t status;
250250
apr_int32_t wanted = APR_FINFO_MIN | APR_FINFO_OWNER | APR_FINFO_PROT;
@@ -287,7 +287,7 @@ static void mag_set_KRB5CCNAME(request_rec *req, struct mag_config *cfg,
287287
}
288288

289289
value = apr_psprintf(req->pool, "FILE:%s", path);
290-
apr_table_set(mc->env, "KRB5CCNAME", value);
290+
apr_table_set(mc->env, cfg->ccname_envvar, value);
291291
}
292292

293293
void mag_export_req_env(request_rec *req, apr_table_t *env)
@@ -316,7 +316,7 @@ void mag_set_req_data(request_rec *req,
316316

317317
#ifdef HAVE_CRED_STORE
318318
if (cfg->deleg_ccache_dir && mc->delegated && mc->ccname) {
319-
mag_set_KRB5CCNAME(req, cfg, mc);
319+
mag_set_ccname_envvar(req, cfg, mc);
320320
}
321321
#endif
322322

src/mod_auth_gssapi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,7 @@ static void *mag_create_dir_config(apr_pool_t *p, char *dir)
12091209

12101210
cfg = (struct mag_config *)apr_pcalloc(p, sizeof(struct mag_config));
12111211
cfg->pool = p;
1212+
cfg->ccname_envvar = "KRB5CCNAME";
12121213

12131214
return cfg;
12141215
}
@@ -1724,6 +1725,9 @@ static const command_rec mag_commands[] = {
17241725
OR_AUTHCFG, "Directory to store delegated credentials"),
17251726
AP_INIT_ITERATE("GssapiDelegCcachePerms", mag_deleg_ccache_perms, NULL,
17261727
OR_AUTHCFG, "Permissions to assign to Ccache files"),
1728+
AP_INIT_TAKE1("GssapiDelegCcacheEnvVar", ap_set_string_slot,
1729+
(void *)APR_OFFSETOF(struct mag_config, ccname_envvar),
1730+
OR_AUTHCFG, "Environment variable to receive ccache name"),
17271731
AP_INIT_FLAG("GssapiDelegCcacheUnique", mag_deleg_ccache_unique, NULL,
17281732
OR_AUTHCFG, "Use unique ccaches for delgation"),
17291733
AP_INIT_FLAG("GssapiImpersonate", ap_set_flag_slot,

src/mod_auth_gssapi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ struct mag_config {
8181
gss_key_value_set_desc *cred_store;
8282
bool deleg_ccache_unique;
8383
bool s4u2self;
84+
char *ccname_envvar;
8485
#endif
8586
struct seal_key *mag_skey;
8687

0 commit comments

Comments
 (0)