]>
Commit | Line | Data |
---|---|---|
e7fd8a39 | 1 | /* @(#)svc_auth.c 2.4 88/08/15 4.0 RPCSRC */ |
28f540f4 RM |
2 | /* |
3 | * Sun RPC is a product of Sun Microsystems, Inc. and is provided for | |
4 | * unrestricted use provided that this legend is included on all tape | |
5 | * media and as a part of the software program in whole or part. Users | |
6 | * may copy or modify Sun RPC without charge, but are not authorized | |
7 | * to license or distribute it to anyone else except as part of a product or | |
8 | * program developed by the user. | |
6d52618b | 9 | * |
28f540f4 RM |
10 | * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE |
11 | * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR | |
12 | * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. | |
6d52618b | 13 | * |
28f540f4 RM |
14 | * Sun RPC is provided with no support and without any obligation on the |
15 | * part of Sun Microsystems, Inc. to assist in its use, correction, | |
16 | * modification or enhancement. | |
17 | * | |
18 | * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE | |
19 | * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC | |
20 | * OR ANY PART THEREOF. | |
21 | * | |
22 | * In no event will Sun Microsystems, Inc. be liable for any lost revenue | |
23 | * or profits or other special, indirect and consequential damages, even if | |
24 | * Sun has been advised of the possibility of such damages. | |
25 | * | |
26 | * Sun Microsystems, Inc. | |
27 | * 2550 Garcia Avenue | |
28 | * Mountain View, California 94043 | |
29 | */ | |
e7fd8a39 UD |
30 | #if !defined(lint) && defined(SCCSIDS) |
31 | static char sccsid[] = "@(#)svc_auth.c 1.19 87/08/11 Copyr 1984 Sun Micro"; | |
32 | #endif | |
28f540f4 RM |
33 | |
34 | /* | |
e7fd8a39 | 35 | * svc_auth.c, Server-side rpc authenticator interface. |
28f540f4 RM |
36 | * *WITHOUT* DES authentication. |
37 | * | |
38 | * Copyright (C) 1984, Sun Microsystems, Inc. | |
39 | */ | |
40 | ||
41 | #include <rpc/rpc.h> | |
e7fd8a39 UD |
42 | #include <rpc/svc.h> |
43 | #include <rpc/svc_auth.h> | |
28f540f4 RM |
44 | |
45 | /* | |
6d52618b UD |
46 | * svcauthsw is the bdevsw of server side authentication. |
47 | * | |
28f540f4 RM |
48 | * Server side authenticators are called from authenticate by |
49 | * using the client auth struct flavor field to index into svcauthsw. | |
6d52618b UD |
50 | * The server auth flavors must implement a routine that looks |
51 | * like: | |
52 | * | |
e7fd8a39 UD |
53 | * enum auth_stat |
54 | * flavorx_auth(rqst, msg) | |
55 | * register struct svc_req *rqst; | |
56 | * register struct rpc_msg *msg; | |
28f540f4 RM |
57 | * |
58 | */ | |
59 | ||
e7fd8a39 UD |
60 | static enum auth_stat _svcauth_null (struct svc_req *, struct rpc_msg *); |
61 | /* no authentication */ | |
62 | extern enum auth_stat _svcauth_unix (struct svc_req *, struct rpc_msg *); | |
63 | /* unix style (uid, gids) */ | |
64 | extern enum auth_stat _svcauth_short (struct svc_req *, struct rpc_msg *); | |
65 | /* short hand unix style */ | |
28f540f4 | 66 | |
e7fd8a39 UD |
67 | static const struct |
68 | { | |
69 | enum auth_stat (*authenticator) (struct svc_req *, struct rpc_msg *); | |
70 | } | |
71 | svcauthsw[] = | |
72 | { | |
73 | { _svcauth_null }, /* AUTH_NULL */ | |
74 | { _svcauth_unix }, /* AUTH_UNIX */ | |
75 | { _svcauth_short } /* AUTH_SHORT */ | |
28f540f4 | 76 | }; |
e7fd8a39 | 77 | #define AUTH_MAX 2 /* HIGHEST AUTH NUMBER */ |
28f540f4 RM |
78 | |
79 | ||
80 | /* | |
81 | * The call rpc message, msg has been obtained from the wire. The msg contains | |
82 | * the raw form of credentials and verifiers. authenticate returns AUTH_OK | |
83 | * if the msg is successfully authenticated. If AUTH_OK then the routine also | |
84 | * does the following things: | |
85 | * set rqst->rq_xprt->verf to the appropriate response verifier; | |
86 | * sets rqst->rq_client_cred to the "cooked" form of the credentials. | |
87 | * | |
6d52618b | 88 | * NB: rqst->rq_cxprt->verf must be pre-allocated; |
28f540f4 RM |
89 | * its length is set appropriately. |
90 | * | |
91 | * The caller still owns and is responsible for msg->u.cmb.cred and | |
92 | * msg->u.cmb.verf. The authentication system retains ownership of | |
93 | * rqst->rq_client_cred, the cooked credentials. | |
94 | * | |
95 | * There is an assumption that any flavour less than AUTH_NULL is | |
96 | * invalid. | |
97 | */ | |
98 | enum auth_stat | |
e7fd8a39 | 99 | _authenticate (register struct svc_req *rqst, struct rpc_msg *msg) |
28f540f4 | 100 | { |
e7fd8a39 | 101 | register int cred_flavor; |
28f540f4 | 102 | |
e7fd8a39 UD |
103 | rqst->rq_cred = msg->rm_call.cb_cred; |
104 | rqst->rq_xprt->xp_verf.oa_flavor = _null_auth.oa_flavor; | |
105 | rqst->rq_xprt->xp_verf.oa_length = 0; | |
106 | cred_flavor = rqst->rq_cred.oa_flavor; | |
107 | if ((cred_flavor <= AUTH_MAX) && (cred_flavor >= AUTH_NULL)) | |
108 | return (*(svcauthsw[cred_flavor].authenticator)) (rqst, msg); | |
28f540f4 | 109 | |
e7fd8a39 | 110 | return AUTH_REJECTEDCRED; |
28f540f4 RM |
111 | } |
112 | ||
e7fd8a39 UD |
113 | static enum auth_stat |
114 | _svcauth_null (struct svc_req *rqst, struct rpc_msg *msg) | |
28f540f4 | 115 | { |
e7fd8a39 | 116 | return AUTH_OK; |
28f540f4 | 117 | } |