From: Michael Tremer Date: Tue, 19 Jul 2022 09:37:30 +0000 (+0000) Subject: mount: Use mount(2) to perform any mount operations X-Git-Tag: 0.9.28~678 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f970e6ec308c5b2471c6fb0b84fd5dbc67b49ce;p=pakfire.git mount: Use mount(2) to perform any mount operations libmount did too much voodoo here which prevented us from running smoothly for unprivileged users. Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/mount.c b/src/libpakfire/mount.c index b0194b19c..e671a6955 100644 --- a/src/libpakfire/mount.c +++ b/src/libpakfire/mount.c @@ -166,9 +166,6 @@ int pakfire_is_mountpoint(struct pakfire* pakfire, const char* path) { static int pakfire_mount(struct pakfire* pakfire, const char* source, const char* target, const char* fstype, unsigned long mflags, const void* data) { const char* options = (const char*)data; - int r; - - char error[1024]; // Check for some basic inputs if (!source || !target) { @@ -176,74 +173,14 @@ static int pakfire_mount(struct pakfire* pakfire, const char* source, const char return 1; } - DEBUG(pakfire, "Mounting %s from %s (%s - %s)\n", - target, source, fstype, options); - -#ifdef PAKFIRE_DEBUG - // Enable debugging for libmount - mnt_init_debug(0xffff); -#endif - - // Allocate a new mount context - struct libmnt_context* ctx = mnt_new_context(); - if (!ctx) - return 1; + DEBUG(pakfire, "Mounting %s from %s (%s - %s)\n", target, source, fstype, options); - // Set source - r = mnt_context_set_source(ctx, source); + // Perform mount() + int r = mount(source, target, fstype, mflags, data); if (r) { - ERROR(pakfire, "Could not set source: %m\n"); - goto ERROR; + ERROR(pakfire, "Could not mount %s: %m\n", target); } - // Set target - r = mnt_context_set_target(ctx, target); - if (r) { - ERROR(pakfire, "Could not set target: %m\n"); - goto ERROR; - } - - // Set filesystem type - if (fstype) { - r = mnt_context_set_fstype(ctx, fstype); - if (r) { - ERROR(pakfire, "Could not set filesystem type: %m\n"); - goto ERROR; - } - } - - // Set mount flags - if (mflags) { - r = mnt_context_set_mflags(ctx, mflags); - if (r) { - ERROR(pakfire, "Could not set mount flags: %m\n"); - goto ERROR; - } - } - - // Set options - if (options) { - r = mnt_context_set_options(ctx, options); - if (r) { - ERROR(pakfire, "Could not set mount options: %m\n"); - goto ERROR; - } - } - - // Perform mount operation - r = mnt_context_mount(ctx); - if (r) { - // Fetch the error message - mnt_context_get_excode(ctx, r, error, sizeof(error)); - - ERROR(pakfire, "Mount unsuccessful: %s\n", error); - goto ERROR; - } - -ERROR: - if (ctx) - mnt_free_context(ctx); - return r; } @@ -395,7 +332,6 @@ RETRY: goto RETRY; } - ERROR(pakfire, "Could not mount /%s: %m\n", mp->target); return r; } }