unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Michael Hoffman" <emacs-hoffman@snkmail.com>
To: 41218@debbugs.gnu.org
Subject: bug#41218: 26.3; Windows: file-writable-p returns t for a file owned by the Administrators group but not writable by the user, a member of the Administrators group
Date: Wed, 13 May 2020 12:05:51 -0400	[thread overview]
Message-ID: <9557-1589385966-320243@sneakemail.com> (raw)
In-Reply-To: <83mu6b7vzg.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 2152 bytes --]

 Thanks for looking into this.

On Wed, May 13, 2020 at 10:25 AM Eli Zaretskii wrote:

> And the fact that one normally needs to jump through hoops (elevating your
> session, using tools that make the file explicitly owned by a privileged
> group, etc.) to create such a situation on Windows is one more reason not
> to bother about this too much. IOW, the situation is rare.
>

The situation arises for me when viewing files within `%ProgramFiles%`
which are often set by installers or similar systems to be owned by
Administrators when installed for all users.

Specifically, it most often comes up when I am using Emacs, as installed by
Chocolatey. Chocolatey installs Emacs to be owned by the Administrators
group.

When I view the definition of a function that is part of the Lisp code that
comes with Emacs `describe-function`, Emacs visits the installed `.el`
file, which I cannot write to. Emacs thinks I can write to it though, which
causes two annoyances:

1. It is easy to make accidental changes to a file that is not writable
(and then I cannot save the file).
2. Flycheck immediately gives me an error message because it tries to open
a file in a place it shouldn't. For example:
Error while checking syntax automatically: (file-error "Opening output
file" "Permission denied" "c:/Program
Files/Emacs/emacs-26.2/share/emacs/26.2/lisp/flycheck_help-fns.el")

Whether installed via Chocolatey or some other manner, I think having the
site Emacs owned by Administrators without direct write access without
elevation is a good practice and keeps one from accidentally changing
things.


> Of course, if someone can explain how to perform this test in a way that
> takes ACLs into account and would be reliable, we could consider
> implementing it (assuming it isn't too expensive, since such a test will
> have to be performed each time a user saves a buffer to its file).
>

The `AuthzAccessCheck()` function from the Authz API might be able to do
this:

https://docs.microsoft.com/en-us/windows/win32/api/authz/nf-authz-authzaccesscheck
https://docs.microsoft.com/en-us/windows/win32/secauthz/how-dacls-control-access-to-an-object

Michael

[-- Attachment #2: Type: text/html, Size: 3205 bytes --]

  reply	other threads:[~2020-05-13 16:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-12 20:30 bug#41218: 26.3; Windows: file-writable-p returns t for a file owned by the Administrators group but not writable by the user, a member of the Administrators group Michael Hoffman
2020-05-13 14:25 ` Eli Zaretskii
2020-05-13 16:05   ` Michael Hoffman [this message]
2020-05-13 16: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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=9557-1589385966-320243@sneakemail.com \
    --to=emacs-hoffman@snkmail.com \
    --cc=41218@debbugs.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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).