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