1
2
3
4
5
6
7
8
9
10#ifndef _LINUX_SUNRPC_SVCAUTH_H_
11#define _LINUX_SUNRPC_SVCAUTH_H_
12
13#include <linux/string.h>
14#include <linux/sunrpc/msg_prot.h>
15#include <linux/sunrpc/cache.h>
16#include <linux/sunrpc/gss_api.h>
17#include <linux/hash.h>
18#include <linux/stringhash.h>
19#include <linux/cred.h>
20
21struct svc_cred {
22 kuid_t cr_uid;
23 kgid_t cr_gid;
24 struct group_info *cr_group_info;
25 u32 cr_flavor;
26
27
28 char *cr_raw_principal;
29
30
31 char *cr_principal;
32 char *cr_targ_princ;
33 struct gss_api_mech *cr_gss_mech;
34};
35
36static inline void init_svc_cred(struct svc_cred *cred)
37{
38 cred->cr_group_info = NULL;
39 cred->cr_raw_principal = NULL;
40 cred->cr_principal = NULL;
41 cred->cr_targ_princ = NULL;
42 cred->cr_gss_mech = NULL;
43}
44
45static inline void free_svc_cred(struct svc_cred *cred)
46{
47 if (cred->cr_group_info)
48 put_group_info(cred->cr_group_info);
49 kfree(cred->cr_raw_principal);
50 kfree(cred->cr_principal);
51 kfree(cred->cr_targ_princ);
52 gss_mech_put(cred->cr_gss_mech);
53 init_svc_cred(cred);
54}
55
56struct svc_rqst;
57struct in6_addr;
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78struct auth_domain {
79 struct kref ref;
80 struct hlist_node hash;
81 char *name;
82 struct auth_ops *flavour;
83 struct rcu_head rcu_head;
84};
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126struct auth_ops {
127 char * name;
128 struct module *owner;
129 int flavour;
130 int (*accept)(struct svc_rqst *rq, __be32 *authp);
131 int (*release)(struct svc_rqst *rq);
132 void (*domain_release)(struct auth_domain *);
133 int (*set_client)(struct svc_rqst *rq);
134};
135
136#define SVC_GARBAGE 1
137#define SVC_SYSERR 2
138#define SVC_VALID 3
139#define SVC_NEGATIVE 4
140#define SVC_OK 5
141#define SVC_DROP 6
142#define SVC_CLOSE 7
143
144
145
146#define SVC_DENIED 8
147#define SVC_PENDING 9
148#define SVC_COMPLETE 10
149
150struct svc_xprt;
151
152extern int svc_authenticate(struct svc_rqst *rqstp, __be32 *authp);
153extern int svc_authorise(struct svc_rqst *rqstp);
154extern int svc_set_client(struct svc_rqst *rqstp);
155extern int svc_auth_register(rpc_authflavor_t flavor, struct auth_ops *aops);
156extern void svc_auth_unregister(rpc_authflavor_t flavor);
157
158extern struct auth_domain *unix_domain_find(char *name);
159extern void auth_domain_put(struct auth_domain *item);
160extern int auth_unix_add_addr(struct net *net, struct in6_addr *addr, struct auth_domain *dom);
161extern struct auth_domain *auth_domain_lookup(char *name, struct auth_domain *new);
162extern struct auth_domain *auth_domain_find(char *name);
163extern struct auth_domain *auth_unix_lookup(struct net *net, struct in6_addr *addr);
164extern int auth_unix_forget_old(struct auth_domain *dom);
165extern void svcauth_unix_purge(struct net *net);
166extern void svcauth_unix_info_release(struct svc_xprt *xpt);
167extern int svcauth_unix_set_client(struct svc_rqst *rqstp);
168
169extern int unix_gid_cache_create(struct net *net);
170extern void unix_gid_cache_destroy(struct net *net);
171
172
173
174
175
176static inline unsigned long hash_str(char const *name, int bits)
177{
178 return hashlen_hash(hashlen_string(NULL, name)) >> (32 - bits);
179}
180
181static inline unsigned long hash_mem(char const *buf, int length, int bits)
182{
183 return full_name_hash(NULL, buf, length) >> (32 - bits);
184}
185
186#endif
187