start: set LXC_HOOK_VERSION

This can be used by scripts to detect what version of the hooks are used. Unblocks #2013. Unblocks #2015. Closes #1766. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 44ae0fb6
......@@ -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>
......
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment