Bug 208663 - It is not possible to use spaces in fstab paths when using jails
Summary: It is not possible to use spaces in fstab paths when using jails
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 10.2-RELEASE
Hardware: amd64 Any
: --- Affects Some People
Assignee: Jamie Gritton
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-10 01:46 UTC by Robert Sevat
Modified: 2016-04-28 02:47 UTC (History)
3 users (show)

See Also:


Attachments
Use strunvis to escape fstab characters (773 bytes, patch)
2016-04-23 02:16 UTC, Jamie Gritton
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Sevat 2016-04-10 01:46:22 UTC
Bug has been fixed in the past, except it does not work for jails.

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=117687
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=55539
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=37569

Steps to reproduce:
1) create a jail named: jail_name

2) configure jail

$ mkdir "/tmp/Space Test"
$ mkdir "/tmp/Space Mountpoint"
$ echo "/tmp/Space\040Test /tmp/Space\040Mountpoint nullfs ro 0 0" >> /etc/fstab.jail_name

2) Start the jail:
# cannot start jail  "jail_name": 
# jail: jail_name: mount.fstab: /tmp/Space\040Mountpoint: No such file or directory

I've tried a bunch of variations. Escaping spaces, \040, '\040', \s, double and single quoting the entire path. Nothing works.

It gives a different error if you use quotes:

"/tmp/Space Test" "/tmp/Space Mountpoint" nullfs ro 0 0
jail: jail_name: mount.fstab: Test: not an absolute pathname

Any ideas of what else I could try or where this goes wrong?

Kind Regards,
Robert Sevat
Comment 1 Jamie Gritton freebsd_committer 2016-04-23 02:16:39 UTC
Created attachment 169588 [details]
Use strunvis to escape fstab characters

I took at look at getfsent(3), and it uses strunvis(3) to parse escape codes (only in the pathnames).  So I've done the same thing when I parse fstab lines and the "mount" parameter.

Now the example you gave works, with the same \040 for space.  The quotes still won't work, but then they don't work in getfsent either, so that sounds proper.
Comment 2 Chris Hutchinson 2016-04-23 06:58:38 UTC
Won't the following work?

$ mkdir /tmp/Space\ Test
$ mkdir /tmp/Space\ Mountpoint

$ echo "/tmp/Space\ Test /tmp/Space\ Mountpoint" nullfs ro 0 0" >> /etc/fstab.jail_name

(untested)

Also, isn't fstab called fsTAB for a reason? While I've never
tried to create one that uses spaces instead of tabs, I
can't help but wonder. :)

--Chris
Comment 3 Jamie Gritton freebsd_committer 2016-04-23 15:14:25 UTC
No, that won't work - strunvis(3) unfortunately doesn't escape things that way.  Also, getfsent(3) treats all whitespace the same.  As it should - I remember being stymied by sendmail.cf files that looked perfect but didn't work right, because there some spaces where a tab should be.
Comment 4 commit-hook freebsd_committer 2016-04-25 03:25:26 UTC
A commit references this bug:

Author: jamie
Date: Mon Apr 25 03:24:48 UTC 2016
New revision: 298562
URL: https://svnweb.freebsd.org/changeset/base/298562

Log:
  Make jail(8) interpret escape codes in fstab the same as getfsent(3).

  PR:		208663
  MFC after:	3 days

Changes:
  head/usr.sbin/jail/command.c
Comment 5 commit-hook freebsd_committer 2016-04-28 01:41:23 UTC
A commit references this bug:

Author: jamie
Date: Thu Apr 28 01:40:47 UTC 2016
New revision: 298729
URL: https://svnweb.freebsd.org/changeset/base/298729

Log:
  MFC r298562:

    Make jail(8) interpret escape codes in fstab the same as getfsent(3).

  PR:		208663

Changes:
_U  stable/10/
  stable/10/usr.sbin/jail/command.c