Commit b4df0a1e by Serge Hallyn Committed by Stéphane Graber

lxc_start: exit early if insufficient privs in daemon mode

Starting a container with insufficient privilege (correctly) fails during lxc_init. However, if starting a daemonized container, we daemonize before we get to that check. Therefore while the container will fail to start, and the logfile will show this, the 'lxc-start -n x -d' command will return success. For ease of scripting, do a check for the required privilege before we exit. Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
parent 06f5c632
...@@ -199,9 +199,19 @@ int main(int argc, char *argv[]) ...@@ -199,9 +199,19 @@ int main(int argc, char *argv[])
free(console); free(console);
} }
if (my_args.daemonize && daemon(0, 0)) { if (my_args.daemonize) {
SYSERROR("failed to daemonize '%s'", my_args.name); /* do an early check for needed privs, since otherwise the
return err; * user won't see the error */
if (!lxc_caps_check()) {
ERROR("Not running with sufficient privilege");
return err;
}
if (daemon(0, 0)) {
SYSERROR("failed to daemonize '%s'", my_args.name);
return err;
}
} }
if (my_args.close_all_fds) if (my_args.close_all_fds)
......
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