2 * linux/include/linux/sunrpc/svcauth.h
4 * RPC server-side authentication stuff.
6 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
9 #ifndef _LINUX_SUNRPC_SVCAUTH_H_
10 #define _LINUX_SUNRPC_SVCAUTH_H_
14 #include <linux/string.h>
15 #include <linux/sunrpc/msg_prot.h>
16 #include <linux/sunrpc/cache.h>
17 #include <linux/hash.h>
19 #define SVC_CRED_NGROUPS 32
23 struct group_info
*cr_group_info
;
26 struct svc_rqst
; /* forward decl */
29 /* Authentication is done in the context of a domain.
31 * Currently, the nfs server uses the auth_domain to stand
32 * for the "client" listed in /etc/exports.
34 * More generally, a domain might represent a group of clients using
35 * a common mechanism for authentication and having a common mapping
36 * between local identity (uid) and network identity. All clients
37 * in a domain have similar general access rights. Each domain can
38 * contain multiple principals which will have different specific right
39 * based on normal Discretionary Access Control.
41 * A domain is created by an authentication flavour module based on name
42 * only. Userspace then fills in detail on demand.
44 * In the case of auth_unix and auth_null, the auth_domain is also
45 * associated with entries in another cache representing the mapping
46 * of ip addresses to the given client.
50 struct hlist_node hash
;
52 struct auth_ops
*flavour
;
56 * Each authentication flavour registers an auth_ops
58 * name is simply the name.
59 * flavour gives the auth flavour. It determines where the flavour is registered
60 * accept() is given a request and should verify it.
61 * It should inspect the authenticator and verifier, and possibly the data.
62 * If there is a problem with the authentication *authp should be set.
63 * The return value of accept() can indicate:
64 * OK - authorised. client and credential are set in rqstp.
65 * reqbuf points to arguments
66 * resbuf points to good place for results. verfier
67 * is (probably) already in place. Certainly space is
69 * DROP - simply drop the request. It may have been deferred
70 * GARBAGE - rpc garbage_args error
71 * SYSERR - rpc system_err error
72 * DENIED - authp holds reason for denial.
73 * COMPLETE - the reply is encoded already and ready to be sent; no
74 * further processing is necessary. (This is used for processing
75 * null procedure calls which are used to set up encryption
78 * accept is passed the proc number so that it can accept NULL rpc requests
79 * even if it cannot authenticate the client (as is sometimes appropriate).
81 * release() is given a request after the procedure has been run.
82 * It should sign/encrypt the results if needed
84 * OK - the resbuf is ready to be sent
85 * DROP - the reply should be quitely dropped
86 * DENIED - authp holds a reason for MSG_DENIED
87 * SYSERR - rpc system_err
90 * This call releases a domain.
92 * Givens a pending request (struct svc_rqst), finds and assigns
93 * an appropriate 'auth_domain' as the client.
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
);
105 #define SVC_GARBAGE 1
108 #define SVC_NEGATIVE 4
112 #define SVC_PENDING 8
113 #define SVC_COMPLETE 9
116 extern int svc_authenticate(struct svc_rqst
*rqstp
, __be32
*authp
);
117 extern int svc_authorise(struct svc_rqst
*rqstp
);
118 extern int svc_set_client(struct svc_rqst
*rqstp
);
119 extern int svc_auth_register(rpc_authflavor_t flavor
, struct auth_ops
*aops
);
120 extern void svc_auth_unregister(rpc_authflavor_t flavor
);
122 extern struct auth_domain
*unix_domain_find(char *name
);
123 extern void auth_domain_put(struct auth_domain
*item
);
124 extern int auth_unix_add_addr(struct in6_addr
*addr
, struct auth_domain
*dom
);
125 extern struct auth_domain
*auth_domain_lookup(char *name
, struct auth_domain
*new);
126 extern struct auth_domain
*auth_domain_find(char *name
);
127 extern struct auth_domain
*auth_unix_lookup(struct in6_addr
*addr
);
128 extern int auth_unix_forget_old(struct auth_domain
*dom
);
129 extern void svcauth_unix_purge(void);
130 extern void svcauth_unix_info_release(void *);
131 extern int svcauth_unix_set_client(struct svc_rqst
*rqstp
);
133 static inline unsigned long hash_str(char *name
, int bits
)
135 unsigned long hash
= 0;
140 if (unlikely(!(c
= *name
++))) {
141 c
= (char)len
; len
= -1;
145 if ((len
& (BITS_PER_LONG
/8-1))==0)
146 hash
= hash_long(hash
^l
, BITS_PER_LONG
);
148 return hash
>> (BITS_PER_LONG
- bits
);
151 static inline unsigned long hash_mem(char *buf
, int length
, int bits
)
153 unsigned long hash
= 0;
159 c
= (char)len
; len
= -1;
164 if ((len
& (BITS_PER_LONG
/8-1))==0)
165 hash
= hash_long(hash
^l
, BITS_PER_LONG
);
167 return hash
>> (BITS_PER_LONG
- bits
);
170 #endif /* __KERNEL__ */
172 #endif /* _LINUX_SUNRPC_SVCAUTH_H_ */