Changeset View
Changeset View
Standalone View
Standalone View
files/0001-fusermount-Support-a-stateless-configuration.patch
- This file was added.
| From a50938bc42da56b8e49b57969d371c064207af36 Mon Sep 17 00:00:00 2001 | |||||
| From: Pierre-Yves <pyu@riseup.net> | |||||
| Date: Tue, 24 Jul 2018 16:07:04 +0200 | |||||
| Subject: [PATCH] fusermount: Support a stateless configuration | |||||
| Signed-off-by: Pierre-Yves <pyu@riseup.net> | |||||
| --- | |||||
| util/fusermount.c | 25 +++++++++++++++++-------- | |||||
| 1 file changed, 17 insertions(+), 8 deletions(-) | |||||
| diff --git a/util/fusermount.c b/util/fusermount.c | |||||
| index 245aeea..e2f6d91 100644 | |||||
| --- a/util/fusermount.c | |||||
| +++ b/util/fusermount.c | |||||
| @@ -38,6 +38,7 @@ | |||||
| #define FUSE_DEV_NEW "/dev/fuse" | |||||
| #define FUSE_VERSION_FILE_OLD "/proc/fs/fuse/version" | |||||
| #define FUSE_CONF "/etc/fuse.conf" | |||||
| +#define SYSTEM_FUSE_CONF "/usr/share/defaults/fuse/fuse.conf" | |||||
| #ifndef MS_DIRSYNC | |||||
| #define MS_DIRSYNC 128 | |||||
| @@ -527,7 +528,7 @@ static void strip_line(char *line) | |||||
| memmove(line, s, strlen(s)+1); | |||||
| } | |||||
| -static void parse_line(char *line, int linenum) | |||||
| +static void parse_line(char *conf_file, char *line, int linenum) | |||||
| { | |||||
| int tmp; | |||||
| if (strcmp(line, "user_allow_other") == 0) | |||||
| @@ -537,12 +538,20 @@ static void parse_line(char *line, int linenum) | |||||
| else if(line[0]) | |||||
| fprintf(stderr, | |||||
| "%s: unknown parameter in %s at line %i: '%s'\n", | |||||
| - progname, FUSE_CONF, linenum, line); | |||||
| + progname, conf_file, linenum, line); | |||||
| } | |||||
| static void read_conf(void) | |||||
| { | |||||
| - FILE *fp = fopen(FUSE_CONF, "r"); | |||||
| + const char *fuse_conf = NULL; | |||||
| + | |||||
| + if (access(FUSE_CONF, F_OK) == 0) { | |||||
| + fuse_conf = FUSE_CONF; | |||||
| + } else { | |||||
| + fuse_conf = SYSTEM_FUSE_CONF; | |||||
| + } | |||||
| + | |||||
| + FILE *fp = fopen(fuse_conf, "r"); | |||||
| if (fp != NULL) { | |||||
| int linenum = 1; | |||||
| char line[256]; | |||||
| @@ -551,12 +560,12 @@ static void read_conf(void) | |||||
| if (isnewline) { | |||||
| if (line[strlen(line)-1] == '\n') { | |||||
| strip_line(line); | |||||
| - parse_line(line, linenum); | |||||
| + parse_line(fuse_conf, line, linenum); | |||||
| } else { | |||||
| isnewline = 0; | |||||
| } | |||||
| } else if(line[strlen(line)-1] == '\n') { | |||||
| - fprintf(stderr, "%s: reading %s: line %i too long\n", progname, FUSE_CONF, linenum); | |||||
| + fprintf(stderr, "%s: reading %s: line %i too long\n", progname, fuse_conf, linenum); | |||||
| isnewline = 1; | |||||
| } | |||||
| @@ -564,11 +573,11 @@ static void read_conf(void) | |||||
| linenum ++; | |||||
| } | |||||
| if (!isnewline) { | |||||
| - fprintf(stderr, "%s: reading %s: missing newline at end of file\n", progname, FUSE_CONF); | |||||
| + fprintf(stderr, "%s: reading %s: missing newline at end of file\n", progname, fuse_conf); | |||||
| } | |||||
| if (ferror(fp)) { | |||||
| - fprintf(stderr, "%s: reading %s: read failed\n", progname, FUSE_CONF); | |||||
| + fprintf(stderr, "%s: reading %s: read failed\n", progname, fuse_conf); | |||||
| exit(1); | |||||
| } | |||||
| fclose(fp); | |||||
| @@ -577,7 +586,7 @@ static void read_conf(void) | |||||
| errno != ENAMETOOLONG && errno != ENOTDIR && | |||||
| errno != EOVERFLOW); | |||||
| fprintf(stderr, "%s: failed to open %s: %s\n", | |||||
| - progname, FUSE_CONF, strerror(errno)); | |||||
| + progname, fuse_conf, strerror(errno)); | |||||
| if (fatal) | |||||
| exit(1); | |||||
| } | |||||
| -- | |||||
| 2.18.0 | |||||
Copyright © 2015-2021 Solus Project. The Solus logo is Copyright © 2016-2021 Solus Project. All Rights Reserved.