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_DENIED 7
112#define SVC_PENDING 8
113#define SVC_COMPLETE 9
114
115
116extern int svc_authenticate(struct svc_rqst *rqstp, __be32 *authp);
117extern int svc_authorise(struct svc_rqst *rqstp);
118extern int svc_set_client(struct svc_rqst *rqstp);
119extern int svc_auth_register(rpc_authflavor_t flavor, struct auth_ops *aops);
120extern void svc_auth_unregister(rpc_authflavor_t flavor);
121
122extern struct auth_domain *unix_domain_find(char *name);
123extern void auth_domain_put(struct auth_domain *item);
124extern int auth_unix_add_addr(struct in6_addr *addr, struct auth_domain *dom);
125extern struct auth_domain *auth_domain_lookup(char *name, struct auth_domain *new);
126extern struct auth_domain *auth_domain_find(char *name);
127extern struct auth_domain *auth_unix_lookup(struct in6_addr *addr);
128extern int auth_unix_forget_old(struct auth_domain *dom);
129extern void svcauth_unix_purge(void);
130extern void svcauth_unix_info_release(void *);
131extern int svcauth_unix_set_client(struct svc_rqst *rqstp);
132
133static inline unsigned long hash_str(char *name, int bits)
134{
135 unsigned long hash = 0;
136 unsigned long l = 0;
137 int len = 0;
138 unsigned char c;
139 do {
140 if (unlikely(!(c = *name++))) {
141 c = (char)len; len = -1;
142 }
143 l = (l << 8) | c;
144 len++;
145 if ((len & (BITS_PER_LONG/8-1))==0)
146 hash = hash_long(hash^l, BITS_PER_LONG);
147 } while (len);
148 return hash >> (BITS_PER_LONG - bits);
149}
150
151static inline unsigned long hash_mem(char *buf, int length, int bits)
152{
153 unsigned long hash = 0;
154 unsigned long l = 0;
155 int len = 0;
156 unsigned char c;
157 do {
158 if (len == length) {
159 c = (char)len; len = -1;
160 } else
161 c = *buf++;
162 l = (l << 8) | c;
163 len++;
164 if ((len & (BITS_PER_LONG/8-1))==0)
165 hash = hash_long(hash^l, BITS_PER_LONG);
166 } while (len);
167 return hash >> (BITS_PER_LONG - bits);
168}
169
170#endif
171
172#endif
173