aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJeff Layton <jlayton@poochiereds.net>2014-06-21 20:52:16 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2014-07-12 18:41:20 -0400
commita0337d1ddb5a4bd609e3ff0955551cb240340340 (patch)
tree70aaa98dc13ac50b41f4741b620b8954508f9728 /net
parent2004c726b9d9a9670b7f837190be9c8dfa7a0e9d (diff)
sunrpc: add a new "stringify_acceptor" rpc_credop
...and add an new rpc_auth function to call it when it exists. This is only applicable for AUTH_GSS mechanisms, so we only specify this for those sorts of credentials. Signed-off-by: Jeff Layton <jlayton@poochiereds.net> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/auth.c9
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c62
2 files changed, 51 insertions, 20 deletions
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index f77366717420..1481efff6aa2 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -363,6 +363,15 @@ rpcauth_cred_key_to_expire(struct rpc_cred *cred)
363} 363}
364EXPORT_SYMBOL_GPL(rpcauth_cred_key_to_expire); 364EXPORT_SYMBOL_GPL(rpcauth_cred_key_to_expire);
365 365
366char *
367rpcauth_stringify_acceptor(struct rpc_cred *cred)
368{
369 if (!cred->cr_ops->crstringify_acceptor)
370 return NULL;
371 return cred->cr_ops->crstringify_acceptor(cred);
372}
373EXPORT_SYMBOL_GPL(rpcauth_stringify_acceptor);
374
366/* 375/*
367 * Destroy a list of credentials 376 * Destroy a list of credentials
368 */ 377 */
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index e34af68603bd..73854314fb85 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -1346,6 +1346,26 @@ gss_cred_init(struct rpc_auth *auth, struct rpc_cred *cred)
1346 return err; 1346 return err;
1347} 1347}
1348 1348
1349static char *
1350gss_stringify_acceptor(struct rpc_cred *cred)
1351{
1352 char *string;
1353 struct gss_cred *gss_cred = container_of(cred, struct gss_cred, gc_base);
1354 struct xdr_netobj *acceptor = &gss_cred->gc_ctx->gc_acceptor;
1355
1356 /* no point if there's no string */
1357 if (!acceptor->len)
1358 return NULL;
1359
1360 string = kmalloc(acceptor->len + 1, GFP_KERNEL);
1361 if (!string)
1362 return string;
1363
1364 memcpy(string, acceptor->data, acceptor->len);
1365 string[acceptor->len] = '\0';
1366 return string;
1367}
1368
1349/* 1369/*
1350 * Returns -EACCES if GSS context is NULL or will expire within the 1370 * Returns -EACCES if GSS context is NULL or will expire within the
1351 * timeout (miliseconds) 1371 * timeout (miliseconds)
@@ -1923,29 +1943,31 @@ static const struct rpc_authops authgss_ops = {
1923}; 1943};
1924 1944
1925static const struct rpc_credops gss_credops = { 1945static const struct rpc_credops gss_credops = {
1926 .cr_name = "AUTH_GSS", 1946 .cr_name = "AUTH_GSS",
1927 .crdestroy = gss_destroy_cred, 1947 .crdestroy = gss_destroy_cred,
1928 .cr_init = gss_cred_init, 1948 .cr_init = gss_cred_init,
1929 .crbind = rpcauth_generic_bind_cred, 1949 .crbind = rpcauth_generic_bind_cred,
1930 .crmatch = gss_match, 1950 .crmatch = gss_match,
1931 .crmarshal = gss_marshal, 1951 .crmarshal = gss_marshal,
1932 .crrefresh = gss_refresh, 1952 .crrefresh = gss_refresh,
1933 .crvalidate = gss_validate, 1953 .crvalidate = gss_validate,
1934 .crwrap_req = gss_wrap_req, 1954 .crwrap_req = gss_wrap_req,
1935 .crunwrap_resp = gss_unwrap_resp, 1955 .crunwrap_resp = gss_unwrap_resp,
1936 .crkey_timeout = gss_key_timeout, 1956 .crkey_timeout = gss_key_timeout,
1957 .crstringify_acceptor = gss_stringify_acceptor,
1937}; 1958};
1938 1959
1939static const struct rpc_credops gss_nullops = { 1960static const struct rpc_credops gss_nullops = {
1940 .cr_name = "AUTH_GSS", 1961 .cr_name = "AUTH_GSS",
1941 .crdestroy = gss_destroy_nullcred, 1962 .crdestroy = gss_destroy_nullcred,
1942 .crbind = rpcauth_generic_bind_cred, 1963 .crbind = rpcauth_generic_bind_cred,
1943 .crmatch = gss_match, 1964 .crmatch = gss_match,
1944 .crmarshal = gss_marshal, 1965 .crmarshal = gss_marshal,
1945 .crrefresh = gss_refresh_null, 1966 .crrefresh = gss_refresh_null,
1946 .crvalidate = gss_validate, 1967 .crvalidate = gss_validate,
1947 .crwrap_req = gss_wrap_req, 1968 .crwrap_req = gss_wrap_req,
1948 .crunwrap_resp = gss_unwrap_resp, 1969 .crunwrap_resp = gss_unwrap_resp,
1970 .crstringify_acceptor = gss_stringify_acceptor,
1949}; 1971};
1950 1972
1951static const struct rpc_pipe_ops gss_upcall_ops_v0 = { 1973static const struct rpc_pipe_ops gss_upcall_ops_v0 = {