Print this page
14019 Allow more control over zone init exit actions
Portions contributed by: Joshua M. Clulow <jmc@joyent.com>
Portions contributed by: Andy Fiddaman <andy@omnios.org>
Reviewed by: C Fraire <cfraire@me.com>
Reviewed by: Gordon Ross <Gordon.W.Ross@gmail.com>
Approved by: Robert Mustacchi <rm@fingolfin.org>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libbrand/common/libbrand.c
          +++ new/usr/src/lib/libbrand/common/libbrand.c
↓ open down ↓ 55 lines elided ↑ open up ↑
  56   56  #define DTD_ELEM_GLOBAL_MOUNT   ((const xmlChar *) "global_mount")
  57   57  #define DTD_ELEM_HALT           ((const xmlChar *) "halt")
  58   58  #define DTD_ELEM_INITNAME       ((const xmlChar *) "initname")
  59   59  #define DTD_ELEM_INSTALL        ((const xmlChar *) "install")
  60   60  #define DTD_ELEM_INSTALLOPTS    ((const xmlChar *) "installopts")
  61   61  #define DTD_ELEM_LOGIN_CMD      ((const xmlChar *) "login_cmd")
  62   62  #define DTD_ELEM_FORCELOGIN_CMD ((const xmlChar *) "forcedlogin_cmd")
  63   63  #define DTD_ELEM_MODNAME        ((const xmlChar *) "modname")
  64   64  #define DTD_ELEM_MOUNT          ((const xmlChar *) "mount")
  65   65  #define DTD_ELEM_RESTARTINIT    ((const xmlChar *) "restartinit")
       66 +#define DTD_ELEM_RESTARTINIT0   ((const xmlChar *) "restartinit0")
       67 +#define DTD_ELEM_RESTARTINITREBOOT      ((const xmlChar *) "restartinitreboot")
  66   68  #define DTD_ELEM_POSTATTACH     ((const xmlChar *) "postattach")
  67   69  #define DTD_ELEM_POSTCLONE      ((const xmlChar *) "postclone")
  68   70  #define DTD_ELEM_POSTINSTALL    ((const xmlChar *) "postinstall")
  69   71  #define DTD_ELEM_POSTSNAP       ((const xmlChar *) "postsnap")
  70   72  #define DTD_ELEM_POSTSTATECHG   ((const xmlChar *) "poststatechange")
  71   73  #define DTD_ELEM_PREDETACH      ((const xmlChar *) "predetach")
  72   74  #define DTD_ELEM_PRESNAP        ((const xmlChar *) "presnap")
  73   75  #define DTD_ELEM_PRESTATECHG    ((const xmlChar *) "prestatechange")
  74   76  #define DTD_ELEM_PREUNINSTALL   ((const xmlChar *) "preuninstall")
  75   77  #define DTD_ELEM_PRIVILEGE      ((const xmlChar *) "privilege")
↓ open down ↓ 447 lines elided ↑ open up ↑
 523  525  }
 524  526  
 525  527  int
 526  528  brand_get_initname(brand_handle_t bh, char *buf, size_t len)
 527  529  {
 528  530          struct brand_handle *bhp = (struct brand_handle *)bh;
 529  531          return (brand_get_value(bhp, NULL, NULL, NULL, NULL,
 530  532              buf, len, DTD_ELEM_INITNAME, B_FALSE, B_FALSE));
 531  533  }
 532  534  
 533      -boolean_t
 534      -brand_restartinit(brand_handle_t bh)
      535 +static boolean_t
      536 +i_brand_restartinit(brand_handle_t bh, const xmlChar *tagname, boolean_t deflt)
 535  537  {
 536  538          struct brand_handle *bhp = (struct brand_handle *)bh;
 537  539          char val[80];
 538  540  
 539  541          if (brand_get_value(bhp, NULL, NULL, NULL, NULL,
 540      -            val, sizeof (val), DTD_ELEM_RESTARTINIT, B_FALSE, B_FALSE) != 0)
 541      -                return (B_TRUE);
      542 +            val, sizeof (val), tagname, B_FALSE, B_FALSE) != 0) {
      543 +                return (deflt);
      544 +        }
 542  545  
 543  546          if (strcmp(val, "false") == 0)
 544  547                  return (B_FALSE);
 545  548          return (B_TRUE);
 546  549  }
 547  550  
      551 +boolean_t
      552 +brand_restartinit(brand_handle_t bh)
      553 +{
      554 +        return (i_brand_restartinit(bh, DTD_ELEM_RESTARTINIT, B_TRUE));
      555 +}
      556 +
      557 +boolean_t
      558 +brand_restartinit0(brand_handle_t bh)
      559 +{
      560 +        return (i_brand_restartinit(bh, DTD_ELEM_RESTARTINIT0, B_FALSE));
      561 +}
      562 +
      563 +boolean_t
      564 +brand_restartinitreboot(brand_handle_t bh)
      565 +{
      566 +        return (i_brand_restartinit(bh, DTD_ELEM_RESTARTINITREBOOT, B_FALSE));
      567 +}
      568 +
 548  569  int
 549  570  brand_get_login_cmd(brand_handle_t bh, const char *username,
 550  571      char *buf, size_t len)
 551  572  {
 552  573          struct brand_handle *bhp = (struct brand_handle *)bh;
 553  574          const char *curr_zone = get_curr_zone();
 554  575          return (brand_get_value(bhp, NULL, NULL, username, curr_zone,
 555  576              buf, len, DTD_ELEM_LOGIN_CMD, B_TRUE, B_FALSE));
 556  577  }
 557  578  
↓ open down ↓ 500 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX