2 * linux/net/sunrpc/rpcauth_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/slab.h>
11 #include <linux/socket.h>
13 #include <linux/utsname.h>
14 #include <linux/sunrpc/clnt.h>
17 # define RPCDBG_FACILITY RPCDBG_AUTH
20 static struct rpc_credops null_credops;
22 static struct rpc_auth *
23 nul_create(struct rpc_clnt *clnt)
25 struct rpc_auth *auth;
27 dprintk("RPC: creating NULL authenticator for client %p\n", clnt);
28 if (!(auth = (struct rpc_auth *) rpc_allocate(0, sizeof(*auth))))
32 auth->au_ops = &authnull_ops;
33 auth->au_expire = 1800 * HZ;
34 rpcauth_init_credcache(auth);
36 return (struct rpc_auth *) auth;
40 nul_destroy(struct rpc_auth *auth)
42 dprintk("RPC: destroying NULL authenticator %p\n", auth);
43 rpcauth_free_credcache(auth);
48 * Create NULL creds for current process
50 static struct rpc_cred *
51 nul_create_cred(int flags)
53 struct rpc_cred *cred;
55 if (!(cred = (struct rpc_cred *) rpc_allocate(flags, sizeof(*cred))))
57 atomic_set(&cred->cr_count, 0);
58 cred->cr_flags = RPCAUTH_CRED_UPTODATE;
59 cred->cr_uid = current->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 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)
111 if (n != RPC_AUTH_NULL) {
112 printk("RPC: bad verf flavor: %ld\n", (unsigned long) n);
115 if ((n = ntohl(*p++)) != 0) {
116 printk("RPC: bad verf size: %ld\n", (unsigned long) n);
123 struct rpc_authops authnull_ops = {
134 struct rpc_credops null_credops = {