Bug 192968 - [autofs] map syntax should allow embedding whitespace or hash sign
Summary: [autofs] map syntax should allow embedding whitespace or hash sign
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Edward Tomasz Napierala
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-24 14:59 UTC by Jan Beich
Modified: 2015-07-08 18:02 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer freebsd_triage 2014-08-24 14:59:05 UTC
Trying to use special_smb (see bug 192852 comment 5) I've noticed accessing shares doesn't work if they contain spaces (common for Windows). Adding \ or "" doesn't help. There's just no way to escape characters. At least fstab(5) allows using \040 or any other C-style sequence.

$ cat /etc/auto_master
/smb		-smb

$ /etc/autofs/special_smb somehost 2>/dev/null
/Virtual Images -fstype=smbfs,-N,-U=,-I=somehost       ://somehost/Virtual Images /Shared Documents       -fstype=smbfs,-N,-U=,-I=somehost       ://somehost/Shared Documents

$ ls /smb/somehost
load: 0.11  cmd: ls 92899 [autofscv] 1.35r 0.00u 0.00s 0% 2824k
^C

$ automountd -d
automountd: waiting for request from the kernel
automountd: not forking due to -d flag; will exit after servicing a single request
automountd: got request 254: from map -smb, path /smb/, prefix "/smb", key "somehost", options ""
automountd: parsing map "-smb"
automountd: executing "/etc/autofs/special_smb somehost" as pid 87751
automountd: "/etc/autofs/special_smb somehost", pid 87751, terminated gracefully
automountd: found node defined at [kernel request]:0; not a mountpoint
automountd: creating subtree at /smb
automountd: creating subtree at /smb/somehost
automountd: directory /smb/somehost does not exist, creating
automountd: creating subtree at /smb/somehost/Virtual
automountd: directory /smb/somehost/Virtual does not exist, creating
automountd: creating subtree at /smb/somehost
automountd: creating subtree at /smb/somehost
automountd: creating subtree at /smb/somehost/Shared
automountd: directory /smb/somehost/Shared does not exist, creating
automountd: creating subtree at /smb/somehost
automountd: creating subtree at /smb/somehost
automountd: nothing to mount; exiting
automountd: completing request 254 with error 0

Other systems appear to support escaping to some degree.

http://docs.oracle.com/cd/E23823_01/html/816-4555/rfsrefer-98.html
https://developer.apple.com/library/mac/documentation/Darwin/Reference/Manpages/man5/auto_master.5.html
Comment 1 Jan Beich freebsd_committer freebsd_triage 2014-08-24 15:55:16 UTC
Test case:

$ cat /etc/auto_master
/foo    auto_foo

$ cat /etc/auto_foo
Long\ Name -fstype=nullfs :/&

$ ls -F /foo
Long\/

$ automountd -d
automountd: waiting for request from the kernel
automountd: not forking due to -d flag; will exit after servicing a single request
automountd: got request 363: from map auto_foo, path /foo/, prefix "/foo", key "", options ""
automountd: parsing map "auto_foo"
automountd: map "auto_foo" maps to "/etc/auto_foo"
automountd: done parsing map "auto_foo"
automountd: found node defined at [kernel request]:0; not a mountpoint
automountd: creating subtree at /foo
automountd: creating subtree at /foo/Long\134
automountd: directory /foo/Long\134 does not exist, creating
automountd: creating subtree at /foo/Long\134
automountd: creating subtree at /foo/Long\134
automountd: nothing to mount; exiting
automountd: completing request 363 with error 0

$ cat /etc/auto_foo
foo\#bar -fstype=nullfs :/&

$ ls -F /foo
load: 0.24  cmd: ls 5515 [autofs_retry] 0.83r 0.00u 0.00s 0% 2824k
^C

$ automountd -d
automountd: waiting for request from the kernel
automountd: not forking due to -d flag; will exit after servicing a single request
automountd: got request 364: from map auto_foo, path /foo/, prefix "/foo", key "", options ""
automountd: parsing map "auto_foo"
automountd: map "auto_foo" maps to "/etc/auto_foo"
automountd: truncated entry at auto_foo, line 2
automountd: completing request 364 with error 5

