4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
27 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
33 #include <sys/types.h>
35 #include <sys/param.h>
39 #include <sys/errno.h>
40 #include <rpcsvc/mount.h>
41 #include <sys/pathconf.h>
42 #include <sys/systeminfo.h>
43 #include <sys/utsname.h>
44 #include <arpa/inet.h>
52 #include <sharefs/share.h>
54 #include "../lib/sharetab.h"
58 nfsauth_access(auth_req
*argp
, auth_res
*result
)
65 result
->auth_perm
= NFSAUTH_DENIED
;
67 nbuf
.len
= argp
->req_client
.n_len
;
68 nbuf
.buf
= argp
->req_client
.n_bytes
;
70 if (nbuf
.len
== 0 || nbuf
.buf
== NULL
)
76 sh
= findentry(argp
->req_path
);
78 syslog(LOG_ERR
, "%s not exported", argp
->req_path
);
82 cln_init_lazy(&cln
, argp
->req_netid
, &nbuf
);
84 result
->auth_perm
= check_client(sh
, &cln
, argp
->req_flavor
,
85 argp
->req_clnt_uid
, argp
->req_clnt_gid
, argp
->req_clnt_gids
.len
,
86 argp
->req_clnt_gids
.val
, &result
->auth_srv_uid
,
87 &result
->auth_srv_gid
, &result
->auth_srv_gids
.len
,
88 &result
->auth_srv_gids
.val
);
92 if (result
->auth_perm
== NFSAUTH_DENIED
) {
93 char *host
= cln_gethost(&cln
);
95 syslog(LOG_ERR
, "%s denied access to %s", host
,
103 nfsauth_func(void *cookie
, char *dataptr
, size_t arg_size
,
104 door_desc_t
*dp
, uint_t n_desc
)
108 nfsauth_res_t res
= {0};
116 * Decode the inbound door data, so we can look at the cmd.
118 xdrmem_create(&xdrs_a
, dataptr
, arg_size
, XDR_DECODE
);
119 if (!xdr_varg(&xdrs_a
, &varg
)) {
121 * If the arguments can't be decoded, bail.
123 if (varg
.vers
== V_ERROR
)
124 syslog(LOG_ERR
, gettext("Arg version mismatch"));
125 res
.stat
= NFSAUTH_DR_DECERR
;
130 * Now set the args pointer to the proper version of the args
134 ap
= &varg
.arg_u
.arg
;
137 /* Additional arguments versions go here */
140 syslog(LOG_ERR
, gettext("Invalid args version"));
141 res
.stat
= NFSAUTH_DR_DECERR
;
146 * Call the specified cmd
150 nfsauth_access(&ap
->areq
, &res
.ares
);
151 res
.stat
= NFSAUTH_DR_OKAY
;
154 res
.stat
= NFSAUTH_DR_BADCMD
;
160 * Free space used to decode the args
162 xdr_free(xdr_varg
, (char *)&varg
);
163 xdr_destroy(&xdrs_a
);
166 * Encode the results before passing thru door.
168 rbsz
= xdr_sizeof(xdr_nfsauth_res
, &res
);
173 xdrmem_create(&xdrs_r
, rbuf
, rbsz
, XDR_ENCODE
);
174 if (!xdr_nfsauth_res(&xdrs_r
, &res
)) {
175 xdr_destroy(&xdrs_r
);
177 xdr_free(xdr_nfsauth_res
, (char *)&res
);
179 * return only the status code
181 res
.stat
= NFSAUTH_DR_EFAIL
;
182 rbsz
= sizeof (uint_t
);
183 rbuf
= (caddr_t
)&res
.stat
;
187 xdr_destroy(&xdrs_r
);
188 xdr_free(xdr_nfsauth_res
, (char *)&res
);
191 (void) door_return((char *)rbuf
, rbsz
, NULL
, 0);
192 (void) door_return(NULL
, 0, NULL
, 0);