all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Locking files for CLASH_DETECTION now supported on MS-Windows
Date: Mon, 25 Feb 2013 21:46:21 -0800	[thread overview]
Message-ID: <512C4C2D.8050704@cs.ucla.edu> (raw)
In-Reply-To: <83ehg3iv18.fsf@gnu.org>

>> Yes, that's one worrisome scenario -- if an MS-Windows
>> Emacs locks a file, POSIXish Emacs instances will ignore
>> the locks and won't be able to set locks themselves.
> 
> No, I think Emacs running on a Posix host will ignore the Windows lock
> file (because it's a regular file) and lock the file itself with a
> different file name .#FOO.0.  So on Posix host, the file will be
> locked, as it is now.

Sorry, I should have been clearer.  My comment was assuming the
patch in Bug#13807, which simplifies the analysis.  In the
current Emacs the races are different and the analysis trickier,
but the bugs are still there.

For example, assuming current trunk (bzr 111882), suppose MS-Windows
host A creates a regular file '.#FOO', and GNU/POSIX host B creates a
symbolic link '.#FOO.0'.  They both think they own the lock for FOO,
which is bad but no worse than Emacs 24.3.  But suppose that A then
releases its lock and GNU/POSIX host C then locks the file with a
symbolic link '.#FOO'.  At this point B and C both think they own the
lock, which is a regression from Emacs 24.3.  The bug exists because
of A's intervention and because of the new MS-Windows behavior.

There are other races like that.  The Bug#13807 patch fixes the races
for GNU/POSIX hosts.  But there are still races if MS-Windows hosts are
involved.

>> (Perhaps
>> the MS-Windows code can try to directly determine whether
>> it has the Create Symbolic Links right; or perhaps it can
>> just try 'symlink' and inspect the resulting errno.)
> 
> The problem is that the error is returned _after_ prompting.

OK, then how about just checking whether the privilege is present?
That shouldn't cause a prompt.  For example, Emacs might invoke
OpenProcessToken and GetTokenInformation to see whether the current
process has SeCreateSymbolicLinkPrivilege.  Or it could do something
simpler and slower, e.g., run the equivalent of system ("WHOAMI /PRIV
| grep 'SeCreateSymbolicLinkPrivilege.*Enabled'") (pardon my lack of
MS-Windows coding skills, but I hope you get the idea).

>> Second, even if an MS-Windows user doesn't have a Create Symbolic
>> Links right, Emacs should still respect a symlink that happens
>> to be there, right?
> 
> If NFS reflects symlinks to Windows, then yes.

Apparently it does, but the symlinks appear to be regular files (!).
See <http://technet.microsoft.com/en-us/library/hh310285%28v=ws.10%29.aspx>
and <http://msdn.microsoft.com/en-us/library/ee380665.aspx>.

This whole area is messy, alas.

How about this idea?  It should be an improvement:
the MS-Windows port could use symbolic links a la the patch in Bug#13807
if SeCreateSymbolicLinkPrivilege is present, and fall back
on the 24.3 behavior if SeCreateSymbolicLinkPrivilege is absent.



  reply	other threads:[~2013-02-26  5:46 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-25 17:43 Locking files for CLASH_DETECTION now supported on MS-Windows Eli Zaretskii
2013-02-25 18:05 ` Paul Eggert
2013-02-25 18:41   ` Eli Zaretskii
2013-02-25 18:56     ` Paul Eggert
2013-02-26  2:03       ` Paul Eggert
2013-02-26  2:43         ` Daniel Colascione
2013-02-26  3:23           ` Paul Eggert
2013-02-26  4:02         ` Eli Zaretskii
2013-02-26  4:28           ` Daniel Colascione
2013-02-26 17:45             ` Eli Zaretskii
2013-02-26  6:05           ` Paul Eggert
2013-02-26 18:41             ` Eli Zaretskii
2013-02-26 18:51               ` Eli Zaretskii
2013-02-26  4:00       ` Eli Zaretskii
2013-02-26  5:46         ` Paul Eggert [this message]
2013-02-26 18:02           ` Eli Zaretskii
2013-02-26 18:17       ` Eli Zaretskii
2013-02-26 22:34         ` Paul Eggert
2013-02-27  4:01           ` Eli Zaretskii
2013-02-27  7:45             ` Paul Eggert
2013-02-27 19:02               ` Eli Zaretskii
2013-02-27 19:01           ` Eli Zaretskii
2013-02-25 19:39     ` Glenn Morris
2013-02-25 19:43       ` Eli Zaretskii
2013-02-25 20:35   ` Stefan Monnier
2013-02-25 22:49     ` Paul Eggert
2013-02-26  3:49       ` Eli Zaretskii
2013-02-26 12:56       ` Richard Stallman
2013-02-26  3:40     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=512C4C2D.8050704@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.