From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: "Michael Hoffman" Newsgroups: gmane.emacs.bugs 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 Message-ID: <9557-1589385966-320243@sneakemail.com> References: <29272-1589315462-76131@sneakemail.com> <83mu6b7vzg.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000c2f09505a589c14b" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="58908"; mail-complaints-to="usenet@ciao.gmane.io" To: 41218@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 13 18:13:12 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jYu0N-000FDU-UY for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 May 2020 18:13:12 +0200 Original-Received: from localhost ([::1]:33272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYu0M-00007k-Uu for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 May 2020 12:13:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYu0E-00005y-Uz for bug-gnu-emacs@gnu.org; Wed, 13 May 2020 12:13:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47633) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYu0E-0005xx-LE for bug-gnu-emacs@gnu.org; Wed, 13 May 2020 12:13:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jYu0E-00072W-Ei for bug-gnu-emacs@gnu.org; Wed, 13 May 2020 12:13:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Michael Hoffman" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 May 2020 16:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41218 X-GNU-PR-Package: emacs Original-Received: via spool by 41218-submit@debbugs.gnu.org id=B41218.158938636527035 (code B ref 41218); Wed, 13 May 2020 16:13:02 +0000 Original-Received: (at 41218) by debbugs.gnu.org; 13 May 2020 16:12:45 +0000 Original-Received: from localhost ([127.0.0.1]:59179 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jYtzx-00071z-E6 for submit@debbugs.gnu.org; Wed, 13 May 2020 12:12:45 -0400 Original-Received: from sneak2.sneakemail.com ([64.46.159.148]:45494) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jYttX-0006s8-6L for 41218@debbugs.gnu.org; Wed, 13 May 2020 12:06:09 -0400 Original-Received: from sneaked (ip-172-17-0-3.ec2.internal [172.17.0.3]) by 66321a2d97ce.localdomain (Postfix) with ESMTP id CFD546000C for <41218@debbugs.gnu.org>; Wed, 13 May 2020 16:06:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=snkmail.com; s=mail; t=1589385966; bh=IhWXWzlHQOV2+eej3l40tRnzl8IBTw5b2t8a8YQhh/Y=; h=References:In-Reply-To:From:Date:Subject:To:From; b=32LtzKAZSlG4eigvCwwHhcenDVaIzYscsWHev+LNinbNqHJ61Ou4FE3JUxe68axK+ j2CAX8qnRg8zcBG6oe8RQylG/UJlTQVElhni8MFLRFkW4bDs15PvKkJGy5n+BGQBPy DMsI8PtutFVy82JIvzzfQIyrLowxOdRDOEsssOl6UawIvOQwRJd0h8iOzedIz75mfz QhGb7URkxADslU8U+Go/0hPn36+5vtrIYOiNYGQCTA6b2NsolzFTvHpyIV5cck3FQs rmPgC7E8gRCPrbsdd6VnIFKSUEM2PZ2DEtQaD3O3d/kYyhtkcjEEzFj3a+A2OERKs8 3VJXUf6eIAEyw== Original-Received: from 40.107.66.105 by mail.sneakemail.com with SMTP; 13 May 2020 16:06:06 -0000 Original-Received: (sneakemail censored 9557-1589385966-320243 #4); 13 May 2020 16:06:06 -0000 Original-Received: (sneakemail censored 9557-1589385966-320243 #3); 13 May 2020 16:06:06 -0000 Original-Received: (sneakemail censored 9557-1589385966-320243 #2); 13 May 2020 16:06:06 -0000 Original-Received: (sneakemail censored 9557-1589385966-320243 #1); 13 May 2020 16:06:06 -0000 Arc-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OwBlg846EtNBmlfGFawUmuY7LR3Q6Pj2MTaf2hhoxhRtSfH/czU92RBZZ5htcdImEzh7YIjNmRzndadoxlzxMtH0vUCIjOLzvy7AplA/uDGst72TP6QXvBfIuS2P/X3nsRO5LU+otdPVYH+VFnSkosXLA6kJaq5rkUvPFpUStOoGNIYVnzrwsowx+I+3HCrzSdNH0bSzlRAcWcrH8umcTDovAk5Sb/SOx7lr6ReRuU4lrPeT6lhRV8qfIqD32zXK3KnFmNT1TjQ3QzMdb4x7IuCN9IS9O/wKXe38KJkFOkNcRq65ewnsrt3wv5cf4bFUh3+8Zt6rZqNht95kh1NjIQ== Arc-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IhWXWzlHQOV2+eej3l40tRnzl8IBTw5b2t8a8YQhh/Y=; b=WuS6Gbar8RVZGIZeu3QkZZPBPAfrkUPLls9toL2J2tWO8uHc2mQ2J9NXHZ88T0WfmimVWbIYf4mAko2Pc6MFm51uNALqLjdo30NuhsAh8YFsNnPfRFntsifNzTkZnXZXmLBH0qRB0y5hQ/yol5k11eEayuGcqjQRpAtIp7fAlYD5klUUZ5lbGrLL2FCDJmPqmuEzVFT8UuZJzVvvDbdp+QQbywq9reiqlyqSIV5mNmR8WFXErwJiVOeP1RVCzHpvLmLiNHp+mObOZpSoTzG/aFELvsP8J+EIygdl7FefkZhha4SALj/zHWsnafNzC6eEL9DRf7TcW1Cpj79/F6RFpA== Arc-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=utoronto.ca; dmarc=pass action=none header.from=utoronto.ca; dkim=pass header.d=utoronto.ca; arc=none Authentication-Results: sneakemail.com; dkim=none (message not signed) header.d=none; sneakemail.com; dmarc=none action=none header.from=utoronto.ca; In-Reply-To: <83mu6b7vzg.fsf@gnu.org> X-Mailer: Perl5 Mail::Internet v X-Mailman-Approved-At: Wed, 13 May 2020 12:12:43 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:180163 Archived-At: --000000000000c2f09505a589c14b Content-Type: text/plain; charset="UTF-8" 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 --000000000000c2f09505a589c14b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks for looking into this.

On Wed, May 13, 2020 at 10:25 AM Eli Zaretskii wrote:
<= /div>
And the fact that on= e 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 to= o much. IOW, the situation is rare.

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

Specifically, i= t most often comes up when I am using Emacs, as installed by Chocolatey. Ch= ocolatey 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 inst= alled `.el` file, which I cannot write to. Emacs thinks I can write to it t= hough, which causes two annoyances:

1. It is easy = to make accidental changes to a file that is not writable (and then I canno= t save the file).
2. Flycheck immediately gives me an error messa= ge because it tries to open a file in a place it shouldn't. For example:
Error while checking syntax automatically: (file-error "Op= ening output file" "Permission denied" "c:/Program File= s/Emacs/emacs-26.2/share/emacs/26.2/lisp/flycheck_help-fns.el")
<= div>
Whether installed via Chocolatey or some other manner, I= think having the site Emacs owned by Administrators without direct write a= ccess 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 imple= menting 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 m= ight be able to do this:


Michael
--000000000000c2f09505a589c14b--