From owner-freebsd-bugs@FreeBSD.ORG Mon Aug 18 10:50:05 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7FBD837B401 for ; Mon, 18 Aug 2003 10:50:05 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0962F43FE0 for ; Mon, 18 Aug 2003 10:50:05 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h7IHo4Up064569 for ; Mon, 18 Aug 2003 10:50:04 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h7IHo4js064563; Mon, 18 Aug 2003 10:50:04 -0700 (PDT) Date: Mon, 18 Aug 2003 10:50:04 -0700 (PDT) Message-Id: <200308181750.h7IHo4js064563@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Simon Barner Subject: Re: bin/55539: [patch] Parse fstab(5) with spaces in path names X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Simon Barner List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Aug 2003 17:50:05 -0000 The following reply was made to PR bin/55539; it has been noted by GNATS. From: Simon Barner To: freebsd-gnats-submit@FreeBSD.org Cc: Garrett Wollman Subject: Re: bin/55539: [patch] Parse fstab(5) with spaces in path names Date: Mon, 18 Aug 2003 18:24:10 +0200 > It has a number of style bugs. [...] > Indentation. I hope it's style(9) conforming now. I have also updated the fstab(5) man page. > Other than that it looks OK. Thanks for reviewing my work :-) Regards, Simon --- fstab.c.orig Mon Aug 18 10:42:11 2003 +++ fstab.c Mon Aug 18 17:50:17 2003 @@ -53,6 +53,7 @@ #include #include #include +#include static FILE *_fs_fp; static struct fstab _fs_fstab; @@ -84,6 +85,41 @@ _fs_fstab.fs_spec = buf; } +/* + * Converts a string *str, that possibly contains vis(1|3) encoded + * characters (visual representation) into the original form. + * See also: unvis(1|3) + * + * Return values: 0 on success, 1 otherwise + */ +int unescape (char *str) { + int state = 0; + char out, *s = str, *t = str; + + if (str == NULL) + return 1; + + while (*s != '\0') { + again: + switch(unvis(&out, *s, &state, 0)) { + case 0: + case UNVIS_NOCHAR: + break; + case UNVIS_VALID: + *t++ = out; + break; + case UNVIS_VALIDPUSH: + *t++ = out; + goto again; + case UNVIS_SYNBAD: + return 1; + } + ++s; + } + *t = '\0'; + return 0; +} + static int fstabscan() { @@ -102,9 +138,19 @@ if (*line == '#' || *line == '\n') continue; if (!strpbrk(p, " \t")) { - _fs_fstab.fs_spec = strsep(&p, ":\n"); - _fs_fstab.fs_file = strsep(&p, ":\n"); + cp = strsep(&p, ":\n"); + if (!unescape (cp)) + _fs_fstab.fs_spec = cp; + else + goto bad; + + cp = strsep(&p, ":\n"); + if (!unescape (cp)) + _fs_fstab.fs_file = cp; + else + goto bad; fixfsfile(); + _fs_fstab.fs_type = strsep(&p, ":\n"); if (_fs_fstab.fs_type) { if (!strcmp(_fs_fstab.fs_type, FSTAB_XX)) @@ -126,13 +172,21 @@ /* OLD_STYLE_FSTAB */ while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') ; - _fs_fstab.fs_spec = cp; + if (!unescape (cp)) + _fs_fstab.fs_spec = cp; + else + goto bad; if (!_fs_fstab.fs_spec || *_fs_fstab.fs_spec == '#') continue; + while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') ; - _fs_fstab.fs_file = cp; + if (!unescape (cp)) + _fs_fstab.fs_file = cp; + else + goto bad; fixfsfile(); + while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') ; _fs_fstab.fs_vfstype = cp; --- fstab.5.orig Mon Aug 18 17:50:43 2003 +++ fstab.5 Mon Aug 18 18:17:48 2003 @@ -10,7 +10,7 @@ .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: +.\" must display the following acknowledgment: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors @@ -79,6 +79,19 @@ describes the mount point for the filesystem. For swap partitions, this field should be specified as ``none''. .Pp +Both the +.Fa fs_spec +and the +.Fa fs_file +field may contain white spaces, that must be encoded in a +.Xr vis 1 compatible way (you can run ``vis -wc'' or ``vis -w'' to +encode the path names properly). +Despite this ability to handle path names with with spaces, system +administrators should avoid them wherever possible in order to keep +file system and mount point specifications simple and clean. +It is only only intended to provide compatibility with systems, +where white spaces in path names are common (mostly SMB/CIFS shares). +.Pp The third field, .Pq Fa fs_vfstype , describes the type of the filesystem. @@ -109,6 +122,8 @@ .\" maybe also say Rock Ridge extensions are handled ? .It Em procfs a file system for accessing process data +.It Em smbfs +SMB/CIFS compatible network shares .El .Pp The fourth field,