Print this page
uts: add a concept of a 'default' set of privileges, separate from 'basic'
uts: give privilege macros more sensible names

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/priv.c
          +++ new/usr/src/uts/common/os/priv.c
↓ open down ↓ 81 lines elided ↑ open up ↑
  82   82  void
  83   83  priv_init(void)
  84   84  {
  85   85  #ifdef DEBUG
  86   86          int alloc_test_priv = 1;
  87   87  #else
  88   88          int alloc_test_priv = priv_debug;
  89   89  #endif
  90   90          rw_init(&privinfo_lock, NULL, RW_DRIVER, NULL);
  91   91  
  92      -        PRIV_BASIC_ASSERT(priv_basic);
  93      -        PRIV_UNSAFE_ASSERT(&priv_unsafe);
       92 +        PRIV_BASIC_ADDSET(priv_basic);
       93 +
       94 +        /*
       95 +         * The "default" set is the basic privileges + any 'default'
       96 +         * privileges.  with no traditional unix connotations.
       97 +         */
       98 +        PRIV_BASIC_ADDSET(priv_default);
       99 +        PRIV_DEFAULT_ADDSET(priv_default);
      100 +
      101 +        PRIV_UNSAFE_ADDSET(&priv_unsafe);
  94  102          priv_fillset(&priv_fullset);
  95  103  
  96  104          /*
  97  105           * When booting with priv_debug set or in a DEBUG kernel, then we'll
  98  106           * add an additional basic privilege and we verify that it is always
  99  107           * present in E.
 100  108           */
 101  109          if (alloc_test_priv != 0 &&
 102  110              (priv_basic_test = priv_getbyname("basic_test", PRIV_ALLOC)) >= 0) {
 103  111                  priv_addset(priv_basic, priv_basic_test);
      112 +                priv_addset(priv_default, priv_basic_test);
 104  113          }
 105  114  
 106  115          devpolicy_init();
 107  116  }
 108  117  
 109  118  /* Utility functions: privilege sets as opaque data types */
 110  119  
 111  120  /*
 112  121   * Guts of prgetprivsize.
 113  122   */
↓ open down ↓ 359 lines elided ↑ open up ↑
 473  482  
 474  483          /* memset? */
 475  484          for (i = 0; i < PRIV_SETSIZE; i++)
 476  485                  set->pbits[i] = ~(priv_chunk_t)0;
 477  486  }
 478  487  
 479  488  void
 480  489  priv_addset(priv_set_t *set, int priv)
 481  490  {
 482  491          ASSERT(priv >= 0 && priv < MAX_PRIVILEGE);
 483      -        __PRIV_ASSERT(set, priv);
      492 +        __PRIV_ADDSET(set, priv);
 484  493  }
 485  494  
 486  495  void
 487  496  priv_delset(priv_set_t *set, int priv)
 488  497  {
 489  498          ASSERT(priv >= 0 && priv < MAX_PRIVILEGE);
 490      -        __PRIV_CLEAR(set, priv);
      499 +        __PRIV_DELSET(set, priv);
 491  500  }
 492  501  
 493  502  boolean_t
 494  503  priv_ismember(const priv_set_t *set, int priv)
 495  504  {
 496  505          ASSERT(priv >= 0 && priv < MAX_PRIVILEGE);
 497      -        return (__PRIV_ISASSERT(set, priv) ? B_TRUE : B_FALSE);
      506 +        return (__PRIV_ISMEMBER(set, priv) ? B_TRUE : B_FALSE);
 498  507  }
 499  508  
 500  509  #define PRIV_TEST_BODY(test) \
 501  510          int i; \
 502  511  \
 503  512          for (i = 0; i < PRIV_SETSIZE; i++) \
 504  513                  if (!(test)) \
 505  514                          return (B_FALSE); \
 506  515  \
 507  516          return (B_TRUE)
↓ open down ↓ 239 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX