diff options
author | Ludovic Courtès <ludo@gnu.org> | 2014-07-23 18:17:06 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2014-07-23 18:20:56 +0200 |
commit | 720ee245dae56759785f968aca1714ea222645ad (patch) | |
tree | 4cbd71b8e8c5deae0c5a3c077f8cc10bd0c09657 /guix/scripts | |
parent | b6debdaa22931646fbbc116048732c6bcb37af3c (diff) |
guix system: Protect against changes to $PATH when activating the system.
Partly fixes <http://bugs.gnu.org/18082>.
Reported by Mark H Weaver <mhw@netris.org>.
* guix/scripts/system.scm (save-environment-excursion): New macro.
(switch-to-system): Wrap 'primitive-load' call in it.
Diffstat (limited to 'guix/scripts')
-rw-r--r-- | guix/scripts/system.scm | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 5737807d8b..4f1869af38 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -172,6 +172,16 @@ When GRUB? is true, install GRUB on DEVICE, using GRUB.CFG." ;; The system profile. (string-append %state-directory "/profiles/system")) +(define-syntax-rule (save-environment-excursion body ...) + "Save the current environment variables, run BODY..., and restore them." + (let ((env (environ))) + (dynamic-wind + (const #t) + (lambda () + body ...) + (lambda () + (environ env))))) + (define* (switch-to-system os #:optional (profile %system-profile)) "Make a new generation of PROFILE pointing to the directory of OS, switch to @@ -185,7 +195,11 @@ it atomically, and then run OS's activation script." (switch-symlinks profile generation) (format #t (_ "activating system...~%")) - (return (primitive-load (derivation->output-path script))) + + ;; The activation script may change $PATH, among others, so protect + ;; against that. + (return (save-environment-excursion + (primitive-load (derivation->output-path script)))) ;; TODO: Run 'deco reload ...'. ))) |