| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
#include <pthread.h> |
| 40 |
#include <assert.h> |
| 41 |
#include <stdio.h> |
| 42 |
#include <string.h> |
| 43 |
|
| 44 |
#include <rpc/rpc.h> |
| 45 |
|
| 46 |
extern SVCAUTH svc_auth_none; |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
enum auth_stat |
| 52 |
_svcauth_unix(rqst, msg) |
| 53 |
struct svc_req *rqst; |
| 54 |
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 |
struct authunix_parms area_aup; |
| 62 |
char area_machname[MAX_MACHINE_NAME+1]; |
| 63 |
gid_t area_gids[NGRPS]; |
| 64 |
} *area; |
| 65 |
u_int auth_len; |
| 66 |
size_t str_len, gid_len; |
| 67 |
u_int i; |
| 68 |
|
| 69 |
assert(rqst != NULL); |
| 70 |
assert(msg != NULL); |
| 71 |
|
| 72 |
area = (struct area *) rqst->rq_clntcred; |
| 73 |
aup = &area->area_aup; |
| 74 |
aup->aup_machname = area->area_machname; |
| 75 |
aup->aup_gids = area->area_gids; |
| 76 |
auth_len = (u_int)msg->rm_call.cb_cred.oa_length; |
| 77 |
xdrmem_create(&xdrs, msg->rm_call.cb_cred.oa_base, auth_len,XDR_DECODE); |
| 78 |
buf = XDR_INLINE(&xdrs, auth_len); |
| 79 |
if (buf != NULL) { |
| 80 |
aup->aup_time = IXDR_GET_INT32(buf); |
| 81 |
str_len = (size_t)IXDR_GET_U_INT32(buf); |
| 82 |
if (str_len > MAX_MACHINE_NAME) { |
| 83 |
stat = AUTH_BADCRED; |
| 84 |
goto done; |
| 85 |
} |
| 86 |
memmove(aup->aup_machname, buf, str_len); |
| 87 |
aup->aup_machname[str_len] = 0; |
| 88 |
str_len = RNDUP(str_len); |
| 89 |
buf += str_len / sizeof (int32_t); |
| 90 |
aup->aup_uid = (int)IXDR_GET_INT32(buf); |
| 91 |
aup->aup_gid = (int)IXDR_GET_INT32(buf); |
| 92 |
gid_len = (size_t)IXDR_GET_U_INT32(buf); |
| 93 |
if (gid_len > NGRPS) { |
| 94 |
stat = AUTH_BADCRED; |
| 95 |
goto done; |
| 96 |
} |
| 97 |
aup->aup_len = gid_len; |
| 98 |
for (i = 0; i < gid_len; i++) { |
| 99 |
aup->aup_gids[i] = (int)IXDR_GET_INT32(buf); |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
if ((5 + gid_len) * BYTES_PER_XDR_UNIT + str_len > auth_len) { |
| 106 |
(void) printf("bad auth_len gid %ld str %ld auth %u\n", |
| 107 |
(long)gid_len, (long)str_len, auth_len); |
| 108 |
stat = AUTH_BADCRED; |
| 109 |
goto done; |
| 110 |
} |
| 111 |
} else if (! xdr_authunix_parms(&xdrs, aup)) { |
| 112 |
xdrs.x_op = XDR_FREE; |
| 113 |
(void)xdr_authunix_parms(&xdrs, aup); |
| 114 |
stat = AUTH_BADCRED; |
| 115 |
goto done; |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
if ((u_int)msg->rm_call.cb_verf.oa_length) { |
| 120 |
rqst->rq_xprt->xp_verf.oa_flavor = |
| 121 |
msg->rm_call.cb_verf.oa_flavor; |
| 122 |
rqst->rq_xprt->xp_verf.oa_base = |
| 123 |
msg->rm_call.cb_verf.oa_base; |
| 124 |
rqst->rq_xprt->xp_verf.oa_length = |
| 125 |
msg->rm_call.cb_verf.oa_length; |
| 126 |
} else { |
| 127 |
rqst->rq_xprt->xp_verf.oa_flavor = AUTH_NULL; |
| 128 |
rqst->rq_xprt->xp_verf.oa_length = 0; |
| 129 |
} |
| 130 |
stat = AUTH_OK; |
| 131 |
done: |
| 132 |
XDR_DESTROY(&xdrs); |
| 133 |
return (stat); |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
enum auth_stat |
| 143 |
_svcauth_short(rqst, msg) |
| 144 |
struct svc_req *rqst; |
| 145 |
struct rpc_msg *msg; |
| 146 |
{ |
| 147 |
return (AUTH_REJECTEDCRED); |
| 148 |
} |