diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2026-05-04 17:54:36 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2026-05-10 17:01:08 +0200 |
| commit | c9dcd203e5356f13b736d5be121fd61874be1a93 (patch) | |
| tree | 7a581b4e6871e2db834c7d3ed558b8024a4b2247 | |
| parent | f13901f6cbd663019090963664ace72345165461 (diff) | |
pull, time-machine: ‘--allow-untrusted-channels’ takes an argument.
* guix/scripts/pull.scm (%default-options): Change ‘require-trusted-channels?’
to ‘require-trusted-channels’.
(show-help, %options): Support optional argument to
‘--allow-untrusted-channels’.
(channel-list): Adjust accordingly.
* guix/scripts/time-machine.scm (show-help, %options)
(%default-options): Likewise.
* tests/guix-time-machine.sh: Add test.
* doc/guix.texi (Invoking guix pull)
(Invoking guix time-machine): Adjust accordingly.
Suggested-by: Reepca Russelstein <reepca@russelstein.xyz>
Change-Id: I342ebbcc7355953487a5c6c8ac85048943a5ac46
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
| -rw-r--r-- | doc/guix.texi | 25 | ||||
| -rw-r--r-- | guix/scripts/pull.scm | 31 | ||||
| -rw-r--r-- | guix/scripts/time-machine.scm | 16 | ||||
| -rw-r--r-- | tests/guix-time-machine.sh | 11 |
4 files changed, 55 insertions, 28 deletions
diff --git a/doc/guix.texi b/doc/guix.texi index a8af7659b9b..a2c79346777 100644 --- a/doc/guix.texi +++ b/doc/guix.texi | |||
| @@ -4827,14 +4827,17 @@ or, if the above file doesn't exist, the currently-used channels as | |||
| 4827 | returned by @command{guix describe}. | 4827 | returned by @command{guix describe}. |
| 4828 | @end itemize | 4828 | @end itemize |
| 4829 | 4829 | ||
| 4830 | @item --allow-untrusted-channels | 4830 | @item --allow-untrusted-channels[=yes|no] |
| 4831 | When @option{--channels} is passed a URL, this option causes | 4831 | Whether to allow pulls from untrusted channels. |
| 4832 | @command{guix pull} to pull the channels returned from that URL, even if | 4832 | |
| 4833 | they are not trusted. | 4833 | By default, @command{guix pull} aborts when downloading a channel file |
| 4834 | that specifies an untrusted channel and merely warns if the list of | ||
| 4835 | channels comes from a local file. This option allows you to change | ||
| 4836 | that. | ||
| 4834 | 4837 | ||
| 4835 | @quotation Warning | 4838 | @quotation Warning |
| 4836 | Using this option can effectively lead to arbitrary code execution on | 4839 | Allowing untrusted channels can effectively lead to arbitrary code |
| 4837 | your system. | 4840 | execution on your system. |
| 4838 | @end quotation | 4841 | @end quotation |
| 4839 | 4842 | ||
| 4840 | @anchor{unsafe-channel-evaluation} | 4843 | @anchor{unsafe-channel-evaluation} |
| @@ -5140,14 +5143,12 @@ immutable. | |||
| 5140 | 5143 | ||
| 5141 | @xref{Invoking guix pull}, for more information. | 5144 | @xref{Invoking guix pull}, for more information. |
| 5142 | 5145 | ||
| 5143 | @item --allow-untrusted-channels | 5146 | @item --allow-untrusted-channels[=yes|no] |
| 5144 | When @option{--channels} is passed a URL, this option causes | 5147 | Whether to allow pulls from untrusted channels. |
| 5145 | @command{guix time-machine} to pull the channels returned from that URL, | ||
| 5146 | even if they are not trusted. | ||
| 5147 | 5148 | ||
| 5148 | @quotation Warning | 5149 | @quotation Warning |
| 5149 | Using this option can effectively lead to arbitrary code execution on | 5150 | Allowing untrusted channels can effectively lead to arbitrary code |
| 5150 | your system. | 5151 | execution on your system. |
| 5151 | @end quotation | 5152 | @end quotation |
| 5152 | 5153 | ||
| 5153 | @xref{trusted-channels, @command{guix pull} documentation}, for more | 5154 | @xref{trusted-channels, @command{guix pull} documentation}, for more |
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index 8474f28ea6e..0e7f8684f23 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm | |||
| @@ -79,7 +79,7 @@ | |||
| 79 | (graft? . #t) | 79 | (graft? . #t) |
| 80 | (debug . 0) | 80 | (debug . 0) |
| 81 | (verbosity . 1) | 81 | (verbosity . 1) |
| 82 | (require-trusted-channels? . #t) | 82 | (require-trusted-channels . default) |
| 83 | (isolated-channel-evaluation? . #t) | 83 | (isolated-channel-evaluation? . #t) |
| 84 | (authenticate-channels? . #t) | 84 | (authenticate-channels? . #t) |
| 85 | (verify-certificate? . #t) | 85 | (verify-certificate? . #t) |
| @@ -105,8 +105,9 @@ Download and deploy the latest version of Guix.\n")) | |||
| 105 | --disable-authentication | 105 | --disable-authentication |
| 106 | disable channel authentication")) | 106 | disable channel authentication")) |
| 107 | (display (G_ " | 107 | (display (G_ " |
| 108 | --allow-untrusted-channels | 108 | --allow-untrusted-channels[=yes|no] |
| 109 | when downloading channels, allow untrusted channels")) | 109 | whether to allow untrusted channels (default: yes |
| 110 | for local channel files, no otherwise)")) | ||
| 110 | (display (G_ " | 111 | (display (G_ " |
| 111 | --unsafe-channel-evaluation | 112 | --unsafe-channel-evaluation |
| 112 | evaluate channels file with the full user authority")) | 113 | evaluate channels file with the full user authority")) |
| @@ -198,9 +199,14 @@ Download and deploy the latest version of Guix.\n")) | |||
| 198 | (option '("disable-authentication") #f #f | 199 | (option '("disable-authentication") #f #f |
| 199 | (lambda (opt name arg result) | 200 | (lambda (opt name arg result) |
| 200 | (alist-cons 'authenticate-channels? #f result))) | 201 | (alist-cons 'authenticate-channels? #f result))) |
| 201 | (option '("allow-untrusted-channels") #f #f | 202 | (option '("allow-untrusted-channels") #f #t |
| 202 | (lambda (opt name arg result) | 203 | (lambda (opt name arg result) |
| 203 | (alist-cons 'require-trusted-channels? #f result))) | 204 | (alist-cons 'require-trusted-channels |
| 205 | (match (and arg (string-downcase arg)) | ||
| 206 | ("yes" #f) | ||
| 207 | ("no" #t) | ||
| 208 | (_ 'default)) | ||
| 209 | result))) | ||
| 204 | (option '("unsafe-channel-evaluation") #f #f | 210 | (option '("unsafe-channel-evaluation") #f #f |
| 205 | (lambda (opt name arg result) | 211 | (lambda (opt name arg result) |
| 206 | (alist-cons 'isolated-channel-evaluation? #f result))) | 212 | (alist-cons 'isolated-channel-evaluation? #f result))) |
| @@ -821,8 +827,8 @@ transformations specified in OPTS (resulting from '--url', '--commit', or | |||
| 821 | (define isolated? | 827 | (define isolated? |
| 822 | (assoc-ref opts 'isolated-channel-evaluation?)) | 828 | (assoc-ref opts 'isolated-channel-evaluation?)) |
| 823 | 829 | ||
| 824 | (define require-trusted-channels? | 830 | (define require-trusted-channels |
| 825 | (assoc-ref opts 'require-trusted-channels?)) | 831 | (assoc-ref opts 'require-trusted-channels)) |
| 826 | 832 | ||
| 827 | (define (load-channels file) | 833 | (define (load-channels file) |
| 828 | (let* ((url? (or (string-prefix? "https://" file) | 834 | (let* ((url? (or (string-prefix? "https://" file) |
| @@ -839,10 +845,13 @@ transformations specified in OPTS (resulting from '--url', '--commit', or | |||
| 839 | ;; When downloading channels, keep going if and only if these are | 845 | ;; When downloading channels, keep going if and only if these are |
| 840 | ;; channels the user trusts. | 846 | ;; channels the user trusts. |
| 841 | (check-trusted-channels result | 847 | (check-trusted-channels result |
| 842 | (if (and (or url? swhid?) | 848 | (match require-trusted-channels |
| 843 | require-trusted-channels?) | 849 | ((? boolean? x) |
| 844 | 'error | 850 | (if x 'error 'warning)) |
| 845 | 'warning)) | 851 | ('default |
| 852 | (if (or url? swhid?) | ||
| 853 | 'error | ||
| 854 | 'warning)))) | ||
| 846 | result) | 855 | result) |
| 847 | (leave (G_ "'~a' did not return a list of channels~%") file)))) | 856 | (leave (G_ "'~a' did not return a list of channels~%") file)))) |
| 848 | 857 | ||
diff --git a/guix/scripts/time-machine.scm b/guix/scripts/time-machine.scm index 9be92213ddb..fdd84ddece2 100644 --- a/guix/scripts/time-machine.scm +++ b/guix/scripts/time-machine.scm | |||
| @@ -71,8 +71,9 @@ If COMMAND is not provided, print path to the time-machine profile.\n")) | |||
| 71 | --disable-authentication | 71 | --disable-authentication |
| 72 | disable channel authentication")) | 72 | disable channel authentication")) |
| 73 | (display (G_ " | 73 | (display (G_ " |
| 74 | --allow-untrusted-channels | 74 | --allow-untrusted-channels[=yes|no] |
| 75 | when downloading channels, allow untrusted channels")) | 75 | whether to allow untrusted channels (default: yes |
| 76 | for local channel files, no otherwise)")) | ||
| 76 | (display (G_ " | 77 | (display (G_ " |
| 77 | --unsafe-channel-evaluation | 78 | --unsafe-channel-evaluation |
| 78 | evaluate channels file with the full user authority")) | 79 | evaluate channels file with the full user authority")) |
| @@ -113,9 +114,14 @@ If COMMAND is not provided, print path to the time-machine profile.\n")) | |||
| 113 | (option '("disable-authentication") #f #f | 114 | (option '("disable-authentication") #f #f |
| 114 | (lambda (opt name arg result) | 115 | (lambda (opt name arg result) |
| 115 | (alist-cons 'authenticate-channels? #f result))) | 116 | (alist-cons 'authenticate-channels? #f result))) |
| 116 | (option '("allow-untrusted-channels") #f #f | 117 | (option '("allow-untrusted-channels") #f #t |
| 117 | (lambda (opt name arg result) | 118 | (lambda (opt name arg result) |
| 118 | (alist-cons 'require-trusted-channels? #f result))) | 119 | (alist-cons 'require-trusted-channels |
| 120 | (match (and arg (string-downcase arg)) | ||
| 121 | ("yes" #f) | ||
| 122 | ("no" #t) | ||
| 123 | (_ 'default)) | ||
| 124 | result))) | ||
| 119 | (option '("no-check-certificate") #f #f | 125 | (option '("no-check-certificate") #f #f |
| 120 | (lambda (opt name arg result) | 126 | (lambda (opt name arg result) |
| 121 | (alist-cons 'verify-certificate? #f result))) | 127 | (alist-cons 'verify-certificate? #f result))) |
| @@ -137,7 +143,7 @@ If COMMAND is not provided, print path to the time-machine profile.\n")) | |||
| 137 | (print-build-trace? . #t) | 143 | (print-build-trace? . #t) |
| 138 | (print-extended-build-trace? . #t) | 144 | (print-extended-build-trace? . #t) |
| 139 | (multiplexed-build-output? . #t) | 145 | (multiplexed-build-output? . #t) |
| 140 | (require-trusted-channels? . #t) | 146 | (require-trusted-channels . default) |
| 141 | (isolated-channel-evaluation? . #t) | 147 | (isolated-channel-evaluation? . #t) |
| 142 | (authenticate-channels? . #t) | 148 | (authenticate-channels? . #t) |
| 143 | (verify-certificate? . #t) | 149 | (verify-certificate? . #t) |
diff --git a/tests/guix-time-machine.sh b/tests/guix-time-machine.sh index 262e3d5fef8..e61232f94fa 100644 --- a/tests/guix-time-machine.sh +++ b/tests/guix-time-machine.sh | |||
| @@ -74,6 +74,17 @@ cat > "$channels_file" <<EOF | |||
| 74 | EOF | 74 | EOF |
| 75 | guix repl -- "$channels_file" | 75 | guix repl -- "$channels_file" |
| 76 | 76 | ||
| 77 | # Under 'pre-inst-env', there are zero trusted channels by default. | ||
| 78 | cat > "$channels_file" <<EOF | ||
| 79 | %default-channels | ||
| 80 | EOF | ||
| 81 | |||
| 82 | # Ignore the user's ~/.config/guix/trusted-channels.scm and ensure this | ||
| 83 | # command fails. | ||
| 84 | XDG_CONFIG_HOME="$XDG_CACHE_HOME/dot-config" \ | ||
| 85 | guix time-machine -C "$channels_file" --allow-untrusted-channels=no 2> "$log_file" && false | ||
| 86 | grep "'guix' is not trusted" "$log_file" | ||
| 87 | |||
| 77 | if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null | 88 | if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null |
| 78 | then | 89 | then |
| 79 | # Ignore the user's ~/.config/guix/trusted-channels.scm. Under | 90 | # Ignore the user's ~/.config/guix/trusted-channels.scm. Under |
