Print this page
patch zone-auto-create-be

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libbrand/common/libbrand.c
          +++ new/usr/src/lib/libbrand/common/libbrand.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  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  /*
  23   23   * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Copyright (c) 2011, Joyent, Inc. All rights reserved.
  25   25   * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
       26 + * Copyright 2015 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  26   27   */
  27   28  
  28   29  #include <assert.h>
  29   30  #include <dirent.h>
  30   31  #include <errno.h>
  31   32  #include <fnmatch.h>
  32   33  #include <signal.h>
  33   34  #include <stdlib.h>
  34   35  #include <unistd.h>
  35   36  #include <strings.h>
↓ open down ↓ 42 lines elided ↑ open up ↑
  78   79  #define DTD_ELEM_SYMLINK        ((const xmlChar *) "symlink")
  79   80  #define DTD_ELEM_SYSBOOT        ((const xmlChar *) "sysboot")
  80   81  #define DTD_ELEM_UNINSTALL      ((const xmlChar *) "uninstall")
  81   82  #define DTD_ELEM_USER_CMD       ((const xmlChar *) "user_cmd")
  82   83  #define DTD_ELEM_VALIDSNAP      ((const xmlChar *) "validatesnap")
  83   84  #define DTD_ELEM_VERIFY_CFG     ((const xmlChar *) "verify_cfg")
  84   85  #define DTD_ELEM_VERIFY_ADM     ((const xmlChar *) "verify_adm")
  85   86  
  86   87  #define DTD_ATTR_ALLOWEXCL      ((const xmlChar *) "allow-exclusive-ip")
  87   88  #define DTD_ATTR_ARCH           ((const xmlChar *) "arch")
       89 +#define DTD_ATTR_AUTO_CREATE_BE ((const xmlChar *) "auto-create-be")
  88   90  #define DTD_ATTR_DIRECTORY      ((const xmlChar *) "directory")
  89   91  #define DTD_ATTR_IPTYPE         ((const xmlChar *) "ip-type")
  90   92  #define DTD_ATTR_MATCH          ((const xmlChar *) "match")
  91   93  #define DTD_ATTR_MODE           ((const xmlChar *) "mode")
  92   94  #define DTD_ATTR_NAME           ((const xmlChar *) "name")
  93   95  #define DTD_ATTR_OPT            ((const xmlChar *) "opt")
  94   96  #define DTD_ATTR_PATH           ((const xmlChar *) "path")
  95   97  #define DTD_ATTR_SET            ((const xmlChar *) "set")
  96   98  #define DTD_ATTR_SOURCE         ((const xmlChar *) "source")
  97   99  #define DTD_ATTR_SPECIAL        ((const xmlChar *) "special")
  98  100  #define DTD_ATTR_TARGET         ((const xmlChar *) "target")
  99  101  #define DTD_ATTR_TYPE           ((const xmlChar *) "type")
 100  102  
 101  103  #define DTD_ENTITY_TRUE         "true"
      104 +#define DTD_ENTITY_FALSE        "false"
 102  105  
 103  106  static volatile boolean_t       libbrand_initialized = B_FALSE;
 104  107  static char                     i_curr_arch[MAXNAMELEN];
 105  108  static char                     i_curr_zone[ZONENAME_MAX];
 106  109  
 107  110  /*ARGSUSED*/
 108  111  static void
 109  112  brand_error_func(void *ctx, const char *msg, ...)
 110  113  {
 111  114          /*
↓ open down ↓ 631 lines elided ↑ open up ↑
 743  746          if (allow_excl == NULL)
 744  747                  return (B_FALSE);
 745  748  
 746  749          /* Note: only return B_TRUE if it's "true" */
 747  750          if (strcmp((char *)allow_excl, DTD_ENTITY_TRUE) == 0)
 748  751                  ret = B_TRUE;
 749  752          else
 750  753                  ret = B_FALSE;
 751  754  
 752  755          xmlFree(allow_excl);
      756 +
      757 +        return (ret);
      758 +}
      759 +
      760 +boolean_t
      761 +brand_auto_create_be(brand_handle_t bh)
      762 +{
      763 +        struct brand_handle     *bhp = (struct brand_handle *)bh;
      764 +        xmlNodePtr              node;
      765 +        xmlChar                 *auto_create_be;
      766 +        boolean_t               ret;
      767 +
      768 +        assert(bhp != NULL);
      769 +
      770 +        if ((node = xmlDocGetRootElement(bhp->bh_platform)) == NULL)
      771 +                return (B_FALSE);
      772 +
      773 +        auto_create_be = xmlGetProp(node, DTD_ATTR_AUTO_CREATE_BE);
      774 +        if (auto_create_be == NULL)
      775 +                return (B_FALSE);
      776 +
      777 +        /* Note: only return B_FALSE if it's "false" */
      778 +        if (strcmp((char *)auto_create_be, DTD_ENTITY_FALSE) == 0)
      779 +                ret = B_FALSE;
      780 +        else
      781 +                ret = B_TRUE;
      782 +
      783 +        xmlFree(auto_create_be);
 753  784  
 754  785          return (ret);
 755  786  }
 756  787  
 757  788  /*
 758  789   * Iterate over brand privileges
 759  790   *
 760  791   * Walks the brand config, searching for <privilege> elements, calling the
 761  792   * specified callback for each.  Returns 0 on success, or -1 on failure.
 762  793   */
↓ open down ↓ 282 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX