The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/2095

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
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: Tycho Andersen <ty...@tycho.ws>
From 58fb9c8efe1b4594379e35e1c9b6ced0dd550b52 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <ty...@tycho.ws>
Date: Wed, 20 Dec 2017 17:52:38 +0000
Subject: [PATCH] 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: Tycho Andersen <ty...@tycho.ws>
---
 src/lxc/lxc_init.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/lxc/lxc_init.c b/src/lxc/lxc_init.c
index 78811de4b..29394c80d 100644
--- a/src/lxc/lxc_init.c
+++ b/src/lxc/lxc_init.c
@@ -195,6 +195,30 @@ static void kill_children(pid_t pid)
        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 i, ret;
@@ -296,6 +320,8 @@ int main(int argc, char *argv[])
 
        lxc_setup_fs();
 
+       remove_self();
+
        pid = fork();
        if (pid < 0)
                exit(EXIT_FAILURE);
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to