git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC 1/3] imap-send: move tunnel setup to its own function

From
Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>
Date
Aug 9, 2017, 14:46 UTC
Message-ID
<fd231e01-1eb2-17a8-52e8-19d9c0a2d4a3@morey-chaisemartin.com>
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
Previous: Nicolas Morey-ChaisemartinNext: Nicolas Morey-Chaisemartin
Message 2 of 22 in “[RFC 0/3] imap-send curl tunnelling support”
  1. Nicolas Morey-ChaisemartinAug 9, 2017
  2. 1/3 imap-send: move tunnel setup to its own functionNicolas Morey-Chaisemartin, Aug 9, 2017
  3. 3/3 imap_send: add support for curl over tunnelNicolas Morey-Chaisemartin, Aug 9, 2017
  4. 2/3 imap-send: use a socketpair instead of pipe to communicate with the tunnelNicolas Morey-Chaisemartin, Aug 9, 2017
  5. Nicolas Morey-ChaisemartinAug 15, 2017
  6. Stefan BellerAug 15, 2017
  7. Johannes SchindelinAug 16, 2017
  8. Nicolas Morey-ChaisemartinAug 21, 2017
  9. Johannes SixtAug 22, 2017
  10. Nicolas Morey-ChaisemartinAug 22, 2017
  11. Johannes SchindelinAug 23, 2017
  12. Jeff KingAug 16, 2017
  13. Nicolas Morey-ChaisemartinAug 21, 2017
  14. Jeff KingAug 23, 2017
  15. Nicolas Morey-ChaisemartinAug 24, 2017
  16. Jeff KingAug 24, 2017
  17. Daniel StenbergAug 24, 2017
  18. Jeff KingAug 24, 2017
  19. Daniel StenbergAug 24, 2017
  20. Nicolas Morey-ChaisemartinAug 24, 2017
  21. Jeff KingAug 24, 2017
  22. Jeff KingAug 16, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.