aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sunrpc/auth.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/linux/sunrpc/auth.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/linux/sunrpc/auth.h')
-rw-r--r--include/linux/sunrpc/auth.h149
1 files changed, 149 insertions, 0 deletions
diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h
new file mode 100644
index 000000000000..04ebc24db348
--- /dev/null
+++ b/include/linux/sunrpc/auth.h
@@ -0,0 +1,149 @@
1/*
2 * linux/include/linux/sunrpc/auth.h
3 *
4 * Declarations for the RPC client authentication machinery.
5 *
6 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef _LINUX_SUNRPC_AUTH_H
10#define _LINUX_SUNRPC_AUTH_H
11
12#ifdef __KERNEL__
13
14#include <linux/config.h>
15#include <linux/sunrpc/sched.h>
16#include <linux/sunrpc/msg_prot.h>
17#include <linux/sunrpc/xdr.h>
18
19#include <asm/atomic.h>
20
21/* size of the nodename buffer */
22#define UNX_MAXNODENAME 32
23
24/* Maximum size (in bytes) of an rpc credential or verifier */
25#define RPC_MAX_AUTH_SIZE (400)
26
27/* Work around the lack of a VFS credential */
28struct auth_cred {
29 uid_t uid;
30 gid_t gid;
31 struct group_info *group_info;
32};
33
34/*
35 * Client user credentials
36 */
37struct rpc_cred {
38 struct hlist_node cr_hash; /* hash chain */
39 struct rpc_credops * cr_ops;
40 unsigned long cr_expire; /* when to gc */
41 atomic_t cr_count; /* ref count */
42 unsigned short cr_flags; /* various flags */
43#ifdef RPC_DEBUG
44 unsigned long cr_magic; /* 0x0f4aa4f0 */
45#endif
46
47 uid_t cr_uid;
48
49 /* per-flavor data */
50};
51#define RPCAUTH_CRED_LOCKED 0x0001
52#define RPCAUTH_CRED_UPTODATE 0x0002
53
54#define RPCAUTH_CRED_MAGIC 0x0f4aa4f0
55
56/*
57 * Client authentication handle
58 */
59#define RPC_CREDCACHE_NR 8
60#define RPC_CREDCACHE_MASK (RPC_CREDCACHE_NR - 1)
61struct rpc_cred_cache {
62 struct hlist_head hashtable[RPC_CREDCACHE_NR];
63 unsigned long nextgc; /* next garbage collection */
64 unsigned long expire; /* cache expiry interval */
65};
66
67struct rpc_auth {
68 unsigned int au_cslack; /* call cred size estimate */
69 unsigned int au_rslack; /* reply verf size guess */
70 unsigned int au_flags; /* various flags */
71 struct rpc_authops * au_ops; /* operations */
72 rpc_authflavor_t au_flavor; /* pseudoflavor (note may
73 * differ from the flavor in
74 * au_ops->au_flavor in gss
75 * case) */
76 atomic_t au_count; /* Reference counter */
77
78 struct rpc_cred_cache * au_credcache;
79 /* per-flavor data */
80};
81#define RPC_AUTH_PROC_CREDS 0x0010 /* process creds (including
82 * uid/gid, fs[ug]id, gids)
83 */
84
85/*
86 * Client authentication ops
87 */
88struct rpc_authops {
89 struct module *owner;
90 rpc_authflavor_t au_flavor; /* flavor (RPC_AUTH_*) */
91#ifdef RPC_DEBUG
92 char * au_name;
93#endif
94 struct rpc_auth * (*create)(struct rpc_clnt *, rpc_authflavor_t);
95 void (*destroy)(struct rpc_auth *);
96
97 struct rpc_cred * (*lookup_cred)(struct rpc_auth *, struct auth_cred *, int);
98 struct rpc_cred * (*crcreate)(struct rpc_auth*, struct auth_cred *, int);
99};
100
101struct rpc_credops {
102 const char * cr_name; /* Name of the auth flavour */
103 void (*crdestroy)(struct rpc_cred *);
104
105 int (*crmatch)(struct auth_cred *, struct rpc_cred *, int);
106 u32 * (*crmarshal)(struct rpc_task *, u32 *);
107 int (*crrefresh)(struct rpc_task *);
108 u32 * (*crvalidate)(struct rpc_task *, u32 *);
109 int (*crwrap_req)(struct rpc_task *, kxdrproc_t,
110 void *, u32 *, void *);
111 int (*crunwrap_resp)(struct rpc_task *, kxdrproc_t,
112 void *, u32 *, void *);
113};
114
115extern struct rpc_authops authunix_ops;
116extern struct rpc_authops authnull_ops;
117#ifdef CONFIG_SUNRPC_SECURE
118extern struct rpc_authops authdes_ops;
119#endif
120
121int rpcauth_register(struct rpc_authops *);
122int rpcauth_unregister(struct rpc_authops *);
123struct rpc_auth * rpcauth_create(rpc_authflavor_t, struct rpc_clnt *);
124void rpcauth_destroy(struct rpc_auth *);
125struct rpc_cred * rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred *, int);
126struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int);
127struct rpc_cred * rpcauth_bindcred(struct rpc_task *);
128void rpcauth_holdcred(struct rpc_task *);
129void put_rpccred(struct rpc_cred *);
130void rpcauth_unbindcred(struct rpc_task *);
131u32 * rpcauth_marshcred(struct rpc_task *, u32 *);
132u32 * rpcauth_checkverf(struct rpc_task *, u32 *);
133int rpcauth_wrap_req(struct rpc_task *task, kxdrproc_t encode, void *rqstp, u32 *data, void *obj);
134int rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, u32 *data, void *obj);
135int rpcauth_refreshcred(struct rpc_task *);
136void rpcauth_invalcred(struct rpc_task *);
137int rpcauth_uptodatecred(struct rpc_task *);
138int rpcauth_init_credcache(struct rpc_auth *, unsigned long);
139void rpcauth_free_credcache(struct rpc_auth *);
140
141static inline
142struct rpc_cred * get_rpccred(struct rpc_cred *cred)
143{
144 atomic_inc(&cred->cr_count);
145 return cred;
146}
147
148#endif /* __KERNEL__ */
149#endif /* _LINUX_SUNRPC_AUTH_H */