+ if (*argv_sp && !strcmp(*argv_sp,"-v")) {
+ opt_v=TRUE;
+ argv_sp++;
+ }
+ if (argv_sp[0] && argv_sp[1] && !strcmp(argv_sp[0],"-o")) {
+ argv_sp++;
+ opt_o=*argv_sp++;
+ }
+ if (*argv_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 */
+ popt_table, /* options */
+ 0))) /* flags; && !POPT_CONTEXT_KEEP_FIRST */
+ while (0<=poptGetNextOpt(context));
+ g_error(_("Excessive argument: %s"),*argv_sp);
+ }
+
+ if (opt_o) {
+char *opt_o_spaced=(char */* de-const; length is not changed */)captive_strdup_alloca(opt_o);
+char *s,quote;
+
+ quote=0;
+ for (s=opt_o_spaced;*s;s++) {
+ /* Be compatible with: poptParseArgvString()
+ * which also does not differentiate '"' and "'" */
+ if (*s=='\\' && s[1]) {
+ s++;
+ continue;
+ }
+ if (quote) {
+ if (*s==quote)
+ quote=0;
+ continue;
+ }
+ switch (*s) {
+ case '"':
+ case '\'':
+ quote=*s;
+ continue;
+ case ',':
+ *s=' ';
+ continue;
+ }
+ }
+ 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);
+ /* 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
+ }
+ }
+
+ g_assert(!options.sandbox_server_argv);
+ g_assert(!options.sandbox_server_ior);
+ /* captive_options_free(&options) will: g_free(options.sandbox_server_argv); */
+ /* Allocation is so terrible to be compatible with: captive_options_copy() */
+ options.sandbox_server_argv=g_malloc(2*sizeof(*options.sandbox_server_argv)+strlen(sandbox_server_argv0)+1);
+ options.sandbox_server_argv[0]=(char *)(options.sandbox_server_argv+2);
+ options.sandbox_server_argv[1]=NULL;
+ strcpy(options.sandbox_server_argv[0],sandbox_server_argv0);
+ options.sandbox=TRUE;
+
+ g_assert(!options.bug_pathname);
+ options.bug_pathname=g_strdup(G_STRINGIFY(VARLIBCAPTIVEDIR) "/bug-%FT%T.captivebug.xml.gz");
+
+ options.syslog_facility=DEFAULT_SYSLOG_FACILITY;
+
+ if (opt_o) {
+ /* Do not: POPT_CONTEXT_POSIXMEHARDER
+ * as mount(8) puts there first un-pre-dashed "ro"/"rw" etc. */
+ if (!(context=poptGetContext(
+ PACKAGE, /* name */
+ opt_o_argc,opt_o_argv, /* argc,argv */
+ popt_table, /* options */
+ POPT_CONTEXT_KEEP_FIRST))) /* flags */
+ g_error(_("Error parsing command-line arguments from pre-parsed '-o': %s"),opt_o);
+ if (poptReadDefaultConfig(context,
+ TRUE)) /* useEnv */
+ g_warning(_("Error reading default popt configuration"));
+ while (0<=poptGetNextOpt(context));
+ rest_argv=poptGetArgs(context);