summaryrefslogtreecommitdiff
path: root/usr/src/lib
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2021-10-23 19:17:07 +0000
committerAndy Fiddaman <omnios@citrus-it.co.uk>2021-10-24 16:47:53 +0000
commit55fcd84f321375248464013e08f0ff6d6e00fffe (patch)
tree3f26604384dd372cce9e6ce73a9739c825f5aec1 /usr/src/lib
parentba5494d78f75a2e62b09b817fc6abf7351a952c2 (diff)
downloadillumos-joyent-55fcd84f321375248464013e08f0ff6d6e00fffe.tar.gz
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>
Diffstat (limited to 'usr/src/lib')
-rw-r--r--usr/src/lib/libbrand/common/libbrand.c29
-rw-r--r--usr/src/lib/libbrand/common/libbrand.h2
-rw-r--r--usr/src/lib/libbrand/common/mapfile-vers2
-rw-r--r--usr/src/lib/libbrand/dtd/brand.dtd.137
4 files changed, 58 insertions, 12 deletions
diff --git a/usr/src/lib/libbrand/common/libbrand.c b/usr/src/lib/libbrand/common/libbrand.c
index d0343acc47..5e6f3e502e 100644
--- a/usr/src/lib/libbrand/common/libbrand.c
+++ b/usr/src/lib/libbrand/common/libbrand.c
@@ -63,6 +63,8 @@
#define DTD_ELEM_MODNAME ((const xmlChar *) "modname")
#define DTD_ELEM_MOUNT ((const xmlChar *) "mount")
#define DTD_ELEM_RESTARTINIT ((const xmlChar *) "restartinit")
+#define DTD_ELEM_RESTARTINIT0 ((const xmlChar *) "restartinit0")
+#define DTD_ELEM_RESTARTINITREBOOT ((const xmlChar *) "restartinitreboot")
#define DTD_ELEM_POSTATTACH ((const xmlChar *) "postattach")
#define DTD_ELEM_POSTCLONE ((const xmlChar *) "postclone")
#define DTD_ELEM_POSTINSTALL ((const xmlChar *) "postinstall")
@@ -522,21 +524,40 @@ brand_get_initname(brand_handle_t bh, char *buf, size_t len)
buf, len, DTD_ELEM_INITNAME, B_FALSE, B_FALSE));
}
-boolean_t
-brand_restartinit(brand_handle_t bh)
+static boolean_t
+i_brand_restartinit(brand_handle_t bh, const xmlChar *tagname, boolean_t deflt)
{
struct brand_handle *bhp = (struct brand_handle *)bh;
char val[80];
if (brand_get_value(bhp, NULL, NULL, NULL, NULL,
- val, sizeof (val), DTD_ELEM_RESTARTINIT, B_FALSE, B_FALSE) != 0)
- return (B_TRUE);
+ val, sizeof (val), tagname, B_FALSE, B_FALSE) != 0) {
+ return (deflt);
+ }
if (strcmp(val, "false") == 0)
return (B_FALSE);
return (B_TRUE);
}
+boolean_t
+brand_restartinit(brand_handle_t bh)
+{
+ return (i_brand_restartinit(bh, DTD_ELEM_RESTARTINIT, B_TRUE));
+}
+
+boolean_t
+brand_restartinit0(brand_handle_t bh)
+{
+ return (i_brand_restartinit(bh, DTD_ELEM_RESTARTINIT0, B_FALSE));
+}
+
+boolean_t
+brand_restartinitreboot(brand_handle_t bh)
+{
+ return (i_brand_restartinit(bh, DTD_ELEM_RESTARTINITREBOOT, B_FALSE));
+}
+
int
brand_get_login_cmd(brand_handle_t bh, const char *username,
char *buf, size_t len)
diff --git a/usr/src/lib/libbrand/common/libbrand.h b/usr/src/lib/libbrand/common/libbrand.h
index 30accf95ba..2dc064481f 100644
--- a/usr/src/lib/libbrand/common/libbrand.h
+++ b/usr/src/lib/libbrand/common/libbrand.h
@@ -62,6 +62,8 @@ extern int brand_get_halt(brand_handle_t, const char *, const char *,
char *, size_t);
extern int brand_get_initname(brand_handle_t, char *, size_t);
extern boolean_t brand_restartinit(brand_handle_t);
+extern boolean_t brand_restartinit0(brand_handle_t);
+extern boolean_t brand_restartinitreboot(brand_handle_t);
extern int brand_get_install(brand_handle_t, const char *, const char *,
char *, size_t);
extern int brand_get_installopts(brand_handle_t, char *, size_t);
diff --git a/usr/src/lib/libbrand/common/mapfile-vers b/usr/src/lib/libbrand/common/mapfile-vers
index be79ae12b7..27999af434 100644
--- a/usr/src/lib/libbrand/common/mapfile-vers
+++ b/usr/src/lib/libbrand/common/mapfile-vers
@@ -80,6 +80,8 @@ SYMBOL_VERSION SUNWprivate {
brand_platform_iter_link;
brand_platform_iter_mounts;
brand_restartinit;
+ brand_restartinit0;
+ brand_restartinitreboot;
local:
*;
};
diff --git a/usr/src/lib/libbrand/dtd/brand.dtd.1 b/usr/src/lib/libbrand/dtd/brand.dtd.1
index a579bee93c..78c30a8355 100644
--- a/usr/src/lib/libbrand/dtd/brand.dtd.1
+++ b/usr/src/lib/libbrand/dtd/brand.dtd.1
@@ -212,17 +212,36 @@
<!ATTLIST initname>
<!--
- restartinit
+ restartinit, restartinit0 and restartinitreboot
- Boolean indicating that the program specified by the initname attr
- should be restarted, or not, if it exits. By default, the init program
- will be restarted if this attribute is not provided. Specifying false
- for this attr will prevent that.
+ These three boolean elements control what action is taken when the
+ program specified by the 'initname' element exits.
- It has no attributes.
+ The default values are:
+
+ restartinit: true
+ restartinit0: false
+ restartinitreboot: false
+
+ If 'restartinit' is set to false then the init process will never be
+ restarted and the zone will shut down once init exits. In this case, the
+ other restartinit elements are ignored.
+
+ When 'restartinit0' is set, init will only be restarted if it exited with
+ an exit status of 0, otherwise the zone will shut down.
+
+ If 'restartinitreboot' is set to true then whenever init should be
+ restarted, based on the other restartinit elements, the zone will instead
+ be rebooted.
+
+ These have no attributes.
-->
<!ELEMENT restartinit (#PCDATA) >
<!ATTLIST restartinit>
+<!ELEMENT restartinit0 (#PCDATA) >
+<!ATTLIST restartinit0>
+<!ELEMENT restartinitreboot (#PCDATA) >
+<!ATTLIST restartinitreboot>
<!--
login_cmd
@@ -627,7 +646,7 @@
-->
<!ELEMENT privilege (#PCDATA) >
-<!ATTLIST privilege set ( default | prohibited | required ) #REQUIRED
+<!ATTLIST privilege set ( default | prohibited | required ) #REQUIRED
name CDATA #REQUIRED
ip-type ( shared | exclusive ) "all" >
@@ -642,7 +661,9 @@
directory in which the configuration file is stored.
-->
-<!ELEMENT brand (modname?, initname, restartinit?, login_cmd,
+<!ELEMENT brand (modname?, initname, restartinit?,
+ restartinit0?, restartinitreboot?,
+ login_cmd,
forcedlogin_cmd, user_cmd, install,
installopts?, boot?, sysboot?, halt?, shutdown?,
verify_cfg?, verify_adm?, postattach?, postclone?,