]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
start: set LXC_HOOK_VERSION
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 11 Dec 2017 11:10:37 +0000 (12:10 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 14 Dec 2017 10:47:36 +0000 (11:47 +0100)
This can be used by scripts to detect what version of the hooks are used.

Unblocks #2013.
Unblocks #2015.
Closes #1766.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
doc/lxc.container.conf.sgml.in
src/lxc/start.c

index cd49b86624a4ab16c98280bf1f25ba89354ced81..9d4b4cb365a41e7d56755dd178e266ef800dfb10 100644 (file)
@@ -1667,6 +1667,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
           conditional on the value of <option>lxc.hook.version</option>. If it
           is set to 1 then LXC_HOOK_SECTION will be set.
           </para></listitem>
+          <listitem><para> LXC_HOOK_VERSION: the version of the hooks. This
+          value is identical to the value of the container's
+          <option>lxc.hook.version</option> config item. If it is set to 0 then
+          old-style hooks are used. If it is set to 1 then new-style hooks are
+          used. </para></listitem>
           <listitem><para> LXC_LOG_LEVEL: the container's log level. </para></listitem>
           <listitem><para> LXC_NAME: is the container's name. </para></listitem>
           <listitem><para> LXC_ROOTFS_MOUNT: the path to the mounted root filesystem. </para></listitem>
index a144d6f8f791a59c2d8cbb1b85e3d303d971c7d8..d6cd543224272dfedce19836d0fcfaa6ce58bafc 100644 (file)
@@ -612,6 +612,7 @@ on_error:
 
 int lxc_init(const char *name, struct lxc_handler *handler)
 {
+       int ret;
        const char *loglevel;
        struct lxc_conf *conf = handler->conf;
 
@@ -656,6 +657,13 @@ int lxc_init(const char *name, struct lxc_handler *handler)
        loglevel = lxc_log_priority_to_string(lxc_log_get_level());
        if (setenv("LXC_LOG_LEVEL", loglevel, 1))
                SYSERROR("Failed to set environment variable LXC_LOG_LEVEL=%s", loglevel);
+
+       if (conf->hooks_version == 0)
+               ret = setenv("LXC_HOOK_VERSION", "0", 1);
+       else
+               ret = setenv("LXC_HOOK_VERSION", "1", 1);
+       if (ret < 0)
+               SYSERROR("Failed to set environment variable LXC_HOOK_VERSION=%u", conf->hooks_version);
        /* End of environment variable setup for hooks. */
 
        TRACE("set environment variables");