• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6/include/linux/sunrpc/
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/sunrpc/sched.h>
15#include <linux/sunrpc/msg_prot.h>
16#include <linux/sunrpc/xdr.h>
17
18#include <asm/atomic.h>
19#include <linux/rcupdate.h>
20
21/* size of the nodename buffer */
22#define UNX_MAXNODENAME	32
23
24struct auth_cred {
25	uid_t	uid;
26	gid_t	gid;
27	struct group_info *group_info;
28	unsigned char machine_cred : 1;
29};
30
31/*
32 * Client user credentials
33 */
34struct rpc_auth;
35struct rpc_credops;
36struct rpc_cred {
37	struct hlist_node	cr_hash;	/* hash chain */
38	struct list_head	cr_lru;		/* lru garbage collection */
39	struct rcu_head		cr_rcu;
40	struct rpc_auth *	cr_auth;
41	const struct rpc_credops *cr_ops;
42#ifdef RPC_DEBUG
43	unsigned long		cr_magic;	/* 0x0f4aa4f0 */
44#endif
45	unsigned long		cr_expire;	/* when to gc */
46	unsigned long		cr_flags;	/* various flags */
47	atomic_t		cr_count;	/* ref count */
48
49	uid_t			cr_uid;
50
51	/* per-flavor data */
52};
53#define RPCAUTH_CRED_NEW	0
54#define RPCAUTH_CRED_UPTODATE	1
55#define RPCAUTH_CRED_HASHED	2
56#define RPCAUTH_CRED_NEGATIVE	3
57
58#define RPCAUTH_CRED_MAGIC	0x0f4aa4f0
59
60/*
61 * Client authentication handle
62 */
63struct rpc_cred_cache;
64struct rpc_authops;
65struct rpc_auth {
66	unsigned int		au_cslack;	/* call cred size estimate */
67				/* guess at number of u32's auth adds before
68				 * reply data; normally the verifier size: */
69	unsigned int		au_rslack;
70				/* for gss, used to calculate au_rslack: */
71	unsigned int		au_verfsize;
72
73	unsigned int		au_flags;	/* various flags */
74	const struct rpc_authops *au_ops;		/* operations */
75	rpc_authflavor_t	au_flavor;	/* pseudoflavor (note may
76						 * differ from the flavor in
77						 * au_ops->au_flavor in gss
78						 * case) */
79	atomic_t		au_count;	/* Reference counter */
80
81	struct rpc_cred_cache *	au_credcache;
82	/* per-flavor data */
83};
84
85/* Flags for rpcauth_lookupcred() */
86#define RPCAUTH_LOOKUP_NEW		0x01	/* Accept an uninitialised cred */
87
88/*
89 * Client authentication ops
90 */
91struct rpc_authops {
92	struct module		*owner;
93	rpc_authflavor_t	au_flavor;	/* flavor (RPC_AUTH_*) */
94	char *			au_name;
95	struct rpc_auth *	(*create)(struct rpc_clnt *, rpc_authflavor_t);
96	void			(*destroy)(struct rpc_auth *);
97
98	struct rpc_cred *	(*lookup_cred)(struct rpc_auth *, struct auth_cred *, int);
99	struct rpc_cred *	(*crcreate)(struct rpc_auth*, struct auth_cred *, int);
100};
101
102struct rpc_credops {
103	const char *		cr_name;	/* Name of the auth flavour */
104	int			(*cr_init)(struct rpc_auth *, struct rpc_cred *);
105	void			(*crdestroy)(struct rpc_cred *);
106
107	int			(*crmatch)(struct auth_cred *, struct rpc_cred *, int);
108	struct rpc_cred *	(*crbind)(struct rpc_task *, struct rpc_cred *, int);
109	__be32 *		(*crmarshal)(struct rpc_task *, __be32 *);
110	int			(*crrefresh)(struct rpc_task *);
111	__be32 *		(*crvalidate)(struct rpc_task *, __be32 *);
112	int			(*crwrap_req)(struct rpc_task *, kxdrproc_t,
113						void *, __be32 *, void *);
114	int			(*crunwrap_resp)(struct rpc_task *, kxdrproc_t,
115						void *, __be32 *, void *);
116};
117
118extern const struct rpc_authops	authunix_ops;
119extern const struct rpc_authops	authnull_ops;
120
121int __init		rpc_init_authunix(void);
122int __init		rpc_init_generic_auth(void);
123int __init		rpcauth_init_module(void);
124void __exit		rpcauth_remove_module(void);
125void __exit		rpc_destroy_generic_auth(void);
126void 			rpc_destroy_authunix(void);
127
128struct rpc_cred *	rpc_lookup_cred(void);
129struct rpc_cred *	rpc_lookup_machine_cred(void);
130int			rpcauth_register(const struct rpc_authops *);
131int			rpcauth_unregister(const struct rpc_authops *);
132struct rpc_auth *	rpcauth_create(rpc_authflavor_t, struct rpc_clnt *);
133void			rpcauth_release(struct rpc_auth *);
134struct rpc_cred *	rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred *, int);
135void			rpcauth_init_cred(struct rpc_cred *, const struct auth_cred *, struct rpc_auth *, const struct rpc_credops *);
136struct rpc_cred *	rpcauth_lookupcred(struct rpc_auth *, int);
137struct rpc_cred *	rpcauth_generic_bind_cred(struct rpc_task *, struct rpc_cred *, int);
138void			put_rpccred(struct rpc_cred *);
139__be32 *		rpcauth_marshcred(struct rpc_task *, __be32 *);
140__be32 *		rpcauth_checkverf(struct rpc_task *, __be32 *);
141int			rpcauth_wrap_req(struct rpc_task *task, kxdrproc_t encode, void *rqstp, __be32 *data, void *obj);
142int			rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, __be32 *data, void *obj);
143int			rpcauth_refreshcred(struct rpc_task *);
144void			rpcauth_invalcred(struct rpc_task *);
145int			rpcauth_uptodatecred(struct rpc_task *);
146int			rpcauth_init_credcache(struct rpc_auth *);
147void			rpcauth_destroy_credcache(struct rpc_auth *);
148void			rpcauth_clear_credcache(struct rpc_cred_cache *);
149
150static inline
151struct rpc_cred *	get_rpccred(struct rpc_cred *cred)
152{
153	atomic_inc(&cred->cr_count);
154	return cred;
155}
156
157#endif /* __KERNEL__ */
158#endif /* _LINUX_SUNRPC_AUTH_H */
159