Print this page
OS-3926 lxbrand in-kernel fchownat(2), fchown(2), lchown(2), chown(2) and 16-bit ID counterparts
OS-3920 lxbrand use native *at(2) system calls for LX emulation

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/policy.c
          +++ new/usr/src/uts/common/os/policy.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  23      - * Copyright 2013, Joyent, Inc. All rights reserved.
       23 + * Copyright 2015 Joyent, Inc.
  24   24   */
  25   25  
  26   26  #include <sys/types.h>
  27   27  #include <sys/sysmacros.h>
  28   28  #include <sys/param.h>
  29   29  #include <sys/systm.h>
  30   30  #include <sys/cred_impl.h>
  31   31  #include <sys/vnode.h>
  32   32  #include <sys/vfs.h>
  33   33  #include <sys/stat.h>
↓ open down ↓ 14 lines elided ↑ open up ↑
  48   48  #include <sys/klpd.h>
  49   49  #include <sys/modctl.h>
  50   50  #include <sys/disp.h>
  51   51  #include <sys/zone.h>
  52   52  #include <inet/optcom.h>
  53   53  #include <sys/sdt.h>
  54   54  #include <sys/vfs.h>
  55   55  #include <sys/mntent.h>
  56   56  #include <sys/contract_impl.h>
  57   57  #include <sys/dld_ioc.h>
       58 +#include <sys/brand.h>
  58   59  
  59   60  /*
  60   61   * There are two possible layers of privilege routines and two possible
  61   62   * levels of secpolicy.  Plus one other we may not be interested in, so
  62   63   * we may need as many as 6 but no more.
  63   64   */
  64   65  #define MAXPRIVSTACK            6
  65   66  
  66   67  int priv_debug = 0;
  67   68  int priv_basic_test = -1;
↓ open down ↓ 1168 lines elided ↑ open up ↑
1236 1237  
1237 1238          if (owner == cr->cr_uid)
1238 1239                  return (0);
1239 1240  
1240 1241          return (PRIV_POLICY(cr, PRIV_FILE_OWNER, allzone, EPERM, NULL));
1241 1242  }
1242 1243  
1243 1244  void
1244 1245  secpolicy_setid_clear(vattr_t *vap, cred_t *cr)
1245 1246  {
     1247 +        proc_t *p = curproc;
     1248 +
     1249 +        /*
     1250 +         * Allow the brand to override this behaviour.
     1251 +         */
     1252 +        if (PROC_IS_BRANDED(p) && BROP(p)->b_setid_clear != NULL) {
     1253 +                /*
     1254 +                 * This brand hook will return 0 if handling is complete, or
     1255 +                 * some other value if the brand would like us to fall back to
     1256 +                 * the usual behaviour.
     1257 +                 */
     1258 +                if (BROP(p)->b_setid_clear(vap, cr) == 0) {
     1259 +                        return;
     1260 +                }
     1261 +        }
     1262 +
1246 1263          if ((vap->va_mode & (S_ISUID | S_ISGID)) != 0 &&
1247 1264              secpolicy_vnode_setid_retain(cr,
1248 1265              (vap->va_mode & S_ISUID) != 0 &&
1249 1266              (vap->va_mask & AT_UID) != 0 && vap->va_uid == 0) != 0) {
1250 1267                  vap->va_mask |= AT_MODE;
1251 1268                  vap->va_mode &= ~(S_ISUID|S_ISGID);
1252 1269          }
1253 1270  }
1254 1271  
1255 1272  int
↓ open down ↓ 1328 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX