Package: udevil
Version: 0.4.4-3
Severity: normal

Dear Maintainer,

Found that the udevil package explicitly prevents loopback rw mounts.
Patch given to fix this and to maintain default behavior in the
absence of an explicit request to make the mount rw.

Patch was created on Debian and verified there.

Patch posted to original project, but the last activity was years ago,
so I don't expect much in the way of an update.

Cheers

-- System Information:
Debian Release: 11.0
  APT prefers stable
  APT policy: (990, 'stable'), (500, 'stable-security'), (500, 'unstable'), 
(500, 'oldstable')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.0-6-amd64 (SMP w/4 CPU threads)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages udevil depends on:
ii  libc6         2.31-13
ii  libglib2.0-0  2.66.8-1
ii  libudev1      247.3-6

Versions of packages udevil recommends:
ii  udisks2  2.9.2-2

Versions of packages udevil suggests:
pn  cifs-utils  <none>
pn  curlftpfs   <none>
ii  eject       2.36.1-8
ii  sshfs       3.7.1+repack-2

-- no debconf information
Description: Allow for rw mounting of loopback filesystems
Patch to allow rw option to pass-through to mount of loopback
filesystem.  Default behavior is maintained where loopback mounts are
ro.
Author: e...@debian.org
Last-Update: 2021-08-19
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/src/udevil.c
+++ b/src/udevil.c
@@ -2267,11 +2267,23 @@
                                                                     NULL, 2 );
         return 1;
     }
-    char* loopopts = g_strdup_printf( "%s%sro", options ? options : "",
-                                                     options ? "," : "" );
+
+    /* Scan options for presence of ro or rw.  If either is found, we
+       do not add ro explicitly. */
+    gchar** option_list = g_strsplit (options ? options : "", ",", -1);
+    bool is_ro_or_rw = false;
+    if (option_list)
+      for (gchar** pp = option_list; *pp && !is_ro_or_rw; ++pp)
+        if (g_strcmp0 (*pp, "ro") == 0 || g_strcmp0 (*pp, "rw") == 0)
+          is_ro_or_rw = true;
+
+    char* loopopts = g_strdup_printf( "%s%s%s", options ? options : "",
+                                      options && !is_ro_or_rw ? "," : "",
+                                      !is_ro_or_rw ? "ro" : "" );
     int exit_status = mount_device( loopdev, fstype, loopopts, point, TRUE );
     if ( exit_status )
         detach_loop( loopdev );
+    g_strfreev( option_list );
     g_free( loopdev );
     g_free( loopopts );
     return exit_status;

Reply via email to