GNU logs - #57031, boring messages


Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#57031] [PATCH] scripts: Show a hint the first time some commands are run as root.
Resent-From: "(" <paren@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Sun, 07 Aug 2022 11:15:02 +0000
Resent-Message-ID: <handler.57031.B.1659870883999 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 57031
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 57031 <at> debbugs.gnu.org
Cc: "\(" <paren@HIDDEN>
X-Debbugs-Original-To: guix-patches@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.1659870883999
          (code B ref -1); Sun, 07 Aug 2022 11:15:02 +0000
Received: (at submit) by debbugs.gnu.org; 7 Aug 2022 11:14:43 +0000
Received: from localhost ([127.0.0.1]:36053 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oKeF0-0000G2-J5
	for submit <at> debbugs.gnu.org; Sun, 07 Aug 2022 07:14:43 -0400
Received: from lists.gnu.org ([209.51.188.17]:55146)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <paren@HIDDEN>) id 1oKeEx-0000Fs-DX
 for submit <at> debbugs.gnu.org; Sun, 07 Aug 2022 07:14:40 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:58594)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <paren@HIDDEN>) id 1oKeEx-0000g8-9L
 for guix-patches@HIDDEN; Sun, 07 Aug 2022 07:14:39 -0400
Received: from knopi.disroot.org ([178.21.23.139]:34124)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <paren@HIDDEN>) id 1oKeEu-0001tp-HW
 for guix-patches@HIDDEN; Sun, 07 Aug 2022 07:14:39 -0400
Received: from localhost (localhost [127.0.0.1])
 by disroot.org (Postfix) with ESMTP id 6AD7144F79;
 Sun,  7 Aug 2022 13:14:32 +0200 (CEST)
X-Virus-Scanned: SPAM Filter at disroot.org
Received: from knopi.disroot.org ([127.0.0.1])
 by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 1v34r6XHONIK; Sun,  7 Aug 2022 13:14:31 +0200 (CEST)
From: "(" <paren@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail;
 t=1659870871; bh=a4OR6X+4gicNOiGfFNkjyP3XnMiOjvybp0Jap0i0VRo=;
 h=From:To:Cc:Subject:Date;
 b=BVjevEJDd3xW91L5vm6h2xNbnodN9lai2TYMAS8gyAjogsc/LqMzIF+rFKAGzuPBL
 FC0L1mfNj6gDM+B4KJVnWMf7Np37MrEiUV6YU2Tschv+Da9ROhzKpZf5aRmhntTUZw
 /Dhp3J1oU7xpam72SBlW3U8hnMO5PXnEVtvFEq6pbhTV0X2nPlDXOripBZzSTOHXqL
 KsRfNGYohga6ivJ6lMdZZBXMrtStSHEe2LZONCRIWb8qMkbeT36SCnU8guFLvVIUvx
 kzk5bY1iL35eUNewuXKBZqKO53utIDznQugYRRRx5qeDa+Q8+Qgf/om4rKWre/v2vh
 E7ofIvKbQ7hHQ==
Date: Sun,  7 Aug 2022 12:14:21 +0100
Message-Id: <20220807111421.14771-1-paren@HIDDEN>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=178.21.23.139; envelope-from=paren@HIDDEN;
 helo=knopi.disroot.org
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.6 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.4 (/)

* guix/scripts/package.scm (guix-package*): Add `#:root-hint?` keyword
  argument. Display a hint if Guix is being run as root and `root-hint?`
  is #t.
* guix/scripts/install.scm (guix-install): Use `#:root-hint? #t` here...
* guix/scripts/remove.scm (guix-remove): ...here...
* guix/scripts/upgrade.scm (guix-upgrade): ...and here.
* guix/scripts/pull.scm (guix-pull): (guix-pull): Display a hint if
  Guix is being run as root.

A pretty common beginner mistake, it seems, is assuming that since
every other package manager you've used requires root for installing,
removing, and upgrading packages, Guix must too.

This commit tries to make it harder to make such an assumption, by
making commands such as `pull`, `package`, and `upgrade` display
a hint the first time they are run as root.
---
 guix/scripts/install.scm |  3 ++-
 guix/scripts/package.scm | 16 +++++++++++++---
 guix/scripts/pull.scm    |  7 +++++++
 guix/scripts/remove.scm  |  3 ++-
 guix/scripts/upgrade.scm |  3 ++-
 guix/ui.scm              | 29 +++++++++++++++++++++++++++++
 6 files changed, 55 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/install.scm b/guix/scripts/install.scm
