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 */
28 /* Authentication is done in the context of a domain.
29 * For a server, a domain represents a group of clients using
30 * a common mechanism for authentication and having a common mapping
31 * between local identity (uid) and network identity. All clients
32 * in a domain have similar general access rights. Each domain can
33 * contain multiple principals which will have different specific right
34 * based on normal Discretionary Access Control.
36 * For a client, a domain represents a number of servers which all
37 * use a common authentication mechanism and network identity name space.
39 * A domain is created by an authentication flavour module based on name
40 * only. Userspace then fills in detail on demand.
42 * The creation of a domain typically implies creation of one or
43 * more caches for storing domain specific information.
52 * Each authentication flavour registers an auth_ops
54 * name is simply the name.
55 * flavour gives the auth flavour. It determines where the flavour is registered
56 * accept() is given a request and should verify it.
57 * It should inspect the authenticator and verifier, and possibly the data.
58 * If there is a problem with the authentication *authp should be set.
59 * The return value of accept() can indicate:
60 * OK - authorised. client and credential are set in rqstp.
61 * reqbuf points to arguments
62 * resbuf points to good place for results. verfier
63 * is (probably) already in place. Certainly space is
65 * DROP - simply drop the request. It may have been deferred
66 * GARBAGE - rpc garbage_args error
67 * SYSERR - rpc system_err error
68 * DENIED - authp holds reason for denial.
69 * COMPLETE - the reply is encoded already and ready to be sent; no
70 * further processing is necessary. (This is used for processing
71 * null procedure calls which are used to set up encryption
74 * accept is passed the proc number so that it can accept NULL rpc requests
75 * even if it cannot authenticate the client (as is sometimes appropriate).
77 * release() is given a request after the procedure has been run.
78 * It should sign/encrypt the results if needed
80 * OK - the resbuf is ready to be sent
81 * DROP - the reply should be quitely dropped
82 * DENIED - authp holds a reason for MSG_DENIED
83 * SYSERR - rpc system_err
86 * This call releases a domain.
92 int (*accept)(struct svc_rqst *rq, u32 *authp);
93 int (*release)(struct svc_rqst *rq);
94 void (*domain_release)(struct auth_domain *);
100 #define SVC_NEGATIVE 4
104 #define SVC_PENDING 8
105 #define SVC_COMPLETE 9
108 extern int svc_authenticate(struct svc_rqst *rqstp, u32 *authp);
109 extern int svc_authorise(struct svc_rqst *rqstp);
110 extern int svc_auth_register(rpc_authflavor_t flavor, struct auth_ops *aops);
111 extern void svc_auth_unregister(rpc_authflavor_t flavor);
113 extern struct auth_domain *unix_domain_find(char *name);
114 extern void auth_domain_put(struct auth_domain *item);
115 extern int auth_unix_add_addr(struct in_addr addr, struct auth_domain *dom);
116 extern struct auth_domain *auth_domain_lookup(struct auth_domain *item, int set);
117 extern struct auth_domain *auth_domain_find(char *name);
118 extern struct auth_domain *auth_unix_lookup(struct in_addr addr);
119 extern int auth_unix_forget_old(struct auth_domain *dom);
120 extern void svcauth_unix_purge(void);
122 static inline unsigned long hash_str(char *name, int bits)
124 unsigned long hash = 0;
129 if (unlikely(!(c = *name++))) {
130 c = (char)len; len = -1;
134 if ((len & (BITS_PER_LONG/8-1))==0)
135 hash = hash_long(hash^l, BITS_PER_LONG);
137 return hash >> (BITS_PER_LONG - bits);
140 static inline unsigned long hash_mem(char *buf, int length, int bits)
142 unsigned long hash = 0;
148 c = (char)len; len = -1;
153 if ((len & (BITS_PER_LONG/8-1))==0)
154 hash = hash_long(hash^l, BITS_PER_LONG);
156 return hash >> (BITS_PER_LONG - bits);
159 extern struct cache_detail auth_domain_cache, ip_map_cache;
161 #endif /* __KERNEL__ */
163 #endif /* _LINUX_SUNRPC_SVCAUTH_H_ */