From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#61901: 30.0.50; [PATCH v3] Add safe-local-variable-directories variable. Date: Thu, 11 May 2023 16:55:54 +0300 Message-ID: <835y8z55w5.fsf@gnu.org> References: <87r0rpi46l.fsf@mailbox.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10452"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61901-done@debbugs.gnu.org To: Antero Mejr Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 11 15:55:17 2023 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 1px6lI-0002Th-HV for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 11 May 2023 15:55:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1px6l7-0004RE-6P; Thu, 11 May 2023 09:55:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1px6l5-0004QN-0k for bug-gnu-emacs@gnu.org; Thu, 11 May 2023 09:55:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1px6l4-0000vZ-NJ for bug-gnu-emacs@gnu.org; Thu, 11 May 2023 09:55:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1px6l4-0000ln-5r for bug-gnu-emacs@gnu.org; Thu, 11 May 2023 09:55:02 -0400 Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 May 2023 13:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 61901 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Mail-Followup-To: 61901@debbugs.gnu.org, eliz@gnu.org, antero@mailbox.org Original-Received: via spool by 61901-done@debbugs.gnu.org id=D61901.16838132952929 (code D ref 61901); Thu, 11 May 2023 13:55:01 +0000 Original-Received: (at 61901-done) by debbugs.gnu.org; 11 May 2023 13:54:55 +0000 Original-Received: from localhost ([127.0.0.1]:50105 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1px6kw-0000lA-Nx for submit@debbugs.gnu.org; Thu, 11 May 2023 09:54:55 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:42724) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1px6kv-0000kv-2O for 61901-done@debbugs.gnu.org; Thu, 11 May 2023 09:54:53 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1px6kp-0000r1-9m; Thu, 11 May 2023 09:54:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=s9KCHZlXdu7mAPJbhsswH7nFz6cql3PFoqyWX/v0rhw=; b=W5rimbgPoVBt MAonUQHCjPBetywuxcbRXBcYNYhBhMz4wMvmOq3ZmhIEMvrS0h8cSriK05E8U7wEUt3En7Mh43mpR ipYkyY7L8YFhxSUaIY/mU+BSfiWD+gsmMAUVbd75riZNzeQxbJxOsutRabNYEfWjGAb6JkJFSn5Ct wgi2qj3yMhn1cErh4WGXrXyJj3fCpxouteM0NTSnPPDF4MqzctZFlee/1ZJ5cF7LCLQs6HNBevWLF A6JOeoUTaLP70FWBAerkqQUklhCMd/pbsEGJ976Ka3UwIMSclGuegXdJlKllk4cNTXXxjhkK7k22C ZEKwpKiKCE3ac9EPCtN7UQ==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1px6ko-0002ug-Q9; Thu, 11 May 2023 09:54:47 -0400 In-Reply-To: <87r0rpi46l.fsf@mailbox.org> (message from Antero Mejr on Tue, 09 May 2023 21:29:54 +0000) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:261571 Archived-At: > From: Antero Mejr > Cc: 61901@debbugs.gnu.org > Date: Tue, 09 May 2023 21:29:54 +0000 > > >> +@defvar safe-local-variable-directories > >> +This is a list of directories where local variables are always enabled. > >> +Directory-local variables loaded from these directories, such as the > >> +variables in @file{.dir-locals.el}, will be enabled even if they are > >> +risky. > >> +@end defvar > > > >This variable should also be documented in the Emacs user manual, not > >only in the ELisp Reference manual -- it's a user option, and a very > >important one at that. > > Added to the manual in custom.texi "Safe File Variables" subsection. > > >> ++++ > >> +** New variable 'safe-local-variable-directories'. > >> +This variable is used to to permanently trust directories containing > >> +risky directory-local variables. > > > >I would rephrase: > > > > This variable names directories in which Emacs will treat all > > directory-local variables as safe. > > Fixed in attached patch. > > >> ALL-VARS is the list of all variables to be set up. > >> @@ -3734,7 +3744,9 @@ n -- to ignore the local variables list.") > >> ! -- to apply the local variables list, and permanently mark these > >> values (*) as safe (in the future, they will be set automatically.) > >> i -- to ignore the local variables list, and permanently mark these > >> - values (*) as ignored\n\n") > >> + values (*) as ignored > >> ++ -- to apply the local variables list, and permanently trust all > >> + directory-local variables in this directory\n\n") > > > >I would remove the "permanently" part, it would just confuse here. > > Fixed. > > >> @@ -3908,6 +3924,7 @@ DIR-NAME is the name of the associated directory. > >> Otherwise it is nil." > >> (null unsafe-vars) > >> (null risky-vars)) > >> (memq enable-local-variables '(:all :safe)) > >> + (member dir-name safe-local-variable-directories) > > > >If you use 'member' for this test, then (a) the documentation of > >safe-local-variable-directories should explicitly say that the > >directories in the list must be in full absolute form, and (b) we > >should consider the various issues with file names that are not > >'equal' as strings, but still name the same directory, such as > >letter-case differences on case-insensitive filesystems. And what > >about equality of "foo/" "and "foo"? > > Clarified the documentation. The directory path requires a trailing > separator, and is case-sensitive regardless of the filesystem (tested > on vFAT). > > >Also, is 'dir-name' above guaranteed to be a fully-expanded absolute > >file name? > > Yes. For TRAMP connections it's a string with text properties, but it's > the same equality-wise. > > #("/ssh:user:/home/user/src/" 5 6 (tramp-default t)) > > >> +(ert-deftest files-tests-safe-local-variable-directories () > >> + ;; safe-local-variable-directories should be risky, > >> + ;; so use it as an arbitrary risky variable. > >> + (let ((test-alist '((safe-local-variable-directories . "some_val"))) > >> + (fakedir "test1/test2") > >> + (enable-local-eval t)) > >> + (with-temp-buffer > >> + (setq safe-local-variable-directories (list fakedir)) > > > >The test should use absolute directory names for directories you put > >into safe-local-variable-directories. > > Fixed. Thanks, I installed this on the master branch, and I'm therefore closing this bug. Please note some minor changes I made in the documentation parts of the changeset, the most notable one being the use of "path" to allude to file names or directory names: the Gnu Coding Standards frown on that. We use "path" only for lists of directories in the style of PATH environment variable or load-path Lisp variable. Thanks again for working on this feature.