OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [libc/] [inet/] [rpc/] [svc_auth_unix.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/*
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
 
30
/*
31
 * svc_auth_unix.c
32
 * Handles UNIX flavor authentication parameters on the service side of rpc.
33
 * There are two svc auth implementations here: AUTH_UNIX and AUTH_SHORT.
34
 * _svcauth_unix does full blown unix style uid,gid+gids auth,
35
 * _svcauth_short uses a shorthand auth to index into a cache of longhand auths.
36
 * Note: the shorthand has been gutted for efficiency.
37
 *
38
 * Copyright (C) 1984, Sun Microsystems, Inc.
39
 */
40
 
41
#define __FORCE_GLIBC
42
#define _GNU_SOURCE
43
#include <features.h>
44
 
45
#include <stdio.h>
46
#include <string.h>
47
#include <rpc/rpc.h>
48
#include <rpc/svc.h>
49
 
50
/*
51
 * Unix longhand authenticator
52
 */
53
enum auth_stat
54
_svcauth_unix (struct svc_req *rqst, struct rpc_msg *msg)
55
{
56
  enum auth_stat stat;
57
  XDR xdrs;
58
  struct authunix_parms *aup;
59
  int32_t *buf;
60
  struct area
61
    {
62
      struct authunix_parms area_aup;
63
      char area_machname[MAX_MACHINE_NAME + 1];
64
      gid_t area_gids[NGRPS];
65
    }
66
   *area;
67
  u_int auth_len;
68
  u_int str_len, gid_len;
69
  u_int i;
70
 
71
  area = (struct area *) rqst->rq_clntcred;
72
  aup = &area->area_aup;
73
  aup->aup_machname = area->area_machname;
74
  aup->aup_gids = area->area_gids;
75
  auth_len = (u_int) msg->rm_call.cb_cred.oa_length;
76
  xdrmem_create (&xdrs, msg->rm_call.cb_cred.oa_base, auth_len, XDR_DECODE);
77
  buf = XDR_INLINE (&xdrs, auth_len);
78
  if (buf != NULL)
79
    {
80
      aup->aup_time = IXDR_GET_LONG (buf);
81
      str_len = IXDR_GET_U_INT32 (buf);
82
      if (str_len > MAX_MACHINE_NAME)
83
        {
84
          stat = AUTH_BADCRED;
85
          goto done;
86
        }
87
      memcpy (aup->aup_machname, (caddr_t) buf, (u_int) str_len);
88
      aup->aup_machname[str_len] = 0;
89
      str_len = RNDUP (str_len);
90
      buf = (int32_t *) ((char *) buf + str_len);
91
      aup->aup_uid = IXDR_GET_LONG (buf);
92
      aup->aup_gid = IXDR_GET_LONG (buf);
93
      gid_len = IXDR_GET_U_INT32 (buf);
94
      if (gid_len > NGRPS)
95
        {
96
          stat = AUTH_BADCRED;
97
          goto done;
98
        }
99
      aup->aup_len = gid_len;
100
      for (i = 0; i < gid_len; i++)
101
        {
102
          aup->aup_gids[i] = IXDR_GET_LONG (buf);
103
        }
104
      /*
105
       * five is the smallest unix credentials structure -
106
       * timestamp, hostname len (0), uid, gid, and gids len (0).
107
       */
108
      if ((5 + gid_len) * BYTES_PER_XDR_UNIT + str_len > auth_len)
109
        {
110
          (void) printf ("bad auth_len gid %d str %d auth %d\n",
111
                         gid_len, str_len, auth_len);
112
          stat = AUTH_BADCRED;
113
          goto done;
114
        }
115
    }
116
  else if (!xdr_authunix_parms (&xdrs, aup))
117
    {
118
      xdrs.x_op = XDR_FREE;
119
      (void) xdr_authunix_parms (&xdrs, aup);
120
      stat = AUTH_BADCRED;
121
      goto done;
122
    }
123
 
124
  /* get the verifier */
125
  if ((u_int)msg->rm_call.cb_verf.oa_length)
126
    {
127
      rqst->rq_xprt->xp_verf.oa_flavor =
128
        msg->rm_call.cb_verf.oa_flavor;
129
      rqst->rq_xprt->xp_verf.oa_base =
130
        msg->rm_call.cb_verf.oa_base;
131
      rqst->rq_xprt->xp_verf.oa_length =
132
        msg->rm_call.cb_verf.oa_length;
133
    }
134
  else
135
    {
136
      rqst->rq_xprt->xp_verf.oa_flavor = AUTH_NULL;
137
      rqst->rq_xprt->xp_verf.oa_length = 0;
138
    }
139
  stat = AUTH_OK;
140
done:
141
  XDR_DESTROY (&xdrs);
142
  return stat;
143
}
144
 
145
 
146
/*
147
 * Shorthand unix authenticator
148
 * Looks up longhand in a cache.
149
 */
150
/*ARGSUSED */
151
enum auth_stat
152
_svcauth_short (struct svc_req *rqst, struct rpc_msg *msg)
153
{
154
  return AUTH_REJECTEDCRED;
155
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.