|
|
|
@ -24,6 +24,7 @@
@@ -24,6 +24,7 @@
|
|
|
|
|
|
|
|
|
|
#include "cache.h" |
|
|
|
|
#include "exec_cmd.h" |
|
|
|
|
#include "run-command.h" |
|
|
|
|
#ifdef NO_OPENSSL |
|
|
|
|
typedef void *SSL; |
|
|
|
|
#endif |
|
|
|
@ -940,8 +941,7 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)
@@ -940,8 +941,7 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)
|
|
|
|
|
struct imap_store *ctx; |
|
|
|
|
struct imap *imap; |
|
|
|
|
char *arg, *rsp; |
|
|
|
|
int s = -1, a[2], preauth; |
|
|
|
|
pid_t pid; |
|
|
|
|
int s = -1, preauth; |
|
|
|
|
|
|
|
|
|
ctx = xcalloc(sizeof(*ctx), 1); |
|
|
|
|
|
|
|
|
@ -952,29 +952,24 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)
@@ -952,29 +952,24 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)
|
|
|
|
|
/* open connection to IMAP server */ |
|
|
|
|
|
|
|
|
|
if (srvc->tunnel) { |
|
|
|
|
imap_info("Starting tunnel '%s'... ", srvc->tunnel); |
|
|
|
|
const char *argv[4]; |
|
|
|
|
struct child_process tunnel = {0}; |
|
|
|
|
|
|
|
|
|
if (socketpair(PF_UNIX, SOCK_STREAM, 0, a)) { |
|
|
|
|
perror("socketpair"); |
|
|
|
|
exit(1); |
|
|
|
|
} |
|
|
|
|
imap_info("Starting tunnel '%s'... ", srvc->tunnel); |
|
|
|
|
|
|
|
|
|
pid = fork(); |
|
|
|
|
if (pid < 0) |
|
|
|
|
_exit(127); |
|
|
|
|
if (!pid) { |
|
|
|
|
if (dup2(a[0], 0) == -1 || dup2(a[0], 1) == -1) |
|
|
|
|
_exit(127); |
|
|
|
|
close(a[0]); |
|
|
|
|
close(a[1]); |
|
|
|
|
execl("/bin/sh", "sh", "-c", srvc->tunnel, NULL); |
|
|
|
|
_exit(127); |
|
|
|
|
} |
|
|
|
|
argv[0] = "sh"; |
|
|
|
|
argv[1] = "-c"; |
|
|
|
|
argv[2] = srvc->tunnel; |
|
|
|
|
argv[3] = NULL; |
|
|
|
|
|
|
|
|
|
close(a[0]); |
|
|
|
|
tunnel.argv = argv; |
|
|
|
|
tunnel.in = -1; |
|
|
|
|
tunnel.out = -1; |
|
|
|
|
if (start_command(&tunnel)) |
|
|
|
|
die("cannot start proxy %s", argv[0]); |
|
|
|
|
|
|
|
|
|
imap->buf.sock.fd[0] = a[1]; |
|
|
|
|
imap->buf.sock.fd[1] = dup(a[1]); |
|
|
|
|
imap->buf.sock.fd[0] = tunnel.out; |
|
|
|
|
imap->buf.sock.fd[1] = tunnel.in; |
|
|
|
|
|
|
|
|
|
imap_info("ok\n"); |
|
|
|
|
} else { |
|
|
|
|