Print this page
smf: switch to a tri-state for process-security properties true=on,false=off,nil=default

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libscf/common/highlevel.c
          +++ new/usr/src/lib/libscf/common/highlevel.c
↓ open down ↓ 25 lines elided ↑ open up ↑
  26   26  
  27   27  /*
  28   28   * This file contains high level functions used by multiple utilities.
  29   29   */
  30   30  
  31   31  #include "libscf_impl.h"
  32   32  
  33   33  #include <assert.h>
  34   34  #include <libuutil.h>
  35   35  #include <string.h>
       36 +#include <strings.h>
  36   37  #include <stdlib.h>
  37   38  #include <sys/systeminfo.h>
  38   39  #include <sys/uadmin.h>
  39   40  #include <sys/utsname.h>
  40   41  #include <sys/secflags.h>
  41   42  
  42   43  #ifdef  __x86
  43   44  #include <smbios.h>
  44   45  
  45   46  /*
↓ open down ↓ 310 lines elided ↑ open up ↑
 356  357  }
 357  358  
 358  359  /*
 359  360   * Read the default security-flags from system/process-security and return a
 360  361   * secflagset_t suitable for psecflags(2)
 361  362   *
 362  363   * Unfortunately, this symbol must _exist_ in the native build, for the sake
 363  364   * of the mapfile, even though we don't ever use it, and it will never work.
 364  365   */
 365  366  struct group_desc {
 366      -        secflagset_t *set;
      367 +        secflagdelta_t *delta;
 367  368          char *fmri;
 368  369  };
 369  370  
 370  371  int
 371      -scf_default_secflags(scf_handle_t *hndl, psecflags_t *flags)
      372 +scf_default_secflags(scf_handle_t *hndl, scf_secflags_t *flags)
 372  373  {
 373  374  #if !defined(NATIVE_BUILD)
 374  375          scf_property_t *prop;
 375  376          scf_value_t *val;
 376  377          const char *flagname;
 377  378          int flag;
 378  379          struct group_desc *g;
 379  380          struct group_desc groups[] = {
 380  381                  {NULL, "svc:/system/process-security/"
 381  382                      ":properties/default"},
 382  383                  {NULL, "svc:/system/process-security/"
 383  384                      ":properties/lower"},
 384  385                  {NULL, "svc:/system/process-security/"
 385  386                      ":properties/upper"},
 386  387                  {NULL, NULL}
 387  388          };
 388  389  
 389      -        groups[0].set = &flags->psf_inherit;
 390      -        groups[1].set = &flags->psf_lower;
 391      -        groups[2].set = &flags->psf_upper;
      390 +        bzero(flags, sizeof (*flags));
 392  391  
 393      -        /* Ensure sane defaults */
 394      -        psecflags_default(flags);
      392 +        groups[0].delta = &flags->ss_default;
      393 +        groups[1].delta = &flags->ss_lower;
      394 +        groups[2].delta = &flags->ss_upper;
 395  395  
 396      -        for (g = groups; g->set != NULL; g++) {
      396 +        for (g = groups; g->delta != NULL; g++) {
 397  397                  for (flag = 0; (flagname = secflag_to_str(flag)) != NULL;
 398  398                      flag++) {
 399  399                          char *pfmri;
 400  400                          uint8_t flagval = 0;
 401  401  
 402  402                          if ((val = scf_value_create(hndl)) == NULL)
 403  403                                  return (-1);
 404  404  
 405  405                          if ((prop = scf_property_create(hndl)) == NULL) {
 406  406                                  scf_value_destroy(val);
↓ open down ↓ 7 lines elided ↑ open up ↑
 414  414                          if (scf_handle_decode_fmri(hndl, pfmri,
 415  415                              NULL, NULL, NULL, NULL, prop, NULL) != 0)
 416  416                                  goto next;
 417  417  
 418  418                          if (scf_property_get_value(prop, val) != 0)
 419  419                                  goto next;
 420  420  
 421  421                          (void) scf_value_get_boolean(val, &flagval);
 422  422  
 423  423                          if (flagval != 0)
 424      -                                secflag_set(g->set, flag);
      424 +                                secflag_set(&g->delta->psd_add, flag);
 425  425                          else
 426      -                                secflag_clear(g->set, flag);
      426 +                                secflag_set(&g->delta->psd_rem, flag);
 427  427  
 428  428  next:
 429  429                          uu_free(pfmri);
 430  430                          scf_value_destroy(val);
 431  431                          scf_property_destroy(prop);
 432  432                  }
 433  433          }
 434  434  
 435      -        if (!psecflags_validate(flags))
 436      -                return (-1);
 437      -
 438  435          return (0);
 439  436  #else
 440  437          assert(0);
 441  438          abort();
 442  439  #endif /* !NATIVE_BUILD */
 443  440  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX