GNU bug report logs - #57031
[PATCH] scripts: Show a hint the first time some commands are run as root.

Previous Next

Package: guix-patches;

Reported by: "(" <paren <at> disroot.org>

Date: Sun, 7 Aug 2022 11:15:02 UTC

Severity: normal

Tags: patch

Full log


View this message in rfc822 format

From: zimoun <zimon.toutoune <at> gmail.com>
To: "(" <paren <at> disroot.org>, 57031 <at> 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 10:23:19 +0200
Hi,

On Thu, 27 Oct 2022 at 06:52, "\( via Guix-patches" via <guix-patches <at> gnu.org> wrote:
> 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.

Ah, I see.  But then,

    guix package --show=hello

would print the hint, no?

>   ;;;; 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)

Something like that SGTM.


Cheers,
simon




This bug report was last modified 2 years and 236 days ago.

Previous Next


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