Annotation of 43BSDReno/lib/librpc/svc_auth.c, revision 1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.