GNU bug report logs -
#57031
[PATCH] scripts: Show a hint the first time some commands are run as root.
Previous Next
Full log
Message #32 received at submit <at> debbugs.gnu.org (full text, mbox):
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)
-- (
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.