exit(EXIT_FAILURE);
}
- if (opts.namespace && opts.hostname
+ if (opts.namespace && opts.hostname && strlen(opts.hostname) > 0
&& sethostname(opts.hostname, strlen(opts.hostname))) {
ERROR("sethostname(%s) failed: %s\n", opts.hostname, strerror(errno));
exit(EXIT_FAILURE);
uloop_init();
if (opts.namespace) {
- jail_process.pid = clone(exec_jail,
- child_stack + STACK_SIZE,
- CLONE_NEWUTS | CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWIPC | SIGCHLD, NULL);
+ int flags = CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWIPC | SIGCHLD;
+ if (opts.hostname)
+ flags |= CLONE_NEWUTS;
+ jail_process.pid = clone(exec_jail, child_stack + STACK_SIZE, flags, NULL);
} else {
jail_process.pid = fork();
}