git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>
To: <git@vger.kernel.org>
Cc: <peff@peff.net>
Subject: [RFC 1/3] imap-send: move tunnel setup to its own function
Date: Wed, 9 Aug 2017 16:46:07 +0200	[thread overview]
Message-ID: <fd231e01-1eb2-17a8-52e8-19d9c0a2d4a3@morey-chaisemartin.com> (raw)
In-Reply-To: <ab866314-608b-eaca-b335-12cffe165526@morey-chaisemartin.com>

Signed-off-by: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>
---
 imap-send.c | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/imap-send.c b/imap-send.c
index b2d0b849b..10f668eb7 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -926,6 +926,27 @@ static int auth_cram_md5(struct imap_store *ctx, struct imap_cmd *cmd, const cha
 	return 0;
 }
 
+static void setup_tunnel(struct imap_server_conf *srvc, int fds[2])
+{
+	struct child_process tunnel = CHILD_PROCESS_INIT;
+
+	imap_info("Starting tunnel '%s'... ", srvc->tunnel);
+
+	argv_array_push(&tunnel.args, srvc->tunnel);
+	tunnel.use_shell = 1;
+	tunnel.in = -1;
+	tunnel.out = -1;
+	if (start_command(&tunnel))
+		die("cannot start proxy %s", srvc->tunnel);
+
+	fds[0] = tunnel.out;
+	fds[1] = tunnel.in;
+
+	imap_info("ok\n");
+
+	return;
+}
+
 static struct imap_store *imap_open_store(struct imap_server_conf *srvc, char *folder)
 {
 	struct credential cred = CREDENTIAL_INIT;
@@ -943,21 +964,7 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc, char *f
 	/* open connection to IMAP server */
 
 	if (srvc->tunnel) {
-		struct child_process tunnel = CHILD_PROCESS_INIT;
-
-		imap_info("Starting tunnel '%s'... ", srvc->tunnel);
-
-		argv_array_push(&tunnel.args, srvc->tunnel);
-		tunnel.use_shell = 1;
-		tunnel.in = -1;
-		tunnel.out = -1;
-		if (start_command(&tunnel))
-			die("cannot start proxy %s", srvc->tunnel);
-
-		imap->buf.sock.fd[0] = tunnel.out;
-		imap->buf.sock.fd[1] = tunnel.in;
-
-		imap_info("ok\n");
+		setup_tunnel(srvc, imap->buf.sock.fd);
 	} else {
 #ifndef NO_IPV6
 		struct addrinfo hints, *ai0, *ai;
-- 
2.14.0.3.gb4ff627ec.dirty



  reply	other threads:[~2017-08-09 14:46 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-09 14:43 [RFC 0/3] imap-send curl tunnelling support Nicolas Morey-Chaisemartin
2017-08-09 14:46 ` Nicolas Morey-Chaisemartin [this message]
2017-08-09 14:46 ` [RFC 2/3] imap-send: use a socketpair instead of pipe to communicate with the tunnel Nicolas Morey-Chaisemartin
2017-08-09 14:46 ` [RFC 3/3] imap_send: add support for curl over tunnel Nicolas Morey-Chaisemartin
2017-08-15 17:49 ` [RFC 0/3] imap-send curl tunnelling support Nicolas Morey-Chaisemartin
2017-08-15 18:18   ` Stefan Beller
2017-08-16 12:30     ` Johannes Schindelin
2017-08-21  7:27       ` Nicolas Morey-Chaisemartin
2017-08-22 17:10         ` Johannes Sixt
2017-08-22 18:22           ` Nicolas Morey-Chaisemartin
2017-08-23 22:35           ` Johannes Schindelin
2017-08-16  8:34 ` Jeff King
2017-08-21  7:34   ` Nicolas Morey-Chaisemartin
2017-08-23 21:43     ` Jeff King
2017-08-24  8:00       ` Nicolas Morey-Chaisemartin
2017-08-24 13:53         ` Jeff King
2017-08-24 14:02           ` Daniel Stenberg
2017-08-24 14:30             ` Jeff King
2017-08-24 21:22               ` Daniel Stenberg
2017-08-24 14:15           ` Nicolas Morey-Chaisemartin
2017-08-24 14:28             ` Jeff King
     [not found] ` <7ee8331d-e154-7539-e000-4087406f39fa@suse.de>
2017-08-16  8:39   ` Jeff King

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=fd231e01-1eb2-17a8-52e8-19d9c0a2d4a3@morey-chaisemartin.com \
    --to=nicolas@morey-chaisemartin.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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 public inbox

	https://80x24.org/mirrors/git.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).