/me should learn to differ between script-languages and C... strings in C are still...
[util-vserver.git] / util-vserver / src / secure-mount.c
1 // $Id$    --*- c++ -*--
2
3 // Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
4 //  
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; version 2 of the License.
8 //  
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //  
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18
19   // secure-mount <general mount(8) options> [--chroot]
20   //              [--mtab <mtabfile>] [--fstab <fstabfile>]
21   //
22   // Executes mount-operations under the current directory: it assumes sources
23   // in the current root-dir while destinations are expected in the chroot
24   // environment.
25
26
27 #ifdef HAVE_CONFIG_H
28 #  include <config.h>
29 #endif
30
31 #include "util.h"
32 #include "pathconfig.h"
33
34 #include <lib/internal.h>
35
36 #include <getopt.h>
37 #include <fcntl.h>
38 #include <errno.h>
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <string.h>
42 #include <strings.h>
43 #include <unistd.h>
44 #include <stdbool.h>
45 #include <sys/mount.h>
46 #include <sys/stat.h>
47 #include <sys/types.h>
48 #include <sys/file.h>
49 #include <linux/fs.h>
50 #include <assert.h>
51 #include <ctype.h>
52 #include <sys/wait.h>
53 #include <libgen.h>
54 #include <signal.h>
55
56 #define ENSC_WRAPPERS_FCNTL     1
57 #include <wrappers.h>
58
59 #define MNTPOINT        "/etc"
60
61 typedef enum { rfsYES, rfsNO, rfsONLY }         RootFsOption;
62
63 struct MountInfo {
64     char const *        src;
65     char const *        dst;
66     char const *        type;
67     unsigned long       flag;
68     unsigned long       xflag;
69     unsigned long       mask;
70     char *              data;
71 };
72
73 struct Options {
74     char const *        mtab;
75     char const *        fstab;
76     bool                do_chroot;
77     bool                ignore_mtab;
78     bool                mount_all;
79     RootFsOption        rootfs;
80
81     int                 cur_dir_fd;
82     int                 cur_rootdir_fd;
83 };
84
85 #define OPTION_BIND     1024
86 #define OPTION_MOVE     1025
87 #define OPTION_MTAB     1026
88 #define OPTION_FSTAB    1027
89 #define OPTION_CHROOT   1028
90 #define OPTION_SECURE   1029
91 #define OPTION_RBIND    1030
92 #define OPTION_ROOTFS   1031
93
94 #define XFLAG_NOAUTO    0x01
95
96 static struct option const
97 CMDLINE_OPTIONS[] = {
98   { "help",    no_argument,       0, 'h' },
99   { "version", no_argument,       0, 'v' },
100   { "bind",    no_argument,       0, OPTION_BIND },
101   { "move",    no_argument,       0, OPTION_MOVE },
102   { "mtab",    required_argument, 0, OPTION_MTAB },
103   { "fstab",   required_argument, 0, OPTION_FSTAB },
104   { "rootfs",  required_argument, 0, OPTION_ROOTFS },
105   { "chroot",  no_argument,       0, OPTION_CHROOT },
106   { "secure",  no_argument,       0, OPTION_SECURE },
107   { "rbind",   no_argument,       0, OPTION_RBIND },
108   { 0, 0, 0, 0 }
109 };
110
111 #ifndef MS_REC
112 #  define MS_REC        0x4000
113 #endif
114
115 static struct FstabOption {
116     char const * const  opt;
117     unsigned long const         flag;
118     unsigned long const         mask;
119     unsigned long const         xflag;
120     bool const                  is_dflt;
121 } const FSTAB_OPTIONS[] = {
122   { "defaults",   0,             (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|
123                                   MS_SYNCHRONOUS), 0, false },
124   { "rbind",      MS_BIND|MS_REC, MS_BIND|MS_REC,  0, false },
125   { "bind",       MS_BIND,        MS_BIND,         0, false },
126   { "move",       MS_MOVE,        MS_MOVE,         0, false },
127   { "async",      0,              MS_SYNCHRONOUS,  0, false },
128   { "sync",       MS_SYNCHRONOUS, MS_SYNCHRONOUS,  0, false },
129   { "atime",      0,              MS_NOATIME,      0, false },
130   { "noatime",    MS_NOATIME,     MS_NOATIME,      0, false },
131   { "dev",        0,              MS_NODEV,        0, false },
132   { "nodev",      MS_NODEV,       MS_NODEV,        0, false },
133   { "exec",       0,              MS_NOEXEC,       0, false },
134   { "noexec",     MS_NOEXEC,      MS_NOEXEC,       0, false },
135   { "suid",       0,              MS_NOSUID,       0, false },
136   { "nosuid",     MS_NOSUID,      MS_NOSUID,       0, false },
137   { "ro",         MS_RDONLY,      MS_RDONLY,       0, false },
138   { "rw",         0,              MS_RDONLY,       0, false },
139   
140   { "remount",    MS_REMOUNT,     MS_REMOUNT,      0, false },
141   { "users",      MS_NOEXEC|MS_NOSUID|MS_NODEV,
142                   MS_NOEXEC|MS_NOSUID|MS_NODEV,    0, false },
143   { "mandlock",   MS_MANDLOCK,    MS_MANDLOCK,     0, false },
144   { "nodiratime", MS_NODIRATIME,  MS_NODIRATIME,   0, false },
145 #ifdef MS_DIRSYNC  
146   { "dirsync",    MS_DIRSYNC,     MS_DIRSYNC,      0, false },
147 #endif
148   { "_netdev",    0,              0,               0, false },
149   { "auto",       0,              0,               0, false },
150   { "noauto",     0,              0,               XFLAG_NOAUTO, false },
151   { "user",       0,              0,               0, false },
152   { "nouser",     0,              0,               0, false },
153 };
154
155 int                     wrapper_exit_code = 1;
156
157 static void
158 showHelp(int fd, char const *cmd, int res)
159 {
160   VSERVER_DECLARE_CMD(cmd);
161   
162   WRITE_MSG(fd, "Usage:  ");
163   WRITE_STR(fd, cmd);
164   WRITE_MSG(fd,
165             " [--help] [--version] [--bind] [--move] [--rbind] [-t <type>] [--chroot]\n"
166             "            [--mtab <filename>] [--fstab <filename>] [--rootfs yes|no|only]\n"
167             "            [-n] -a|([-o <options>] [--] <src> <dst>)\n\n"
168             "Executes mount-operations under the current directory: it assumes sources in\n"
169             "the current root-dir while destinations are expected in the chroot environment.\n\n"
170             "For non-trivial mount-operations it uses the external 'mount' program which\n"
171             "can be overridden by the $MOUNT environment variable.\n\n"
172             "Options:\n"
173             "  --bind|move|rbind        ...  set the correspond flags; with this options\n"
174             "                                the mount will be executed internally without\n"
175             "                                calling an external mount program.\n"
176             "  -t <type>                ...  assume the given filesystem type\n"
177             "  -o <options>             ...  set additional options; see mount(2) for details\n"
178             "  -n                       ...  do not update the mtab-file\n"
179             "  --mtab <filename>        ...  use <filename> as an alternative mtab file\n"
180             "                                [default: /etc/mtab]\n"
181             "  --chroot                 ...  chroot into the current directory before\n"
182             "                                mounting the filesystem\n"
183             "  --fstab <filename>       ...  use <filename> as an alternative fstab file;\n"
184             "                                this option has an effect only with the '-a'\n"
185             "                                option [default: /etc/fstab]\n"
186             "  --rootfs yes|no|only     ...  specifies how to handle an entry for a rootfs\n"
187             "                                ('/') when processing an fstab file. 'yes' will\n"
188             "                                mount it among the other entries, 'only' will\n"
189             "                                mount only the rootfs entry, and 'no' will ignore\n"
190             "                                it and mount only the other entries [default: yes]\n"
191             "  -a                       ...  mount everything listed in the fstab-file\n\n"
192             "  <src>                    ...  the source-filesystem; this path is absolute\n"
193             "                                to the current root-filesystem. Only valid\n"
194             "                                without the '-a' option.\n"
195             "  <dst>                    ...  the destination mount-point; when used with\n"
196             "                                '--chroot', this path is relative to the current\n"
197             "                                directory. Only valid without the '-a' option\n\n"
198             "Please report bugs to " PACKAGE_BUGREPORT "\n");
199
200   exit(res);
201 }
202
203 static void
204 showVersion()
205 {
206   WRITE_MSG(1,
207             "secure-mount " VERSION " -- secure mounting of directories\n"
208             "This program is part of " PACKAGE_STRING "\n\n"
209             "Copyright (C) 2003 Enrico Scholz\n"
210             VERSION_COPYRIGHT_DISCLAIMER);
211   exit(0);
212 }
213
214 inline static bool
215 isSameObject(struct stat const *lhs,
216              struct stat const *rhs)
217 {
218   return (lhs->st_dev==rhs->st_dev &&
219           lhs->st_ino==rhs->st_ino);
220 }
221
222 static int
223 fchroot(int fd)
224 {
225   if (fchdir(fd)==-1 || chroot(".")==-1) return -1;
226   return 0;
227 }
228
229 static int
230 writeX(int fd, void const *buf, size_t len)
231 {
232   if ((size_t)(write(fd, buf, len))!=len) return -1;
233   return 0;
234 }
235
236 static int
237 writeStrX(int fd, char const *str)
238 {
239   return writeX(fd, str, strlen(str));
240 }
241
242 static inline char const *
243 getType(struct MountInfo const *mnt)
244 {
245   if (mnt->type==0)                         return "none";
246   else if (strncmp(mnt->type, "ext", 3)==0) return "ufs";
247   else                                      return mnt->type;
248 }
249
250 inline static void
251 restoreRoot(struct Options const *opt)
252 {
253   if (opt->do_chroot!=0 && fchroot(opt->cur_rootdir_fd)==-1) {
254     perror("secure-mount: fchdir(\"/\")");
255     WRITE_MSG(2, "Failed to restore root-directory; aborting\n");
256     exit(1);
257   }
258 }
259
260 static int
261 updateMtab(struct MountInfo const *mnt, struct Options const *opt)
262 {
263   int           res = -1;
264   int           fd;
265   assert(opt->mtab!=0);
266
267   if (opt->do_chroot && fchroot(opt->cur_dir_fd)==-1) {
268       perror("secure-mount: fchroot(\".\")");
269       return -1;
270   }
271
272   fd=open(opt->mtab, O_CREAT|O_APPEND|O_WRONLY, 0644);
273   
274   if (fd==-1) {
275     perror("secure-mount: open(<mtab>)");
276     goto err0;
277   }
278
279   if (flock(fd, LOCK_EX)==-1) {
280     perror("secure-mount: flock()");
281     goto err1;
282   }
283
284   if (writeStrX(fd, mnt->src)==-1 ||
285       writeStrX(fd, " ")==-1 ||
286       writeStrX(fd, mnt->dst)==-1 ||
287       writeStrX(fd, " ")==-1 ||
288       writeStrX(fd, getType(mnt))==-1 ||
289       writeStrX(fd, " ")==-1 ||
290       writeStrX(fd, mnt->data ? mnt->data : "defaults")==-1 ||
291       writeStrX(fd, " 0 0\n")==-1) {
292     perror("secure-mount: write()");
293     goto err1;
294   }
295
296   res = 0;
297
298   err1: close(fd);
299   err0:
300   restoreRoot(opt);
301   return res;
302 }
303
304 static bool
305 callExternalMount(struct MountInfo const *mnt)
306 {
307   char const *  argv[10];
308   size_t        idx = 0;
309   pid_t         pid;
310   int           status;
311   char const *  mount_prog = getenv("MOUNT");
312
313   if (mount_prog==0) mount_prog = MOUNT_PROG;
314
315   argv[idx++] = mount_prog;
316   argv[idx++] = "-n";
317   if      (mnt->flag & MS_BIND) argv[idx++] = "--bind";
318   else if (mnt->flag & MS_MOVE) argv[idx++] = "--move";
319
320   argv[idx++] = "-o";
321   if (mnt->data && *mnt->data &&
322       strcmp(mnt->data, "defaults")!=0) {
323     if (mnt->mask & MS_NODEV)
324       argv[idx++] = mnt->data;
325     else {
326       char *    tmp = alloca(strlen(mnt->data) + sizeof("nodev,"));
327       strcpy(tmp, "nodev,");
328       strcat(tmp, mnt->data);
329       argv[idx++] = tmp;
330     }
331   }
332   else
333     argv[idx++] = "nodev";
334
335   if (mnt->type) {
336     argv[idx++] = "-t";
337     argv[idx++] = mnt->type;
338   }
339
340   argv[idx++] = mnt->src;
341   argv[idx++] = ".";
342   argv[idx]   = 0;
343
344   pid = fork();
345   if (pid==-1) {
346     perror("secure-mount: fork()");
347     return false;
348   }
349
350   if (pid==0) {
351     execv(mount_prog, const_cast(char **)(argv));
352     PERROR_Q("secure-mount: execv", mount_prog);
353     exit(1);
354   }
355
356   if (wait4(pid, &status, 0, 0)==-1) {
357     perror("secure-mount: wait4()");
358     return false;
359   }
360
361   return (WIFEXITED(status)) && (WEXITSTATUS(status)==0);
362 }
363
364 inline static bool
365 secureChdir(char const *dir, struct Options const *opt)
366 {
367   int           dir_fd;
368   bool          res = false;
369   
370   if (opt->do_chroot!=0 && fchroot(opt->cur_dir_fd)==-1) {
371     perror("secure-mount: fchroot(\".\")");
372     return false;
373   }
374
375   if (chdir(dir)==-1) {
376     PERROR_Q("secure-mount: chdir", dir);
377     goto err;
378   }
379
380   dir_fd = open(".", O_RDONLY|O_DIRECTORY);
381   if (dir_fd==-1) {
382     perror("secure-mount: open(\".\")");
383     goto err;
384   }
385
386   restoreRoot(opt);
387   if (fchdir(dir_fd)==-1)
388     PERROR_Q("secure-mount: fchdir", dir);
389   else
390     res = true;
391   
392   close(dir_fd);
393   return res;
394
395   err:
396   restoreRoot(opt);
397   return false;
398 }
399
400 static bool
401 mountSingle(struct MountInfo const *mnt, struct Options const *opt)
402 {
403   assert(mnt->dst!=0);
404   
405   if (!secureChdir(mnt->dst, opt))
406     return false;
407
408   if (mnt->flag & (MS_BIND|MS_MOVE)) {
409     if (mount(mnt->src, ".",
410               mnt->type ? mnt->type : "",
411               mnt->flag,  mnt->data)==-1) {
412       perror("secure-mount: mount()");
413       return false;
414     }
415   }
416   else if (!callExternalMount(mnt))
417     return false;
418
419   if (!opt->ignore_mtab &&
420       updateMtab(mnt, opt)==-1) {
421     WRITE_MSG(2, "Failed to update mtab-file\n");
422       // no error
423   }
424   
425   return true;
426 }
427
428 static struct FstabOption const *
429 searchOption(char const *opt, size_t len)
430 {
431   struct FstabOption const *            i;
432   for (i=FSTAB_OPTIONS+0; i<FSTAB_OPTIONS+DIM_OF(FSTAB_OPTIONS); ++i)
433     if (strncmp(i->opt, opt, len)==0) return i;
434
435   return 0;
436 }
437
438 static bool
439 transformOptionList(struct MountInfo *info, size_t UNUSED *col)
440 {
441   char const *                  ptr = info->data;
442
443   do {
444     char const *                pos = strchr(ptr, ',');
445     struct FstabOption const *  opt;
446     
447     if (pos==0) pos = ptr+strlen(ptr);
448     opt = searchOption(ptr, pos-ptr);
449
450     if (opt!=0) {
451       info->flag  &= ~opt->mask;
452       info->flag  |=  opt->flag;
453       info->mask  |=  opt->mask;
454       info->xflag |=  opt->xflag;
455     }
456
457     if (*pos!='\0')
458       ptr = pos+1;
459     else
460       ptr = pos;
461
462   } while (*ptr!='\0');
463
464   return true;
465 }
466
467 #define MOVE_TO_NEXT_FIELD(PTR,ALLOW_EOL)               \
468   while (!isspace(*PTR) && *PTR!='\0') ++PTR;           \
469   if (col) *col = buf-start_buf+1;                      \
470   if (!(ALLOW_EOL) && *PTR=='\0') return prFAIL;        \
471   *PTR++ = '\0';                                        \
472   while (isspace(*PTR)) ++PTR
473
474 static enum {prDOIT, prFAIL, prIGNORE}
475   parseFstabLine(struct MountInfo *info, char *buf, size_t *col)
476 {
477   char const * const    start_buf = buf;
478   size_t                err_col;
479
480   while (isspace(*buf)) ++buf;
481   if (*buf=='#' || *buf=='\0')  return prIGNORE;
482
483   info->src  = buf;
484   MOVE_TO_NEXT_FIELD(buf, false);
485   info->dst  = buf;
486   MOVE_TO_NEXT_FIELD(buf, false);
487   info->type = buf;
488   MOVE_TO_NEXT_FIELD(buf, false);
489   err_col    = buf-start_buf+1;
490   info->data = buf;
491   MOVE_TO_NEXT_FIELD(buf, true);
492
493   if (strcmp(info->type, "swap")==0) return prIGNORE;
494   if (strcmp(info->type, "none")==0) info->type = 0;
495
496   info->flag  = MS_NODEV;
497   info->mask  = 0;
498   info->xflag = 0;
499   if (col) *col = err_col;
500   if (!transformOptionList(info,col)) return prFAIL;
501   if (info->xflag & XFLAG_NOAUTO)     return prIGNORE;
502
503   return prDOIT;
504 }
505
506 #undef MOVE_TO_NEXT_FIELD
507
508 static void
509 showFstabPosition(int fd, char const *fname, size_t line_nr, size_t col_nr)
510 {
511   char          buf[3*sizeof(line_nr)*2 + 4];
512   size_t        len = utilvserver_fmt_uint(buf+1, line_nr)+1;
513   
514   buf[0]     = ':';
515   buf[len++] = ':';
516   len += utilvserver_fmt_uint(buf+len, col_nr);
517   WRITE_STR(fd, fname);
518   write(fd, buf, len);
519 }
520
521
522 static bool
523 mountFstab(struct Options const *opt)
524 {
525   bool          res = false;
526   int           fd;
527   off_t         len;
528
529   assert(opt->fstab!=0);
530   fd = open(opt->fstab, O_RDONLY);
531   if (fd==-1) {
532     perror("secure-mount: open(<fstab>)");
533     goto err0;
534   }
535
536   len = lseek(fd, 0, SEEK_END); 
537   if (len==-1 ||
538       lseek(fd, 0, SEEK_SET)==-1) {
539     perror("secure-mount: lseek(<fstab>)");
540     goto err1;
541   }
542
543   {
544     char        buf[len+2];
545     char        *ptr, *ptrptr;
546     size_t      line_nr=0, col_nr;
547
548     if (read(fd, buf, len+1)!=len) {
549       perror("secure-mount: read()");
550       goto err1;
551     }
552     buf[len]   = '#';   // workaround for broken dietlibc strtok_r()
553                         // implementation
554     buf[len+1] = '\0';
555     ptrptr     = buf;
556
557     while ((ptr=strsep(&ptrptr, "\n")) != 0) {
558       struct MountInfo  mnt;
559       ++line_nr;
560
561       switch (parseFstabLine(&mnt, ptr, &col_nr)) {
562         case prFAIL     :
563           showFstabPosition(2, opt->fstab, line_nr, col_nr);
564           WRITE_MSG(2, ": syntax error\n");
565           goto err1;
566
567         case prIGNORE   :  break;
568         case prDOIT     : {
569           bool          is_rootfs = (strcmp(mnt.dst, "/")==0);
570           chdir("/");
571           if (( is_rootfs && opt->rootfs==rfsNO) ||
572               (!is_rootfs && opt->rootfs==rfsONLY)) { /* ignore the entry */ }
573           else if (!mountSingle(&mnt, opt)) {
574             showFstabPosition(2, opt->fstab, line_nr, 1);
575             WRITE_MSG(2, ": failed to mount fstab-entry\n");
576           }
577           break;
578         }
579         default         :
580           assert(false);
581       }
582     }
583   }
584
585   res = true;
586
587   err1: close(fd);
588   err0: return res;
589 }
590
591 static void
592 initFDs(struct Options *opt)
593 {
594   opt->cur_dir_fd     = Eopen(".", O_RDONLY|O_DIRECTORY, 0);
595   opt->cur_rootdir_fd = Eopen("/", O_RDONLY|O_DIRECTORY, 0);
596
597   Efcntl(opt->cur_dir_fd,     F_SETFD, FD_CLOEXEC);
598   Efcntl(opt->cur_rootdir_fd, F_SETFD, FD_CLOEXEC);
599 }
600
601 static RootFsOption
602 parseRootFS(char const *str)
603 {
604   if      (strcasecmp(str, "yes")==0)  return rfsYES;
605   else if (strcasecmp(str, "no")==0)   return rfsNO;
606   else if (strcasecmp(str, "only")==0) return rfsONLY;
607   else {
608     WRITE_MSG(2, "secure-mount: invalid option for '--rootfs': '");
609     WRITE_STR(2, str);
610     WRITE_MSG(2, "'\n");
611     exit(wrapper_exit_code);
612   }
613 }
614
615 int main(int argc, char *argv[])
616 {
617   struct MountInfo      mnt = {
618     .src         = 0,
619     .dst         = 0,
620     .type        = 0,
621     .flag        = 0,
622     .xflag       = 0,
623     .data        = 0,
624   };
625
626   struct Options        opt = {
627     .mtab           = "/etc/mtab",
628     .fstab          = "/etc/fstab",
629     .do_chroot      = 0,
630     .ignore_mtab    = false,
631     .mount_all      = false,
632     .cur_dir_fd     = -1,
633     .cur_rootdir_fd = -1,
634     .rootfs         = rfsYES
635   };
636
637   while (1) {
638     int         c = getopt_long(argc, argv, "ht:nao:", CMDLINE_OPTIONS, 0);
639     if (c==-1) break;
640     
641     switch (c) {
642       case 'h'          :  showHelp(1, argv[0], 0);
643       case 'v'          :  showVersion();
644       case 't'          :  mnt.type = optarg;         break;
645       case 'n'          :  opt.ignore_mtab = true;    break;
646       case 'a'          :  opt.mount_all   = true;    break;
647       case 'o'          :  mnt.data        = optarg;  break;
648       case OPTION_RBIND :  mnt.flag       |= MS_REC;  /*@fallthrough@*/
649       case OPTION_BIND  :  mnt.flag       |= MS_BIND; break;
650       case OPTION_MOVE  :  mnt.flag       |= MS_MOVE; break;
651       case OPTION_MTAB  :  opt.mtab        = optarg;  break;
652       case OPTION_FSTAB :  opt.fstab       = optarg;  break;
653       case OPTION_CHROOT:  opt.do_chroot   = true;    break;
654       case OPTION_ROOTFS:  opt.rootfs      = parseRootFS(optarg); break;
655       case OPTION_SECURE:
656         WRITE_MSG(2, "secure-mount: The '--secure' option is deprecated...\n");
657         break;
658       default           :
659         WRITE_MSG(2, "Try '");
660         WRITE_STR(2, argv[0]);
661         WRITE_MSG(2, " --help\" for more information.\n");
662         return EXIT_FAILURE;
663         break;
664     }
665   }
666
667
668   if (opt.mount_all && optind<argc) {
669     WRITE_MSG(2, "Can not specify <src> and '-a' at the same time\n");
670     return EXIT_FAILURE;
671   }
672
673   initFDs(&opt);
674   signal(SIGCHLD, SIG_DFL);
675   
676   if (opt.mount_all) {
677     if (!mountFstab(&opt)) return EXIT_FAILURE;
678     else                   return EXIT_SUCCESS;
679   }
680
681   if (optind+2!=argc) {
682     WRITE_MSG(2, "Invalid <src> <dst> pair specified\n");
683     return EXIT_FAILURE;
684   }
685
686   if (mnt.data) {
687     mnt.data = strdup(mnt.data);
688     if (!transformOptionList(&mnt, 0)) {
689       WRITE_MSG(2, "Invalid options specified\n");
690       return EXIT_FAILURE;
691     }
692   }
693     
694   mnt.src  = argv[optind++];
695   mnt.dst  = argv[optind++];
696
697   if (!mountSingle(&mnt, &opt)) return EXIT_FAILURE;
698     
699   return EXIT_SUCCESS;
700 }