Commit 1f76453a by Serge Hallyn Committed by Stéphane Graber

set close-all-fds by default

When containers request to be daemonized, close-all-fd is set to true. But when we switched ot daemonize-by-default we didn't set close-all-fd by default. Fix that. In order to do that we have to always have a lxc_conf object. As a consequence, after this patch we can drop a bunch of checks for c->lxc_conf existing. We should consider removing those. This patch does not do that. This should close https://github.com/lxc/lxc/issues/354Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent fccc348b
...@@ -457,6 +457,14 @@ static bool lxcapi_load_config(struct lxc_container *c, const char *alt_file) ...@@ -457,6 +457,14 @@ static bool lxcapi_load_config(struct lxc_container *c, const char *alt_file)
return ret; return ret;
} }
static void do_set_daemonize(struct lxc_container *c, bool state)
{
c->daemonize = state;
/* daemonize implies close_all_fds so set it */
if (state)
c->lxc_conf->close_all_fds = 1;
}
static bool lxcapi_want_daemonize(struct lxc_container *c, bool state) static bool lxcapi_want_daemonize(struct lxc_container *c, bool state)
{ {
if (!c || !c->lxc_conf) if (!c || !c->lxc_conf)
...@@ -465,10 +473,7 @@ static bool lxcapi_want_daemonize(struct lxc_container *c, bool state) ...@@ -465,10 +473,7 @@ static bool lxcapi_want_daemonize(struct lxc_container *c, bool state)
ERROR("Error getting mem lock"); ERROR("Error getting mem lock");
return false; return false;
} }
c->daemonize = state; do_set_daemonize(c, state);
/* daemonize implies close_all_fds so set it */
if (state == 1)
c->lxc_conf->close_all_fds = 1;
container_mem_unlock(c); container_mem_unlock(c);
return true; return true;
} }
...@@ -4098,7 +4103,9 @@ struct lxc_container *lxc_container_new(const char *name, const char *configpath ...@@ -4098,7 +4103,9 @@ struct lxc_container *lxc_container_new(const char *name, const char *configpath
container_destroy(c); container_destroy(c);
lxcapi_clear_config(c); lxcapi_clear_config(c);
} }
c->daemonize = true; if (!c->lxc_conf)
c->lxc_conf = lxc_conf_init();
do_set_daemonize(c, true);
c->pidfile = NULL; c->pidfile = NULL;
// assign the member functions // assign the member functions
......
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