Samba Question

Simon Barner barner at in.tum.de
Sun Apr 4 13:12:39 PDT 2004


Darryl Hoar wrote:
> I have Samba installed on a Freebsd 5.1 server.
> I am trying to map a share from a windows machine
> so that I can copy the data.  I can not change the
> windows share name.  It has a space in it.  How
> do I specify the share name in fstab.
> 
> share name:  PSR COMPLETE
> 
> //user at mymachine/PSR COMPLETE  /psrcomplete smbfs  ro,noauto 0  0
> 
> doesn't work.  Can't use quote marks

Hi,

I once had the same problem, and I came up with the following patch:
http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/55539

(I have attached version of the patch that applies to FreeBSD 5.2.1,
otherwise please use the very last version of it (at the bottom of the
problem report page).

The following instructions assume that you have the system sources in
/usr/src

# cd /usr/src
# patch < /path/to/fstab-vis.patch

Now either do a full buildworld cycle, or use the following commands
(untested):

# cd /usr/src/lib/libc
# make depend && make && make install clean
# cd /usr/src/share/man/man5
# make depend && make && make install clean

Now you can encode the spaces with the vis(1) utility:

vis -w
<your mount point goes here><ENTER>

See also the updated fstab(5) man page.

If you try this patch, please tell me, whether it works for you, perhaps
someday I can get it committed.

Regards,
 Simon
-------------- next part --------------
--- lib/libc/gen/fstab.c.orig	Mon Apr  7 14:55:00 2003
+++ lib/libc/gen/fstab.c	Sun Apr  4 21:45:30 2004
@@ -49,6 +49,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <vis.h>
 #include "un-namespace.h"
 
 static FILE *_fs_fp;
@@ -110,6 +111,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()
 {
@@ -128,9 +164,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))
@@ -152,13 +198,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;
--- share/man/man5/fstab.5.orig	Thu Dec 12 18:25:57 2002
+++ share/man/man5/fstab.5	Sun Apr  4 21:46:35 2004
@@ -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
@@ -78,6 +78,19 @@
 .Pq Fa fs_file ,
 describes the mount point for the file system.
 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 ,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: Digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20040404/1275483e/attachment.bin


More information about the freebsd-questions mailing list