all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 48240@debbugs.gnu.org
Subject: bug#48240: [PATCH 4/4] ssh: Honor GUIX_DAEMON_SOCKET on the target machine.
Date: Wed,  5 May 2021 23:32:05 +0200	[thread overview]
Message-ID: <20210505213205.28519-4-ludo@gnu.org> (raw)
In-Reply-To: <20210505213205.28519-1-ludo@gnu.org>

Fixes <https://bugs.gnu.org/48240>.
Reported by Ricardo Wurmus <rekado@elephly.net>.

* guix/ssh.scm (remote-daemon-channel)[redirect]: Define
'connect-to-daemon'.  Use the same-named procedure from (guix store)
when available, and honor GUIX_DAEMON_SOCKET.
---
 guix/ssh.scm | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/guix/ssh.scm b/guix/ssh.scm
index b39b90f733..77a9732ce5 100644
--- a/guix/ssh.scm
+++ b/guix/ssh.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2016, 2017, 2018, 2019, 2020, 2021, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -253,7 +253,22 @@ EXP never returns or calls 'primitive-exit' when it's done."
        (use-modules (ice-9 match) (rnrs io ports)
                     (rnrs bytevectors))
 
-       (let ((sock    (socket AF_UNIX SOCK_STREAM 0))
+       (define connect-to-daemon
+         ;; XXX: 'connect-to-daemon' used to be private and before that it
+         ;; didn't even exist, hence these shenanigans.
+         (let ((connect-to-daemon
+                (false-if-exception (module-ref (resolve-module '(guix store))
+                                                'connect-to-daemon))))
+           (lambda (uri)
+             (if connect-to-daemon
+                 (connect-to-daemon uri)
+                 (let ((sock (socket AF_UNIX SOCK_STREAM 0)))
+                   (connect sock AF_UNIX ,socket-name)
+                   sock)))))
+
+       ;; Use 'connect-to-daemon' to honor GUIX_DAEMON_SOCKET.
+       (let ((sock    (connect-to-daemon (or (getenv "GUIX_DAEMON_SOCKET")
+                                             socket-name)))
              (stdin   (current-input-port))
              (stdout  (current-output-port))
              (select* (lambda (read write except)
@@ -272,8 +287,6 @@ EXP never returns or calls 'primitive-exit' when it's done."
          (setvbuf stdin 'block 65536)
          (setvbuf sock 'block 65536)
 
-         (connect sock AF_UNIX ,socket-name)
-
          (let loop ()
            (match (select* (list stdin sock) '() '())
              ((reads () ())
-- 
2.31.1





  parent reply	other threads:[~2021-05-05 21:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-05 16:04 bug#48240: “guix copy” to host with daemon listening on TCP fails Ricardo Wurmus
2021-05-05 21:32 ` bug#48240: [PATCH 1/4] store: 'open-connection' never returns #f Ludovic Courtès
2021-05-05 21:32   ` bug#48240: [PATCH 2/4] ssh: 'connect-to-remote-daemon' raises a nicer message upon error Ludovic Courtès
2021-05-05 21:32   ` bug#48240: [PATCH 3/4] store: Export 'connect-to-daemon' Ludovic Courtès
2021-05-05 21:32   ` Ludovic Courtès [this message]
2021-05-08 13:10 ` bug#48240: “guix copy” to host with daemon listening on TCP fails Ludovic Courtès
2021-05-11  8:43 ` bug#48240: “guix_ " Simon Streit
2021-05-11  9:56   ` bug#48240: “guix " Ludovic Courtès
2021-05-12  7:48     ` Simon Streit
2021-05-11 10:52   ` Ludovic Courtès
2021-05-11 14:01     ` Bone Baboon via Bug reports for GNU Guix
2021-05-11 21:22       ` Ludovic Courtès
2021-05-12  7:49     ` Simon Streit
2021-05-12 19:44     ` Simon Streit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210505213205.28519-4-ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=48240@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.