all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* mismatch between what Emacs considers read-only and file permissions
@ 2015-02-04 17:12 Will Parsons
  2015-02-04 19:04 ` Eli Zaretskii
       [not found] ` <mailman.19279.1423076671.1147.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 6+ messages in thread
From: Will Parsons @ 2015-02-04 17:12 UTC (permalink / raw)
  To: help-gnu-emacs

How does Emacs determine whether to mark a buffer read-only when
visiting a file that is writable?  I've encountered anomalies under
two separate conditions:

1) Under Windows

I make heavy use of the Cygwin environment under Windows, but usually
use the native Windows Emacs.  I've never bothered to track down the
exact circumstances, but assume that Cygwin is setting file
permissions in a way that confuses native Emacs.  I've dealt with this
by simply binding a key to toggle-read-only and using it when editing
a writable file that is marked read-only.

2) Editing system configuration files as root under FreeBSD

This is more puzzling.  Normally, if I edit a system configuration
file (e.g., /etc/fstab), I'm working in an X-session as a regular
user.  I then su to root and fire up Emacs to edit the file, and there
is no problem.  Occasionally, however, I log into a console directly
as root to edit a configuation file, and here Emacs marks the buffer
as read-only when the file permissions are:

-rw-r--r--  1 root  wheel

Thre is no problem actually editing and saving the file if the buffer
read-only attribute is turned off, but why is Emacs marking it
read-only in the first place?

(Emacs version is 24.4.1.)

-- 
Will


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: mismatch between what Emacs considers read-only and file permissions
  2015-02-04 17:12 mismatch between what Emacs considers read-only and file permissions Will Parsons
@ 2015-02-04 19:04 ` Eli Zaretskii
       [not found] ` <mailman.19279.1423076671.1147.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2015-02-04 19:04 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Will Parsons <varro@nodomain.invalid>
> Date: 4 Feb 2015 17:12:52 GMT
> 
> How does Emacs determine whether to mark a buffer read-only when
> visiting a file that is writable?

By looking at the file permission bits.

> 1) Under Windows
> 
> I make heavy use of the Cygwin environment under Windows, but usually
> use the native Windows Emacs.  I've never bothered to track down the
> exact circumstances, but assume that Cygwin is setting file
> permissions in a way that confuses native Emacs.

Cygwin attempts to emulate Posix user/group/other permission bits by
manipulating Windows NT security attributes.  The way it does that
will only work as you'd expect when those attributes are tested by
Cygwin programs. Native Windows build of Emacs, OTOH, not only doesn't
support the Cygwin fiddling with the NTSec features, it doesn't even
look at those attributes when it checks files for accessibility;
instead, it probes only the read-only bit (which is not affected by
NTSec).

My advice is not to mix Cygwin programs with native Emacs on Windows.
Good native ports of Unix and GNU software to Windows are available,
and you are advised to use them instead, if you don't want to deal
with these incompatibilities.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: mismatch between what Emacs considers read-only and file permissions
       [not found] ` <mailman.19279.1423076671.1147.help-gnu-emacs@gnu.org>
@ 2015-02-04 19:53   ` Will Parsons
  2015-02-04 20:00     ` Eli Zaretskii
                       ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Will Parsons @ 2015-02-04 19:53 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii wrote:
>> From: Will Parsons <varro@nodomain.invalid>
>> Date: 4 Feb 2015 17:12:52 GMT
>> 
>> How does Emacs determine whether to mark a buffer read-only when
>> visiting a file that is writable?
>
> By looking at the file permission bits.
>
>> 1) Under Windows
>> 
>> I make heavy use of the Cygwin environment under Windows, but usually
>> use the native Windows Emacs.  I've never bothered to track down the
>> exact circumstances, but assume that Cygwin is setting file
>> permissions in a way that confuses native Emacs.
>
> Cygwin attempts to emulate Posix user/group/other permission bits by
> manipulating Windows NT security attributes.  The way it does that
> will only work as you'd expect when those attributes are tested by
> Cygwin programs. Native Windows build of Emacs, OTOH, not only doesn't
> support the Cygwin fiddling with the NTSec features, it doesn't even
> look at those attributes when it checks files for accessibility;
> instead, it probes only the read-only bit (which is not affected by
> NTSec).
>
> My advice is not to mix Cygwin programs with native Emacs on Windows.
> Good native ports of Unix and GNU software to Windows are available,
> and you are advised to use them instead, if you don't want to deal
> with these incompatibilities.

I've been using Cywin for over a decade and find it far too useful to
live without.  As I had stated, I'm perfectly happy to deal the
incompatibilities simply by changing the read-only attribute on the
buffer when needed.

My real question is the second circumstance, where a file with the
Unix write bit set is marked read-only by Emacs.  Since it only occurs
when I log in directly as root in console mode (which I don't do that
often), I can live with that too, using the same method.  By *why*
does it happen?

-- 
Will


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: mismatch between what Emacs considers read-only and file permissions
  2015-02-04 19:53   ` Will Parsons
