Fixed message typo.
[captive.git] / src / client / fuse / main.c
index c018808..114e921 100644 (file)
@@ -57,7 +57,7 @@
 /* FIXME: Dupe with libcaptive/client/options.c */
 #define DEFAULT_SYSLOG_FACILITY LOG_DAEMON
 /* Each element must be preceded by a comma (',')! */
-#define LIBFUSE_ADDONS ",default_permissions,kernel_cache"
+#define LIBFUSE_ADDONS ",default_permissions,allow_other,kernel_cache"
 
 
 CaptiveVfsObject *capfuse_captive_vfs_object;
@@ -106,7 +106,10 @@ struct fuse *capfuse_fuse;
                        &capfuse_mountpoint,    /* mountpoint */
                        &capfuse_multithreaded, /* multithreaded */
                        &capfuse_fd)))  /* fd */
-               g_error(_("FUSE fuse_setup() failed"));
+               g_error(_(
+                               "FUSE fuse_setup() failed!\n"
+                               "You may need Linux kernel 2.6.14 or higher with its 'fuse.ko' enabled.\n"
+                               "You may also need to install or upgrade 'fuse' package to your system."));
        if (fuse_loop(capfuse_fuse)) {
                /* Do not: g_error(_("FUSE fuse_loop() error"));
                 * as it is caused on each umount(8).
@@ -143,14 +146,16 @@ char **sp;
 }
 #endif
 
-       g_log_set_always_fatal(~(0
-                       |G_LOG_LEVEL_MESSAGE
-                       |G_LOG_LEVEL_INFO
-                       |G_LOG_LEVEL_DEBUG
-                       ));
+       /* Do not set g_log_set_always_fatal() here as we would not be able
+        * to restart failed children due to communication-failure alarms.
+        */
 
        captive_standalone_init();
 
+       /* poptGetNextOpt() below requires valid: captive_options */
+       captive_options_init(&options);
+       captive_options=&options;       /* for parsing by 'CAPTIVE_POPT_INCLUDE' */
+
        argv_sp=argv+1;
        if (*argv_sp && (*argv_sp)[0]!='-')
                image_filename=*argv_sp++;
@@ -172,6 +177,7 @@ char **sp;
                /* Lethal path but still give chance for "--help" etc. */
                /* Do not: POPT_CONTEXT_POSIXMEHARDER
                 * as mount(8) puts there first un-pre-dashed "ro"/"rw" etc. */
+               /* poptGetNextOpt() requires valid: captive_options */
                if ((context=poptGetContext(
                                PACKAGE,        /* name */
                                argc,(/*en-const*/const char **)argv,   /* argc,argv */
@@ -210,18 +216,43 @@ char *s,quote;
                        }
                if (poptParseArgvString(opt_o_spaced,&opt_o_argc,&opt_o_argv))
                        g_error(_("Error splitting arguments of the space-reparsed '-o': %s"),opt_o_spaced);
-               /* Pre-dash "ro"/"rw" to let libcaptive to be aware of the mode. */
+               /* Adjust the options for all the subsystems eating the same string vector. */
                for (csp=opt_o_argv;*csp;csp++) {
+                       /* Unsupported mount(8) options not valid for fusermount(8) and causing:
+                        *      fusermount: mount failed: Invalid argument */
+                       if (0
+                                       || !strcmp(*csp,"defaults")
+                                       || !strcmp(*csp,  "auto")
+                                       || !strcmp(*csp,"noauto")
+                                       || !strcmp(*csp,"user")) {
+                               memmove(csp,csp+1,(opt_o_argv+opt_o_argc+1-(csp+1))*sizeof(*csp));
+                               opt_o_argc--;
+                               csp--;
+                               continue;
+                               }
+                       /* Pre-dash "ro"/"rw" to let libcaptive to be aware of the mode.
+                        * We will put the final "ro"/"rw" there again from 'captive_options.rwmode' later. */
                        if (!strcmp(*csp,"ro"))
                                *csp="--ro";
                        if (!strcmp(*csp,"rw"))
                                *csp="--rw";
+                       /* LUFS "uid" and "gid" options should map to FUSE well, I hope. */
+#define STRNCMP_CONST(mem,string) strncmp((mem),(string),strlen((string)))
+                       if (0
+                                       || !STRNCMP_CONST(*csp,"fmask=")
+                                       || !STRNCMP_CONST(*csp,"dmask=")
+                                       || !STRNCMP_CONST(*csp,"channels=")
+                                       || !STRNCMP_CONST(*csp,"root=")
+                                       || !strcmp(*csp,"own_fs")
+                                       || !strcmp(*csp,"quiet")
+                                       || !STRNCMP_CONST(*csp,"dir_cache_ttl=")
+                                       )
+                               g_error(_("Seen obsolete LUFS option \"%s\" - please update your \"/etc/fstab\" for FUSE options instead"),
+                                               *csp);
+#undef STRNCMP_CONST
                        }
                }
 
-       captive_options_init(&options);
-       captive_options=&options;       /* for parsing by 'CAPTIVE_POPT_INCLUDE' */
-
        g_assert(!options.sandbox_server_argv);
        g_assert(!options.sandbox_server_ior);
        /* captive_options_free(&options) will: g_free(options.sandbox_server_argv); */
@@ -284,7 +315,7 @@ const char *fsname;
                else
                        fsname=program_name;
                if (strncmp(fsname,self_prefix,self_prefix_len))
-                       g_error(_("Cannot detected default filesystem name from my basename: %s"),fsname);
+                       g_error(_("Cannot detect default filesystem name from my basename: %s"),fsname);
                fsname+=self_prefix_len;
                if (!captive_options_module_load(&options.filesystem,
                                captive_printf_alloca("%s/%s.sys",G_STRINGIFY(VARLIBCAPTIVEDIR),fsname)))