Commit a0337d1d authored by Jeff Layton's avatar Jeff Layton Committed by Trond Myklebust

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: default avatarJeff Layton <jlayton@poochiereds.net>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent 2004c726
...@@ -140,6 +140,7 @@ struct rpc_credops { ...@@ -140,6 +140,7 @@ struct rpc_credops {
void *, __be32 *, void *); void *, __be32 *, void *);
int (*crkey_timeout)(struct rpc_cred *); int (*crkey_timeout)(struct rpc_cred *);
bool (*crkey_to_expire)(struct rpc_cred *); bool (*crkey_to_expire)(struct rpc_cred *);
char * (*crstringify_acceptor)(struct rpc_cred *);
}; };
extern const struct rpc_authops authunix_ops; extern const struct rpc_authops authunix_ops;
...@@ -182,6 +183,7 @@ void rpcauth_clear_credcache(struct rpc_cred_cache *); ...@@ -182,6 +183,7 @@ void rpcauth_clear_credcache(struct rpc_cred_cache *);
int rpcauth_key_timeout_notify(struct rpc_auth *, int rpcauth_key_timeout_notify(struct rpc_auth *,
struct rpc_cred *); struct rpc_cred *);
bool rpcauth_cred_key_to_expire(struct rpc_cred *); bool rpcauth_cred_key_to_expire(struct rpc_cred *);
char * rpcauth_stringify_acceptor(struct rpc_cred *);
static inline static inline
struct rpc_cred * get_rpccred(struct rpc_cred *cred) struct rpc_cred * get_rpccred(struct rpc_cred *cred)
......
...@@ -363,6 +363,15 @@ rpcauth_cred_key_to_expire(struct rpc_cred *cred) ...@@ -363,6 +363,15 @@ rpcauth_cred_key_to_expire(struct rpc_cred *cred)
} }
EXPORT_SYMBOL_GPL(rpcauth_cred_key_to_expire); EXPORT_SYMBOL_GPL(rpcauth_cred_key_to_expire);
char *
rpcauth_stringify_acceptor(struct rpc_cred *cred)
{
if (!cred->cr_ops->crstringify_acceptor)
return NULL;
return cred->cr_ops->crstringify_acceptor(cred);
}
EXPORT_SYMBOL_GPL(rpcauth_stringify_acceptor);
/* /*
* Destroy a list of credentials * Destroy a list of credentials
*/ */
......
...@@ -1346,6 +1346,26 @@ gss_cred_init(struct rpc_auth *auth, struct rpc_cred *cred) ...@@ -1346,6 +1346,26 @@ gss_cred_init(struct rpc_auth *auth, struct rpc_cred *cred)
return err; return err;
} }
static char *
gss_stringify_acceptor(struct rpc_cred *cred)
{
char *string;
struct gss_cred *gss_cred = container_of(cred, struct gss_cred, gc_base);
struct xdr_netobj *acceptor = &gss_cred->gc_ctx->gc_acceptor;
/* no point if there's no string */
if (!acceptor->len)
return NULL;
string = kmalloc(acceptor->len + 1, GFP_KERNEL);
if (!string)
return string;
memcpy(string, acceptor->data, acceptor->len);
string[acceptor->len] = '\0';
return string;
}
/* /*
* Returns -EACCES if GSS context is NULL or will expire within the * Returns -EACCES if GSS context is NULL or will expire within the
* timeout (miliseconds) * timeout (miliseconds)
...@@ -1923,29 +1943,31 @@ static const struct rpc_authops authgss_ops = { ...@@ -1923,29 +1943,31 @@ static const struct rpc_authops authgss_ops = {
}; };
static const struct rpc_credops gss_credops = { static const struct rpc_credops gss_credops = {
.cr_name = "AUTH_GSS", .cr_name = "AUTH_GSS",
.crdestroy = gss_destroy_cred, .crdestroy = gss_destroy_cred,
.cr_init = gss_cred_init, .cr_init = gss_cred_init,
.crbind = rpcauth_generic_bind_cred, .crbind = rpcauth_generic_bind_cred,
.crmatch = gss_match, .crmatch = gss_match,
.crmarshal = gss_marshal, .crmarshal = gss_marshal,
.crrefresh = gss_refresh, .crrefresh = gss_refresh,
.crvalidate = gss_validate, .crvalidate = gss_validate,
.crwrap_req = gss_wrap_req, .crwrap_req = gss_wrap_req,
.crunwrap_resp = gss_unwrap_resp, .crunwrap_resp = gss_unwrap_resp,
.crkey_timeout = gss_key_timeout, .crkey_timeout = gss_key_timeout,
.crstringify_acceptor = gss_stringify_acceptor,
}; };
static const struct rpc_credops gss_nullops = { static const struct rpc_credops gss_nullops = {
.cr_name = "AUTH_GSS", .cr_name = "AUTH_GSS",
.crdestroy = gss_destroy_nullcred, .crdestroy = gss_destroy_nullcred,
.crbind = rpcauth_generic_bind_cred, .crbind = rpcauth_generic_bind_cred,
.crmatch = gss_match, .crmatch = gss_match,
.crmarshal = gss_marshal, .crmarshal = gss_marshal,
.crrefresh = gss_refresh_null, .crrefresh = gss_refresh_null,
.crvalidate = gss_validate, .crvalidate = gss_validate,
.crwrap_req = gss_wrap_req, .crwrap_req = gss_wrap_req,
.crunwrap_resp = gss_unwrap_resp, .crunwrap_resp = gss_unwrap_resp,
.crstringify_acceptor = gss_stringify_acceptor,
}; };
static const struct rpc_pipe_ops gss_upcall_ops_v0 = { static const struct rpc_pipe_ops gss_upcall_ops_v0 = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment