[PATCH] Use absolute path for home activation script.

  • Done
  • quality assurance status badge
Details
2 participants
  • Andrew Tropin
  • Ludovic Courtès
Owner
unassigned
Submitted by
Andrew Tropin
Severity
normal

Debbugs page

Andrew Tropin wrote 3 years ago
(address . guix-patches@gnu.org)
87tu74z479.fsf@trop.in
* gnu/home/services.scm (compute-activation-script): Use absolute path for
home activation script.

---
gnu/home/services.scm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Toggle diff (15 lines)
diff --git a/gnu/home/services.scm b/gnu/home/services.scm
index b05ec53e2a..6d5e4308a0 100644
--- a/gnu/home/services.scm
+++ b/gnu/home/services.scm
@@ -418,7 +418,7 @@ (define (compute-activation-script init-gexp gexps)
(new-home-env (getenv "GUIX_NEW_HOME"))
(new-home (or new-home-env
;; Path of the activation file if called interactively
- (dirname (car (command-line)))))
+ (canonicalize-path (dirname (car (command-line))))))
(old-home-env (getenv "GUIX_OLD_HOME"))
(old-home (or old-home-env
(if (file-exists? (he-init-file he-path))
--
2.37.0
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmLfoPoACgkQIgjSCVjB
3rDtTA/+Icr92AcMQPhA+JwYCyC3P6w/v12tCTerGWodNzRk1m42y35KpDY2QUfc
hvOz+Vb5w+VJZALcC/iPcB1Hp2Hrnf5BoMEhtin1XYZ40nx4yh5kUXde5qdkuqxT
xkqHzoJ4JjjQHeH1ZCTyvLlLRP/THuLY5OxSjUvpf4lrzULnd4GpMNbFcYdyqWTq
YWjxvZEfwHf0C/jYZZ3dqWDoTPVdb40f0K5jGqIYrdlmdBsvR4qQJGpMpxD3XlQK
Gl9Tmm5rZ9aDXBXwCCk03QPnkvYlP9olCfvuYLwUE84J738979hhCfyUDn2kS1zi
xvLlU0cXxNMoayNRtopZ1r346Oc4oKbIKohS9xWc6z8NhhLie+51MXrBVax2zqbD
j00Ol2Mn0hetbrNfGgRPqLEqlPQbkswDuC3khIuhUsEAjEoVKKj6qIMAa5aDKPoC
buGN2rHxMWe2/pAMaJyde8mnUnW6HXwv3ljrfMkKQJVpfZ4IWuswKlVApOz6m1Xw
G+lIkfVX55rJWBArVpQYDLRNh5zf9z4K9IyxsMMB4a7utC+7nhhSLXz5mzp3EWO+
FAGYxOKQ7StRAcSGot/USgkcV0YIpfFjXVbqtIO3bjuXNqbob3augBeUGlDF9+uf
gs/X1DVToctvU1XQA5zTUQvYmorEIyfonagpFWsZ2GAbXMU+hqE=
=i8pA
-----END PGP SIGNATURE-----

Ludovic Courtès wrote 3 years ago
(name . Andrew Tropin)(address . andrew@trop.in)(address . 56777@debbugs.gnu.org)
871qsy68wd.fsf@gnu.org
Hi Andrew,

Andrew Tropin <andrew@trop.in> skribis:

Toggle quote (18 lines)
> * gnu/home/services.scm (compute-activation-script): Use absolute path for
> home activation script.
>
> ---
> gnu/home/services.scm | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gnu/home/services.scm b/gnu/home/services.scm
> index b05ec53e2a..6d5e4308a0 100644
> --- a/gnu/home/services.scm
> +++ b/gnu/home/services.scm
> @@ -418,7 +418,7 @@ (define (compute-activation-script init-gexp gexps)
> (new-home-env (getenv "GUIX_NEW_HOME"))
> (new-home (or new-home-env
> ;; Path of the activation file if called interactively
> - (dirname (car (command-line)))))
> + (canonicalize-path (dirname (car (command-line))))))

Just wondering: what’s the rationale?

This is harmless-looking and perhaps it’s all fine, but IME calling
‘canonicalize-path’ might sometimes paper over problems related to file
name handling.

Thanks,
Ludo’.
Andrew Tropin wrote 3 years ago
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 56777@debbugs.gnu.org)
87pmgi2p10.fsf@trop.in
On 2022-08-29 23:24, Ludovic Courtès wrote:

Toggle quote (24 lines)
> Hi Andrew,
>
> Andrew Tropin <andrew@trop.in> skribis:
>
>> * gnu/home/services.scm (compute-activation-script): Use absolute path for
>> home activation script.
>>
>> ---
>> gnu/home/services.scm | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/gnu/home/services.scm b/gnu/home/services.scm
>> index b05ec53e2a..6d5e4308a0 100644
>> --- a/gnu/home/services.scm
>> +++ b/gnu/home/services.scm
>> @@ -418,7 +418,7 @@ (define (compute-activation-script init-gexp gexps)
>> (new-home-env (getenv "GUIX_NEW_HOME"))
>> (new-home (or new-home-env
>> ;; Path of the activation file if called interactively
>> - (dirname (car (command-line)))))
>> + (canonicalize-path (dirname (car (command-line))))))
>
> Just wondering: what’s the rationale?

