Print this page
uts: add a concept of a 'default' set of privileges, separate from 'basic'

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libc/port/gen/privlib.c
          +++ new/usr/src/lib/libc/port/gen/privlib.c
↓ open down ↓ 192 lines elided ↑ open up ↑
 193  193                          }
 194  194                          qsort(tmparr, tmp->pd_nprivs, sizeof (struct strint),
 195  195                              strintcmp);
 196  196                          for (i = 0; i < tmp->pd_nprivs; i++)
 197  197                                  tmp->pd_setsort[i] = tmparr[i].rank;
 198  198                          libc_free(tmparr);
 199  199                          break;
 200  200                  case PRIV_INFO_BASICPRIVS:
 201  201                          tmp->pd_basicset = (priv_set_t *)&st->set[0];
 202  202                          break;
      203 +                case PRIV_INFO_DEFAULTPRIVS:
      204 +                        tmp->pd_defaultset = (priv_set_t *)&st->set[0];
      205 +                        break;
 203  206                  default:
 204  207                          /* unknown, ignore */
 205  208                          break;
 206  209                  }
 207  210                  x += na->info.priv_info_size;
 208  211          }
 209  212          return (tmp);
 210  213  out:
 211  214          libc_free(tmp->pd_setnames);
 212  215          libc_free(tmp->pd_privnames);
↓ open down ↓ 276 lines elided ↑ open up ↑
 489  492          va_start(pa, gid);
 490  493  
 491  494          nset = priv_vlist(pa);
 492  495  
 493  496          va_end(pa);
 494  497  
 495  498          if (nset == NULL)
 496  499                  return (-1);
 497  500  
 498  501          /* Always add the basic set */
      502 +        /* XXX: Always add the _default_ set? */
 499  503          if (d->pd_basicset != NULL)
 500  504                  priv_union(d->pd_basicset, nset);
 501  505  
 502  506          /*
 503  507           * This is not a significant failure: it allows us to start programs
 504  508           * with sufficient privileges and with the proper uid.   We don't
 505  509           * care enough about the extra groups in that case.
 506  510           */
 507  511          if (flags & PU_RESETGROUPS)
 508  512                  (void) setgroups(0, NULL);
↓ open down ↓ 132 lines elided ↑ open up ↑
 641  645          if (!priv_issubset(nset, tmpset))
 642  646                  goto end;
 643  647  
 644  648          bracketpriv = priv_allocset();
 645  649          if (bracketpriv == NULL)
 646  650                  goto end;
 647  651  
 648  652          priv_copyset(nset, bracketpriv);
 649  653  
 650  654          /* Always add the basic set */
      655 +        /* XXX: Always add the default set? */
 651  656          priv_union(priv_basic(), nset);
 652  657  
 653  658          /* But don't add what we don't have */
 654  659          priv_intersect(tmpset, nset);
 655  660  
 656  661          (void) getppriv(inheritable, tmpset);
 657  662  
 658  663          /* And stir in the inheritable privileges */
 659  664          priv_union(tmpset, nset);
 660  665  
↓ open down ↓ 207 lines elided ↑ open up ↑
 868  873          __priv_emptyset(GETPRIVDATA(), set);
 869  874  }
 870  875  
 871  876  void
 872  877  priv_basicset(priv_set_t *set)
 873  878  {
 874  879          priv_copyset(priv_basic(), set);
 875  880  }
 876  881  
 877  882  void
      883 +priv_defaultset(priv_set_t *set)
      884 +{
      885 +        priv_copyset(priv_default(), set);
      886 +}
      887 +
      888 +void
 878  889  __priv_fillset(priv_data_t *d, priv_set_t *set)
 879  890  {
 880  891          (void) memset(set, ~0, d->pd_setsize);
 881  892  }
 882  893  
 883  894  void
 884  895  priv_fillset(priv_set_t *set)
 885  896  {
 886  897          __priv_fillset(GETPRIVDATA(), set);
 887  898  }
↓ open down ↓ 141 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX