Bug 89851 - fstab-generator interprets backslashes in CIFS mounts
Summary: fstab-generator interprets backslashes in CIFS mounts
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
Depends on:
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:


Note You need to log in before you can comment on or make changes to this bug.
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:

\\\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

Documentation=man:fstab(5) man:systemd-fstab-generator(8)


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 (\\ExtHDD)

Let's add more backslashes to the CIFS path:

\\\\\\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

Documentation=man:fstab(5) man:systemd-fstab-generator(8)


However, mount commands refuses to work:

$ sudo mount /mnt/nas 
mount.cifs: bad UNC (\\\\\\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. // 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

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

the me->mnt_fsname is \\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 \\\\

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.