emacs leaves behind corrupted symlinks on CIFS share (#1271407)

Resolves: #1271407
This commit is contained in:
Jan Synacek 2016-10-12 13:56:32 +02:00
parent 6a092add34
commit 430d29bb0b
2 changed files with 101 additions and 1 deletions

94
emacs-samba.patch Normal file
View File

@ -0,0 +1,94 @@
commit 1dd54e3eef7543720eff161457677a35fae2435c
Author: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue Oct 11 13:06:42 2016 -0700
Work around Samba bug with ':' in symlink contents
* src/filelock.c (current_lock_owner): When reading the contents
of a lock, treat the UTF-8 for U+F022 as if it were ':' (Bug#24656).
diff --git a/src/filelock.c b/src/filelock.c
index a2e1df9..d4dfc1d 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -72,8 +72,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Normally use a symbolic link to represent a lock.
The strategy: to lock a file FN, create a symlink .#FN in FN's
- directory, with link data `user@host.pid'. This avoids a single
- mount (== failure) point for lock files.
+ directory, with link data USER@HOST.PID:BOOT. This avoids a single
+ mount (== failure) point for lock files. The :BOOT is omitted if
+ the boot time is not available.
When the host in the lock data is the current host, we can check if
the pid is valid with kill.
@@ -102,13 +103,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
This is compatible with the locking scheme used by Interleaf (which
has contributed this implementation for Emacs), and was designed by
- Ethan Jacobson, Kimbo Mundy, and others.
-
- --karl@cs.umb.edu/karl@hq.ileaf.com.
+ Karl Berry, Ethan Jacobson, Kimbo Mundy, and others.
On some file systems, notably those of MS-Windows, symbolic links
- do not work well, so instead of a symlink .#FN -> 'user@host.pid',
- the lock is a regular file .#FN with contents 'user@host.pid'. To
+ do not work well, so instead of a symlink .#FN -> USER@HOST.PID:BOOT,
+ the lock is a regular file .#FN with contents USER@HOST.PID:BOOT. To
establish a lock, a nonce file is created and then renamed to .#FN.
On MS-Windows this renaming is atomic unless the lock is forcibly
acquired. On other systems the renaming is atomic if the lock is
@@ -289,8 +288,8 @@ enum { MAX_LFINFO = 8 * 1024 };
typedef struct
{
- /* Location of '@', '.', ':' in USER. If there's no colon, COLON
- points to the end of USER. */
+ /* Location of '@', '.', and ':' (or equivalent) in USER. If there's
+ no colon or equivalent, COLON points to the end of USER. */
char *at, *dot, *colon;
/* Lock file contents USER@HOST.PID with an optional :BOOT_TIME
@@ -548,7 +547,7 @@ current_lock_owner (lock_info_type *owner, char *lfname)
if (!dot)
return -1;
- /* The PID is everything from the last `.' to the `:'. */
+ /* The PID is everything from the last '.' to the ':' or equivalent. */
if (! c_isdigit (dot[1]))
return -1;
errno = 0;
@@ -556,7 +555,8 @@ current_lock_owner (lock_info_type *owner, char *lfname)
if (errno == ERANGE)
pid = -1;
- /* After the `:', if there is one, comes the boot time. */
+ /* After the ':' or equivalent, if there is one, comes the boot time. */
+ char *boot = owner->colon + 1;
switch (owner->colon[0])
{
case 0:
@@ -564,10 +564,19 @@ current_lock_owner (lock_info_type *owner, char *lfname)
lfinfo_end = owner->colon;
break;
+ case '\357':
+ /* Treat "\357\200\242" (U+F022 in UTF-8) as if it were ":".
+ This works around a bug in Samba, which can mistakenly
+ transliterate ':' to U+F022 in symlink contents (Bug#24656).
+ See <https://bugzilla.redhat.com/show_bug.cgi?id=1271407#c8>. */
+ if (! (boot[0] == '\200' && boot[1] == '\242'))
+ return -1;
+ boot += 2;
+ /* Fall through. */
case ':':
- if (! c_isdigit (owner->colon[1]))
+ if (! c_isdigit (boot[0]))
return -1;
- boot_time = strtoimax (owner->colon + 1, &lfinfo_end, 10);
+ boot_time = strtoimax (boot, &lfinfo_end, 10);
break;
default:

View File

@ -5,7 +5,7 @@ Summary: GNU Emacs text editor
Name: emacs Name: emacs
Epoch: 1 Epoch: 1
Version: 25.1 Version: 25.1
Release: 1%{?dist} Release: 2%{?dist}
License: GPLv3+ and CC0-1.0 License: GPLv3+ and CC0-1.0
URL: http://www.gnu.org/software/emacs/ URL: http://www.gnu.org/software/emacs/
Group: Applications/Editors Group: Applications/Editors
@ -25,6 +25,8 @@ Patch1: emacs-spellchecker.patch
# Fix for default PDF viewer bug #971162 # Fix for default PDF viewer bug #971162
Patch2: emacs-pdf-default.patch Patch2: emacs-pdf-default.patch
Patch3: emacs-system-crypto-policies.patch Patch3: emacs-system-crypto-policies.patch
# rhbz#1271407 (upstreamed)
Patch4: emacs-samba.patch
BuildRequires: atk-devel BuildRequires: atk-devel
BuildRequires: cairo-devel BuildRequires: cairo-devel
@ -167,6 +169,7 @@ packages that add functionality to Emacs.
%patch1 -p1 -b .spellchecker %patch1 -p1 -b .spellchecker
%patch2 -p1 -b .pdf-default.patch %patch2 -p1 -b .pdf-default.patch
%patch3 -p1 -b .system-crypto-policies %patch3 -p1 -b .system-crypto-policies
%patch4 -p1 -b .samba
autoconf autoconf
# We prefer our emacs.desktop file # We prefer our emacs.desktop file
@ -446,6 +449,9 @@ update-desktop-database &> /dev/null || :
%dir %{_datadir}/emacs/site-lisp/site-start.d %dir %{_datadir}/emacs/site-lisp/site-start.d
%changelog %changelog
* Wed Oct 12 2016 Jan Synáček <jsynacek@redhat.com> - 1:25.1-2
- emacs leaves behind corrupted symlinks on CIFS share (#1271407)
* Mon Sep 19 2016 Jan Synáček <jsynacek@redhat.com> - 1:25.1-1 * Mon Sep 19 2016 Jan Synáček <jsynacek@redhat.com> - 1:25.1-1
- update to 25.1 (#1377031) - update to 25.1 (#1377031)