$ cat /etc/auto_master
/-    auto_foo

$ cat /etc/auto_foo
/mnt -fstype=nullfs :/Disk\ \#555

$ ls -F /mnt

$ automountd -d
automountd: waiting for request from the kernel
automountd: not forking due to -d flag; will exit after servicing a single request
automountd: got request 373: from map auto_foo, path /mnt/, prefix "/", key "", options ""
automountd: parsing map "auto_foo"
automountd: map "auto_foo" maps to "/etc/auto_foo"
automountd: done parsing map "auto_foo"
automountd: found node defined at auto_foo:1; it is a mountpoint
automountd: executing "mount -t nullfs -o automounted /Disk\134 /mnt/" as pid 5861
mount_nullfs: /Disk\: No such file or directory
automountd: "mount -t nullfs -o automounted /Disk\134 /mnt/", pid 5861, terminated with exit status 64
automountd: mount failed
automountd: completing request 373 with error 5
Comment 2 Jan Beich freebsd_committer freebsd_triage 2014-08-24 18:35:14 UTC
Another interesting real example:

  mntpoint -fstype=fuse,allow_other :sshfs\#user@example.com\:/path/to/mount

on FreeBSD would look

  mntpoint -fstype=whatever,allow_other,mountprog=/usr/local/bin/sshfs :user@example.com\:/path/to/mount

or with private keys of ~foo/.ssh

  mntpoint -fstype=whatever,allow_other,ssh_command="sudo -u foo ssh",mountprog=/usr/local/bin/sshfs :user@example.com\:/path/to/mount

https://help.ubuntu.com/community/Autofs

$ automountd -d
automountd: waiting for request from the kernel
automountd: not forking due to -d flag; will exit after servicing a single request
automountd: got request 16: from map auto_media, path /media/mntpoint/, prefix "/media", key "mntpoint", options ""
automountd: parsing map "auto_media"
automountd: map "auto_media" maps to "/etc/auto_media"
automountd: done parsing map "auto_media"
automountd: found node defined at auto_media:8; it is a mountpoint
automountd: executing "mount -t whatever -o allow_other,ssh_command=,automounted ' /media/mntpoint/" as pid 82910
mount: ': Operation not supported by device
automountd: "mount -t whatever -o allow_other,ssh_command=,automounted ' /media/mntpoint/", pid 82910, terminated with exit status 1
automountd: mount failed
automountd: completing request 16 with error 5
Comment 3 commit-hook freebsd_committer freebsd_triage 2014-09-05 14:32:28 UTC
A commit references this bug:

Author: trasz
Date: Fri Sep  5 14:32:09 UTC 2014
New revision: 271167
URL: http://svnweb.freebsd.org/changeset/base/271167

Log:
  Make it possible to quote names in autofs maps using double quotes.

  Note that this is a workaround, not a proper solution.  If you know
  lex well, and want to help - please let me know, I'll explain how it
  should work.

  PR:		192968
  MFC after:	1 week
  Sponsored by:	The FreeBSD Foundation

Changes:
  head/usr.sbin/autofs/token.l
Comment 4 commit-hook freebsd_committer freebsd_triage 2014-09-17 08:26:21 UTC
A commit references this bug:

Author: trasz
Date: Wed Sep 17 08:25:49 UTC 2014
New revision: 271704
URL: http://svnweb.freebsd.org/changeset/base/271704

Log:
  MFC r271167:

  Make it possible to quote names in autofs maps using double quotes.

  Note that this is a workaround, not a proper solution.  If you know
  lex well, and want to help - please let me know, I'll explain how it
  should work.

  PR:		192968
  Approved by:	re (kib)
  Sponsored by:	The FreeBSD Foundation

Changes:
_U  stable/10/
  stable/10/usr.sbin/autofs/token.l
Comment 5 Edward Tomasz Napierala freebsd_committer freebsd_triage 2014-09-17 08:34:12 UTC
Meh, reopen.  This way I won't forget that it should get fixed in a better way.
Comment 6 Glen Barber freebsd_committer freebsd_triage 2015-07-08 18:02:30 UTC
Close PRs that have had a corresponding fix committed.