* bug#42983: "sudo -E guix pull" breaks ~/.config/guix/current for regular user
@ 2020-08-22 10:27 Danny Milosavljevic
2020-08-22 16:20 ` Bengt Richter
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Danny Milosavljevic @ 2020-08-22 10:27 UTC (permalink / raw)
To: 42983
[-- Attachment #1: Type: text/plain, Size: 1492 bytes --]
Hello,
Paul <paul@denknerd.org> reported on IRC that his guix behaved strangely. Upon
investigation we found that the following happens (on a Guix system), when logged
in as regular user (not root):
$ readlink ~/.config/guix/current
/var/guix/profiles/per-user/dannym/current-guix
$ sudo -E guix pull
$ readlink ~/.config/guix/current
/var/guix/profiles/per-user/root/current-guix
You can also rm -f ~/.config/guix/current after that and do everything above
again and it will happen again. It even happens when guix pull has nothing to
do.
That doesn't seem right. We should at least try to prevent this from happening,
or warn or something.
The guix package manager that did that is:
$ sudo -E guix describe
Generation 64 Aug 22 2020 11:41:04 (current)
guix dad963a
repository URL: https://git.savannah.gnu.org/git/guix.git
branch: master
commit: dad963a4393ea51409baa63817b26b449ed58338
heads 50b97d4
repository URL: https://github.com/daym/heads-guix.git
branch: wip-musl
commit: 50b97d446ebafd0be7a0e19d87cd236882093244
$ sudo -i
# guix describe
Generation 64 22. August 2020 11:41:04 (aktuell)
guix dad963a
Repository-URL: https://git.savannah.gnu.org/git/guix.git
Branch: master
Commit: dad963a4393ea51409baa63817b26b449ed58338
heads 50b97d4
Repository-URL: https://github.com/daym/heads-guix.git
Branch: wip-musl
Commit: 50b97d446ebafd0be7a0e19d87cd236882093244
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#42983: "sudo -E guix pull" breaks ~/.config/guix/current for regular user
2020-08-22 10:27 bug#42983: "sudo -E guix pull" breaks ~/.config/guix/current for regular user Danny Milosavljevic
@ 2020-08-22 16:20 ` Bengt Richter
2020-08-23 23:53 ` Danny Milosavljevic
2020-08-22 16:22 ` Leo Famulari
2020-08-24 0:11 ` Danny Milosavljevic
2 siblings, 1 reply; 9+ messages in thread
From: Bengt Richter @ 2020-08-22 16:20 UTC (permalink / raw)
To: Danny Milosavljevic; +Cc: 42983
Hi,
On +2020-08-22 12:27:50 +0200, Danny Milosavljevic wrote:
> Hello,
>
> Paul <paul@denknerd.org> reported on IRC that his guix behaved strangely. Upon
> investigation we found that the following happens (on a Guix system), when logged
> in as regular user (not root):
>
> $ readlink ~/.config/guix/current
> /var/guix/profiles/per-user/dannym/current-guix
> $ sudo -E guix pull
> $ readlink ~/.config/guix/current
> /var/guix/profiles/per-user/root/current-guix
>
> You can also rm -f ~/.config/guix/current after that and do everything above
> again and it will happen again. It even happens when guix pull has nothing to
> do.
>
> That doesn't seem right. We should at least try to prevent this from happening,
> or warn or something.
>
ISTM it looks like a bug that should be fixed[1], urgently, not just warned about :)
[1] eliminated from the possibility of happening :)
> The guix package manager that did that is:
>
> $ sudo -E guix describe
> Generation 64 Aug 22 2020 11:41:04 (current)
> guix dad963a
> repository URL: https://git.savannah.gnu.org/git/guix.git
> branch: master
> commit: dad963a4393ea51409baa63817b26b449ed58338
> heads 50b97d4
> repository URL: https://github.com/daym/heads-guix.git
> branch: wip-musl
> commit: 50b97d446ebafd0be7a0e19d87cd236882093244
>
> $ sudo -i
> # guix describe
> Generation 64 22. August 2020 11:41:04 (aktuell)
> guix dad963a
> Repository-URL: https://git.savannah.gnu.org/git/guix.git
> Branch: master
> Commit: dad963a4393ea51409baa63817b26b449ed58338
> heads 50b97d4
> Repository-URL: https://github.com/daym/heads-guix.git
> Branch: wip-musl
> Commit: 50b97d446ebafd0be7a0e19d87cd236882093244
I find it peculiar that root (sudo -i) looks like it's using swedish locale
("aktuell" is swedish for "current") with the rest of the output identical.
(Hm, maybe that's also Norwegian ;-)
If describe is describing two things that are identical end values of
readlink -f thing{1..2}, I think it would be helpful to show the thing{1..2}
profile links it's using.
BTW, what would sudo guix describe without the -E (preserving user environment) have produced?
--
Regards,
Bengt Richter
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#42983: "sudo -E guix pull" breaks ~/.config/guix/current for regular user
2020-08-22 10:27 bug#42983: "sudo -E guix pull" breaks ~/.config/guix/current for regular user Danny Milosavljevic
2020-08-22 16:20 ` Bengt Richter
@ 2020-08-22 16:22 ` Leo Famulari
2020-08-23 21:24 ` Danny Milosavljevic
2020-08-24 0:11 ` Danny Milosavljevic
2 siblings, 1 reply; 9+ messages in thread
From: Leo Famulari @ 2020-08-22 16:22 UTC (permalink / raw)
To: Danny Milosavljevic; +Cc: 42983
On Sat, Aug 22, 2020 at 12:27:50PM +0200, Danny Milosavljevic wrote:
> Paul <paul@denknerd.org> reported on IRC that his guix behaved strangely. Upon
> investigation we found that the following happens (on a Guix system), when logged
> in as regular user (not root):
>
> $ readlink ~/.config/guix/current
> /var/guix/profiles/per-user/dannym/current-guix
> $ sudo -E guix pull
> $ readlink ~/.config/guix/current
> /var/guix/profiles/per-user/root/current-guix
What is expected to happen in this case? Why would one want to use an
unprivileged environment with privileges to do `guix pull`, which is a
per-user operation?
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#42983: "sudo -E guix pull" breaks ~/.config/guix/current for regular user
2020-08-22 16:22 ` Leo Famulari
@ 2020-08-23 21:24 ` Danny Milosavljevic
2020-08-23 21:45 ` Leo Famulari
0 siblings, 1 reply; 9+ messages in thread
From: Danny Milosavljevic @ 2020-08-23 21:24 UTC (permalink / raw)
To: Leo Famulari; +Cc: 42983
[-- Attachment #1: Type: text/plain, Size: 546 bytes --]
Hi Leo,
On Sat, 22 Aug 2020 12:22:41 -0400
Leo Famulari <leo@famulari.name> wrote:
> What is expected to happen in this case? Why would one want to use an
> unprivileged environment with privileges to do `guix pull`, which is a
> per-user operation?
Paul did not know that it is a per-user operation.
I did almost exactly the same thing when I was a new guix user.
That's pretty much what one is used to from Debian etc.
I don't really know whether it should do anything useful, but the current
situation is seriously weird.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#42983: "sudo -E guix pull" breaks ~/.config/guix/current for regular user
2020-08-23 21:24 ` Danny Milosavljevic
@ 2020-08-23 21:45 ` Leo Famulari
0 siblings, 0 replies; 9+ messages in thread
From: Leo Famulari @ 2020-08-23 21:45 UTC (permalink / raw)
To: Danny Milosavljevic; +Cc: 42983
[-- Attachment #1: Type: text/plain, Size: 1307 bytes --]
On Sun, Aug 23, 2020 at 11:24:43PM +0200, Danny Milosavljevic wrote:
> Paul did not know that it is a per-user operation.
>
> I did almost exactly the same thing when I was a new guix user.
> That's pretty much what one is used to from Debian etc.
I see. Coming from Debian, I also had trouble learning the differences
between various options of sudo, and also the differences between login
shells, interactive shells, etc. They don't matter on Debian, but they
do matter for Guix.
> I don't really know whether it should do anything useful, but the current
> situation is seriously weird.
Considering how often people stumble on this, I've been wondering if
Guix should handle privilege escalation internally, rather than asking
users to learn these arcane details of Unix.
Systemd does that. For example, given an operation that requires
privileges, if I attempt to run it without privileges, it will use
polkit (I think) to escalate safely. It's optional and not all distros
enable it by default. It looks like this:
------
$ systemctl restart guix-daemon
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'guix-daemon.service'.
Authenticating as: leo,,, (leo)
Password:
==== AUTHENTICATION COMPLETE ===
------
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#42983: "sudo -E guix pull" breaks ~/.config/guix/current for regular user
2020-08-22 10:27 bug#42983: "sudo -E guix pull" breaks ~/.config/guix/current for regular user Danny Milosavljevic
2020-08-22 16:20 ` Bengt Richter
2020-08-22 16:22 ` Leo Famulari
@ 2020-08-24 0:11 ` Danny Milosavljevic
2020-08-28 13:41 ` Ludovic Courtès
2 siblings, 1 reply; 9+ messages in thread
From: Danny Milosavljevic @ 2020-08-24 0:11 UTC (permalink / raw)
To: 42983
[-- Attachment #1: Type: text/plain, Size: 1870 bytes --]
On Sat, 22 Aug 2020 12:27:50 +0200
Danny Milosavljevic <dannym@scratchpost.org> wrote:
> /var/guix/profiles/per-user/dannym/current-guix
Follow-up errors (translated to English manually):
dannym@dayas ~$ guix pull
Migrating profile generations to „/var/guix/profiles/per-user/dannym“ …
guix pull: error: symlink: file exists: "/var/guix/profiles/per-user/dannym/current-guix"
1 dannym@dayas ~$ rm ~/.config/guix/current
dannym@dayas ~$ cd .config/guix/
dannym@dayas ~/.config/guix$ ln -s /var/guix/profiles/per-user/dannym/current-guix current
dannym@dayas ~/.config/guix$ guix pull
Refreshing channel „guix“ from Git-Repository „https://git.savannah.gnu.org/git/guix.git“ …
guix pull: error: Git-Error: failed open - '/home/dannym/.cache/guix/checkouts/pjmkglp4t7znuugeurpurzikxq3tnlaywmisyr27shj7apsnalwq/.git/FETCH_HEAD' is locked: Permission denied
That's some weird guix pull state.
The culprit, I think, is this:
(define (ensure-default-profile)
(ensure-profile-directory)
;; In 0.15.0+ we'd create ~/.config/guix/current-[0-9]*-link symlinks. Move
;; them to %PROFILE-DIRECTORY.
;;
;; XXX: Ubuntu's 'sudo' preserves $HOME by default, and thus the second
;; condition below is always false when one runs "sudo guix pull". As a
;; workaround, skip this code when $SUDO_USER is set. See
;; <https://bugs.gnu.org/36785>.
(unless (or (getenv "SUDO_USER")
(string=? %profile-directory
(dirname
(canonicalize-profile %user-profile-directory))))
(migrate-generations %user-profile-directory %profile-directory))
where
%profile-directory = "/var/guix/profiles/per-user/dannym"
%user-profile-directory = "/home/dannym/.config/guix/current" (which is a
symlink to /var/guix/profiles/per-user/root/current-guix)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#42983: "sudo -E guix pull" breaks ~/.config/guix/current for regular user
2020-08-24 0:11 ` Danny Milosavljevic
@ 2020-08-28 13:41 ` Ludovic Courtès
0 siblings, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2020-08-28 13:41 UTC (permalink / raw)
To: Danny Milosavljevic; +Cc: 42983
Hi Danny,
Danny Milosavljevic <dannym@scratchpost.org> skribis:
> The culprit, I think, is this:
>
> (define (ensure-default-profile)
> (ensure-profile-directory)
>
> ;; In 0.15.0+ we'd create ~/.config/guix/current-[0-9]*-link symlinks. Move
> ;; them to %PROFILE-DIRECTORY.
> ;;
> ;; XXX: Ubuntu's 'sudo' preserves $HOME by default, and thus the second
> ;; condition below is always false when one runs "sudo guix pull". As a
> ;; workaround, skip this code when $SUDO_USER is set. See
> ;; <https://bugs.gnu.org/36785>.
> (unless (or (getenv "SUDO_USER")
> (string=? %profile-directory
> (dirname
> (canonicalize-profile %user-profile-directory))))
> (migrate-generations %user-profile-directory %profile-directory))
>
> where
>
> %profile-directory = "/var/guix/profiles/per-user/dannym"
> %user-profile-directory = "/home/dannym/.config/guix/current" (which is a
> symlink to /var/guix/profiles/per-user/root/current-guix)
We could detect such inconsistencies and emit a warning/hint. I’m
unsure just how far we need to go in trying to prevent users from
shooting themselves in the foot, though. Thoughts?
> Ohh, yeah, sudo without "-E" works fine (sudo guix pull, too).
Yes.
Ludo’.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-08-28 13:42 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-22 10:27 bug#42983: "sudo -E guix pull" breaks ~/.config/guix/current for regular user Danny Milosavljevic
2020-08-22 16:20 ` Bengt Richter
2020-08-23 23:53 ` Danny Milosavljevic
[not found] ` <20200824023829.GA18670@LionPure>
2020-08-25 8:43 ` Danny Milosavljevic
2020-08-22 16:22 ` Leo Famulari
2020-08-23 21:24 ` Danny Milosavljevic
2020-08-23 21:45 ` Leo Famulari
2020-08-24 0:11 ` Danny Milosavljevic
2020-08-28 13:41 ` Ludovic Courtès
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).