summaryrefslogtreecommitdiffstats
path: root/utils/gssd/gssd_proc.c
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2013-04-19 13:02:36 -0400
committerSteve Dickson <steved@redhat.com>2013-04-22 12:47:20 -0400
commit302de786930a2c533068f9d8909a817b40f07c32 (patch)
treede4a5fda75cbae6f3df282d1e2a222033b729cae /utils/gssd/gssd_proc.c
parent85352dd5ffd0d9a451b79fa61d24a518b553d280 (diff)
downloadnfs-utils-302de786930a2c533068f9d8909a817b40f07c32.tar.gz
nfs-utils-302de786930a2c533068f9d8909a817b40f07c32.tar.xz
nfs-utils-302de786930a2c533068f9d8909a817b40f07c32.zip
gssd: Allow GSSAPI to try to acquire credentials first.
GSSAPI can be given a uid number as a special name, and then gss_acquire_cred() can use the name to try to find credentials for the user. Give GSSAPI a chance to do it on its own, then fallback to the classic method of trolling through the file system to find a credential cache. This patch uses a little know feature of GSSAPI that permits to acquire crdentials specifying the user's UID. Normally GSSAPI will simply perform a getpwuid() call and use the user name to generate a principal name and then see if it can find a TGT for that principal in the local ccache. This feature is vital to allow the GSS-Proxy to be able to initiate crdentials on behalf of rpc.gssd using client keytabs stored in the filsystem. GSS-Proxy works through an interposer-type plugin (new feature in MIT 1.11) that allows to intercept all GSSAPI requestes and relay them to a system daemon via a socket. This daemon (GSS-Proxy) then can perform operations on behalf of other applications with additional logic. In the rpc.gssd case the GSS-Proxy daemon allows applications running as system users to properly access krb5 protected shares by creating a credential cache on the fly when necessary. This way all applications that need access to krb5 protected shares do not need to be taught how to initiate crdentials on their own, nor they need to be wrapped in additional init scripts like k5start or use wasteful cronjobs to keep credentials fresh. All is needed is to drop a keytab with the right keys in a special location on the system and gss-proxy will do the rest. Signed-off-by: Simo Sorce <simo@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'utils/gssd/gssd_proc.c')
-rw-r--r--utils/gssd/gssd_proc.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
index d6f07e6..2280088 100644
--- a/utils/gssd/gssd_proc.c
+++ b/utils/gssd/gssd_proc.c
@@ -800,7 +800,8 @@ create_auth_rpc_client(struct clnt_info *clp,
CLIENT **clnt_return,
AUTH **auth_return,
uid_t uid,
- int authtype)
+ int authtype,
+ gss_cred_id_t cred)
{
CLIENT *rpc_clnt = NULL;
struct rpc_gss_sec sec;
@@ -826,7 +827,7 @@ create_auth_rpc_client(struct clnt_info *clp,
sec.qop = GSS_C_QOP_DEFAULT;
sec.svc = RPCSEC_GSS_SVC_NONE;
- sec.cred = GSS_C_NO_CREDENTIAL;
+ sec.cred = cred;
sec.req_flags = 0;
if (authtype == AUTHTYPE_KRB5) {
sec.mech = (gss_OID)&krb5oid;
@@ -951,6 +952,7 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname,
char **dirname;
int create_resp = -1;
int err, downcall_err = -EACCES;
+ gss_cred_id_t gss_cred;
OM_uint32 maj_stat, min_stat, lifetime_rec;
printerr(1, "handling krb5 upcall (%s)\n", clp->dirname);
@@ -985,15 +987,20 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname,
if (uid != 0 || (uid == 0 && root_uses_machine_creds == 0 &&
service == NULL)) {
/* Tell krb5 gss which credentials cache to use */
- for (dirname = ccachesearch; *dirname != NULL; dirname++) {
+ /* Try first to acquire credentials directly via GSSAPI */
+ err = gssd_acquire_user_cred(uid, &gss_cred);
+ if (!err)
+ create_resp = create_auth_rpc_client(clp, &rpc_clnt, &auth, uid,
+ AUTHTYPE_KRB5, gss_cred);
+ /* if create_auth_rplc_client fails try the traditional method of
+ * trolling for credentials */
+ for (dirname = ccachesearch; create_resp != 0 && *dirname != NULL; dirname++) {
err = gssd_setup_krb5_user_gss_ccache(uid, clp->servername, *dirname);
if (err == -EKEYEXPIRED)
downcall_err = -EKEYEXPIRED;
else if (!err)
create_resp = create_auth_rpc_client(clp, &rpc_clnt, &auth, uid,
- AUTHTYPE_KRB5);
- if (create_resp == 0)
- break;
+ AUTHTYPE_KRB5, GSS_C_NO_CREDENTIAL);
}
}
if (create_resp != 0) {
@@ -1019,7 +1026,8 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname,
gssd_setup_krb5_machine_gss_ccache(*ccname);
if ((create_auth_rpc_client(clp, &rpc_clnt,
&auth, uid,
- AUTHTYPE_KRB5)) == 0) {
+ AUTHTYPE_KRB5,
+ GSS_C_NO_CREDENTIAL)) == 0) {
/* Success! */
success++;
break;