GNU bug report logs -
#57031
[PATCH] scripts: Show a hint the first time some commands are run as root.
Previous Next
Full log
View this message in rfc822 format
Hi,
On Sun, 11 Sep 2022 at 20:59, "\( via Guix-patches" via <guix-patches <at> gnu.org> 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…
> - (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?
> + (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
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.