It's been a while since I posted it, but IIRC, in case the activation
script called manually from other directory without this change the
relative new-home can be set, which can fail later if some of activation
code changes the current working directory, but reference home
environment by relative path. Probably I faced this one, when was
working on prototype for https://issues.guix.gnu.org/56669

Another hypothetical case, which can fail:
ln -s /gnu/store/...-home ~/tmp/he
~/tmp/he/activate
rm ~/tmp/he
# Dangling symlink ~/.guix-home -> ~/tmp/he

Last one can be solved by resolving full path of new-home in
symlink-manager, but always setting new-home to absolute path to home
item in the store seems as a way to avoid both potential problems
mentioned above.

This change is pushed as ffc391500ac7eae1ef100d8d36f6c01f4f606170

Toggle quote (5 lines)
>
> This is harmless-looking and perhaps it’s all fine, but IME calling
> ‘canonicalize-path’ might sometimes paper over problems related to file
> name handling.

Will keep it in mind.

--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmMNtcwACgkQIgjSCVjB
3rBfIw//VXg1ZYs8D3ednwtwK/+yiNin/j1LmPtGk8D5wgHQuommMvxw6sMTXIve
TiGgBcoJI/4HiSD1RfOgAT2EpoO8XkYNmmPRztkYSMFVfSQ+C90ELv2//sFXgEqN
qGjOnS+fa+/hpSPgaUl1XFRznNj4RGjE3Bt/l28qML/hr/MBlXu/Tjv3sYbjm36n
VDgeV7lWU3ieaXNNkhymRZ691I3lXL/09xoMvBvmnm6Ww49PQKUEORkDfvx12ZVD
ySQYOTwZvN74owc21aa5hscimePnwBS0o+gfmt/KmIFte7tgxGn8roMaDKKhYes1
Z4oEbmVnC0lI1HEvfl+B33Pn0DdZwYFcd9EXsLRfqnY2EfaM9PuS9RSlX8lfLr+6
HTWx+Fy48XvMgfATTNk1W4GavpTRH8StggIHNhALVtGQ9p5+gHNqA5OBwH1xWpdr
9vTHzGjUXycDln/MDuuhjGHLCnM8RLzVGpbCFVmXO1wn1cmW6h1GRiKrqNH4DdrR
8QSrHBuZzYMoO/LVA96kAXi/6WCGjj3iWK2AwXLb2zLAbDuSHIjgkIQDFVY3SSpo
jIEpEj+9914sayp4f2/EKpvkA5rZX2tL5RedD/Lj3cpoxf7bRgjhtdOZDhZ3cqz6
Atm5Ta1Tf6zbMnu2xAozx6PIw10uZ1ypdBJtaxo5oVeJgB++JDY=
=7yv2
-----END PGP SIGNATURE-----

Ludovic Courtès wrote 3 years ago
control message for bug #56777
(address . control@debbugs.gnu.org)
87pmgg9mc0.fsf@gnu.org
close 56777
quit
?
Your comment

This issue is archived.

To comment on this conversation send an email to 56777@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 56777
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help