Mountpoint containing a space not working

Bug #1861903 reported by Anisse Astier
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Expired
Medium
Unassigned

Bug Description

If I want to mount a directory containing a space (for example to match a remote share name), it will not work currently with the default cc_mounts plugin.

 - if I surround the mountpoint with quotes, it will create the destination directory properly, but then /etc/fstab won't contain the quotes and the spaces will cause parsing error in /etc/fstab
 - If I use the common workaround of replacing spaces with \040, then the directory will contain a literal '\' and then '040', and the mountpoint won't be found because mount interprets the escape sequence properly.

My suggestion: when outputting to /etc/fstab, escape spaces (and any other character part of fstab grammar) properly. This way the cloud-init config will just work.

Revision history for this message
Dan Watkins (oddbloke) wrote :

Hi Anisse,

Thanks for using cloud-init and filing this bug! To be sure that we can reproduce the exact issue you're seeing, could you add an example cloud configuration that reproduces the issue here, please?

Once you've done so, please move this bug back to New and we'll take another look at it.

Thanks again!

Dan

Changed in cloud-init:
status: New → Incomplete
Revision history for this message
Anisse Astier (anisse) wrote :

Here is an example:

mounts:
  - [ '/dev/sr0', '/mnt/Cdrom Drive', auto, 'uid=1000,gid=1000', '0', '0' ]

Then after boot:

# ls /mnt/
'Cdrom Drive'
# tail -n1 /etc/fstab
/dev/sr0 /mnt/Cdrom Drive auto uid=1000,gid=1000,comment=cloudconfig 0 0
# mount /mnt/Cdrom\ Drive/
mount: /etc/fstab: parse error at line 5 -- ignored
mount: /mnt/Cdrom Drive/: can't find in /etc/fstab.

If I work around it like this:
mounts:
  - [ '/dev/sr0', '/mnt/Cdrom\040Drive', auto, 'uid=1000,gid=1000', '0', '0' ]

Then after boot:

# ls /mnt/
'Cdrom\040Drive'
# tail -n1 /etc/fstab
/dev/sr0 /mnt/Cdrom\040Drive auto uid=1000,gid=1000,comment=cloudconfig 0 0
# mount /mnt/Cdrom\ Drive/
mount: /mnt/Cdrom Drive: mount point does not exist.
# mount /mnt/Cdrom\\040Drive/
mount: /mnt/Cdrom\040Drive/: can't find in /etc/fstab.

Changed in cloud-init:
status: Incomplete → New
Ryan Harper (raharper)
Changed in cloud-init:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Dan Watkins (oddbloke) wrote :

Thanks for the update, Anisse! Would you be interested in working on a fix for this?

Revision history for this message
Anisse Astier (anisse) wrote :

Hi Dan,

I'm afraid the Canonical CLA is too much work to do this on my work time for a single drive-by contribution. Maybe if I find time on my own, but I doubt it. I could however point a future contributor to what I've found:

 - fstab entries are space or tab separated according to the man page. Some implementations (musl getmntent) consider any whitespace matching isspace() to be a correct separator.
 - To be more complete, I'd escape any non-printable ascii character. It might means escaping utf-8 wide characters, but that would

Revision history for this message
Anisse Astier (anisse) wrote :

[continued, sorry]
… be ok. This is a complex issue with interaction between the python code in cloud-init, the filesystem charset, and the the mount parsing code of fstab; but it shouldn't be insurmountable.

Regards,

Anisse

Revision history for this message
James Falcon (falcojr) wrote :
Changed in cloud-init:
status: Triaged → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.