2 * linux/net/sunrpc/auth_null.c
4 * AUTH_NULL authentication. Really :-)
6 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
9 #include <linux/types.h>
10 #include <linux/socket.h>
11 #include <linux/module.h>
13 #include <linux/utsname.h>
14 #include <linux/sunrpc/clnt.h>
15 #include <linux/sched.h>
18 # define RPCDBG_FACILITY RPCDBG_AUTH
21 static struct rpc_credops null_credops;
23 static struct rpc_auth *
24 nul_create(struct rpc_clnt *clnt, rpc_authflavor_t flavor)
26 struct rpc_auth *auth;
28 dprintk("RPC: creating NULL authenticator for client %p\n", clnt);
29 if (!(auth = (struct rpc_auth *) kmalloc(sizeof(*auth),GFP_KERNEL)))
33 auth->au_ops = &authnull_ops;
34 auth->au_expire = 1800 * HZ;
35 rpcauth_init_credcache(auth);
37 return (struct rpc_auth *) auth;
41 nul_destroy(struct rpc_auth *auth)
43 dprintk("RPC: destroying NULL authenticator %p\n", auth);
44 rpcauth_free_credcache(auth);
48 * Create NULL creds for current process
50 static struct rpc_cred *
51 nul_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags)
53 struct rpc_cred *cred;
55 if (!(cred = (struct rpc_cred *) kmalloc(sizeof(*cred),GFP_KERNEL)))
57 atomic_set(&cred->cr_count, 0);
58 cred->cr_flags = RPCAUTH_CRED_UPTODATE;
59 cred->cr_uid = acred->uid;
60 cred->cr_ops = &null_credops;
66 * Destroy cred handle.
69 nul_destroy_cred(struct rpc_cred *cred)
75 * Match cred handle against current process
78 nul_match(struct auth_cred *acred, struct rpc_cred *cred, int taskflags)
87 nul_marshal(struct rpc_task *task, u32 *p, int ruid)
89 *p++ = htonl(RPC_AUTH_NULL);
91 *p++ = htonl(RPC_AUTH_NULL);
98 * Refresh credential. This is a no-op for AUTH_NULL
101 nul_refresh(struct rpc_task *task)
103 return task->tk_status = -EACCES;
107 nul_validate(struct rpc_task *task, u32 *p)
109 rpc_authflavor_t flavor;
112 flavor = ntohl(*p++);
113 if (flavor != RPC_AUTH_NULL) {
114 printk("RPC: bad verf flavor: %u\n", flavor);
120 printk("RPC: bad verf size: %u\n", size);
127 struct rpc_authops authnull_ops = {
128 .owner = THIS_MODULE,
129 .au_flavor = RPC_AUTH_NULL,
133 .create = nul_create,
134 .destroy = nul_destroy,
135 .crcreate = nul_create_cred,
139 struct rpc_credops null_credops = {
140 .crdestroy = nul_destroy_cred,
141 .crmatch = nul_match,
142 .crmarshal = nul_marshal,
143 .crrefresh = nul_refresh,
144 .crvalidate = nul_validate,