Bug 89851 - fstab-generator interprets backslashes in CIFS mounts
Summary: fstab-generator interprets backslashes in CIFS mounts
Status: RESOLVED NOTOURBUG
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: All Linux (All)
: medium normal
Assignee: systemd-bugs
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-31 17:56 UTC by Artyom Aleksyuk
Modified: 2015-04-08 05:59 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Artyom Aleksyuk 2015-03-31 17:56:15 UTC
Hello. I'm using systemd 219 on Ubuntu 15.04.
I have the following line in /etc/fstab:

\\192.168.1.110\ExtHDD /mnt/nas cifs vers=3.0,nofail,credentials=/etc/net_pass,uid=1000,gid=1000 0 0

"sudo mount /mnt/nas/" works properly in this case. Hovewer, fstab-generator creates an incorrect mount unit:

# Automatically generated by systemd-fstab-generator

[Unit]
SourcePath=/etc/fstab
Documentation=man:fstab(5) man:systemd-fstab-generator(8)

[Mount]
What=\192.168.1.110\ExtHDD
Where=/mnt/nas
Type=cifs
Options=vers=3.0,nofail,credentials=/etc/net_pass,uid=1000,gid=1000

Note a missing backslash before the IP address. "systemctl status mnt-nas.mount" obviously tells that unit wasn't able to start:

марта 31 20:23:32 artyom-H97-D3H mount[7360]: mount.cifs: bad UNC (\192.168.1.110\ExtHDD)

Let's add more backslashes to the CIFS path:

\\\\192.168.1.110\\ExtHDD /mnt/nas cifs vers=3.0,nofail,credentials=/etc/net_pass,uid=1000,gid=1000 0 0

In this case, generated mount unit is correct:

# Automatically generated by systemd-fstab-generator

[Unit]
SourcePath=/etc/fstab
Documentation=man:fstab(5) man:systemd-fstab-generator(8)

[Mount]
What=\\192.168.1.110\ExtHDD
Where=/mnt/nas
Type=cifs
Options=vers=3.0,nofail,x-gvfs-show,credentials=/etc/nas_passwd,uid=1000,gid=1000,cache=loose

However, mount commands refuses to work:

$ sudo mount /mnt/nas 
mount.cifs: bad UNC (\\\\192.168.1.110\\ExtHDD)

I don't precisely know if fstab entries should contain escape characters (extra backslashes). Nonetheless, fstab-generator and mount command should have the same behaviour anyway.
Comment 1 Martin Pitt 2015-04-08 05:46:47 UTC
Note that fstab should contain forward slashes for cifs, e. g. //192.168.1.110/ExtHDD in your case. Where did you see the backslashes documented? This documentation should be fixed. Or was that added by some tool? Which one?

Nevertheless, this shouldn't be unescaped by the fstab generator.
Comment 2 Martin Pitt 2015-04-08 05:59:14 UTC
This unescaping is already done by getmntent(). With an fstab entry like

  \\1.2.3.4\stuff /mnt/stuff cifs defaults,nofail 0 0

the me->mnt_fsname is \1.2.3.4\stuff. fstab uses \ as an escape character, so I'm afraid this pretty much behaves as specified and you have to escape \ too if you use them (i. e. use \\\\1.2.3.4...).

It's best to avoid those at all and use forward slashes for CIFS mounts.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.