Commit 58fb9c8e by Tycho Andersen

unlink lxc-init

It's sort of an implementation detail that this exists at all, and we should probably not pollute the container's mount tables or FS with this. Signed-off-by: 's avatarTycho Andersen <tycho@tycho.ws>
parent 2c3a005d
...@@ -195,6 +195,30 @@ static void kill_children(pid_t pid) ...@@ -195,6 +195,30 @@ static void kill_children(pid_t pid)
fclose(f); fclose(f);
} }
static void remove_self(void)
{
char path[PATH_MAX];
ssize_t n;
n = readlink("/proc/self/exe", path, sizeof(path));
if (n < 0) {
SYSERROR("Failed to readlink \"/proc/self/exe\"");
return;
}
path[n] = 0;
if (umount2(path, MNT_DETACH) < 0) {
SYSERROR("Failed to unmount \"%s\"", path);
return;
}
if (unlink(path) < 0) {
SYSERROR("Failed to unlink \"%s\"", path);
return;
}
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int i, ret; int i, ret;
...@@ -296,6 +320,8 @@ int main(int argc, char *argv[]) ...@@ -296,6 +320,8 @@ int main(int argc, char *argv[])
lxc_setup_fs(); lxc_setup_fs();
remove_self();
pid = fork(); pid = fork();
if (pid < 0) if (pid < 0)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
......
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