Bug 1384153 - samba incorrectly modifies symlink contents containing colons
Summary: samba incorrectly modifies symlink contents containing colons
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Kernel Maintainer List
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-10-12 16:47 UTC by Charles R. Anderson
Modified: 2020-02-10 09:10 UTC (History)
19 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1271407
Environment:
Last Closed:


Attachments (Terms of Use)

Description Charles R. Anderson 2016-10-12 16:47:25 UTC
Samba is modifying the contents of symbolic links that are created with ':' in them.  It shouldn't be modifying the contents of symlinks.  See below:

> First, the contents of a symbolic link do not have to be a file name, which
> means that file system restrictions are irrelevant in symlink contents. I
> can create a symbolic link from 'foo' to 'a:/never/never/land', and that's
> OK even if 'a:/never/never/land' does not and cannot exist.
> 
> Second, the file system in question was a Fedora tmpfs file system mounted
> via CIFS, and this specific file system (tmpfs) does allow ':' in file
> names. CIFS should not arbitrarily exclude ':' when both client and server
> allow ':' in file names.

+++ This bug was initially created as a clone of Bug #1271407 +++

Description of problem:
Emacs creates a corrupted symlink on a CIFS share when editing a file, and then fails to delete it when closing the file.  This doesn't happen for local files.


Version-Release number of selected component (if applicable):
emacs-24.5-2.fc21.x86_64
kernel-4.1.6-100.fc21.x86_64

How reproducible:
always

Steps to Reproduce:
1. emacs /path/to/CIFS/mount/foo
2. start making changes
3. look at the .#foo symlink created, it has a funny character between the PID and another large number.
4. Save and exit emacs.
5. The symlink stays behind and is not deleted.

Actual results:

CIFS share shows a funny character in the symlink:

-rw-rw-r--. 1 cra cra        0 Oct 13 18:04 foo
lrwxrwxrwx. 1 cra cra       39 Oct 13  2015 .#foo -> cra@hostname.33151441383545

The funny character between 3315 and 1441383545 is "ef 80 a2" in hex:

>cat | hexdump -C 

00000000  ef 80 a2 0a                                       |....|
00000004

Local file (ext4) shows no funny character:

-rw-r-----.   1 cra cra      9 Oct 13 18:04 foo
lrwxrwxrwx.   1 cra cra     37 Oct 13 18:09 .#foo ->  cra@hostname.3346:cra@dustpuppy.wpi.edu.3346:1441383545

Expected results:
No funny character in the symlink content.  The symlink should be removed by emacs upon closing the file.

Additional info:
The CIFS server is Centos 5 running samba-3.0.33-3.40.el5_10.

--- Additional comment from Charles R. Anderson on 2015-10-13 18:16:14 EDT ---

Correction to Local file (ext4) shows no funny character:

-rw-r-----.   1 cra cra      9 Oct 13 18:04 foo
lrwxrwxrwx.   1 cra cra     37 Oct 13 18:09 .#foo -> cra@hostname.3346:1441383545

--- Additional comment from Fedora End Of Life on 2015-11-04 05:11:54 EST ---

This message is a reminder that Fedora 21 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 21. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '21'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 21 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

--- Additional comment from Fedora End Of Life on 2015-12-02 10:41:06 EST ---

Fedora 21 changed to end-of-life (EOL) status on 2015-12-01. Fedora 21 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

--- Additional comment from Charles R. Anderson on 2016-01-25 17:08:22 EST ---

Still an issue with F23.  Maybe this is a Samba bug rather than an Emacs bug?

--- Additional comment from Charles R. Anderson on 2016-01-25 17:11:05 EST ---

I think this is an Emacs bug.  The same problem happens with symlinks on a CIFS share from a samba-3.0.33-3.40.el5_10 EL5 server and also a samba-4.2.3-11.el7_2.x86_64 EL7 server.

