diff options
author | Simo Sorce <simo@redhat.com> | 2017-11-16 15:39:01 -0500 |
---|---|---|
committer | Simo Sorce <simo@redhat.com> | 2017-11-16 16:28:28 -0500 |
commit | 799c0303440e66004b4517e66d7f2852cfd313e4 (patch) | |
tree | 294e1eb2acf0dfe3f043d5be13f6de28e16e4f48 /utils/gssd/gss_util.c | |
parent | 8d9bf479441d9d7a44a86b69026a7e9d431d3ade (diff) | |
download | nfs-utils-fixrootccache.tar.gz nfs-utils-fixrootccache.tar.xz nfs-utils-fixrootccache.zip |
Avoid clobbering root's ccache if possiblefixrootccache
If the gssapi library is modern enough, store the ccache in a process
scoped keyring by default. This will avoid clobbering root's default
ccache, and keep the creds from littering the filesystem.
Signed-off-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'utils/gssd/gss_util.c')
-rw-r--r-- | utils/gssd/gss_util.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/utils/gssd/gss_util.c b/utils/gssd/gss_util.c index 2e6d40f..6235b7a 100644 --- a/utils/gssd/gss_util.c +++ b/utils/gssd/gss_util.c @@ -81,6 +81,9 @@ #include <gssapi/gssapi_generic.h> #define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name #endif +#ifdef HAVE_GSS_ACQUIRE_CRED_FROM +#include <gssapi/gssapi_ext.h> +#endif #include "gss_util.h" #include "err_util.h" #include "gssd.h" @@ -88,6 +91,7 @@ #include <unistd.h> #endif #include <stdlib.h> +#include <stdbool.h> #ifdef HAVE_COM_ERR_H #include <com_err.h> #endif @@ -269,7 +273,7 @@ pgsserr(char *msg, u_int32_t maj_stat, u_int32_t min_stat, const gss_OID mech) } int -gssd_acquire_cred(char *server_name, const gss_OID oid) +gssd_acquire_cred(char *server_name, bool machine, const gss_OID oid) { gss_buffer_desc name; gss_name_t target_name; @@ -294,6 +298,17 @@ gssd_acquire_cred(char *server_name, const gss_OID oid) } } +#ifdef HAVE_GSS_ACQUIRE_CRED_FROM + if (machine) { + gss_key_value_element_desc gssd_ccache = { "ccache", + GSSD_SECURE_MACHINE_CACHE }; + gss_key_value_set_desc cred_store = {1, &gssd_ccache}; + maj_stat = gss_acquire_cred_from(&min_stat, target_name, + GSS_C_INDEFINITE, GSS_C_NO_OID_SET, + GSS_C_ACCEPT, &cred_store, + &gssd_creds, NULL, NULL); + } else +#endif maj_stat = gss_acquire_cred(&min_stat, target_name, GSS_C_INDEFINITE, GSS_C_NO_OID_SET, GSS_C_ACCEPT, &gssd_creds, NULL, NULL); |