Skip to content

Commit b4f5124

Browse files
committed
Allow to export errors as environment variables
Introduce a new option to export errors in environment variables. This allows applications to display better errors or take actions based on the returned error type. Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Robbie Harwood <rharwood@redhat.com> Resolves #128 Resolves #129
1 parent f2c4293 commit b4f5124

File tree

5 files changed

+131
-72
lines changed

5 files changed

+131
-72
lines changed

README

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,22 @@ the default owners and/or mode will be retained.
379379

380380
#### Example
381381
GssapiDelegCcachePerms mode:0660 gid:webuiworkers
382+
383+
384+
### GssapiPublishErrors
385+
386+
This option is used to publish errors as Environment Variables for use by
387+
httpd processes.
388+
389+
A general error type is provided in the MAG_ERROR variable, and can have the
390+
following values: "GSS ERROR", "INTERNAL ERROR", "AUTH NOT ALLOWED"
391+
Additionally, in the variable named MAG_ERROR_TEXT there may be a free form
392+
error message.
393+
394+
When the error type is "GSS ERROR" the variables GSS_ERROR_MAJ and
395+
GSS_ERROR_MIN contain the numeric errors returned by GSSAPI, and the
396+
MAG_ERROR_TEXT will contain a GSS Error message, possibly prepended by
397+
an additional message that provides more context.
398+
399+
- **Enable with:** GssapiPublishErrors On
400+
- **Default:** GssapiPublishErrors Off

src/environ.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,3 +366,17 @@ void mag_set_req_data(request_rec *req,
366366
ap_set_module_config(req->request_config, &auth_gssapi_module, mc->env);
367367
mag_export_req_env(req, mc->env);
368368
}
369+
370+
void mag_publish_error(request_rec *req, uint32_t maj, uint32_t min,
371+
const char *gss_err, const char *mag_err)
372+
{
373+
if (gss_err) {
374+
apr_table_set(req->subprocess_env, "GSS_ERROR_MAJ",
375+
apr_psprintf(req->pool, "%u", (unsigned)maj));
376+
apr_table_set(req->subprocess_env, "GSS_ERROR_MIN",
377+
apr_psprintf(req->pool, "%u", (unsigned)min));
378+
apr_table_set(req->subprocess_env, "MAG_ERROR_TEXT", gss_err);
379+
}
380+
if (mag_err)
381+
apr_table_set(req->subprocess_env, "MAG_ERROR", mag_err);
382+
}

src/environ.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ void mag_export_req_env(request_rec *req, apr_table_t *env);
1313
void mag_set_req_data(request_rec *req,
1414
struct mag_config *cfg,
1515
struct mag_conn *mc);
16+
17+
void mag_publish_error(request_rec *req, uint32_t maj, uint32_t min,
18+
const char *gss_err, const char *mag_err);

0 commit comments

Comments
 (0)