sunrpc: add a new "stringify_acceptor" rpc_credop
[deliverable/linux.git] / net / sunrpc / auth_gss / auth_gss.c
index e34af68603bdec1d7ba207c3bc3fee8143f84ffe..73854314fb85a3e42c6ef3865fbb50bdd21014bc 100644 (file)
@@ -1346,6 +1346,26 @@ gss_cred_init(struct rpc_auth *auth, struct rpc_cred *cred)
        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
  * timeout (miliseconds)
@@ -1923,29 +1943,31 @@ static const struct rpc_authops authgss_ops = {
 };
 
 static const struct rpc_credops gss_credops = {
-       .cr_name        = "AUTH_GSS",
-       .crdestroy      = gss_destroy_cred,
-       .cr_init        = gss_cred_init,
-       .crbind         = rpcauth_generic_bind_cred,
-       .crmatch        = gss_match,
-       .crmarshal      = gss_marshal,
-       .crrefresh      = gss_refresh,
-       .crvalidate     = gss_validate,
-       .crwrap_req     = gss_wrap_req,
-       .crunwrap_resp  = gss_unwrap_resp,
-       .crkey_timeout  = gss_key_timeout,
+       .cr_name                = "AUTH_GSS",
+       .crdestroy              = gss_destroy_cred,
+       .cr_init                = gss_cred_init,
+       .crbind                 = rpcauth_generic_bind_cred,
+       .crmatch                = gss_match,
+       .crmarshal              = gss_marshal,
+       .crrefresh              = gss_refresh,
+       .crvalidate             = gss_validate,
+       .crwrap_req             = gss_wrap_req,
+       .crunwrap_resp          = gss_unwrap_resp,
+       .crkey_timeout          = gss_key_timeout,
+       .crstringify_acceptor   = gss_stringify_acceptor,
 };
 
 static const struct rpc_credops gss_nullops = {
-       .cr_name        = "AUTH_GSS",
-       .crdestroy      = gss_destroy_nullcred,
-       .crbind         = rpcauth_generic_bind_cred,
-       .crmatch        = gss_match,
-       .crmarshal      = gss_marshal,
-       .crrefresh      = gss_refresh_null,
-       .crvalidate     = gss_validate,
-       .crwrap_req     = gss_wrap_req,
-       .crunwrap_resp  = gss_unwrap_resp,
+       .cr_name                = "AUTH_GSS",
+       .crdestroy              = gss_destroy_nullcred,
+       .crbind                 = rpcauth_generic_bind_cred,
+       .crmatch                = gss_match,
+       .crmarshal              = gss_marshal,
+       .crrefresh              = gss_refresh_null,
+       .crvalidate             = gss_validate,
+       .crwrap_req             = gss_wrap_req,
+       .crunwrap_resp          = gss_unwrap_resp,
+       .crstringify_acceptor   = gss_stringify_acceptor,
 };
 
 static const struct rpc_pipe_ops gss_upcall_ops_v0 = {
This page took 0.025135 seconds and 5 git commands to generate.