From: Michael Tremer Date: Sun, 21 Mar 2021 14:37:42 +0000 (+0000) Subject: libpakfire: Move root into mount map X-Git-Tag: 0.9.28~1285^2~493 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b75591fc471ca2dbcf81b094e2500687f3f9d0b9;p=pakfire.git libpakfire: Move root into mount map Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index bca06dd63..4c12ad5ea 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -84,6 +84,8 @@ static const struct pakfire_mountpoint { int flags; const char* options; } mountpoints[] = { + { "pakfire_root", "", "tmpfs", 0, NULL }, + { "pakfire_proc", "proc", "proc", MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL }, // Bind mount /proc/sys as read-only with the following exceptions: @@ -134,6 +136,10 @@ static int pakfire_mount(Pakfire pakfire) { int r; for (const struct pakfire_mountpoint* mp = mountpoints; mp->source; mp++) { + // Skip mounting root when operating in / + if (strcmp(pakfire->path, "/") == 0 && !*mp->target) + continue; + DEBUG(pakfire, "Mounting /%s\n", mp->target); char* target = pakfire_path_join(pakfire->path, mp->target); @@ -419,11 +425,6 @@ PAKFIRE_EXPORT int pakfire_create(Pakfire* pakfire, const char* path, const char // Destroy everything when done p->destroy_on_free = 1; - - // Mount tmpfs - r = __mount(p, "pakfire_root", path, "tmpfs", 0, NULL); - if (r) - goto ERROR; } // Set path