Package: djmount
Version: 0.71-3
Severity: wishlist
Tags: patch upstream

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256


(Transcription of a Bug report received by email from: Kevin Vargo 
<[email protected]>)

Hello Dario,

I'd like to submit a patch for djmount, to permit "ignoring" of non-relevant 
mount options, 
as per -s/sloppy from mount.

I've attached my patch vs. 0.71-3.

If I need to provide something 
else/somehow else, please advise, I'll be happy to try. 

I've not submitted a separate bug report, as I couldn't see how to submit the 
patch with it.


Bug report is basically:

`djmount' can't be used from /etc/fstab, because djmount considers any unknown 
options to be 
an error, and exits.  `mount' supports a '-s' option for "sloppy" where unknown 
options are 
ignored.

I've added both '-s' and '-o sloppy' to the latest (0.71-3) to engage behavior 
that reports, 
but really ignores unknown options.  That is, this patch permits specification 
of 'sloppy' 
as an /etc/fstab option, and thereafter permits unknown options to be logged as 
warnings, but 
`djmount' continues.

Then, an /etc/fstab entry like:

djmount                 /media/upnp             fuse    
noauto,ro,user,allow_other,sloppy    0    0


succeeds, whereas prior, it would fail because 'standard' options like 'nodev' 
and 'nosuid' are 
unknown to djmount as in:


[W] Found unknown option = noexec; ignoring
[W] Found unknown option = nosuid; ignoring
[W] Found unknown option = nodev; ignoring
[I]   Mount options = ro,noexec,nosuid,nodev,s,allow_other
[I] Charset : successfully initialised charset='UTF-8'
total 0


Thanks,
Kevin


- -- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 3.1.0-1-686-pae (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages djmount depends on:
ii  fuse-utils  2.8.6-4
ii  libc6       2.13-26
ii  libfuse2    2.8.6-4
ii  libtalloc2  2.0.7+git20120207-1
ii  libupnp3    1:1.6.6-5.1

djmount recommends no packages.

djmount suggests no packages.

- -- no debconf information

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIcBAEBCAAGBQJPPPCnAAoJEKgvu4Pz1XAzD3sQAL8ctwNwUl3hHaArHQI232C1
7MSGvBDjGEBXGTwm/jseqjBPscdVb8VLMbTgjz+vw1ZKIFYGF0w/0K69y0gDyU4R
NXpUyKo0ueXW4dYyPrAzTGmdwuQtyizrzLImUacCRBs/wVeI1/AWaJDiqrpAq4o2
Fm06Mc2H0HPGcEZc4PofENz0TdsQxJwt2MscdyB9AcISuO8hAFDLImGnW7wbyY15
NJAjsvPHRCMwEG9rB20TRs9eh/klCN5KIggi2blE1x+X75DZZXnPGp1yFpvxFLzX
L0ey+e+zZdL8HrQotbhhZSkPv33D9J4Rt8JHWwZBDI1/PVymES/bti3wtB068w4S
vKPX1JMrPIpuQ7+97ObOlzeO7Tdg4q4lbpydRy1BGtb0ypuA6enXhU7hu5KiybRs
vyyvpjGg2uiSEvXvb4Bo4BuspGeVOFwhRLnajsf3d2uRK6MgGMPpuX50JMtiGJuw
ltO4fdqikftR0LXRV2giaFgxwoDC3rvVHK/YMnytXsnZjvvf1FIv38u7v+hUu875
jb5+mLr5MQBnLK3lK7Ytl8xDk0VqMnKoyc8odQvfKNgSxXzPmdhiNB0RPqKafPSz
qlYLVm17VCXnBshG2NFDoQ0jp2y9qLQaDfne9fYJ1PdY3TVrOCj0Xtwvv2FZ6apR
LOF/CIUBCewhyOtRbc7F
=Nt5Z
-----END PGP SIGNATURE-----
--- djmount-0.71.orig/djmount/fuse_main.c	2006-08-27 16:12:20.000000000 -0400
+++ djmount-0.71/djmount/fuse_main.c	2011-12-23 15:39:29.000000000 -0500
@@ -529,6 +529,7 @@
      "    --version              print version number, then exit\n"
      "    -o [options]           mount options (see below)\n"
      "    -d[levels]             enable debug output (implies -f)\n"
+     "    -s                     sloppy -- ignore unknown options\n"
      "    -f                     foreground operation (default: daemonized)\n"
      "\n"
      "Mount options (one or more comma separated options) :\n"
@@ -538,6 +539,7 @@
      "    playlists              use playlists for AV files, instead of plain files\n"
      "    search_history=<size>  number of remembered searches (default: %d)\n"
      "                           (set to 0 to disable search)\n"
+     "    sloppy                 ignore unknown options (e.g., for /etc/fstab)\n"
      "\n", DEFAULT_SEARCH_HISTORY_SIZE);
   fprintf 
     (stream,
@@ -635,6 +637,9 @@
 	Log_Printf (LOG_DEBUG, "  Fuse option = %s", fuse_argv[fuse_argc]); \
 	fuse_argc++
 
+	//Ignore unknown options "sloppy" -- mount -s
+	bool options_sloppy = false;
+
 	int opt = 1;
 	char* o;
 	while ((o = argv[opt++])) {
@@ -646,6 +651,9 @@
 			
 		} else if (strcmp(o, "-f") == 0) {
 			background = false;
+			
+		} else if (strcmp(o, "-s") == 0) {
+			options_sloppy = true;
 
 		} else if (*o != '-') { 
 			// mount point
@@ -657,6 +665,10 @@
 			char* options_copy = strdup (options);
 			char* tokptr = 0;
 			char* s;
+
+			char** unknown_options = talloc_size(tmp_ctx, sizeof(char) * strlen(options_copy));
+			int unknown_ptr = -1;
+
 			for (s = strtok_r (options_copy, ",", &tokptr); 
 			     s != NULL; 
 			     s = strtok_r (NULL, ",", &tokptr)) {
@@ -669,16 +681,43 @@
 				} else if (strncmp(s, "search_history=", 15)
 					   == 0) {
 					search_history_size = atoi (s+15);
+				//check for '-s|-o sloppy' -- ignore unknown options
+				} else if (strncmp(s, "sloppy", 15) == 0 ||
+						(strlen(s) == 1 && strncmp(s, "s", 1) == 0)) {
+					options_sloppy = true;
 				} else if (strncmp(s, "fsname=", 7) == 0 ||
 					   strstr (FUSE_ALLOWED_OPTIONS, s)) {
 					FUSE_ARG ("-o");
 					FUSE_ARG (talloc_strdup (tmp_ctx, s));
 				} else {
+					//Record unknown options for analysis, after we're sure
+					//we don't see '-o sloppy'
+					unknown_options[++unknown_ptr] = strdup(s);
+				}
+			}
+
+			//Now, we should know if we have invalid option(s), or can
+			//ignore:
+			if (unknown_ptr >= 0) {
+				//If debug...
+				int i = 0;
+				for (i = 0; i <= unknown_ptr; i++) {
+					char* message = talloc_size(tmp_ctx, sizeof(char) * 100);
+					snprintf(message, 100, "Found unknown option = %s%s",
+						unknown_options[i], (options_sloppy ? "; ignoring" : ""));
+					//printf("%s\n", message);
+					Log_Printf (LOG_WARNING, message);
+					talloc_free (message);
+				}
+				//If 'sloppy' is not enabled...
+				if (! options_sloppy) {
 					bad_usage (argv[0], 
-						   "unknown mount option '%s'",
-						   s); // ---------->
+						   "unknown mount option '%s' (and [-s|-o sloppy] not provided)",
+						   unknown_options[0]); // ---------->
 				}
 			}
+			talloc_free(unknown_options);
+
 			free (options_copy);
 			Log_Printf (LOG_INFO, "  Mount options = %s", options);
 			

Reply via email to