@ 2015-02-04 20:00     ` Eli Zaretskii
       [not found]     ` <mailman.19282.1423080028.1147.help-gnu-emacs@gnu.org>
  2015-02-05 13:24     ` Stefan Monnier
  2 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2015-02-04 20:00 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Will Parsons <varro@nodomain.invalid>
> Date: 4 Feb 2015 19:53:33 GMT
> 
> > My advice is not to mix Cygwin programs with native Emacs on Windows.
> > Good native ports of Unix and GNU software to Windows are available,
> > and you are advised to use them instead, if you don't want to deal
> > with these incompatibilities.
> 
> I've been using Cywin for over a decade and find it far too useful to
> live without.

Unless you are using applications for which native Windows ports are
not available at all, you can have the same usefulness without Cygwin.

> My real question is the second circumstance, where a file with the
> Unix write bit set is marked read-only by Emacs.  Since it only occurs
> when I log in directly as root in console mode (which I don't do that
> often), I can live with that too, using the same method.  By *why*
> does it happen?

Because using sudo doesn't make you root, it only gives you root's
security privileges.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: mismatch between what Emacs considers read-only and file permissions
       [not found]     ` <mailman.19282.1423080028.1147.help-gnu-emacs@gnu.org>
@ 2015-02-04 20:19       ` Will Parsons
  0 siblings, 0 replies; 6+ messages in thread
From: Will Parsons @ 2015-02-04 20:19 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii wrote:
>> From: Will Parsons <varro@nodomain.invalid>
>> Date: 4 Feb 2015 19:53:33 GMT
>
>> My real question is the second circumstance, where a file with the
>> Unix write bit set is marked read-only by Emacs.  Since it only occurs
>> when I log in directly as root in console mode (which I don't do that
>> often), I can live with that too, using the same method.  By *why*
>> does it happen?
>
> Because using sudo doesn't make you root, it only gives you root's
> security privileges.

Who said anything about using sudo?  I clearly stated that I was
logging in directly as root to a console.

-- 
Will


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: mismatch between what Emacs considers read-only and file permissions
  2015-02-04 19:53   ` Will Parsons
  2015-02-04 20:00     ` Eli Zaretskii
       [not found]     ` <mailman.19282.1423080028.1147.help-gnu-emacs@gnu.org>
@ 2015-02-05 13:24     ` Stefan Monnier
  2 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2015-02-05 13:24 UTC (permalink / raw)
  To: help-gnu-emacs

> I've been using Cywin for over a decade and find it far too useful to
> live without.

BTW, have you tried to use the Cygwin version of Emacs?
Since 24.4 it can be built with the W32 GUI code (rather than the X11
GUI code).


        Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-02-05 13:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-04 17:12 mismatch between what Emacs considers read-only and file permissions Will Parsons
2015-02-04 19:04 ` Eli Zaretskii
     [not found] ` <mailman.19279.1423076671.1147.help-gnu-emacs@gnu.org>
2015-02-04 19:53   ` Will Parsons
2015-02-04 20:00     ` Eli Zaretskii
     [not found]     ` <mailman.19282.1423080028.1147.help-gnu-emacs@gnu.org>
2015-02-04 20:19       ` Will Parsons
2015-02-05 13:24     ` Stefan Monnier

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.