Bug 1271407 - emacs leaves behind corrupted symlinks on CIFS share
emacs leaves behind corrupted symlinks on CIFS share
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: emacs (Show other bugs)
24
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Jan Synacek
Fedora Extras Quality Assurance
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-10-13 18:13 EDT by Charles R. Anderson
Modified: 2016-10-18 11:53 EDT (History)
16 users (show)

See Also:
Fixed In Version: emacs-25.1-2.fc25 emacs-25.1-2.fc24
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1384153 (view as bug list)
Environment:
Last Closed: 2016-10-15 12:09:34 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Charles R. Anderson 2015-10-13 18:13:57 EDT
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.
Comment 1 Charles R. Anderson 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
Comment 2 Fedora End Of Life 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.
Comment 3 Fedora End Of Life 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.
Comment 4 Charles R. Anderson 2016-01-25 17:08:22 EST
Still an issue with F23.  Maybe this is a Samba bug rather than an Emacs bug?
Comment 5 Charles R. Anderson 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.
Comment 6 Charles R. Anderson 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
Comment 7 Jan Synacek 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.
Comment 8 Paul Eggert 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.
Comment 9 Jan Synacek 2016-10-12 05:18:57 EDT
The workaround can be found at http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=1dd54e3eef7543720eff161457677a35fae2435c.
Comment 10 Paul Eggert 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".
Comment 11 Charles R. Anderson 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.
Comment 12 Paul Eggert 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.
Comment 13 Charles R. Anderson 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 14 Alexander Bokovoy 2016-10-12 12:48:26 EDT
To make clear: this is not a samba bug. It is a cifs.ko bug, e.g. kernel side.
Comment 15 Charles R. Anderson 2016-10-12 12:50:26 EDT
Please apply this patch to emacs and relase updates for all supported Fedora releases:

http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=1dd54e3eef7543720eff161457677a35fae2435c

Thanks!
Comment 16 Jan Synacek 2016-10-13 02:14:43 EDT
I'm already working on it. Also, after comment#9, you can see that I have already created a bug for samba. Please, leave this bug on emacs.
Comment 17 Fedora Update System 2016-10-13 23:20:52 EDT
emacs-25.1-2.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-b839b149bf
Comment 18 Fedora Update System 2016-10-14 00:56:18 EDT
emacs-25.1-2.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-3c06e0bcf6
Comment 19 Fedora Update System 2016-10-15 12:09:34 EDT
emacs-25.1-2.fc25 has been pushed to the Fedora 25 stable repository. If problems still persist, please make note of it in this bug report.
Comment 20 Fedora Update System 2016-10-18 11:53:40 EDT
emacs-25.1-2.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.

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