elric1/knc — pull request #1 by nicowilliams (2013-07-12 00:14:34+00:00)
Title: Naming and creds

These commits make the API a bit more symmetric and allow more control (and document it) over when credentials are released, which is useful for privilege dropping purposes.

We should do something even more likely to drop access to privileged data: provide an export/import interface so you can: a) export a knc context, b) exec a child and pass it the exported context via an open, unlinked tmp file or shared memory, c) re-import the context. Actually, this needn't even look like an export/import pair of functions, more like:

int
knc_allow_inherit(knc_ctx); /* returns an fd to import from */

void
knc_ctx knc_inherit(int);

Even the knc_stream info, including fildes numbers, needed for the event loop should be passed via this one fd.

So an app would accept a context, knc_set_cred(ctx, GSS_C_NO_CREDENTIAL), do something with the deleg cred (possibly gss_export_cred(), possibly gss_store_cred()), knc_free_deleg_cred(ctx), then fork(), knc_allow_inherit(), setuid() and so on, then exec(), then knc_inherit().