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/malloc.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_auth
*
21 nul_create(struct rpc_clnt
*clnt
)
23 struct rpc_auth
*auth
;
25 dprintk("RPC: creating NULL authenticator for client %p\n", clnt
);
26 if (!(auth
= (struct rpc_auth
*) rpc_allocate(0, sizeof(*auth
))))
30 auth
->au_ops
= &authnull_ops
;
31 auth
->au_expire
= 1800 * HZ
;
32 rpcauth_init_credcache(auth
);
34 return (struct rpc_auth
*) auth
;
38 nul_destroy(struct rpc_auth
*auth
)
40 dprintk("RPC: destroying NULL authenticator %p\n", auth
);
45 * Create NULL creds for current process
47 static struct rpc_cred
*
48 nul_create_cred(struct rpc_task
*task
)
50 struct rpc_cred
*cred
;
52 if (!(cred
= (struct rpc_cred
*) rpc_malloc(task
, sizeof(*cred
)))) {
53 task
->tk_status
= -ENOMEM
;
58 cred
->cr_flags
= RPCAUTH_CRED_UPTODATE
;
64 * Destroy cred handle.
67 nul_destroy_cred(struct rpc_cred
*cred
)
73 * Match cred handle against current process
76 nul_match(struct rpc_task
*task
, struct rpc_cred
*cred
)
85 nul_marshal(struct rpc_task
*task
, u32
*p
, int ruid
)
87 *p
++ = htonl(RPC_AUTH_NULL
);
89 *p
++ = htonl(RPC_AUTH_NULL
);
96 * Refresh credential. This is a no-op for AUTH_NULL
99 nul_refresh(struct rpc_task
*task
)
101 return task
->tk_status
= -EACCES
;
105 nul_validate(struct rpc_task
*task
, u32
*p
)
109 if (n
!= RPC_AUTH_NULL
) {
110 printk("RPC: bad verf flavor: %ld\n", (unsigned long) n
);
113 if ((n
= ntohl(*p
++)) != 0) {
114 printk("RPC: bad verf size: %ld\n", (unsigned long) n
);
121 struct rpc_authops authnull_ops
= {