aboutsummaryrefslogtreecommitdiffstats
path: root/util/tmpmount.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-05-28 18:46:27 +0200
committerMattias Andrée <m@maandree.se>2026-05-28 18:46:27 +0200
commit55e9f58fa7c551aebfd6084b778cd942fa8b20ce (patch)
tree7177e49a9c3a3c2e9cd4f88e8507cb19c9f6c1b0 /util/tmpmount.c
parentm fix (diff)
downloadrelease-scripts-55e9f58fa7c551aebfd6084b778cd942fa8b20ce.tar.gz
release-scripts-55e9f58fa7c551aebfd6084b778cd942fa8b20ce.tar.bz2
release-scripts-55e9f58fa7c551aebfd6084b778cd942fa8b20ce.tar.xz
Update (fixes support for a few edge cases, and leaves nothing laying around)
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
-rw-r--r--util/tmpmount.c44
1 files changed, 44 insertions, 0 deletions
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 <sys/mount.h>
+#include <sched.h>
+#include <libsimple.h>
+#include <libsimple-arg.h>
+
+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 <real group>:");
+ if (seteuid(getuid()))
+ eprintf("seteuid <real user>:");
+
+ execvp(argv[0], argv);
+ enprintf(errno == ENOENT ? 127 : 126, "execvp %s:", argv[0]);
+ return 0;
+}