git: 90d93d75b9d1 - main - sysutils/fusefs-ext2: Allow default_permissions override

From: Emanuel Haupt <ehaupt_at_FreeBSD.org>
Date: Wed, 06 Sep 2023 06:34:03 UTC
The branch main has been updated by ehaupt:

URL: https://cgit.FreeBSD.org/ports/commit/?id=90d93d75b9d18e66b76d0b30b9675e7928b93bc5

commit 90d93d75b9d18e66b76d0b30b9675e7928b93bc5
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2023-09-06 06:30:49 +0000
Commit:     Emanuel Haupt <ehaupt@FreeBSD.org>
CommitDate: 2023-09-06 06:31:11 +0000

    sysutils/fusefs-ext2: Allow default_permissions override
    
    The fuse-ext2 program always enables the default_permissions and
    allow_other options. This is wrong. The user should be able to override
    those.
    
    Since upstream appears to be unmaintained (no commits for 3 years),
    patch this bug locally.
    
    PR:             273586
---
 .../fusefs-ext2/files/patch-fuse-ext2_fuse-ext2.c  | 61 ++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/sysutils/fusefs-ext2/files/patch-fuse-ext2_fuse-ext2.c b/sysutils/fusefs-ext2/files/patch-fuse-ext2_fuse-ext2.c
new file mode 100644
index 000000000000..6b12035108f4
--- /dev/null
+++ b/sysutils/fusefs-ext2/files/patch-fuse-ext2_fuse-ext2.c
@@ -0,0 +1,61 @@
+--- fuse-ext2/fuse-ext2.c.orig	2019-05-09 08:29:33 UTC
++++ fuse-ext2/fuse-ext2.c
+@@ -18,15 +18,14 @@
+  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+  */
+ 
++#include <stdbool.h>
+ #include "fuse-ext2.h"
+ 
+ static const char *HOME = "http://github.com/alperakcan/fuse-ext2/";
+ 
+ #if __FreeBSD__ == 10
+-static char def_opts[] = "allow_other,default_permissions,local,";
+ static char def_opts_rd[] = "noappledouble,";
+ #else
+-static char def_opts[] = "allow_other,default_permissions,";
+ static char def_opts_rd[] = "";
+ #endif
+ 
+@@ -171,8 +170,10 @@ static int parse_options (int argc, char *argv[], stru
+ static char * parse_mount_options (const char *orig_opts, struct extfs_data *opts)
+ {
+ 	char *options, *s, *opt, *val, *ret;
++	bool allow_other = true;
++	bool default_permissions = true;
+ 
+-	ret = malloc(strlen(def_opts) + strlen(def_opts_rd) + strlen(orig_opts) + 256 + PATH_MAX);
++	ret = malloc(strlen(def_opts_rd) + strlen(orig_opts) + 256 + PATH_MAX);
+ 	if (!ret) {
+ 		return NULL;
+ 	}
+@@ -231,6 +232,14 @@ static char * parse_mount_options (const char *orig_op
+ #if __FreeBSD__ == 10
+ 			strcat(ret, "force,");
+ #endif
++		} else if (!strcmp(opt, "noallow_other")) {
++			allow_other = false;
++			strcat(ret, opt);
++			strcat(ret, ",");
++		} else if (!strcmp(opt, "nodefault_permissions")) {
++			default_permissions = false;
++			strcat(ret, opt);
++			strcat(ret, ",");
+ 		} else { /* Probably FUSE option. */
+ 			strcat(ret, opt);
+ 			if (val) {
+@@ -246,7 +255,13 @@ static char * parse_mount_options (const char *orig_op
+ 		opts->readonly = 1;
+ 	}
+ 
+-	strcat(ret, def_opts);
++	if (allow_other)
++		strcat(ret, "allow_other,");
++	if (default_permissions)
++		strcat(ret, "default_permissions,");
++#if __FreeBSD__ == 10
++	strcat(ret, "local,");
++#endif
+ 	if (opts->readonly == 1) {
+ 		strcat(ret, def_opts_rd);
+ 		strcat(ret, "ro,");