Unverified Commit e14d8270 by Tycho Andersen Committed by Christian Brauner

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 1bab0cad
......@@ -74,6 +74,30 @@ static void usage(void) {
" and does not need to be run by hand\n\n");
}
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[])
{
pid_t pid;
......@@ -166,6 +190,8 @@ int main(int argc, char *argv[])
lxc_setup_fs();
remove_self();
pid = fork();
if (pid < 0)
......
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