index 63e625f266..bf11fc7b11 100644
--- a/guix/scripts/install.scm
+++ b/guix/scripts/install.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -80,4 +81,4 @@ (define opts
                         (list %package-default-options #f)
                         #:argument-handler handle-argument))
 
-  (guix-package* opts))
+  (guix-package* opts #:root-hint? #t))
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 7d92598efa..8936c70e1f 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -12,6 +12,7 @@
 ;;; Copyright © 2018 Steve Sprang <scs@HIDDEN>
 ;;; Copyright © 2022 Josselin Poiret <dev@HIDDEN>
 ;;; Copyright © 2022 Antero Mejr <antero@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1077,12 +1078,21 @@ (define opts
     (parse-command-line args %options (list %default-options #f)
                         #:argument-handler handle-argument))
 
-  (guix-package* opts))
+  (guix-package* opts #:root-hint? #t))
 
-(define (guix-package* opts)
+(define* (guix-package* opts #:key (root-hint? #f))
   "Run the 'guix package' command on OPTS, an alist resulting for command-line
-option processing with 'parse-command-line'."
+option processing with 'parse-command-line'.  If ROOT-HINT? is #T, a hint is
+shown on the first usage of this procedure that informs users about Guix's
+support for per-user package management."
   (with-error-handling
+    (when (and root-hint?
+               (not (hint-given? 'package-root-hint))
+               (= (getuid) 0))
+      (record-hint 'package-root-hint)
+      (display-hint (G_ "`guix package' is user-specific, not system-wide,
+so running this command as root will affect only the `root' user.")))
+
     (or (process-query opts)
         (parameterize ((%store  (open-connection))
                        (%graft? (assoc-ref opts 'graft?)))
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index b0cc459d63..6e3d7db7c7 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2013-2015, 2017-2022 Ludovic Courtès <ludo@HIDDEN>
 ;;; Copyright © 2017 Marius Bakke <mbakke@HIDDEN>
 ;;; Copyright © 2020, 2021 Tobias Geerinckx-Rice <me@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -834,6 +835,12 @@ (define (no-arguments arg _)
             (current-channels (profile-channels profile))
             (validate-pull    (assoc-ref opts 'validate-pull))
             (authenticate?    (assoc-ref opts 'authenticate-channels?)))
+       (when (and (not (hint-given? 'pull-root-hint))
+                  (= (getuid) 0))
+         (record-hint 'pull-root-hint)
+         (display-hint (G_ "`guix pull' is user-specific, not system-wide;
+running it as root will only affect the `root' user.")))
+
        (cond
         ((assoc-ref opts 'query)
          (process-query opts profile))
diff --git a/guix/scripts/remove.scm b/guix/scripts/remove.scm
index a46ad04d56..131649eace 100644
--- a/guix/scripts/remove.scm
+++ b/guix/scripts/remove.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -76,4 +77,4 @@ (define opts
                         (list %package-default-options #f)
                         #:argument-handler handle-argument))
 
-  (guix-package* opts))
+  (guix-package* opts #:root-hint? #t))
diff --git a/guix/scripts/upgrade.scm b/guix/scripts/upgrade.scm
index beb59cbe6f..dd14600fe4 100644
--- a/guix/scripts/upgrade.scm
+++ b/guix/scripts/upgrade.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@HIDDEN>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@HIDDEN>
 ;;; Copyright © 2020 Simon Tournier <zimon.toutoune@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -87,4 +88,4 @@ (define opts
                               #f)
                         #:argument-handler handle-argument))
 
-  (guix-package* opts))
+  (guix-package* opts #:root-hint? #t))
diff --git a/guix/ui.scm b/guix/ui.scm
index a7acd41440..44607d80d2 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -18,6 +18,7 @@
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
 ;;; Copyright © 2018 Steve Sprang <scs@HIDDEN>
 ;;; Copyright © 2022 Taiju HIGASHI <higashi@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -136,6 +137,11 @@ (define-module (guix ui)
             switch-to-generation*
             delete-generation*
 
+            hint-directory
+            hint-file
+            record-hint
+            hint-given?
+
             %default-message-language
             current-message-language
 
@@ -2032,6 +2038,29 @@ (define* (package-specification->name+version+output spec
                  (package-name->name+version name)))
     (values name version sub-drv)))
 
+
+;;;
+;;; One-time hints.
+;;;
+
+(define (hint-directory)
+  "Return the directory name where previously given hints are recorded."
+  (string-append (cache-directory #:ensure? #f) "/hints"))
+
+(define (hint-file hint)
+  "Return the name of the file that marks HINT as already printed."
+  (string-append (hint-directory) "/" (symbol->string hint)))
+
+(define (record-hint hint)
+  "Mark HINT as already given."
+  (let ((file (hint-file hint)))
+    (mkdir-p (dirname file))
+    (close-fdes (open-fdes file (logior O_CREAT O_WRONLY)))))
+
+(define (hint-given? hint)
+  "Return true if HINT was already given."
+  (file-exists? (hint-file hint)))
+
 
 ;;;
 ;;; Command-line option processing.
-- 
2.37.1





Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: "(" <paren@HIDDEN>
Subject: bug#57031: Acknowledgement ([PATCH] scripts: Show a hint the
 first time some commands are run as root.)
Message-ID: <handler.57031.B.1659870883999.ack <at> debbugs.gnu.org>
References: <20220807111421.14771-1-paren@HIDDEN>
X-Gnu-PR-Message: ack 57031
X-Gnu-PR-Package: guix-patches
X-Gnu-PR-Keywords: patch
Reply-To: 57031 <at> debbugs.gnu.org
Date: Sun, 07 Aug 2022 11:15:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 guix-patches@HIDDEN

If you wish to submit further information on this problem, please
send it to 57031 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
57031: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D57031
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#57031] [PATCH v2] scripts: Show a hint the first time some commands are run as root.
References: <20220807111421.14771-1-paren@HIDDEN>
In-Reply-To: <20220807111421.14771-1-paren@HIDDEN>
Resent-From: "(" <paren@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Sun, 07 Aug 2022 11:20:01 +0000
Resent-Message-ID: <handler.57031.B57031.16598711751499 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 57031
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 57031 <at> debbugs.gnu.org
Cc: "\(" <paren@HIDDEN>
Received: via spool by 57031-submit <at> debbugs.gnu.org id=B57031.16598711751499
          (code B ref 57031); Sun, 07 Aug 2022 11:20:01 +0000
Received: (at 57031) by debbugs.gnu.org; 7 Aug 2022 11:19:35 +0000
Received: from localhost ([127.0.0.1]:36059 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oKeJi-0000O6-Jl
	for submit <at> debbugs.gnu.org; Sun, 07 Aug 2022 07:19:35 -0400
Received: from knopi.disroot.org ([178.21.23.139]:52698)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <paren@HIDDEN>) id 1oKeJg-0000Ny-PF
 for 57031 <at> debbugs.gnu.org; Sun, 07 Aug 2022 07:19:33 -0400
Received: from localhost (localhost [127.0.0.1])
 by disroot.org (Postfix) with ESMTP id 24A5844FE6;
 Sun,  7 Aug 2022 13:19:32 +0200 (CEST)
X-Virus-Scanned: SPAM Filter at disroot.org
Received: from knopi.disroot.org ([127.0.0.1])
 by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id OrsBhXYrvaVl; Sun,  7 Aug 2022 13:19:30 +0200 (CEST)
From: "(" <paren@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail;
 t=1659871170; bh=Oaqilhtl+xUnLp1X+Xf7qfOo3GvJ9MY28hRuzF1F48E=;
 h=From:To:Cc:Subject:Date;
 b=bTWPO72fAOQuzCauEeumzwIOkPalyO8BvoKLFh68HEHBswWTYu/mZpBSEI32oNayP
 vHJgMI4UqqQPbG/kR1lOWm2aIv0e4vYdWA8JYkAspX/PFYtfyUVEdwN8T/5rHafiHK
 h7pDaRQqJBvR/tqBa5hYtRFwsjgfFA7Ms8VqkyWyIh5+Lr915Qb12pubR9EfDFP7DV
 M8q0oRtns4jgCpWcmYILM0IFw+Q1bydVBVGfcFmvrCGBWlo83Zyp0qouMx68wgA3EN
 hY66lEoiq9w8F3y7ojnRrkYhQgsMY3BREQwttZJEcarrbY45MiNzTVdXpaJBllnRp6
 D6nf9DuOMZNcA==
Date: Sun,  7 Aug 2022 12:19:29 +0100
Message-Id: <20220807111929.15617-1-paren@HIDDEN>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 2.0 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  * guix/scripts/shell.scm (hint-given?, hint-directory,
 hint-file, 
 record-hint): Move these... * guix/ui.scm: ...here. Export them. *
 guix/scripts/package.scm
 (guix-package*): Add `#:root-hint?` keywor [...] 
 Content analysis details:   (2.0 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 2.0 PDS_OTHER_BAD_TLD      Untrustworthy TLDs
 [URI: jpoiret.xyz (xyz)]
 -0.0 SPF_PASS               SPF: sender matches SPF record
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

* guix/scripts/shell.scm (hint-given?, hint-directory, hint-file,
  record-hint): Move these...
* guix/ui.scm: ...here. Export them.
* guix/scripts/package.scm (guix-package*): Add `#:root-hint?` keyword
  argument. Display a hint if Guix is being run as root and `root-hint?`
  is #t.
* guix/scripts/install.scm (guix-install): Use `#:root-hint? #t` here...
* guix/scripts/remove.scm (guix-remove): ...here...
* guix/scripts/upgrade.scm (guix-upgrade): ...and here.
* guix/scripts/pull.scm (guix-pull): (guix-pull): Display a hint if
  Guix is being run as root.

A pretty common beginner mistake, it seems, is assuming that since
every other package manager you've used requires root for installing,
removing, and upgrading packages, Guix must too.

This commit tries to make it harder to make such an assumption, by
making commands such as `pull`, `package`, and `upgrade` display
a hint the first time they are run as root.
---
 guix/scripts/install.scm |  3 ++-
 guix/scripts/package.scm | 16 +++++++++++++---
 guix/scripts/pull.scm    |  7 +++++++
 guix/scripts/remove.scm  |  3 ++-
 guix/scripts/shell.scm   | 23 -----------------------
 guix/scripts/upgrade.scm |  3 ++-
 guix/ui.scm              | 29 +++++++++++++++++++++++++++++
 7 files changed, 55 insertions(+), 29 deletions(-)

diff --git a/guix/scripts/install.scm b/guix/scripts/install.scm
index 63e625f266..bf11fc7b11 100644
--- a/guix/scripts/install.scm
+++ b/guix/scripts/install.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -80,4 +81,4 @@ (define opts
                         (list %package-default-options #f)
                         #:argument-handler handle-argument))
 
-  (guix-package* opts))
+  (guix-package* opts #:root-hint? #t))
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 7d92598efa..8936c70e1f 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -12,6 +12,7 @@
 ;;; Copyright © 2018 Steve Sprang <scs@HIDDEN>
 ;;; Copyright © 2022 Josselin Poiret <dev@HIDDEN>
 ;;; Copyright © 2022 Antero Mejr <antero@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1077,12 +1078,21 @@ (define opts
     (parse-command-line args %options (list %default-options #f)
                         #:argument-handler handle-argument))
 
-  (guix-package* opts))
+  (guix-package* opts #:root-hint? #t))
 
-(define (guix-package* opts)
+(define* (guix-package* opts #:key (root-hint? #f))
   "Run the 'guix package' command on OPTS, an alist resulting for command-line
-option processing with 'parse-command-line'."
+option processing with 'parse-command-line'.  If ROOT-HINT? is #T, a hint is
+shown on the first usage of this procedure that informs users about Guix's
+support for per-user package management."
   (with-error-handling
+    (when (and root-hint?
+               (not (hint-given? 'package-root-hint))
+               (= (getuid) 0))
+      (record-hint 'package-root-hint)
+      (display-hint (G_ "`guix package' is user-specific, not system-wide,
+so running this command as root will affect only the `root' user.")))
+
     (or (process-query opts)
         (parameterize ((%store  (open-connection))
                        (%graft? (assoc-ref opts 'graft?)))
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index b0cc459d63..6e3d7db7c7 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2013-2015, 2017-2022 Ludovic Courtès <ludo@HIDDEN>
 ;;; Copyright © 2017 Marius Bakke <mbakke@HIDDEN>
 ;;; Copyright © 2020, 2021 Tobias Geerinckx-Rice <me@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -834,6 +835,12 @@ (define (no-arguments arg _)
             (current-channels (profile-channels profile))
             (validate-pull    (assoc-ref opts 'validate-pull))
             (authenticate?    (assoc-ref opts 'authenticate-channels?)))
+       (when (and (not (hint-given? 'pull-root-hint))
+                  (= (getuid) 0))
+         (record-hint 'pull-root-hint)
+         (display-hint (G_ "`guix pull' is user-specific, not system-wide;
+running it as root will only affect the `root' user.")))
+
        (cond
         ((assoc-ref opts 'query)
          (process-query opts profile))
diff --git a/guix/scripts/remove.scm b/guix/scripts/remove.scm
index a46ad04d56..131649eace 100644
--- a/guix/scripts/remove.scm
+++ b/guix/scripts/remove.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -76,4 +77,4 @@ (define opts
                         (list %package-default-options #f)
                         #:argument-handler handle-argument))
 
-  (guix-package* opts))
+  (guix-package* opts #:root-hint? #t))
diff --git a/guix/scripts/shell.scm b/guix/scripts/shell.scm
index c115a00320..3ac7d80eb0 100644
--- a/guix/scripts/shell.scm
+++ b/guix/scripts/shell.scm
@@ -489,29 +489,6 @@ (define (validated-spec spec)
       (exp
        (pretty-print exp port)))))
 
-
-;;;
-;;; One-time hints.
-;;;
-
-(define (hint-directory)
-  "Return the directory name where previously given hints are recorded."
-  (string-append (cache-directory #:ensure? #f) "/hints"))
-
-(define (hint-file hint)
-  "Return the name of the file that marks HINT as already printed."
-  (string-append (hint-directory) "/" (symbol->string hint)))
-
-(define (record-hint hint)
-  "Mark HINT as already given."
-  (let ((file (hint-file hint)))
-    (mkdir-p (dirname file))
-    (close-fdes (open-fdes file (logior O_CREAT O_WRONLY)))))
-
-(define (hint-given? hint)
-  "Return true if HINT was already given."
-  (file-exists? (hint-file hint)))
-
 
 (define-command (guix-shell . args)
   (category development)
diff --git a/guix/scripts/upgrade.scm b/guix/scripts/upgrade.scm
index beb59cbe6f..dd14600fe4 100644
--- a/guix/scripts/upgrade.scm
+++ b/guix/scripts/upgrade.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@HIDDEN>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@HIDDEN>
 ;;; Copyright © 2020 Simon Tournier <zimon.toutoune@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -87,4 +88,4 @@ (define opts
                               #f)
                         #:argument-handler handle-argument))
 
-  (guix-package* opts))
+  (guix-package* opts #:root-hint? #t))
diff --git a/guix/ui.scm b/guix/ui.scm
index a7acd41440..44607d80d2 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -18,6 +18,7 @@
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
 ;;; Copyright © 2018 Steve Sprang <scs@HIDDEN>
 ;;; Copyright © 2022 Taiju HIGASHI <higashi@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -136,6 +137,11 @@ (define-module (guix ui)
             switch-to-generation*
             delete-generation*
 
+            hint-directory
+            hint-file
+            record-hint
+            hint-given?
+
             %default-message-language
             current-message-language
 
@@ -2032,6 +2038,29 @@ (define* (package-specification->name+version+output spec
                  (package-name->name+version name)))
     (values name version sub-drv)))
 
+
+;;;
+;;; One-time hints.
+;;;
+
+(define (hint-directory)
+  "Return the directory name where previously given hints are recorded."
+  (string-append (cache-directory #:ensure? #f) "/hints"))
+
+(define (hint-file hint)
+  "Return the name of the file that marks HINT as already printed."
+  (string-append (hint-directory) "/" (symbol->string hint)))
+
+(define (record-hint hint)
+  "Mark HINT as already given."
+  (let ((file (hint-file hint)))
+    (mkdir-p (dirname file))
+    (close-fdes (open-fdes file (logior O_CREAT O_WRONLY)))))
+
+(define (hint-given? hint)
+  "Return true if HINT was already given."
+  (file-exists? (hint-file hint)))
+
 
 ;;;
 ;;; Command-line option processing.
-- 
2.37.1





Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#57031] [PATCH v2] scripts: Show a hint the first time some commands are run as root.
Resent-From: "(" <paren@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Sun, 07 Aug 2022 11:23:02 +0000
Resent-Message-ID: <handler.57031.B57031.16598713651826 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 57031
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: "(" <paren@HIDDEN>, <57031 <at> debbugs.gnu.org>
Received: via spool by 57031-submit <at> debbugs.gnu.org id=B57031.16598713651826
          (code B ref 57031); Sun, 07 Aug 2022 11:23:02 +0000
Received: (at 57031) by debbugs.gnu.org; 7 Aug 2022 11:22:45 +0000
Received: from localhost ([127.0.0.1]:36063 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oKeMm-0000TO-LK
	for submit <at> debbugs.gnu.org; Sun, 07 Aug 2022 07:22:44 -0400
Received: from knopi.disroot.org ([178.21.23.139]:55070)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <paren@HIDDEN>) id 1oKeMl-0000TG-3S
 for 57031 <at> debbugs.gnu.org; Sun, 07 Aug 2022 07:22:43 -0400
Received: from localhost (localhost [127.0.0.1])
 by disroot.org (Postfix) with ESMTP id 7704044F71;
 Sun,  7 Aug 2022 13:22:42 +0200 (CEST)
X-Virus-Scanned: SPAM Filter at disroot.org
Received: from knopi.disroot.org ([127.0.0.1])
 by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id BMc5quHDxtvw; Sun,  7 Aug 2022 13:22:41 +0200 (CEST)
Mime-Version: 1.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail;
 t=1659871361; bh=n8+989l7TlR7dcmumOS3J0LGbhOv2e80OxniX/nZynQ=;
 h=Date:Subject:From:To:References:In-Reply-To;
 b=QIrQ+HFKmJ2qhSxmuNsyoH1TiCn6yUPzV67U77xMXbt2wIt0us9P4Na7kJJFYnMJw
 vR6ZO2RUc4PKcyusDy9UKornwpmzsPU9nzombvOEPN1Ka/GxX5FWlqiuHlN1KMHd5T
 2cOUkDWofo52NttaoLQdZC3CGGoU0MQUtVxYKRIkHbVO8yXxFbC38cfoetGfcCh7ZR
 54IzA9BBnkSvFn/1VJqJN8w/ni6NU/Hi/GFA45P4csKJVIW7nuty/wY+6TBDW89I5j
 NbRav3SKWfNuplaqim5Pat25BDHeZ3ZiDB6mQKQLNj1OpdCvrJxw5W+23d9ilayaTS
 W1SsC4vEW3FFw==
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
Date: Sun, 07 Aug 2022 12:22:41 +0100
Message-Id: <CLZRAGCJY28H.XICCZHEOIRHQ@guix-aspire>
From: "(" <paren@HIDDEN>
References: <20220807111929.15617-1-paren@HIDDEN>
In-Reply-To: <20220807111929.15617-1-paren@HIDDEN>
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This patch tries to solve the same problem as #57016, except instead
of bailing out on `sudo guix pull`, `sudo guix package`, or similar,
it displays a hint the first time they are run advising users that
Guix's package management is per-user.

    -- (




Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#57031] [PATCH] scripts: Show a hint the first time some commands are run as root.
Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Mon, 05 Sep 2022 21:12:02 +0000
Resent-Message-ID: <handler.57031.B57031.166241228111180 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 57031
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: "(" <paren@HIDDEN>
Cc: 57031 <at> debbugs.gnu.org
Received: via spool by 57031-submit <at> debbugs.gnu.org id=B57031.166241228111180
          (code B ref 57031); Mon, 05 Sep 2022 21:12:02 +0000
Received: (at 57031) by debbugs.gnu.org; 5 Sep 2022 21:11:21 +0000
Received: from localhost ([127.0.0.1]:49058 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oVJNJ-0002uF-68
	for submit <at> debbugs.gnu.org; Mon, 05 Sep 2022 17:11:21 -0400
Received: from eggs.gnu.org ([209.51.188.92]:54064)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1oVJNH-0002u2-GD
 for 57031 <at> debbugs.gnu.org; Mon, 05 Sep 2022 17:11:19 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:40640)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1oVJNC-0002yl-3g; Mon, 05 Sep 2022 17:11:14 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To:
 From; bh=ZfuHBFKHKKcDt0YvsoliiCRGoUaD2rmrRcuTh6xMJBY=; b=ZbsPdolsDjyMA1OL3yTy
 pp7N+CyWa7J5Izaeb06rD7G2LurEl1G0jVkVDbgGiHfew4DEMVgdBWo7IuSeaD3T0hT31rcoov3QO
 EGxE9cons6CnGVvgb2HnZXK5v2CplScGkJ9IXTkv5LXPJsL0Jgh3ZwTDpzgWBjHsGivpO+G3QYlwk
 drU4zV3s3P6vpD9gsMyFSikbs2jgpi+V7k5wAAcRP3/QjH9U14XmgOS1NTKecreSzq5Tpb0tEx8ME
 UKE2xVlMl0rCctg5BPRlZD27f+E4EBOkddFgInm/bYS9QaqQGFUAUV3xKS5RsjKgxbvc1TtyBsJef
 THe3wZTWrE0acA==;
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=33234 helo=ribbon)
 by fencepost.gnu.org with esmtpsa
 (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1)
 (envelope-from <ludo@HIDDEN>)
 id 1oVJNB-0003qE-NW; Mon, 05 Sep 2022 17:11:13 -0400
From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
References: <20220807111421.14771-1-paren@HIDDEN>
 <20220807111929.15617-1-paren@HIDDEN>
Date: Mon, 05 Sep 2022 23:11:11 +0200
In-Reply-To: <20220807111929.15617-1-paren@HIDDEN> (paren@HIDDEN's
 message of "Sun, 7 Aug 2022 12:19:29 +0100")
Message-ID: <87tu5l1q8g.fsf_-_@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hello,

"(" <paren@HIDDEN> skribis:

> * guix/scripts/shell.scm (hint-given?, hint-directory, hint-file,
>   record-hint): Move these...
> * guix/ui.scm: ...here. Export them.
> * guix/scripts/package.scm (guix-package*): Add `#:root-hint?` keyword
>   argument. Display a hint if Guix is being run as root and `root-hint?`
>   is #t.
> * guix/scripts/install.scm (guix-install): Use `#:root-hint? #t` here...
> * guix/scripts/remove.scm (guix-remove): ...here...
> * guix/scripts/upgrade.scm (guix-upgrade): ...and here.
> * guix/scripts/pull.scm (guix-pull): (guix-pull): Display a hint if
>   Guix is being run as root.
>
> A pretty common beginner mistake, it seems, is assuming that since
> every other package manager you've used requires root for installing,
> removing, and upgrading packages, Guix must too.
>
> This commit tries to make it harder to make such an assumption, by
> making commands such as `pull`, `package`, and `upgrade` display
> a hint the first time they are run as root.

I like this change!

One nitpick: Could you make moving the hint code from shell.scm to
ui.scm a separate commit?


[...]

> +         (display-hint (G_ "`guix pull' is user-specific, not system-wid=
e;
> +running it as root will only affect the `root' user.")))

Please use Texinfo markup in hints: @command{guix pull}, etc.  (Likewise
for the second hint.)

> +(define* (guix-package* opts #:key (root-hint? #f))
>    "Run the 'guix package' command on OPTS, an alist resulting for comman=
d-line
> -option processing with 'parse-command-line'."
> +option processing with 'parse-command-line'.  If ROOT-HINT? is #T, a hin=
t is
> +shown on the first usage of this procedure that informs users about Guix=
's
> +support for per-user package management."
>    (with-error-handling
> +    (when (and root-hint?
> +               (not (hint-given? 'package-root-hint))
> +               (=3D (getuid) 0))

Unless I=E2=80=99m mistaken, =E2=80=98root-hint?=E2=80=99 is always true; s=
hould we just remove
it?

BTW, when running =E2=80=98sudo guix install=E2=80=99, the hint is going to
~root/.cache/guix, right?

Thanks,
Ludo=E2=80=99.




Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#57031] [PATCH] scripts: Show a hint the first time some commands are run as root.
Resent-From: "(" <paren@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Sun, 11 Sep 2022 13:06:01 +0000
Resent-Message-ID: <handler.57031.B57031.166290155525416 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 57031
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Cc: 57031 <at> debbugs.gnu.org
Received: via spool by 57031-submit <at> debbugs.gnu.org id=B57031.166290155525416
          (code B ref 57031); Sun, 11 Sep 2022 13:06:01 +0000
Received: (at 57031) by debbugs.gnu.org; 11 Sep 2022 13:05:55 +0000
Received: from localhost ([127.0.0.1]:41093 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oXMeo-0006bs-LW
	for submit <at> debbugs.gnu.org; Sun, 11 Sep 2022 09:05:54 -0400
Received: from knopi.disroot.org ([178.21.23.139]:48676)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <paren@HIDDEN>) id 1oXMem-0006bg-0g
 for 57031 <at> debbugs.gnu.org; Sun, 11 Sep 2022 09:05:52 -0400
Received: from localhost (localhost [127.0.0.1])
 by disroot.org (Postfix) with ESMTP id 5696D4A040;
 Sun, 11 Sep 2022 15:05:50 +0200 (CEST)
X-Virus-Scanned: SPAM Filter at disroot.org
Received: from knopi.disroot.org ([127.0.0.1])
 by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 3lpcZEERd2ZL; Sun, 11 Sep 2022 15:05:49 +0200 (CEST)
Mime-Version: 1.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail;
 t=1662901529; bh=BpKEM/V0i+MGA3vyE0OH71E1xJcRSoUKVxuJiZ/mJQM=;
 h=Date:Cc:Subject:From:To:References:In-Reply-To;
 b=c/+7o62iP0r7S3mMhKpyc3llpcSvWX+1tFKtJLwqYucU2p35D0W7+0Bvr3G4uo0u8
 iWt38OHHN9OrAym5s3rhOHEw769WHBYIHQ5WODhFrddSm2PCahTIwcJg2wVBtsC8QI
 f09rkxTXa9ZRTF8s4InaFnPmCWHhbo2dvCnlCKA4GYQBsibXXDjrGW/03Og1fxt3vh
 ltH8rEmtsLpsO0hMjlbDbYsU14DPq1vx9poQghD4iVJSaNRAVO4O6+geO86bnWE54s
 V940DgEpZUtxjFGVZnHbmHzG8AeB0Gsi6/aNDQxIRSYXsTT5zEj8qb/Sbg852XT2t0
 qojhOKsukmqTA==
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
Date: Sun, 11 Sep 2022 14:05:28 +0100
Message-Id: <CMTLE8655ZLJ.FFMSVME9LBAV@guix-aspire>
From: "(" <paren@HIDDEN>
References: <20220807111421.14771-1-paren@HIDDEN>
 <20220807111929.15617-1-paren@HIDDEN> <87tu5l1q8g.fsf_-_@HIDDEN>
In-Reply-To: <87tu5l1q8g.fsf_-_@HIDDEN>
X-Spam-Score: 1.0 (+)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

Hey Ludo,

On Mon Sep 5, 2022 at 10:11 PM BST, Ludovic Court=C3=A8s wrote:
> One nitpick: Could you make moving the hint code from shell.scm to
> ui.scm a separate commit?

Sure!

> > +         (display-hint (G_ "`guix pull' is user-specific, not system-w=
ide;
> > +running it as root will only affect the `root' user.")))
>
> Please use Texinfo markup in hints: @command{guix pull}, etc.  (Likewise
> for the second hint.)

Oh, I didn't realize you could do that.

> > +(define* (guix-package* opts #:key (root-hint? #f))
> >    "Run the 'guix package' command on OPTS, an alist resulting for comm=
and-line
> > -option processing with 'parse-command-line'."
> > +option processing with 'parse-command-line'.  If ROOT-HINT? is #T, a h=
int is
> > +shown on the first usage of this procedure that informs users about Gu=
ix's
> > +support for per-user package management."
> >    (with-error-handling
> > +    (when (and root-hint?
> > +               (not (hint-given? 'package-root-hint))
> > +               (=3D (getuid) 0))
>
> Unless I=E2=80=99m mistaken, =E2=80=98root-hint?=E2=80=99 is always true;=
 should we just remove
> it?

No, it's not always true; we don't use `#:root-hint #t' in `guix search' an=
d
`guix show', so that `sudo guix show foobar' doesn't trigger the root hint.

> BTW, when running =E2=80=98sudo guix install=E2=80=99, the hint is going =
to
> ~root/.cache/guix, right?

Probably -.o.-

    -- (




Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#57031] [PATCH v2 1/2] ui: Make one-time hint API public.
References: <20220807111421.14771-1-paren@HIDDEN>
In-Reply-To: <20220807111421.14771-1-paren@HIDDEN>
Resent-From: "(" <paren@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Sun, 11 Sep 2022 20:00:02 +0000
Resent-Message-ID: <handler.57031.B57031.166292639124559 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 57031
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 57031 <at> debbugs.gnu.org
Cc: "\(" <paren@HIDDEN>
Received: via spool by 57031-submit <at> debbugs.gnu.org id=B57031.166292639124559
          (code B ref 57031); Sun, 11 Sep 2022 20:00:02 +0000
Received: (at 57031) by debbugs.gnu.org; 11 Sep 2022 19:59:51 +0000
Received: from localhost ([127.0.0.1]:43610 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oXT7P-0006Nx-3g
	for submit <at> debbugs.gnu.org; Sun, 11 Sep 2022 15:59:51 -0400
Received: from knopi.disroot.org ([178.21.23.139]:59702)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <paren@HIDDEN>) id 1oXT7N-0006Nl-23
 for 57031 <at> debbugs.gnu.org; Sun, 11 Sep 2022 15:59:49 -0400
Received: from localhost (localhost [127.0.0.1])
 by disroot.org (Postfix) with ESMTP id 33C224A06A;
 Sun, 11 Sep 2022 21:59:48 +0200 (CEST)
X-Virus-Scanned: SPAM Filter at disroot.org
Received: from knopi.disroot.org ([127.0.0.1])
 by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id ClGgwd7ye4Vc; Sun, 11 Sep 2022 21:59:46 +0200 (CEST)
From: "(" <paren@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail;
 t=1662926386; bh=59Y8FNHYI47zfC+7QOGV/W/vMtqsFtjf/5X+93Cf7yo=;
 h=From:To:Cc:Subject:Date;
 b=h+C2SlGEcMApc/ciK39iTaSHPJ1ALuSXQ2oHJ2PhAugrIy8BrePKXXyi9vS8H6+Oj
 WPl5xTpA6YZAsgb2KSVRwCZ9tmAETJSz3e6kf+rlOEDPAnrxD97mcI78UwT/8tA/k/
 NngByrDG9ZhREVpkT1isriGySsJyl/SYOyZ2gnAG6/x79H/pgNADqt5NMH2TmtNiWR
 PUlW5D+Ex1JjfC6/y0EDy/nQP1bNSfL+t8uX8AM1YWmZ1FWjC+bJNKl8dHhddbMjBG
 XrVK2r7UxeZOFkc2W5hS5E49TLWVNBX6CEiUlLExYfNtdrbXxMwtpM/zCW630jw7Sp
 E5f/tf7kVuvGw==
Date: Sun, 11 Sep 2022 20:59:40 +0100
Message-Id: <20220911195941.8442-1-paren@HIDDEN>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 1.0 (+)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

* guix/scripts/shell.scm (hint-directory, hint-file, record-hint,
  hint-given?): Move these...
* guix/ui.scm (hint-directory, hint-file, record-hint, hint-given?):
  ...here.
---
 guix/scripts/shell.scm | 23 -----------------------
 guix/ui.scm            | 29 +++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/guix/scripts/shell.scm b/guix/scripts/shell.scm
index c115a00320..3ac7d80eb0 100644
--- a/guix/scripts/shell.scm
+++ b/guix/scripts/shell.scm
@@ -489,29 +489,6 @@ (define (validated-spec spec)
       (exp
        (pretty-print exp port)))))
 
-
-;;;
-;;; One-time hints.
-;;;
-
-(define (hint-directory)
-  "Return the directory name where previously given hints are recorded."
-  (string-append (cache-directory #:ensure? #f) "/hints"))
-
-(define (hint-file hint)
-  "Return the name of the file that marks HINT as already printed."
-  (string-append (hint-directory) "/" (symbol->string hint)))
-
-(define (record-hint hint)
-  "Mark HINT as already given."
-  (let ((file (hint-file hint)))
-    (mkdir-p (dirname file))
-    (close-fdes (open-fdes file (logior O_CREAT O_WRONLY)))))
-
-(define (hint-given? hint)
-  "Return true if HINT was already given."
-  (file-exists? (hint-file hint)))
-
 
 (define-command (guix-shell . args)
   (category development)
diff --git a/guix/ui.scm b/guix/ui.scm
index dad2b853ac..3512c761d2 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -19,6 +19,7 @@
 ;;; Copyright © 2018 Steve Sprang <scs@HIDDEN>
 ;;; Copyright © 2022 Taiju HIGASHI <higashi@HIDDEN>
 ;;; Copyright © 2022 Liliana Marie Prikler <liliana.prikler@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -137,6 +138,11 @@ (define-module (guix ui)
             switch-to-generation*
             delete-generation*
 
+            hint-directory
+            hint-file
+            record-hint
+            hint-given?
+
             %default-message-language
             current-message-language
 
@@ -2057,6 +2063,29 @@ (define* (package-specification->name+version+output spec
                  (package-name->name+version name)))
     (values name version sub-drv)))
 
+
+;;;
+;;; One-time hints.
+;;;
+
+(define (hint-directory)
+  "Return the directory name where previously given hints are recorded."
+  (string-append (cache-directory #:ensure? #f) "/hints"))
+
+(define (hint-file hint)
+  "Return the name of the file that marks HINT as already printed."
+  (string-append (hint-directory) "/" (symbol->string hint)))
+
+(define (record-hint hint)
+  "Mark HINT as already given."
+  (let ((file (hint-file hint)))
+    (mkdir-p (dirname file))
+    (close-fdes (open-fdes file (logior O_CREAT O_WRONLY)))))
+
+(define (hint-given? hint)
+  "Return true if HINT was already given."
+  (file-exists? (hint-file hint)))
+
 
 ;;;
 ;;; Command-line option processing.
-- 
2.37.3





Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#57031] [PATCH v2 2/2] scripts: Warn the first time pull or package is run as root.
Resent-From: "(" <paren@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Sun, 11 Sep 2022 20:00:02 +0000
Resent-Message-ID: <handler.57031.B57031.166292639524571 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 57031
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 57031 <at> debbugs.gnu.org
Cc: "\(" <paren@HIDDEN>
Received: via spool by 57031-submit <at> debbugs.gnu.org id=B57031.166292639524571
          (code B ref 57031); Sun, 11 Sep 2022 20:00:02 +0000
Received: (at 57031) by debbugs.gnu.org; 11 Sep 2022 19:59:55 +0000
Received: from localhost ([127.0.0.1]:43612 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oXT7S-0006OE-L6
	for submit <at> debbugs.gnu.org; Sun, 11 Sep 2022 15:59:55 -0400
Received: from knopi.disroot.org ([178.21.23.139]:60004)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <paren@HIDDEN>) id 1oXT7O-0006Nq-7m
 for 57031 <at> debbugs.gnu.org; Sun, 11 Sep 2022 15:59:51 -0400
Received: from localhost (localhost [127.0.0.1])
 by disroot.org (Postfix) with ESMTP id 89CC74A05F;
 Sun, 11 Sep 2022 21:59:49 +0200 (CEST)
X-Virus-Scanned: SPAM Filter at disroot.org
Received: from knopi.disroot.org ([127.0.0.1])
 by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id IU8JOtr7iJe5; Sun, 11 Sep 2022 21:59:48 +0200 (CEST)
From: "(" <paren@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail;
 t=1662926386; bh=2OIz/g1AGKdN7bhp06i5QfSAegwJ3pRM6+GN+a7vxZg=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=MVV/X8yp+FJg4cM9StVUsBH3EMoCaw2baMHZoj3+ZoDJs0/AIE2l2vZMHXHEg/x8I
 5tbSpwTPa6hixMN+y+FKNFOefRGEEXMF0bcWgQfwOEuTbsOKwYciLdjZu7YvFW7s9W
 WEZC0uzjvve/Yz6RaEhBapG7Pn4/JZKZvVB4MRTae+msTSE/lsvE6KiuprcFYI2skg
 CIvlXjBVHLbK+Z5BGv2OtvdFGPl+SqNkwi4AA0wrxWRqngX9T+nHHGbo/Ybgz5qsJC
 utxlV930PAz7iOFUBAtig9JCOlot+UgPCaY3rJmw5Enj/gbJnus4c22SBCylQ5HtSX
 j0KQ/P9DVlCOA==
Date: Sun, 11 Sep 2022 20:59:41 +0100
Message-Id: <20220911195941.8442-2-paren@HIDDEN>
In-Reply-To: <20220911195941.8442-1-paren@HIDDEN>
References: <20220911195941.8442-1-paren@HIDDEN>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 3.0 (+++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview: * guix/scripts/pull.scm (guix-pull): Warn the first time it's
 being run as root. * guix/scripts/package.scm (guix-package*): Likewise if
 the new `root-hint?' argument is `#t'. (guix-package): Use `#:r [...] 
 Content analysis details:   (3.0 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 1.0 FROM_ONE_CHAR          Bogus FROM name
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 SPF_PASS               SPF: sender matches SPF record
 2.0 PDS_OTHER_BAD_TLD      Untrustworthy TLDs
 [URI: jpoiret.xyz (xyz)]
 -0.0 T_SCC_BODY_TEXT_LINE   No description available.
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 2.0 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  * guix/scripts/pull.scm (guix-pull): Warn the first time it's
    being run as root. * guix/scripts/package.scm (guix-package*): Likewise if
    the new `root-hint?' argument is `#t'. (guix-package): Use `#:r [...] 
 
 Content analysis details:   (2.0 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
  1.0 FROM_ONE_CHAR          Bogus FROM name
  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 SPF_PASS               SPF: sender matches SPF record
  2.0 PDS_OTHER_BAD_TLD      Untrustworthy TLDs
                             [URI: jpoiret.xyz (xyz)]
 -0.0 T_SCC_BODY_TEXT_LINE   No description available.
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager

* guix/scripts/pull.scm (guix-pull): Warn the first time it's being
  run as root.
* guix/scripts/package.scm (guix-package*): Likewise if the new
  `root-hint?' argument is `#t'.
(guix-package): Use `#:root-hint? #t' in invocation of `guix-package*'.
* guix/scripts/install.scm (guix-install): Likewise.
* guix/scripts/remove.scm (guix-remove): Likewise.
* guix/scripts/remove.scm (guix-upgrade): Likewise.

A pretty common beginner mistake, it seems, is assuming that since
every other package manager you've used requires root for installing,
removing, and upgrading packages, Guix must too.

This commit tries to make it harder to make such an assumption, by
making commands such as `pull`, `package`, and `upgrade` display
a warning the first time they are run as root.
---
 guix/scripts/install.scm |  3 ++-
 guix/scripts/package.scm | 15 ++++++++++++---
 guix/scripts/pull.scm    |  6 ++++++
 guix/scripts/remove.scm  |  3 ++-
 guix/scripts/upgrade.scm |  3 ++-
 5 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/install.scm b/guix/scripts/install.scm
index 63e625f266..bf11fc7b11 100644
--- a/guix/scripts/install.scm
+++ b/guix/scripts/install.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -80,4 +81,4 @@ (define opts
                         (list %package-default-options #f)
                         #:argument-handler handle-argument))
 
-  (guix-package* opts))
+  (guix-package* opts #:root-hint? #t))
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 7ba2661bbb..7379e69388 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -12,6 +12,7 @@
 ;;; Copyright © 2018 Steve Sprang <scs@HIDDEN>
 ;;; Copyright © 2022 Josselin Poiret <dev@HIDDEN>
 ;;; Copyright © 2022 Antero Mejr <antero@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1079,12 +1080,20 @@ (define opts
     (parse-command-line args %options (list %default-options #f)
                         #:argument-handler handle-argument))
 
-  (guix-package* opts))
+  (guix-package* opts #:root-hint? #t))
 
-(define (guix-package* opts)
+(define* (guix-package* opts #:key (root-hint? #f))
   "Run the 'guix package' command on OPTS, an alist resulting for command-line
-option processing with 'parse-command-line'."
+option processing with 'parse-command-line'.  If ROOT-HINT? is #T, a hint is
+shown on the first usage of this procedure that informs users about Guix's
+support for per-user package management."
   (with-error-handling
+    (when (and root-hint?
+               (not (hint-given? 'package-root-hint))
+               (zero? (getuid)))
+      (record-hint 'package-root-hint)
+      (warning (G_ "this command is user-specific, so running it as root \
+will affect only the 'root' user~%")))
     (or (process-query opts)
         (parameterize ((%store  (open-connection))
                        (%graft? (assoc-ref opts 'graft?)))
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 19224cf70b..188b632450 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2013-2015, 2017-2022 Ludovic Courtès <ludo@HIDDEN>
 ;;; Copyright © 2017 Marius Bakke <mbakke@HIDDEN>
 ;;; Copyright © 2020, 2021 Tobias Geerinckx-Rice <me@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -827,6 +828,11 @@ (define (no-arguments arg _)
     (leave (G_ "~A: extraneous argument~%") arg))
 
   (with-error-handling
+    (when (and (not (hint-given? 'pull-root-hint))
+               (zero? (getuid)))
+      (record-hint 'pull-root-hint)
+      (warning (G_ "this command is user-specific, so running it as root \
+will affect only the 'root' user~%")))
     (with-git-error-handling
      (let* ((opts         (parse-command-line args %options
                                               (list %default-options)
diff --git a/guix/scripts/remove.scm b/guix/scripts/remove.scm
index a46ad04d56..131649eace 100644
--- a/guix/scripts/remove.scm
+++ b/guix/scripts/remove.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -76,4 +77,4 @@ (define opts
                         (list %package-default-options #f)
                         #:argument-handler handle-argument))
 
-  (guix-package* opts))
+  (guix-package* opts #:root-hint? #t))
diff --git a/guix/scripts/upgrade.scm b/guix/scripts/upgrade.scm
index beb59cbe6f..dd14600fe4 100644
--- a/guix/scripts/upgrade.scm
+++ b/guix/scripts/upgrade.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@HIDDEN>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@HIDDEN>
 ;;; Copyright © 2020 Simon Tournier <zimon.toutoune@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -87,4 +88,4 @@ (define opts
                               #f)
                         #:argument-handler handle-argument))
 
-  (guix-package* opts))
+  (guix-package* opts #:root-hint? #t))
-- 
2.37.3





Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#57031] [PATCH v2 2/2] scripts: Warn the first time pull or package is run as root.
Resent-From: zimoun <zimon.toutoune@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Wed, 26 Oct 2022 22:54:02 +0000
Resent-Message-ID: <handler.57031.B.166682478910387 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 57031
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 57031 <at> debbugs.gnu.org
Cc: "\(" <paren@HIDDEN>
X-Debbugs-Original-To: "( via Guix-patches via" <guix-patches@HIDDEN>, 57031 <at> debbugs.gnu.org
Received: via spool by submit <at> debbugs.gnu.org id=B.166682478910387
          (code B ref -1); Wed, 26 Oct 2022 22:54:02 +0000
Received: (at submit) by debbugs.gnu.org; 26 Oct 2022 22:53:09 +0000
Received: from localhost ([127.0.0.1]:55477 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1onpGn-0002hS-B5
	for submit <at> debbugs.gnu.org; Wed, 26 Oct 2022 18:53:09 -0400
Received: from lists.gnu.org ([209.51.188.17]:49216)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1onpGl-0002hF-MW
 for submit <at> debbugs.gnu.org; Wed, 26 Oct 2022 18:53:08 -0400
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 <zimon.toutoune@HIDDEN>)
 id 1onpGl-0005Ok-FP
 for guix-patches@HIDDEN; Wed, 26 Oct 2022 18:53:07 -0400
Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <zimon.toutoune@HIDDEN>)
 id 1onpGj-0001OC-MF
 for guix-patches@HIDDEN; Wed, 26 Oct 2022 18:53:07 -0400
Received: by mail-wr1-x435.google.com with SMTP id w14so4670877wru.8
 for <guix-patches@HIDDEN>; Wed, 26 Oct 2022 15:53:04 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:message-id:date:references
 :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id
 :reply-to; bh=JV1yqY6C+F7cj3clF1shYHjJCMupUjrla+Weq/KAS50=;
 b=jQ2ve+ISYfHroaw9Hhm33gIH9W7c0mDUx1cY0F31iGCB3fgGDu9vGHcWsk/evSk65c
 l9i49WXDH+hdPU3yRk/FhiDjgxNmLtKNLVvnnD+jElAWNw7Q3+JLUJcyCdx3Q7i8K0cF
 nepoXvtt8cbvo5W3SvfV9k5/Vf7KpETGWt/YethLYFhlLMy0axxLf2r+XkemxgrRdYN3
 svg2DhEOeEgD5PgQpGVO+6o4S4gxgdBkGXZOCEEI0YSPnzHZB/ZMW+cEBDIxG1UWZ4Fm
 uiQFRmUYhRAgtBAVlV5Y72qKD92mw8ZUERavUEIFXnI8YBnoOLdQ2FYlZ/TTr6DBndDz
 PFbw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:message-id:date:references
 :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=JV1yqY6C+F7cj3clF1shYHjJCMupUjrla+Weq/KAS50=;
 b=Pc19CdogxjSsuHTM6yANjEwdkAxj0DZA1vjwli2gmSwwhLon6jgwAJo6vwqGRVuMFf
 /sYOwCrgsmpHmYRlp4eyJOt9YuYmEe8u9mbA3DnEqPZcAuTPH1xj+MNzOFH6GcdOwKKR
 rP0t1SVImjda22iAqClWNTtKNPxhEa/MqrSwPzkZsRVxO45cG+N8L9bkpHVDcWLd51NT
 kLWFB8pXJhMgEg290Pk5bgqC8BtaAF0oA3KCv1W8rXuaj0qp6zG+y3h5z6oxoTpsebbD
 z9m7ePdonaS/u0vdcYygIztWcZm8vy/2F5pIos0yEi8cfVlBTt72vk86K3/PkIG3fmZI
 CI7g==
X-Gm-Message-State: ACrzQf1iKff1DUWHabHgfyskTG5oaPd3eQUoprcDOBZnX/sWoi8iA4RK
 LyGV54J74ukwpoIDBoD3GpU=
X-Google-Smtp-Source: AMsMyM5gLubu45+Be+t6IC3STO0hpRQKnuPUJqa9En85SJq1JqU+ssrLLP4z7H7d6JBu6P2uVM/ihQ==
X-Received: by 2002:adf:f68a:0:b0:236:6e9b:dc91 with SMTP id
 v10-20020adff68a000000b002366e9bdc91mr13168774wrp.207.1666824782074; 
 Wed, 26 Oct 2022 15:53:02 -0700 (PDT)
Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e])
 by smtp.gmail.com with ESMTPSA id
 l8-20020a5d4808000000b002345cb2723esm6195458wrq.17.2022.10.26.15.53.01
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 26 Oct 2022 15:53:01 -0700 (PDT)
From: zimoun <zimon.toutoune@HIDDEN>
In-Reply-To: <20220911195941.8442-2-paren@HIDDEN>
References: <20220911195941.8442-1-paren@HIDDEN>
 <20220911195941.8442-2-paren@HIDDEN>
Date: Wed, 26 Oct 2022 20:14:49 +0200
Message-ID: <86lep2jvty.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=2a00:1450:4864:20::435;
 envelope-from=zimon.toutoune@HIDDEN; helo=mail-wr1-x435.google.com
X-Spam_score_int: -4
X-Spam_score: -0.5
X-Spam_bar: /
X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_03_06=1.592,
 DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -0.3 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.3 (-)

Hi,

On Sun, 11 Sep 2022 at 20:59, "\( via Guix-patches" via <guix-patches@HIDDEN=
rg> wrote:

> * guix/scripts/pull.scm (guix-pull): Warn the first time it's being
>   run as root.
> * guix/scripts/package.scm (guix-package*): Likewise if the new
>   `root-hint?' argument is `#t'.
> (guix-package): Use `#:root-hint? #t' in invocation of `guix-package*'.
> * guix/scripts/install.scm (guix-install): Likewise.
> * guix/scripts/remove.scm (guix-remove): Likewise.
> * guix/scripts/remove.scm (guix-upgrade): Likewise.
>
> A pretty common beginner mistake, it seems, is assuming that since
> every other package manager you've used requires root for installing,
> removing, and upgrading packages, Guix must too.
>
> This commit tries to make it harder to make such an assumption, by
> making commands such as `pull`, `package`, and `upgrade` display
> a warning the first time they are run as root.

This patch LGTM aside=E2=80=A6


> -  (guix-package* opts))
> +  (guix-package* opts #:root-hint? #t))

[...]

> -  (guix-package* opts))
> +  (guix-package* opts #:root-hint? #t))

[...]

> -(define (guix-package* opts)
> +(define* (guix-package* opts #:key (root-hint? #f))

Why this =E2=80=99root-hint?=E2=80=99 argument?  Is it useful or can we dro=
p it?


> +    (when (and root-hint?
> +               (not (hint-given? 'package-root-hint))
> +               (zero? (getuid)))
> +      (record-hint 'package-root-hint)
> +      (warning (G_ "this command is user-specific, so running it as root=
 \
> +will affect only the 'root' user~%")))

[...]

> +    (when (and (not (hint-given? 'pull-root-hint))
> +               (zero? (getuid)))
> +      (record-hint 'pull-root-hint)
> +      (warning (G_ "this command is user-specific, so running it as root=
 \
> +will affect only the 'root' user~%")))

It looks pretty similar.  Is it possible to avoid the duplication?


Cheers,
simon




Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#57031] [PATCH v2 2/2] scripts: Warn the first time pull or package is run as root.
Resent-From: zimoun <zimon.toutoune@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Wed, 26 Oct 2022 22:54:03 +0000
Resent-Message-ID: <handler.57031.B57031.166682479010395 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 57031
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 57031 <at> debbugs.gnu.org
Cc: "\(" <paren@HIDDEN>
X-Debbugs-Original-To: "( via Guix-patches via" <guix-patches@HIDDEN>, 57031 <at> debbugs.gnu.org
Received: via spool by 57031-submit <at> debbugs.gnu.org id=B57031.166682479010395
          (code B ref 57031); Wed, 26 Oct 2022 22:54:03 +0000
Received: (at 57031) by debbugs.gnu.org; 26 Oct 2022 22:53:10 +0000
Received: from localhost ([127.0.0.1]:55479 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1onpGn-0002hU-Rw
	for submit <at> debbugs.gnu.org; Wed, 26 Oct 2022 18:53:10 -0400
Received: from mail-wr1-f48.google.com ([209.85.221.48]:40891)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1onpGm-0002h6-7E
 for 57031 <at> debbugs.gnu.org; Wed, 26 Oct 2022 18:53:08 -0400
Received: by mail-wr1-f48.google.com with SMTP id z14so15436497wrn.7
 for <57031 <at> debbugs.gnu.org>; Wed, 26 Oct 2022 15:53:08 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:message-id:date:references
 :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id
 :reply-to; bh=JV1yqY6C+F7cj3clF1shYHjJCMupUjrla+Weq/KAS50=;
 b=jQ2ve+ISYfHroaw9Hhm33gIH9W7c0mDUx1cY0F31iGCB3fgGDu9vGHcWsk/evSk65c
 l9i49WXDH+hdPU3yRk/FhiDjgxNmLtKNLVvnnD+jElAWNw7Q3+JLUJcyCdx3Q7i8K0cF
 nepoXvtt8cbvo5W3SvfV9k5/Vf7KpETGWt/YethLYFhlLMy0axxLf2r+XkemxgrRdYN3
 svg2DhEOeEgD5PgQpGVO+6o4S4gxgdBkGXZOCEEI0YSPnzHZB/ZMW+cEBDIxG1UWZ4Fm
 uiQFRmUYhRAgtBAVlV5Y72qKD92mw8ZUERavUEIFXnI8YBnoOLdQ2FYlZ/TTr6DBndDz
 PFbw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:message-id:date:references
 :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=JV1yqY6C+F7cj3clF1shYHjJCMupUjrla+Weq/KAS50=;
 b=F7EjHyqSZq2zq7HMjpZ25VC8X7nD7CQwlZc2P62p48heT7OyJsslbJTlPND5c6hCCn
 +yzdj0LFl7ofNGqprmdZgyb96XEhdlRRtAfxEJnSaJdrQ4eKrfRDDDkMoZrSYSUimRS5
 iCRau65bHXVo6dxkXb1dHgdV2QGzf5wgxswoeMLAZIUtgnuE70p7nB819X+TqXlFMB9Y
 hLmfY5CmUX7TqkhrXVcuwwdTP/EHU0uXh4ZADWozO5rOOHmEwnnO6YldGcLTdBFTuESf
 E5zVVLeb2aG5+bgPY8cPOVk+O6X0tg+uEWF7KQFPKsMPoYN75xGnPv2iGXKaW/RIR8i7
 KdfA==
X-Gm-Message-State: ACrzQf0Ri4X6/gq7VBsXYjTMh63KrwIByC8eg++o0FSmI1+QVYgFkxUO
 pMxw7zxUp0kdq2CyLU+f9P0=
X-Google-Smtp-Source: AMsMyM5gLubu45+Be+t6IC3STO0hpRQKnuPUJqa9En85SJq1JqU+ssrLLP4z7H7d6JBu6P2uVM/ihQ==
X-Received: by 2002:adf:f68a:0:b0:236:6e9b:dc91 with SMTP id
 v10-20020adff68a000000b002366e9bdc91mr13168774wrp.207.1666824782074; 
 Wed, 26 Oct 2022 15:53:02 -0700 (PDT)
Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e])
 by smtp.gmail.com with ESMTPSA id
 l8-20020a5d4808000000b002345cb2723esm6195458wrq.17.2022.10.26.15.53.01
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 26 Oct 2022 15:53:01 -0700 (PDT)
From: zimoun <zimon.toutoune@HIDDEN>
In-Reply-To: <20220911195941.8442-2-paren@HIDDEN>
References: <20220911195941.8442-1-paren@HIDDEN>
 <20220911195941.8442-2-paren@HIDDEN>
Date: Wed, 26 Oct 2022 20:14:49 +0200
Message-ID: <86lep2jvty.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 1.1 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  Hi, On Sun, 11 Sep 2022 at 20:59, "\( via Guix-patches" via
 wrote: > * guix/scripts/pull.scm (guix-pull): Warn the first time it's being
 > run as root. > * guix/scripts/package.scm (guix-package*): Likewise if
 the new > `root-hint?' argument is `#t'. > (guix-package) [...] 
 Content analysis details:   (1.1 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 SPF_PASS               SPF: sender matches SPF record
 1.1 DATE_IN_PAST_03_06     Date: is 3 to 6 hours before Received: date
 0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
 provider (zimon.toutoune[at]gmail.com)
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 RCVD_IN_MSPIKE_H2      RBL: Average reputation (+2)
 [209.85.221.48 listed in wl.mailspike.net]
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
 no trust [209.85.221.48 listed in list.dnswl.org]
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.1 (/)

Hi,

On Sun, 11 Sep 2022 at 20:59, "\( via Guix-patches" via <guix-patches@HIDDEN=
rg> wrote:

> * guix/scripts/pull.scm (guix-pull): Warn the first time it's being
>   run as root.
> * guix/scripts/package.scm (guix-package*): Likewise if the new
>   `root-hint?' argument is `#t'.
> (guix-package): Use `#:root-hint? #t' in invocation of `guix-package*'.
> * guix/scripts/install.scm (guix-install): Likewise.
> * guix/scripts/remove.scm (guix-remove): Likewise.
> * guix/scripts/remove.scm (guix-upgrade): Likewise.
>
> A pretty common beginner mistake, it seems, is assuming that since
> every other package manager you've used requires root for installing,
> removing, and upgrading packages, Guix must too.
>
> This commit tries to make it harder to make such an assumption, by
> making commands such as `pull`, `package`, and `upgrade` display
> a warning the first time they are run as root.

This patch LGTM aside=E2=80=A6


> -  (guix-package* opts))
> +  (guix-package* opts #:root-hint? #t))

[...]

> -  (guix-package* opts))
> +  (guix-package* opts #:root-hint? #t))

[...]

> -(define (guix-package* opts)
> +(define* (guix-package* opts #:key (root-hint? #f))

Why this =E2=80=99root-hint?=E2=80=99 argument?  Is it useful or can we dro=
p it?


> +    (when (and root-hint?
> +               (not (hint-given? 'package-root-hint))
> +               (zero? (getuid)))
> +      (record-hint 'package-root-hint)
> +      (warning (G_ "this command is user-specific, so running it as root=
 \
> +will affect only the 'root' user~%")))

[...]

> +    (when (and (not (hint-given? 'pull-root-hint))
> +               (zero? (getuid)))
> +      (record-hint 'pull-root-hint)
> +      (warning (G_ "this command is user-specific, so running it as root=
 \
> +will affect only the 'root' user~%")))

It looks pretty similar.  Is it possible to avoid the duplication?


Cheers,
simon




Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#57031] [PATCH v2 2/2] scripts: Warn the first time pull or package is run as root.
Resent-From: "(" <paren@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Thu, 27 Oct 2022 05:53:02 +0000
Resent-Message-ID: <handler.57031.B.166684997421392 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 57031
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: zimon.toutoune@HIDDEN, 57031 <at> debbugs.gnu.org
X-Debbugs-Original-To: "zimoun" <zimon.toutoune@HIDDEN>, "( via Guix-patches via" <guix-patches@HIDDEN>, <57031 <at> debbugs.gnu.org>
Received: via spool by submit <at> debbugs.gnu.org id=B.166684997421392
          (code B ref -1); Thu, 27 Oct 2022 05:53:02 +0000
Received: (at submit) by debbugs.gnu.org; 27 Oct 2022 05:52:54 +0000
Received: from localhost ([127.0.0.1]:55934 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1onvoz-0005Yx-LF
	for submit <at> debbugs.gnu.org; Thu, 27 Oct 2022 01:52:53 -0400
Received: from lists.gnu.org ([209.51.188.17]:38986)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <paren@HIDDEN>) id 1onvoy-0005Yq-3u
 for submit <at> debbugs.gnu.org; Thu, 27 Oct 2022 01:52:53 -0400
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 <paren@HIDDEN>) id 1onvoq-0006Ca-DL
 for guix-patches@HIDDEN; Thu, 27 Oct 2022 01:52:48 -0400
Received: from knopi.disroot.org ([178.21.23.139])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <paren@HIDDEN>) id 1onvoo-0004UZ-4x
 for guix-patches@HIDDEN; Thu, 27 Oct 2022 01:52:44 -0400
Received: from localhost (localhost [127.0.0.1])
 by disroot.org (Postfix) with ESMTP id 64C684E735;
 Thu, 27 Oct 2022 07:52:38 +0200 (CEST)
X-Virus-Scanned: SPAM Filter at disroot.org
Received: from knopi.disroot.org ([127.0.0.1])
 by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id OMjDqZlUFB0a; Thu, 27 Oct 2022 07:52:37 +0200 (CEST)
Mime-Version: 1.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail;
 t=1666849957; bh=3rAD1/KyJ69qz8QIvl9pzAPsYF/pcTUPIW0AT/nbCDw=;
 h=Date:Subject:From:To:References:In-Reply-To;
 b=b+/qMCfrgHsTEPbebTZLaWcYr8dYIeLKdEJBl3VEY5yxb50ETruPwu18zwZHj6xWP
 yKX5aG/3r8BaY6Tt7bITWOzgCffgg5FmujVEhKjntEhIfKb6uBroQ5OM7NrlGp1Fun
 XvLGZdEu/nfYBUXeC/T0hvatpCHpq/0b89EeTcfU8yzQZ5qRmv/9CfZ9kjTTaACQVm
 bM816vbSVTm+Mo/+t5/ZbHgDZGxmcHB2L/GSDD91qr6AsrcIgEoAhaCi9EisUVm5uj
 zs2qT3Qh67HK5obmGoaMgwDtpbn7DjR0gAL/Mcalr0u0AGMk6Ytkr382OOvhW2Zgvv
 MbWh/LnIgOh9A==
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
Date: Thu, 27 Oct 2022 06:52:36 +0100
Message-Id: <CNWGZUVC3SC1.2FM8LO0EOJ62F@guix-framework>
From: "(" <paren@HIDDEN>
References: <20220911195941.8442-1-paren@HIDDEN>
 <20220911195941.8442-2-paren@HIDDEN> <86lep2jvty.fsf@HIDDEN>
In-Reply-To: <86lep2jvty.fsf@HIDDEN>
Received-SPF: pass client-ip=178.21.23.139; envelope-from=paren@HIDDEN;
 helo=knopi.disroot.org
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Heya,

On Wed Oct 26, 2022 at 7:14 PM BST, zimoun wrote:
> > -  (guix-package* opts))
> > +  (guix-package* opts #:root-hint? #t))
>
> [...]
>
> > -  (guix-package* opts))
> > +  (guix-package* opts #:root-hint? #t))
>
> [...]
>
> > -(define (guix-package* opts)
> > +(define* (guix-package* opts #:key (root-hint? #f))
>
> Why this =E2=80=99root-hint?=E2=80=99 argument?  Is it useful or can we d=
rop it?

This allows us to disable root hints for ``guix package'' variants, so eg
``sudo guix show'' will not trigger the root hint.

> > +    (when (and root-hint?
> > +               (not (hint-given? 'package-root-hint))
> > +               (zero? (getuid)))
> > +      (record-hint 'package-root-hint)
> > +      (warning (G_ "this command is user-specific, so running it as ro=
ot \
> > +will affect only the 'root' user~%")))
>
> [...]
>
> > +    (when (and (not (hint-given? 'pull-root-hint))
> > +               (zero? (getuid)))
> > +      (record-hint 'pull-root-hint)
> > +      (warning (G_ "this command is user-specific, so running it as ro=
ot \
> > +will affect only the 'root' user~%")))
>
> It looks pretty similar.  Is it possible to avoid the duplication?

...I guess? Maybe we could do something like this?:

  ;;;; guix/scripts.scm

  (define (warn-if-root hint-name)
    (when (and (not (hint-given hint-name))
               (zero? (getuid)))
      (record-hint hint-name)
      (warning (G_ "this command is user-specific, so running it as root \
  > > +will affect only the 'root' user~%"))))

  ;;;; guix/scripts/package.scm

  (when root-hint?
    (warn-if-root 'package-root-hint))

  ;;;; guix/scripts/pull.scm

  (warn-if-root 'pull-root-hint)

    -- (




Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#57031] [PATCH v2 2/2] scripts: Warn the first time pull or package is run as root.
Resent-From: "(" <paren@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Thu, 27 Oct 2022 05:53:02 +0000
Resent-Message-ID: <handler.57031.B57031.166684996221364 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 57031
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: zimon.toutoune@HIDDEN, 57031 <at> debbugs.gnu.org
X-Debbugs-Original-To: "zimoun" <zimon.toutoune@HIDDEN>, "( via Guix-patches via" <guix-patches@HIDDEN>, <57031 <at> debbugs.gnu.org>
Received: via spool by 57031-submit <at> debbugs.gnu.org id=B57031.166684996221364
          (code B ref 57031); Thu, 27 Oct 2022 05:53:02 +0000
Received: (at 57031) by debbugs.gnu.org; 27 Oct 2022 05:52:42 +0000
Received: from localhost ([127.0.0.1]:55931 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1onvoo-0005YW-Ak
	for submit <at> debbugs.gnu.org; Thu, 27 Oct 2022 01:52:42 -0400
Received: from knopi.disroot.org ([178.21.23.139]:37408)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <paren@HIDDEN>) id 1onvol-0005YN-Py
 for 57031 <at> debbugs.gnu.org; Thu, 27 Oct 2022 01:52:41 -0400
Received: from localhost (localhost [127.0.0.1])
 by disroot.org (Postfix) with ESMTP id 64C684E735;
 Thu, 27 Oct 2022 07:52:38 +0200 (CEST)
X-Virus-Scanned: SPAM Filter at disroot.org
Received: from knopi.disroot.org ([127.0.0.1])
 by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id OMjDqZlUFB0a; Thu, 27 Oct 2022 07:52:37 +0200 (CEST)
Mime-Version: 1.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail;
 t=1666849957; bh=3rAD1/KyJ69qz8QIvl9pzAPsYF/pcTUPIW0AT/nbCDw=;
 h=Date:Subject:From:To:References:In-Reply-To;
 b=b+/qMCfrgHsTEPbebTZLaWcYr8dYIeLKdEJBl3VEY5yxb50ETruPwu18zwZHj6xWP
 yKX5aG/3r8BaY6Tt7bITWOzgCffgg5FmujVEhKjntEhIfKb6uBroQ5OM7NrlGp1Fun
 XvLGZdEu/nfYBUXeC/T0hvatpCHpq/0b89EeTcfU8yzQZ5qRmv/9CfZ9kjTTaACQVm
 bM816vbSVTm+Mo/+t5/ZbHgDZGxmcHB2L/GSDD91qr6AsrcIgEoAhaCi9EisUVm5uj
 zs2qT3Qh67HK5obmGoaMgwDtpbn7DjR0gAL/Mcalr0u0AGMk6Ytkr382OOvhW2Zgvv
 MbWh/LnIgOh9A==
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
Date: Thu, 27 Oct 2022 06:52:36 +0100
Message-Id: <CNWGZUVC3SC1.2FM8LO0EOJ62F@guix-framework>
From: "(" <paren@HIDDEN>
References: <20220911195941.8442-1-paren@HIDDEN>
 <20220911195941.8442-2-paren@HIDDEN> <86lep2jvty.fsf@HIDDEN>
In-Reply-To: <86lep2jvty.fsf@HIDDEN>
X-Spam-Score: 1.3 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  Heya, On Wed Oct 26, 2022 at 7:14 PM BST, zimoun wrote: >
 > - (guix-package* opts)) > > + (guix-package* opts #:root-hint? #t)) > >
 [...] > > > - (guix-package* opts)) > > + (guix-package* opts #:root-hint?
 [...] Content analysis details:   (1.3 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 1.3 FROM_ONE_CHAR          Bogus FROM name
 -0.0 SPF_PASS               SPF: sender matches SPF record
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.3 (/)

Heya,

On Wed Oct 26, 2022 at 7:14 PM BST, zimoun wrote:
> > -  (guix-package* opts))
> > +  (guix-package* opts #:root-hint? #t))
>
> [...]
>
> > -  (guix-package* opts))
> > +  (guix-package* opts #:root-hint? #t))
>
> [...]
>
> > -(define (guix-package* opts)
> > +(define* (guix-package* opts #:key (root-hint? #f))
>
> Why this =E2=80=99root-hint?=E2=80=99 argument?  Is it useful or can we d=
rop it?

This allows us to disable root hints for ``guix package'' variants, so eg
``sudo guix show'' will not trigger the root hint.

> > +    (when (and root-hint?
> > +               (not (hint-given? 'package-root-hint))
> > +               (zero? (getuid)))
> > +      (record-hint 'package-root-hint)
> > +      (warning (G_ "this command is user-specific, so running it as ro=
ot \
> > +will affect only the 'root' user~%")))
>
> [...]
>
> > +    (when (and (not (hint-given? 'pull-root-hint))
> > +               (zero? (getuid)))
> > +      (record-hint 'pull-root-hint)
> > +      (warning (G_ "this command is user-specific, so running it as ro=
ot \
> > +will affect only the 'root' user~%")))
>
> It looks pretty similar.  Is it possible to avoid the duplication?

...I guess? Maybe we could do something like this?:

  ;;;; guix/scripts.scm

  (define (warn-if-root hint-name)
    (when (and (not (hint-given hint-name))
               (zero? (getuid)))
      (record-hint hint-name)
      (warning (G_ "this command is user-specific, so running it as root \
  > > +will affect only the 'root' user~%"))))

  ;;;; guix/scripts/package.scm

  (when root-hint?
    (warn-if-root 'package-root-hint))

  ;;;; guix/scripts/pull.scm

  (warn-if-root 'pull-root-hint)

    -- (




Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#57031] [PATCH v3 1/2] ui: Make one-time hint API public.
References: <20220807111421.14771-1-paren@HIDDEN>
In-Reply-To: <20220807111421.14771-1-paren@HIDDEN>
Resent-From: "(" <paren@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Thu, 27 Oct 2022 19:43:01 +0000
Resent-Message-ID: <handler.57031.B57031.166689977627121 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 57031
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 57031 <at> debbugs.gnu.org
Cc: "\(" <paren@HIDDEN>
Received: via spool by 57031-submit <at> debbugs.gnu.org id=B57031.166689977627121
          (code B ref 57031); Thu, 27 Oct 2022 19:43:01 +0000
Received: (at 57031) by debbugs.gnu.org; 27 Oct 2022 19:42:56 +0000
Received: from localhost ([127.0.0.1]:59415 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oo8mF-00073M-Qc
	for submit <at> debbugs.gnu.org; Thu, 27 Oct 2022 15:42:56 -0400
Received: from knopi.disroot.org ([178.21.23.139]:57158)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <paren@HIDDEN>) id 1oo8mE-000737-CO
 for 57031 <at> debbugs.gnu.org; Thu, 27 Oct 2022 15:42:55 -0400
Received: from localhost (localhost [127.0.0.1])
 by disroot.org (Postfix) with ESMTP id CB1744E81B;
 Thu, 27 Oct 2022 21:42:52 +0200 (CEST)
X-Virus-Scanned: SPAM Filter at disroot.org
Received: from knopi.disroot.org ([127.0.0.1])
 by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024)
 with UTF8SMTP id C6BIFCH-tePl; Thu, 27 Oct 2022 21:42:51 +0200 (CEST)
From: "(" <paren@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail;
 t=1666899770; bh=aD82VbXMexYv2POWO4x3TPxE3rTnQJpkD/WFHqo4aWg=;
 h=From:To:Cc:Subject:Date;
 b=R0icBIqSQ7bs4r82geWg6sj/E5XY71hD1l0rkHQtoRlbGz+0tyGiXDU0lV3HWro+U
 RXlMfT/MT/kyKU6MqZi2ORu/pFOSSUbHNMzmClEcK62biBMTqvbkgCLlPv2xUM0Z9L
 TO8yJmVQMGax0Nc4FGQkh90q4XiBOKNGMepQhCuUg8YLyKkzW3drFSZLxgFbO9RYIW
 uuKKOzK3n5gEjHCqJeqH4ZdAUL3GYX9jHLx8cG3K9P8hEkChORh9ai7ab9gXqVj1LI
 Aq7cQLybf0iVAYQguyM2sAbDiGOzc0RC+DJ4/xOJAl30gfGPyMf13tRIuFiDyoDdhL
 EAf0QpaEXwVQg==
Date: Thu, 27 Oct 2022 20:42:42 +0100
Message-Id: <20221027194243.15612-1-paren@HIDDEN>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 1.3 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  * guix/scripts/shell.scm (hint-directory, hint-file,
 record-hint, 
 hint-given?): Move these... * guix/ui.scm (hint-directory, hint-file,
 record-hint, 
 hint-given?): ...here. --- guix/scripts/shell.scm | [...] 
 Content analysis details:   (1.3 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 1.3 FROM_ONE_CHAR          Bogus FROM name
 -0.0 SPF_PASS               SPF: sender matches SPF record
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.3 (/)

* guix/scripts/shell.scm (hint-directory, hint-file, record-hint,
  hint-given?): Move these...
* guix/ui.scm (hint-directory, hint-file, record-hint, hint-given?):
  ...here.
---
 guix/scripts/shell.scm | 23 -----------------------
 guix/ui.scm            | 29 +++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/guix/scripts/shell.scm b/guix/scripts/shell.scm
index a2836629ad..c66ff4e5c4 100644
--- a/guix/scripts/shell.scm
+++ b/guix/scripts/shell.scm
@@ -505,29 +505,6 @@ (define (validated-spec spec)
       (exp
        (pretty-print exp port)))))
 
-
-;;;
-;;; One-time hints.
-;;;
-
-(define (hint-directory)
-  "Return the directory name where previously given hints are recorded."
-  (string-append (cache-directory #:ensure? #f) "/hints"))
-
-(define (hint-file hint)
-  "Return the name of the file that marks HINT as already printed."
-  (string-append (hint-directory) "/" (symbol->string hint)))
-
-(define (record-hint hint)
-  "Mark HINT as already given."
-  (let ((file (hint-file hint)))
-    (mkdir-p (dirname file))
-    (close-fdes (open-fdes file (logior O_CREAT O_WRONLY)))))
-
-(define (hint-given? hint)
-  "Return true if HINT was already given."
-  (file-exists? (hint-file hint)))
-
 
 (define-command (guix-shell . args)
   (category development)
diff --git a/guix/ui.scm b/guix/ui.scm
index dad2b853ac..3512c761d2 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -19,6 +19,7 @@
 ;;; Copyright © 2018 Steve Sprang <scs@HIDDEN>
 ;;; Copyright © 2022 Taiju HIGASHI <higashi@HIDDEN>
 ;;; Copyright © 2022 Liliana Marie Prikler <liliana.prikler@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -137,6 +138,11 @@ (define-module (guix ui)
             switch-to-generation*
             delete-generation*
 
+            hint-directory
+            hint-file
+            record-hint
+            hint-given?
+
             %default-message-language
             current-message-language
 
@@ -2057,6 +2063,29 @@ (define* (package-specification->name+version+output spec
                  (package-name->name+version name)))
     (values name version sub-drv)))
 
+
+;;;
+;;; One-time hints.
+;;;
+
+(define (hint-directory)
+  "Return the directory name where previously given hints are recorded."
+  (string-append (cache-directory #:ensure? #f) "/hints"))
+
+(define (hint-file hint)
+  "Return the name of the file that marks HINT as already printed."
+  (string-append (hint-directory) "/" (symbol->string hint)))
+
+(define (record-hint hint)
+  "Mark HINT as already given."
+  (let ((file (hint-file hint)))
+    (mkdir-p (dirname file))
+    (close-fdes (open-fdes file (logior O_CREAT O_WRONLY)))))
+
+(define (hint-given? hint)
+  "Return true if HINT was already given."
+  (file-exists? (hint-file hint)))
+
 
 ;;;
 ;;; Command-line option processing.

base-commit: f928abac369f699f425ddee925d0d0c2dc0a635d
-- 
2.38.0





Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#57031] [PATCH v3 2/2] scripts: Warn the first time pull or package is run as root.
Resent-From: "(" <paren@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Thu, 27 Oct 2022 19:43:02 +0000
Resent-Message-ID: <handler.57031.B57031.166689978027135 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 57031
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 57031 <at> debbugs.gnu.org
Cc: "\(" <paren@HIDDEN>
Received: via spool by 57031-submit <at> debbugs.gnu.org id=B57031.166689978027135
          (code B ref 57031); Thu, 27 Oct 2022 19:43:02 +0000
Received: (at 57031) by debbugs.gnu.org; 27 Oct 2022 19:43:00 +0000
Received: from localhost ([127.0.0.1]:59417 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oo8mK-00073Z-89
	for submit <at> debbugs.gnu.org; Thu, 27 Oct 2022 15:43:00 -0400
Received: from knopi.disroot.org ([178.21.23.139]:57292)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <paren@HIDDEN>) id 1oo8mE-000738-BE
 for 57031 <at> debbugs.gnu.org; Thu, 27 Oct 2022 15:42:55 -0400
Received: from localhost (localhost [127.0.0.1])
 by disroot.org (Postfix) with ESMTP id 394DF4E821;
 Thu, 27 Oct 2022 21:42:53 +0200 (CEST)
X-Virus-Scanned: SPAM Filter at disroot.org
Received: from knopi.disroot.org ([127.0.0.1])
 by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024)
 with UTF8SMTP id SBmJFtkuryEX; Thu, 27 Oct 2022 21:42:51 +0200 (CEST)
From: "(" <paren@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail;
 t=1666899771; bh=6NEkYhvLxikMziXYAM8sT06+h0t6jC1dinzPnK4aS3Q=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=NA1TZ0T5MCFYIBlUhyjnvH5Y6qB/wUFrzYwqPBQjqE8h8uXrAX7rQYQiq2aaECETc
 z2bxSztnqIte62NNWYvZiUfBwGk8XvuYTihquU0BaNC4a7r1bBeOZQvwLz+rSHrHtE
 TzNbD7zs65bqlFQPlqve3D6VgW0msqgR5Miljz/mlvrRgYfe2HgSE/GrMx7Rt7zsfI
 cOv9d1r8J2YOv3VIwDngLYMebq+95EvT3AVfSqbp1ieTZHgDxD+f41g7RMxYMl9dMo
 +ScYbIpBiaO3WlxLJifiya5ebaLqeO59+v44r56g7+atUE0nj631S9cwAn0jRN8Bfl
 XhTeWGeD/zetg==
Date: Thu, 27 Oct 2022 20:42:43 +0100
Message-Id: <20221027194243.15612-2-paren@HIDDEN>
In-Reply-To: <20221027194243.15612-1-paren@HIDDEN>
References: <20221027194243.15612-1-paren@HIDDEN>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 3.3 (+++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview: * guix/ui.scm (root-warning): New variable. *
 guix/scripts/pull.scm
 (guix-pull): Warn the first time it's being run as root. *
 guix/scripts/package.scm
 (guix-package*): Likewise if the new `root-hint? [...] 
 Content analysis details:   (3.3 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 1.3 FROM_ONE_CHAR          Bogus FROM name
 -0.0 SPF_PASS               SPF: sender matches SPF record
 2.0 PDS_OTHER_BAD_TLD      Untrustworthy TLDs
 [URI: jpoiret.xyz (xyz)]
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 2.3 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  * guix/ui.scm (root-warning): New variable. * guix/scripts/pull.scm
    (guix-pull): Warn the first time it's being run as root. * guix/scripts/package.scm
    (guix-package*): Likewise if the new `root-hint? [...] 
 
 Content analysis details:   (2.3 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
  1.3 FROM_ONE_CHAR          Bogus FROM name
 -0.0 SPF_PASS               SPF: sender matches SPF record
  2.0 PDS_OTHER_BAD_TLD      Untrustworthy TLDs
                             [URI: jpoiret.xyz (xyz)]
  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager

* guix/ui.scm (root-warning): New variable.
* guix/scripts/pull.scm (guix-pull): Warn the first time it's being
  run as root.
* guix/scripts/package.scm (guix-package*): Likewise if the new
  `root-hint?' argument is `#t'.
(guix-package): Use `#:root-hint? #t' in invocation of `guix-package*'.
* guix/scripts/install.scm (guix-install): Likewise.
* guix/scripts/remove.scm (guix-remove): Likewise.
* guix/scripts/remove.scm (guix-upgrade): Likewise.

A pretty common beginner mistake, it seems, is assuming that since
every other package manager you've used requires root for installing,
removing, and upgrading packages, Guix must too.

This commit tries to make it harder to make such an assumption, by
making commands such as `pull`, `package`, and `upgrade` display
a warning the first time they are run as root.
---
 guix/scripts/install.scm |  3 ++-
 guix/scripts/package.scm | 11 ++++++++---
 guix/scripts/pull.scm    |  2 ++
 guix/scripts/remove.scm  |  3 ++-
 guix/scripts/upgrade.scm |  3 ++-
 guix/ui.scm              |  8 ++++++++
 6 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/install.scm b/guix/scripts/install.scm
index 63e625f266..bf11fc7b11 100644
--- a/guix/scripts/install.scm
+++ b/guix/scripts/install.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -80,4 +81,4 @@ (define opts
                         (list %package-default-options #f)
                         #:argument-handler handle-argument))
 
-  (guix-package* opts))
+  (guix-package* opts #:root-hint? #t))
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index b9090307ac..10cf32475b 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -12,6 +12,7 @@
 ;;; Copyright © 2018 Steve Sprang <scs@HIDDEN>
 ;;; Copyright © 2022 Josselin Poiret <dev@HIDDEN>
 ;;; Copyright © 2022 Antero Mejr <antero@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1078,12 +1079,16 @@ (define opts
     (parse-command-line args %options (list %default-options #f)
                         #:argument-handler handle-argument))
 
-  (guix-package* opts))
+  (guix-package* opts #:root-hint? #t))
 
-(define (guix-package* opts)
+(define* (guix-package* opts #:key (root-hint? #f))
   "Run the 'guix package' command on OPTS, an alist resulting for command-line
-option processing with 'parse-command-line'."
+option processing with 'parse-command-line'.  If ROOT-HINT? is #T, a hint is
+shown on the first usage of this procedure that informs users about Guix's
+support for per-user package management."
   (with-error-handling
+    (when root-hint?
+      (root-warning 'package-root-hint))
     (or (process-query opts)
         (parameterize ((%store  (open-connection))
                        (%graft? (assoc-ref opts 'graft?)))
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 7b6c58dbc3..98aaf0b377 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2013-2015, 2017-2022 Ludovic Courtès <ludo@HIDDEN>
 ;;; Copyright © 2017 Marius Bakke <mbakke@HIDDEN>
 ;;; Copyright © 2020, 2021 Tobias Geerinckx-Rice <me@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -826,6 +827,7 @@ (define (no-arguments arg _)
     (leave (G_ "~A: extraneous argument~%") arg))
 
   (with-error-handling
+    (root-warning 'pull-root-hint)
     (with-git-error-handling
      (let* ((opts         (parse-command-line args %options
                                               (list %default-options)
diff --git a/guix/scripts/remove.scm b/guix/scripts/remove.scm
index a46ad04d56..131649eace 100644
--- a/guix/scripts/remove.scm
+++ b/guix/scripts/remove.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -76,4 +77,4 @@ (define opts
                         (list %package-default-options #f)
                         #:argument-handler handle-argument))
 
-  (guix-package* opts))
+  (guix-package* opts #:root-hint? #t))
diff --git a/guix/scripts/upgrade.scm b/guix/scripts/upgrade.scm
index beb59cbe6f..dd14600fe4 100644
--- a/guix/scripts/upgrade.scm
+++ b/guix/scripts/upgrade.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@HIDDEN>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@HIDDEN>
 ;;; Copyright © 2020 Simon Tournier <zimon.toutoune@HIDDEN>
+;;; Copyright © 2022 ( <paren@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -87,4 +88,4 @@ (define opts
                               #f)
                         #:argument-handler handle-argument))
 
-  (guix-package* opts))
+  (guix-package* opts #:root-hint? #t))
diff --git a/guix/ui.scm b/guix/ui.scm
index 3512c761d2..0f1a603025 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -142,6 +142,7 @@ (define-module (guix ui)
             hint-file
             record-hint
             hint-given?
+            root-warning
 
             %default-message-language
             current-message-language
@@ -2086,6 +2087,13 @@ (define (hint-given? hint)
   "Return true if HINT was already given."
   (file-exists? (hint-file hint)))
 
+(define (root-warning hint-name)
+  (when (and (not (hint-given? hint-name))
+             (zero? (getuid)))
+    (record-hint hint-name)
+    (warning (G_ "this command is user-specific, so running it as root \
+will affect only the 'root' user~%"))))
+
 
 ;;;
 ;;; Command-line option processing.
-- 
2.38.0






Last modified: Thu, 27 Oct 2022 19:45:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.