--- Additional comment from Charles R. Anderson on 2016-07-22 09:45:51 EDT ---

Still exists on Fedora 24.

emacs-25.0.95-2.fc24.x86_64
kernel-4.6.4-301.fc24.x86_64

--- Additional comment from Jan Synacek on 2016-10-10 07:56:34 EDT ---

This still happens with emacs-25.1-1.fc24.x86_64.

You can work around this by turning off interlocking:

(setq create-lockfiles nil)

Reported at https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24656.

--- Additional comment from Paul Eggert on 2016-10-11 15:45:30 EDT ---

This is a bug in Samba, not in Emacs. I can reproduce the bug without Emacs on a CIFS file system (locally mounted, Fedora 24) by running this simple C program:

#include <unistd.h>
int main (void) { return symlink ("a:b", "f") != 0; }

This creates a symbolic link from "f" to "a<F022>b", where "<F022>" stands for the UTF-8 representation for U+F022, i.e., the bytes EF, 80, A2.

--- Additional comment from Jan Synacek on 2016-10-12 05:18:57 EDT ---

The workaround can be found at http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=1dd54e3eef7543720eff161457677a35fae2435c.

--- Additional comment from Paul Eggert on 2016-10-12 11:28:57 EDT ---

Since the bug is in Samba, the "Component" field of this bug report should be changed from "emacs" to "samba".

--- Additional comment from Charles R. Anderson on 2016-10-12 11:50:45 EDT ---

(In reply to Paul Eggert from comment #10)
> Since the bug is in Samba, the "Component" field of this bug report should
> be changed from "emacs" to "samba".

How is using a character that isn't allowed on a specific filesystem considered to be a bug in that filesystem?  It seems to me to be an emacs bug to assume that any character is allowed to be used... If emacs tried to use '/' in a filename it wouldn't be considerd a bug in Ext4 would it?  Just like '/' is a path separator in Unix filesystems, ':' is a path separator in other filesystems.

--- Additional comment from Paul Eggert on 2016-10-12 12:36:06 EDT ---

(In reply to Charles R. Anderson from comment #11)

> How is using a character that isn't allowed on a specific filesystem
> considered to be a bug in that filesystem?

First, the contents of a symbolic link do not have to be a file name, which means that file system restrictions are irrelevant in symlink contents. I can create a symbolic link from 'foo' to 'a:/never/never/land', and that's OK even if 'a:/never/never/land' does not and cannot exist.

Second, the file system in question was a Fedora tmpfs file system mounted via CIFS, and this specific file system (tmpfs) does allow ':' in file names. CIFS should not arbitrarily exclude ':' when both client and server allow ':' in file names.

--- Additional comment from Charles R. Anderson on 2016-10-12 12:44:16 EDT ---

(In reply to Paul Eggert from comment #12)
> (In reply to Charles R. Anderson from comment #11)
> 
> > How is using a character that isn't allowed on a specific filesystem
> > considered to be a bug in that filesystem?
> 
> First, the contents of a symbolic link do not have to be a file name, which
> means that file system restrictions are irrelevant in symlink contents. I
> can create a symbolic link from 'foo' to 'a:/never/never/land', and that's
> OK even if 'a:/never/never/land' does not and cannot exist.
> 
> Second, the file system in question was a Fedora tmpfs file system mounted
> via CIFS, and this specific file system (tmpfs) does allow ':' in file
> names. CIFS should not arbitrarily exclude ':' when both client and server
> allow ':' in file names.

Okay, I'll clone this bug for samba then, but leave this one as-is so the emacs workaround can be released for Fedora.  We need the workaround since Samba servers won't necessarily be upgraded on the same schedule as Fedora clients.

Comment 1 Alexander Bokovoy 2016-10-12 16:50:34 UTC
Moving to kernel, this is not a Samba bug, cifs.ko produces wrong file path on wire even when 'mapchars' option is not used (default).


Note You need to log in before you can comment on or make changes to this bug.