From: "\( via Guix-patches" via <guix-patches@gnu.org>
To: zimon.toutoune@gmail.com, 57031@debbugs.gnu.org
Subject: [bug#57031] [PATCH v2 2/2] scripts: Warn the first time pull or package is run as root.
Date: Thu, 27 Oct 2022 06:52:36 +0100 [thread overview]
Message-ID: <CNWGZUVC3SC1.2FM8LO0EOJ62F@guix-framework> (raw)
In-Reply-To: <86lep2jvty.fsf@gmail.com>
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 ’root-hint?’ argument? Is it useful or can we drop 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 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?
...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)
-- (
next prev parent reply other threads:[~2022-10-27 5:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-07 11:14 [bug#57031] [PATCH] scripts: Show a hint the first time some commands are run as root ( via Guix-patches via
2022-08-07 11:19 ` [bug#57031] [PATCH v2] " ( via Guix-patches via
2022-08-07 11:22 ` ( via Guix-patches via
2022-09-05 21:11 ` [bug#57031] [PATCH] " Ludovic Courtès
2022-09-11 13:05 ` ( via Guix-patches via
2022-09-11 19:59 ` [bug#57031] [PATCH v2 1/2] ui: Make one-time hint API public ( via Guix-patches via
2022-09-11 19:59 ` [bug#57031] [PATCH v2 2/2] scripts: Warn the first time pull or package is run as root ( via Guix-patches via
2022-10-26 18:14 ` zimoun
2022-10-27 5:52 ` ( via Guix-patches via [this message]
2022-10-27 8:23 ` zimoun
2022-10-28 14:33 ` ( via Guix-patches via
2022-10-27 19:42 ` [bug#57031] [PATCH v3 1/2] ui: Make one-time hint API public ( via Guix-patches via
2022-10-27 19:42 ` [bug#57031] [PATCH v3 2/2] scripts: Warn the first time pull or package is run as root ( via Guix-patches via
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CNWGZUVC3SC1.2FM8LO0EOJ62F@guix-framework \
--to=guix-patches@gnu.org \
--cc=57031@debbugs.gnu.org \
--cc=paren@disroot.org \
--cc=zimon.toutoune@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).