From 55e9f58fa7c551aebfd6084b778cd942fa8b20ce Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 28 May 2026 18:46:27 +0200 Subject: Update (fixes support for a few edge cases, and leaves nothing laying around) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- util/tmpmount.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 util/tmpmount.c (limited to 'util/tmpmount.c') diff --git a/util/tmpmount.c b/util/tmpmount.c new file mode 100644 index 0000000..75e225d --- /dev/null +++ b/util/tmpmount.c @@ -0,0 +1,44 @@ +/* See LICENSE file for copyright and license details. */ +#include +#include +#include +#include + +NUSAGE(125, "mountpoint utility [argument] ..."); + + +int +main(int argc, char *argv[]) +{ + const char *mountpoint; + + libsimple_default_failure_exit = 125; + + ARGBEGIN { + default: + usage(); + } ARGEND; + + if (argc < 2) + usage(); + + mountpoint = *argv++; + argc--; + + if (unshare(CLONE_NEWNS)) + eprintf("unshare CLONE_NEWNS:"); + if (mount("none", "/", NULL, MS_REC | MS_SLAVE, NULL)) + eprintf("mount none / NULL MS_REC|MS_SLAVE NULL:"); + + if (mount("tmpfs", mountpoint, "tmpfs", 0, NULL)) + eprintf("mount tmpfs %s tmpfs 0 NULL:", mountpoint); + + if (setegid(getgid())) + eprintf("setegid :"); + if (seteuid(getuid())) + eprintf("seteuid :"); + + execvp(argv[0], argv); + enprintf(errno == ENOENT ? 127 : 126, "execvp %s:", argv[0]); + return 0; +} -- cgit v1.3.1