summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstefanf <stefanf@FreeBSD.org>2012-10-11 07:54:29 +0000
committerstefanf <stefanf@FreeBSD.org>2012-10-11 07:54:29 +0000
commit054e35b9ef9943ad6326092f93b873b1495d9540 (patch)
treeb05b06e22059a3f54deb614bdf39816c4f4355e5
parent1ae38f4b7e17061a85721eef3680d89b8ecb16f4 (diff)
downloadFreeBSD-src-054e35b9ef9943ad6326092f93b873b1495d9540.zip
FreeBSD-src-054e35b9ef9943ad6326092f93b873b1495d9540.tar.gz
Decode the first two fstab fields with strunvis(3). This allows having spaces
in devices and mount paths, encoded as \s or \040. PR: bin/117687 Submitted by: Martin Kammerhofer Discussed on: arch
-rw-r--r--lib/libc/gen/fstab.c5
-rw-r--r--share/man/man5/fstab.511
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c
index 356b871..1351a27 100644
--- a/lib/libc/gen/fstab.c
+++ b/lib/libc/gen/fstab.c
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <vis.h>
#include "un-namespace.h"
static FILE *_fs_fp;
@@ -149,11 +150,15 @@ fstabscan(void)
/* OLD_STYLE_FSTAB */
while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0')
;
+ if (strunvis(cp, cp) < 0)
+ goto bad;
_fs_fstab.fs_spec = cp;
if (!_fs_fstab.fs_spec || *_fs_fstab.fs_spec == '#')
continue;
while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0')
;
+ if (strunvis(cp, cp) < 0)
+ goto bad;
_fs_fstab.fs_file = cp;
fixfsfile();
while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0')
diff --git a/share/man/man5/fstab.5 b/share/man/man5/fstab.5
index 060d57c..d516767 100644
--- a/share/man/man5/fstab.5
+++ b/share/man/man5/fstab.5
@@ -32,7 +32,7 @@
.\" @(#)fstab.5 8.1 (Berkeley) 6/5/93
.\" $FreeBSD$
.\"
-.Dd June 7, 2011
+.Dd October 11, 2012
.Dt FSTAB 5
.Os
.Sh NAME
@@ -66,12 +66,20 @@ The first field,
.Pq Fa fs_spec ,
describes the special device or
remote file system to be mounted.
+The contents are decoded by the
+.Xr strunvis 3
+function.
+This allows using spaces or tabs in the device name which would be
+interpreted as field separators otherwise.
.Pp
The second field,
.Pq Fa fs_file ,
describes the mount point for the file system.
For swap partitions, this field should be specified as
.Dq none .
+The contents are decoded by the
+.Xr strunvis 3
+function, as above.
.Pp
The third field,
.Pq Fa fs_vfstype ,
@@ -338,6 +346,7 @@ resides in
.Xr mount 8 ,
.Xr quotacheck 8 ,
.Xr quotaon 8 ,
+.Xr strunvis 3 ,
.Xr swapon 8 ,
.Xr umount 8
.Sh HISTORY
OpenPOWER on IntegriCloud