unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#44623] [PATCH] archive: Warn about replacing an ACL symlink.
@ 2020-11-13 20:20 Tobias Geerinckx-Rice via Guix-patches via
  2020-11-15 20:50 ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Tobias Geerinckx-Rice via Guix-patches via @ 2020-11-13 20:20 UTC (permalink / raw)
  To: 44623

* guix/scripts/archive.scm (authorize-key): Warn when %ACL-FILE is a
symbolic link and print an additional hint for Guix System users.
---
 guix/scripts/archive.scm | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/guix/scripts/archive.scm b/guix/scripts/archive.scm
index 02557ce454..d284196f41 100644
--- a/guix/scripts/archive.scm
+++ b/guix/scripts/archive.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -310,6 +311,16 @@ the input port."
         (leave (G_ "failed to read public key: ~a: ~a~%")
                (error-source err) (error-string err)))))
 
+  ;; Warn about potentially volatile ACLs, but continue: system reconfiguration
+  ;; might not be possible without (newly-authorized) substitutes.
+  (when (and (access? %acl-file F_OK)
+             (eq? 'symlink (stat:type (lstat %acl-file))))
+    (warning (G_ "replacing symbolic link ~a with a regular file~%")
+             %acl-file)
+    (when (string-prefix? (%store-prefix) (readlink %acl-file))
+      (display-hint (G_ "On Guix System, add public keys to the
+@code{authorized-keys} field of your @code{operating-system} instead."))))
+
   (let ((key (read-key))
         (acl (current-acl)))
     (unless (eq? 'public-key (canonical-sexp-nth-data key 0))
-- 
2.29.2





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

* [bug#44623] [PATCH] archive: Warn about replacing an ACL symlink.
  2020-11-13 20:20 [bug#44623] [PATCH] archive: Warn about replacing an ACL symlink Tobias Geerinckx-Rice via Guix-patches via
@ 2020-11-15 20:50 ` Ludovic Courtès
  2020-11-15 22:06   ` bug#44623: " Tobias Geerinckx-Rice via Guix-patches via
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2020-11-15 20:50 UTC (permalink / raw)
  To: Tobias Geerinckx-Rice; +Cc: 44623

Tobias Geerinckx-Rice <me@tobias.gr> skribis:

> * guix/scripts/archive.scm (authorize-key): Warn when %ACL-FILE is a
> symbolic link and print an additional hint for Guix System users.

Oh, I was convinced that ‘guix archive --authorize’ would now fail on
Guix System, but indeed it doesn’t, due to the canonical rename trick.

> +  ;; Warn about potentially volatile ACLs, but continue: system reconfiguration
> +  ;; might not be possible without (newly-authorized) substitutes.
> +  (when (and (access? %acl-file F_OK)
> +             (eq? 'symlink (stat:type (lstat %acl-file))))

You can do both at once (thus avoiding a TOCTTOU race) with:

  (let ((stat (false-if-exception (lstat %acl-file))))
    (when (and stat …)
      …))

Otherwise LGTM (for ‘master’), thanks!

Ludo’.




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

* bug#44623: [PATCH] archive: Warn about replacing an ACL symlink.
  2020-11-15 20:50 ` Ludovic Courtès
@ 2020-11-15 22:06   ` Tobias Geerinckx-Rice via Guix-patches via
  0 siblings, 0 replies; 3+ messages in thread
From: Tobias Geerinckx-Rice via Guix-patches via @ 2020-11-15 22:06 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 44623-done

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

Ludovic Courtès 写道:
> Tobias Geerinckx-Rice <me@tobias.gr> skribis:
>
>> * guix/scripts/archive.scm (authorize-key): Warn when %ACL-FILE 
>> is a
>> symbolic link and print an additional hint for Guix System 
>> users.
>
> Oh, I was convinced that ‘guix archive --authorize’ would now 
> fail on
> Guix System, but indeed it doesn’t, due to the canonical rename 
> trick.

I don't want it to fail.

Just today I used ‘guix archive --authorize’ so ‘guix system 
reconfigure’ (to add the key!) wouldn't take all day.  Killer 
feature!

> You can do both at once (thus avoiding a TOCTTOU race) with:

That is significantly better.  Pushed as 
5d15733c426d232e98098d99a5bfe145586609a4.

Thank you!

T G-R

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

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

end of thread, other threads:[~2020-11-15 22:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-13 20:20 [bug#44623] [PATCH] archive: Warn about replacing an ACL symlink Tobias Geerinckx-Rice via Guix-patches via
2020-11-15 20:50 ` Ludovic Courtès
2020-11-15 22:06   ` bug#44623: " Tobias Geerinckx-Rice via Guix-patches via

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.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).