mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-19 12:20:17 -08:00
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). Backport from master.
This commit is contained in:
parent
2deb20c1bd
commit
40c426a150
1 changed files with 23 additions and 14 deletions
|
|
@ -71,8 +71,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
/* Normally use a symbolic link to represent a lock.
|
/* Normally use a symbolic link to represent a lock.
|
||||||
The strategy: to lock a file FN, create a symlink .#FN in FN's
|
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
|
directory, with link data USER@HOST.PID:BOOT. This avoids a single
|
||||||
mount (== failure) point for lock files.
|
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
|
When the host in the lock data is the current host, we can check if
|
||||||
the pid is valid with kill.
|
the pid is valid with kill.
|
||||||
|
|
@ -101,13 +102,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
This is compatible with the locking scheme used by Interleaf (which
|
This is compatible with the locking scheme used by Interleaf (which
|
||||||
has contributed this implementation for Emacs), and was designed by
|
has contributed this implementation for Emacs), and was designed by
|
||||||
Ethan Jacobson, Kimbo Mundy, and others.
|
Karl Berry, Ethan Jacobson, Kimbo Mundy, and others.
|
||||||
|
|
||||||
--karl@cs.umb.edu/karl@hq.ileaf.com.
|
|
||||||
|
|
||||||
On some file systems, notably those of MS-Windows, symbolic links
|
On some file systems, notably those of MS-Windows, symbolic links
|
||||||
do not work well, so instead of a symlink .#FN -> 'user@host.pid',
|
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'. To
|
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.
|
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
|
On MS-Windows this renaming is atomic unless the lock is forcibly
|
||||||
acquired. On other systems the renaming is atomic if the lock is
|
acquired. On other systems the renaming is atomic if the lock is
|
||||||
|
|
@ -298,8 +297,8 @@ enum { MAX_LFINFO = 8 * 1024 };
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
/* Location of '@', '.', ':' in USER. If there's no colon, COLON
|
/* Location of '@', '.', and ':' (or equivalent) in USER. If there's
|
||||||
points to the end of USER. */
|
no colon or equivalent, COLON points to the end of USER. */
|
||||||
char *at, *dot, *colon;
|
char *at, *dot, *colon;
|
||||||
|
|
||||||
/* Lock file contents USER@HOST.PID with an optional :BOOT_TIME
|
/* Lock file contents USER@HOST.PID with an optional :BOOT_TIME
|
||||||
|
|
@ -557,7 +556,7 @@ current_lock_owner (lock_info_type *owner, char *lfname)
|
||||||
if (!dot)
|
if (!dot)
|
||||||
return -1;
|
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]))
|
if (! c_isdigit (dot[1]))
|
||||||
return -1;
|
return -1;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
@ -565,7 +564,8 @@ current_lock_owner (lock_info_type *owner, char *lfname)
|
||||||
if (errno == ERANGE)
|
if (errno == ERANGE)
|
||||||
pid = -1;
|
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])
|
switch (owner->colon[0])
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
|
@ -573,10 +573,19 @@ current_lock_owner (lock_info_type *owner, char *lfname)
|
||||||
lfinfo_end = owner->colon;
|
lfinfo_end = owner->colon;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ':':
|
case '\357':
|
||||||
if (! c_isdigit (owner->colon[1]))
|
/* 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;
|
return -1;
|
||||||
boot_time = strtoimax (owner->colon + 1, &lfinfo_end, 10);
|
boot += 2;
|
||||||
|
/* Fall through. */
|
||||||
|
case ':':
|
||||||
|
if (! c_isdigit (boot[0]))
|
||||||
|
return -1;
|
||||||
|
boot_time = strtoimax (boot, &lfinfo_end, 10);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue