3  *
   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.
   7  *
   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.
  12  *
  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]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  24  */
  25 
  26 /*
  27  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  28  * Use is subject to license terms.
  29  */
  30 
  31 #include <stdio.h>
  32 #include <stdlib.h>
  33 #include <sys/types.h>
  34 #include <string.h>
  35 #include <sys/param.h>
  36 #include <sys/stat.h>
  37 #include <sys/file.h>
  38 #include <sys/time.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>
  45 #include <signal.h>
  46 #include <syslog.h>
  47 #include <locale.h>
  48 #include <unistd.h>
 
 
  73         /*
  74          * Find the export
  75          */
  76         sh = findentry(argp->req_path);
  77         if (sh == NULL) {
  78                 syslog(LOG_ERR, "%s not exported", argp->req_path);
  79                 return;
  80         }
  81 
  82         cln_init_lazy(&cln, argp->req_netid, &nbuf);
  83 
  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);
  89 
  90         sharefree(sh);
  91 
  92         if (result->auth_perm == NFSAUTH_DENIED) {
  93                 char *host = cln_gethost(&cln);
  94                 if (host != NULL)
  95                         syslog(LOG_ERR, "%s denied access to %s", host,
  96                             argp->req_path);
  97         }
  98 
  99         cln_fini(&cln);
 100 }
 101 
 102 void
 103 nfsauth_func(void *cookie, char *dataptr, size_t arg_size,
 104         door_desc_t *dp, uint_t n_desc)
 105 
 106 {
 107         nfsauth_arg_t   *ap;
 108         nfsauth_res_t    res = {0};
 109         XDR              xdrs_a;
 110         XDR              xdrs_r;
 111         size_t           rbsz;
 112         caddr_t          rbuf;
 113         varg_t           varg = {0};
 114 
 115         /*
 116          * Decode the inbound door data, so we can look at the cmd.
 117          */
 118         xdrmem_create(&xdrs_a, dataptr, arg_size, XDR_DECODE);
 119         if (!xdr_varg(&xdrs_a, &varg)) {
 120                 /*
 121                  * If the arguments can't be decoded, bail.
 122                  */
 123                 if (varg.vers == V_ERROR)
 124                         syslog(LOG_ERR, gettext("Arg version mismatch"));
 125                 res.stat = NFSAUTH_DR_DECERR;
 
 | 
 
 
   3  *
   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.
   7  *
   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.
  12  *
  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]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  * Copyright 2016 Nexenta Systems, Inc.
  26  */
  27 
  28 #include <stdio.h>
  29 #include <stdlib.h>
  30 #include <sys/types.h>
  31 #include <string.h>
  32 #include <sys/param.h>
  33 #include <sys/stat.h>
  34 #include <sys/file.h>
  35 #include <sys/time.h>
  36 #include <sys/errno.h>
  37 #include <rpcsvc/mount.h>
  38 #include <sys/pathconf.h>
  39 #include <sys/systeminfo.h>
  40 #include <sys/utsname.h>
  41 #include <arpa/inet.h>
  42 #include <signal.h>
  43 #include <syslog.h>
  44 #include <locale.h>
  45 #include <unistd.h>
 
 
  70         /*
  71          * Find the export
  72          */
  73         sh = findentry(argp->req_path);
  74         if (sh == NULL) {
  75                 syslog(LOG_ERR, "%s not exported", argp->req_path);
  76                 return;
  77         }
  78 
  79         cln_init_lazy(&cln, argp->req_netid, &nbuf);
  80 
  81         result->auth_perm = check_client(sh, &cln, argp->req_flavor,
  82             argp->req_clnt_uid, argp->req_clnt_gid, argp->req_clnt_gids.len,
  83             argp->req_clnt_gids.val, &result->auth_srv_uid,
  84             &result->auth_srv_gid, &result->auth_srv_gids.len,
  85             &result->auth_srv_gids.val);
  86 
  87         sharefree(sh);
  88 
  89         if (result->auth_perm == NFSAUTH_DENIED) {
  90                 syslog(LOG_ERR, "%s denied access to %s", cln_gethost(&cln),
  91                     argp->req_path);
  92         }
  93 
  94         cln_fini(&cln);
  95 }
  96 
  97 void
  98 nfsauth_func(void *cookie, char *dataptr, size_t arg_size, door_desc_t *dp,
  99     uint_t n_desc)
 100 {
 101         nfsauth_arg_t   *ap;
 102         nfsauth_res_t    res = {0};
 103         XDR              xdrs_a;
 104         XDR              xdrs_r;
 105         size_t           rbsz;
 106         caddr_t          rbuf;
 107         varg_t           varg = {0};
 108 
 109         /*
 110          * Decode the inbound door data, so we can look at the cmd.
 111          */
 112         xdrmem_create(&xdrs_a, dataptr, arg_size, XDR_DECODE);
 113         if (!xdr_varg(&xdrs_a, &varg)) {
 114                 /*
 115                  * If the arguments can't be decoded, bail.
 116                  */
 117                 if (varg.vers == V_ERROR)
 118                         syslog(LOG_ERR, gettext("Arg version mismatch"));
 119                 res.stat = NFSAUTH_DR_DECERR;
 
 |