{"thread":{"id":"21227","subject":"[PATCH v3 2/8] imap-send: use separate read and write fds","startedAt":"2009-10-13T19:25:17Z","lastAt":"2009-10-16T14:27:33Z","messageCount":16,"participants":["Erik Faye-Lund","Johannes Sixt"],"isPatch":true,"patchVersion":3,"patchTotal":8},"messages":[{"id":"124875","messageId":"1255461925-2244-1-git-send-email-kusmabite@gmail.com","threadId":"21227","inReplyTo":null,"subject":"[PATCH v3 0/8] imap-send: Windows support","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-13T19:25:17Z","receivedAt":"2009-10-13T19:25:17Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"\nHere's the 3rd iteration of my patches for\nWindows-compatibility in imap-send.\n\n - Patch 1-3 is about getting rid of or rewriting\n   code with portability issues.\n - Patch 4 fixes a compilation error on Windows\n - Patch 5 enables compilation of imap-send\n - Patch 6-7 enables SSL-suport for mingw\n - Patch 8 enables imap-send and SSL for msvc\n\nChanges in this iteration compared to v2 are as\nfollows:\n\n - A typo has been corrected in the commit message\n   for 1/8\n - some unneeded preprocessor directives has been\n   deleted from patch 4/8\n\nThanks to Matt Kraai for reviewing v2\n\nP.S:\nPerhaps some people are only on the msysgit mailing\nlist and wonders where v2 went -- I forgot to CC\nyou guys last round, sorry about that! If you're\ninterrested, you can read the discussion here:\n\nhttp://thread.gmane.org/gmane.comp.version-control.git/129471\n\nErik Faye-Lund (6):\n  imap-send: use separate read and write fds\n  imap-send: use run-command API for tunneling\n  imap-send: fix compilation-error on Windows\n  imap-send: build imap-send on Windows\n  mingw: wrap SSL_set_(w|r)fd to call _get_osfhandle\n  mingw: enable OpenSSL\n\nJeff King (1):\n  imap-send: remove useless uid code\n\nMarius Storm-Olsen (1):\n  MSVC: Enable OpenSSL, and translate -lcrypto\n\n Makefile                        |    4 +-\n compat/mingw.h                  |   21 ++++\n compat/vcbuild/scripts/clink.pl |    3 +\n contrib/buildsystems/engine.pl  |    3 +\n imap-send.c                     |  226 +++++++++------------------------------\n 5 files changed, 77 insertions(+), 180 deletions(-)\n"},{"id":"124868","messageId":"1255461925-2244-2-git-send-email-kusmabite@gmail.com","threadId":"21227","inReplyTo":"1255461925-2244-1-git-send-email-kusmabite@gmail.com","subject":"[PATCH v3 1/8] imap-send: remove useless uid code","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-13T19:25:18Z","receivedAt":"2009-10-13T19:25:18Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"\nFrom: Jeff King <peff@peff.net>\n\nThe imap-send code is based on code from isync, a program\nfor syncing imap mailboxes. Because of this, it has\ninherited some code that makes sense for isync, but not for\nimap-send.\n\nIn particular, when storing a message, it does one of:\n\n  - if the server supports it, note the server-assigned\n    unique identifier (UID) given to each message\n\n  - otherwise, assigned a random UID and store it in the\n    message header as X-TUID\n\nPresumably this is used in isync to be able to synchronize\nmailstores multiple times without duplication. But for\nimap-send, the values are useless; we never do anything\nwith them and simply forget them at the end of the program.\n\nThis patch removes the useless code. Not only is it nice for\nmaintainability to get rid of dead code, but the removed\ncode relied on the existence of /dev/urandom, which made it\na portability problem for non-Unix platforms.\n\nSigned-off-by: Jeff King <peff@peff.net>\nSigned-off-by: Erik Faye-Lund <kusmabite@gmail.com>\n---\n imap-send.c |  155 ++++------------------------------------------------------\n 1 files changed, 11 insertions(+), 144 deletions(-)\n\ndiff --git a/imap-send.c b/imap-send.c\nindex 3847fd1..8da7a94 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -123,9 +123,6 @@ static int nfvasprintf(char **strp, const char *fmt, va_list ap)\n \treturn len;\n }\n \n-static void arc4_init(void);\n-static unsigned char arc4_getbyte(void);\n-\n struct imap_server_conf {\n \tchar *name;\n \tchar *tunnel;\n@@ -489,52 +486,6 @@ static int nfsnprintf(char *buf, int blen, const char *fmt, ...)\n \treturn ret;\n }\n \n-static struct {\n-\tunsigned char i, j, s[256];\n-} rs;\n-\n-static void arc4_init(void)\n-{\n-\tint i, fd;\n-\tunsigned char j, si, dat[128];\n-\n-\tif ((fd = open(\"/dev/urandom\", O_RDONLY)) < 0 && (fd = open(\"/dev/random\", O_RDONLY)) < 0) {\n-\t\tfprintf(stderr, \"Fatal: no random number source available.\\n\");\n-\t\texit(3);\n-\t}\n-\tif (read_in_full(fd, dat, 128) != 128) {\n-\t\tfprintf(stderr, \"Fatal: cannot read random number source.\\n\");\n-\t\texit(3);\n-\t}\n-\tclose(fd);\n-\n-\tfor (i = 0; i < 256; i++)\n-\t\trs.s[i] = i;\n-\tfor (i = j = 0; i < 256; i++) {\n-\t\tsi = rs.s[i];\n-\t\tj += si + dat[i & 127];\n-\t\trs.s[i] = rs.s[j];\n-\t\trs.s[j] = si;\n-\t}\n-\trs.i = rs.j = 0;\n-\n-\tfor (i = 0; i < 256; i++)\n-\t\tarc4_getbyte();\n-}\n-\n-static unsigned char arc4_getbyte(void)\n-{\n-\tunsigned char si, sj;\n-\n-\trs.i++;\n-\tsi = rs.s[rs.i];\n-\trs.j += si;\n-\tsj = rs.s[rs.j];\n-\trs.s[rs.i] = sj;\n-\trs.s[rs.j] = si;\n-\treturn rs.s[(si + sj) & 0xff];\n-}\n-\n static struct imap_cmd *v_issue_imap_cmd(struct imap_store *ctx,\n \t\t\t\t\t struct imap_cmd_cb *cb,\n \t\t\t\t\t const char *fmt, va_list ap)\n@@ -1198,88 +1149,20 @@ static int imap_make_flags(int flags, char *buf)\n \treturn d;\n }\n \n-#define TUIDL 8\n-\n-static int imap_store_msg(struct store *gctx, struct msg_data *data, int *uid)\n+static int imap_store_msg(struct store *gctx, struct msg_data *data)\n {\n \tstruct imap_store *ctx = (struct imap_store *)gctx;\n \tstruct imap *imap = ctx->imap;\n \tstruct imap_cmd_cb cb;\n-\tchar *fmap, *buf;\n \tconst char *prefix, *box;\n-\tint ret, i, j, d, len, extra, nocr;\n-\tint start, sbreak = 0, ebreak = 0;\n-\tchar flagstr[128], tuid[TUIDL * 2 + 1];\n+\tint ret, d;\n+\tchar flagstr[128];\n \n \tmemset(&cb, 0, sizeof(cb));\n \n-\tfmap = data->data;\n-\tlen = data->len;\n-\tnocr = !data->crlf;\n-\textra = 0, i = 0;\n-\tif (!CAP(UIDPLUS) && uid) {\n-\tnloop:\n-\t\tstart = i;\n-\t\twhile (i < len)\n-\t\t\tif (fmap[i++] == '\\n') {\n-\t\t\t\textra += nocr;\n-\t\t\t\tif (i - 2 + nocr == start) {\n-\t\t\t\t\tsbreak = ebreak = i - 2 + nocr;\n-\t\t\t\t\tgoto mktid;\n-\t\t\t\t}\n-\t\t\t\tif (!memcmp(fmap + start, \"X-TUID: \", 8)) {\n-\t\t\t\t\textra -= (ebreak = i) - (sbreak = start) + nocr;\n-\t\t\t\t\tgoto mktid;\n-\t\t\t\t}\n-\t\t\t\tgoto nloop;\n-\t\t\t}\n-\t\t/* invalid message */\n-\t\tfree(fmap);\n-\t\treturn DRV_MSG_BAD;\n-\tmktid:\n-\t\tfor (j = 0; j < TUIDL; j++)\n-\t\t\tsprintf(tuid + j * 2, \"%02x\", arc4_getbyte());\n-\t\textra += 8 + TUIDL * 2 + 2;\n-\t}\n-\tif (nocr)\n-\t\tfor (; i < len; i++)\n-\t\t\tif (fmap[i] == '\\n')\n-\t\t\t\textra++;\n-\n-\tcb.dlen = len + extra;\n-\tbuf = cb.data = xmalloc(cb.dlen);\n-\ti = 0;\n-\tif (!CAP(UIDPLUS) && uid) {\n-\t\tif (nocr) {\n-\t\t\tfor (; i < sbreak; i++)\n-\t\t\t\tif (fmap[i] == '\\n') {\n-\t\t\t\t\t*buf++ = '\\r';\n-\t\t\t\t\t*buf++ = '\\n';\n-\t\t\t\t} else\n-\t\t\t\t\t*buf++ = fmap[i];\n-\t\t} else {\n-\t\t\tmemcpy(buf, fmap, sbreak);\n-\t\t\tbuf += sbreak;\n-\t\t}\n-\t\tmemcpy(buf, \"X-TUID: \", 8);\n-\t\tbuf += 8;\n-\t\tmemcpy(buf, tuid, TUIDL * 2);\n-\t\tbuf += TUIDL * 2;\n-\t\t*buf++ = '\\r';\n-\t\t*buf++ = '\\n';\n-\t\ti = ebreak;\n-\t}\n-\tif (nocr) {\n-\t\tfor (; i < len; i++)\n-\t\t\tif (fmap[i] == '\\n') {\n-\t\t\t\t*buf++ = '\\r';\n-\t\t\t\t*buf++ = '\\n';\n-\t\t\t} else\n-\t\t\t\t*buf++ = fmap[i];\n-\t} else\n-\t\tmemcpy(buf, fmap + i, len - i);\n-\n-\tfree(fmap);\n+\tcb.dlen = data->len;\n+\tcb.data = xmalloc(cb.dlen);\n+\tmemcpy(cb.data, data->data, data->len);\n \n \td = 0;\n \tif (data->flags) {\n@@ -1288,26 +1171,14 @@ static int imap_store_msg(struct store *gctx, struct msg_data *data, int *uid)\n \t}\n \tflagstr[d] = 0;\n \n-\tif (!uid) {\n-\t\tbox = gctx->conf->trash;\n-\t\tprefix = ctx->prefix;\n-\t\tcb.create = 1;\n-\t\tif (ctx->trashnc)\n-\t\t\timap->caps = imap->rcaps & ~(1 << LITERALPLUS);\n-\t} else {\n-\t\tbox = gctx->name;\n-\t\tprefix = !strcmp(box, \"INBOX\") ? \"\" : ctx->prefix;\n-\t\tcb.create = 0;\n-\t}\n-\tcb.ctx = uid;\n+\tbox = gctx->name;\n+\tprefix = !strcmp(box, \"INBOX\") ? \"\" : ctx->prefix;\n+\tcb.create = 0;\n \tret = imap_exec_m(ctx, &cb, \"APPEND \\\"%s%s\\\" %s\", prefix, box, flagstr);\n \timap->caps = imap->rcaps;\n \tif (ret != DRV_OK)\n \t\treturn ret;\n-\tif (!uid)\n-\t\tctx->trashnc = 0;\n-\telse\n-\t\tgctx->count++;\n+\tgctx->count++;\n \n \treturn DRV_OK;\n }\n@@ -1483,7 +1354,6 @@ int main(int argc, char **argv)\n {\n \tstruct msg_data all_msgs, msg;\n \tstruct store *ctx = NULL;\n-\tint uid = 0;\n \tint ofs = 0;\n \tint r;\n \tint total, n = 0;\n@@ -1491,9 +1361,6 @@ int main(int argc, char **argv)\n \n \tgit_extract_argv0_path(argv[0]);\n \n-\t/* init the random number generator */\n-\tarc4_init();\n-\n \tsetup_git_directory_gently(&nongit_ok);\n \tgit_config(git_imap_config, NULL);\n \n@@ -1540,7 +1407,7 @@ int main(int argc, char **argv)\n \t\t\tbreak;\n \t\tif (server.use_html)\n \t\t\twrap_in_html(&msg);\n-\t\tr = imap_store_msg(ctx, &msg, &uid);\n+\t\tr = imap_store_msg(ctx, &msg);\n \t\tif (r != DRV_OK)\n \t\t\tbreak;\n \t\tn++;\n-- \n1.6.4\n"},{"id":"124867","messageId":"1255461925-2244-3-git-send-email-kusmabite@gmail.com","threadId":"21227","inReplyTo":"1255461925-2244-2-git-send-email-kusmabite@gmail.com","subject":"[PATCH v3 2/8] imap-send: use separate read and write fds","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-13T19:25:19Z","receivedAt":"2009-10-13T19:25:19Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"\nThis is a patch that enables us to use the run-command\nAPI, which is supported on Windows.\n\nSigned-off-by: Erik Faye-Lund <kusmabite@gmail.com>\n---\n imap-send.c |   37 +++++++++++++++++++++++--------------\n 1 files changed, 23 insertions(+), 14 deletions(-)\n\ndiff --git a/imap-send.c b/imap-send.c\nindex 8da7a94..7216453 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -151,7 +151,7 @@ struct imap_list {\n };\n \n struct imap_socket {\n-\tint fd;\n+\tint fd[2];\n \tSSL *ssl;\n };\n \n@@ -301,8 +301,12 @@ static int ssl_socket_connect(struct imap_socket *sock, int use_tls_only, int ve\n \t\tssl_socket_perror(\"SSL_new\");\n \t\treturn -1;\n \t}\n-\tif (!SSL_set_fd(sock->ssl, sock->fd)) {\n-\t\tssl_socket_perror(\"SSL_set_fd\");\n+\tif (!SSL_set_rfd(sock->ssl, sock->fd[0])) {\n+\t\tssl_socket_perror(\"SSL_set_rfd\");\n+\t\treturn -1;\n+\t}\n+\tif (!SSL_set_wfd(sock->ssl, sock->fd[1])) {\n+\t\tssl_socket_perror(\"SSL_set_wfd\");\n \t\treturn -1;\n \t}\n \n@@ -324,11 +328,12 @@ static int socket_read(struct imap_socket *sock, char *buf, int len)\n \t\tn = SSL_read(sock->ssl, buf, len);\n \telse\n #endif\n-\t\tn = xread(sock->fd, buf, len);\n+\t\tn = xread(sock->fd[0], buf, len);\n \tif (n <= 0) {\n \t\tsocket_perror(\"read\", sock, n);\n-\t\tclose(sock->fd);\n-\t\tsock->fd = -1;\n+\t\tclose(sock->fd[0]);\n+\t\tclose(sock->fd[1]);\n+\t\tsock->fd[0] = sock->fd[1] = -1;\n \t}\n \treturn n;\n }\n@@ -341,11 +346,12 @@ static int socket_write(struct imap_socket *sock, const char *buf, int len)\n \t\tn = SSL_write(sock->ssl, buf, len);\n \telse\n #endif\n-\t\tn = write_in_full(sock->fd, buf, len);\n+\t\tn = write_in_full(sock->fd[1], buf, len);\n \tif (n != len) {\n \t\tsocket_perror(\"write\", sock, n);\n-\t\tclose(sock->fd);\n-\t\tsock->fd = -1;\n+\t\tclose(sock->fd[0]);\n+\t\tclose(sock->fd[1]);\n+\t\tsock->fd[0] = sock->fd[1] = -1;\n \t}\n \treturn n;\n }\n@@ -358,7 +364,8 @@ static void socket_shutdown(struct imap_socket *sock)\n \t\tSSL_free(sock->ssl);\n \t}\n #endif\n-\tclose(sock->fd);\n+\tclose(sock->fd[0]);\n+\tclose(sock->fd[1]);\n }\n \n /* simple line buffering */\n@@ -911,7 +918,7 @@ static void imap_close_server(struct imap_store *ictx)\n {\n \tstruct imap *imap = ictx->imap;\n \n-\tif (imap->buf.sock.fd != -1) {\n+\tif (imap->buf.sock.fd[0] != -1) {\n \t\timap_exec(ictx, NULL, \"LOGOUT\");\n \t\tsocket_shutdown(&imap->buf.sock);\n \t}\n@@ -939,7 +946,7 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)\n \tctx = xcalloc(sizeof(*ctx), 1);\n \n \tctx->imap = imap = xcalloc(sizeof(*imap), 1);\n-\timap->buf.sock.fd = -1;\n+\timap->buf.sock.fd[0] = imap->buf.sock.fd[1] = -1;\n \timap->in_progress_append = &imap->in_progress;\n \n \t/* open connection to IMAP server */\n@@ -966,7 +973,8 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)\n \n \t\tclose(a[0]);\n \n-\t\timap->buf.sock.fd = a[1];\n+\t\timap->buf.sock.fd[0] = a[1];\n+\t\timap->buf.sock.fd[1] = dup(a[1]);\n \n \t\timap_info(\"ok\\n\");\n \t} else {\n@@ -1043,7 +1051,8 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)\n \t\t\tgoto bail;\n \t\t}\n \n-\t\timap->buf.sock.fd = s;\n+\t\timap->buf.sock.fd[0] = s;\n+\t\timap->buf.sock.fd[1] = dup(s);\n \n \t\tif (srvc->use_ssl &&\n \t\t    ssl_socket_connect(&imap->buf.sock, 0, srvc->ssl_verify)) {\n-- \n1.6.4\n"},{"id":"124869","messageId":"1255461925-2244-4-git-send-email-kusmabite@gmail.com","threadId":"21227","inReplyTo":"1255461925-2244-3-git-send-email-kusmabite@gmail.com","subject":"[PATCH v3 3/8] imap-send: use run-command API for tunneling","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-13T19:25:20Z","receivedAt":"2009-10-13T19:25:20Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"\nSigned-off-by: Erik Faye-Lund <kusmabite@gmail.com>\n---\n imap-send.c |   37 ++++++++++++++++---------------------\n 1 files changed, 16 insertions(+), 21 deletions(-)\n\ndiff --git a/imap-send.c b/imap-send.c\nindex 7216453..dc3da98 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -24,6 +24,7 @@\n \n #include \"cache.h\"\n #include \"exec_cmd.h\"\n+#include \"run-command.h\"\n #ifdef NO_OPENSSL\n typedef void *SSL;\n #endif\n@@ -940,8 +941,7 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)\n \tstruct imap_store *ctx;\n \tstruct imap *imap;\n \tchar *arg, *rsp;\n-\tint s = -1, a[2], preauth;\n-\tpid_t pid;\n+\tint s = -1, preauth;\n \n \tctx = xcalloc(sizeof(*ctx), 1);\n \n@@ -952,29 +952,24 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)\n \t/* open connection to IMAP server */\n \n \tif (srvc->tunnel) {\n-\t\timap_info(\"Starting tunnel '%s'... \", srvc->tunnel);\n+\t\tconst char *argv[4];\n+\t\tstruct child_process tunnel = {0};\n \n-\t\tif (socketpair(PF_UNIX, SOCK_STREAM, 0, a)) {\n-\t\t\tperror(\"socketpair\");\n-\t\t\texit(1);\n-\t\t}\n+\t\timap_info(\"Starting tunnel '%s'... \", srvc->tunnel);\n \n-\t\tpid = fork();\n-\t\tif (pid < 0)\n-\t\t\t_exit(127);\n-\t\tif (!pid) {\n-\t\t\tif (dup2(a[0], 0) == -1 || dup2(a[0], 1) == -1)\n-\t\t\t\t_exit(127);\n-\t\t\tclose(a[0]);\n-\t\t\tclose(a[1]);\n-\t\t\texecl(\"/bin/sh\", \"sh\", \"-c\", srvc->tunnel, NULL);\n-\t\t\t_exit(127);\n-\t\t}\n+\t\targv[0] = \"/bin/sh\";\n+\t\targv[1] = \"-c\";\n+\t\targv[2] = srvc->tunnel;\n+\t\targv[3] = NULL;\n \n-\t\tclose(a[0]);\n+\t\ttunnel.argv = argv;\n+\t\ttunnel.in = -1;\n+\t\ttunnel.out = -1;\n+\t\tif (start_command(&tunnel))\n+\t\t\tdie(\"cannot start proxy %s\", argv[0]);\n \n-\t\timap->buf.sock.fd[0] = a[1];\n-\t\timap->buf.sock.fd[1] = dup(a[1]);\n+\t\timap->buf.sock.fd[0] = tunnel.out;\n+\t\timap->buf.sock.fd[1] = tunnel.in;\n \n \t\timap_info(\"ok\\n\");\n \t} else {\n-- \n1.6.4\n"},{"id":"124871","messageId":"1255461925-2244-5-git-send-email-kusmabite@gmail.com","threadId":"21227","inReplyTo":"1255461925-2244-4-git-send-email-kusmabite@gmail.com","subject":"[PATCH v3 4/8] imap-send: fix compilation-error on Windows","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-13T19:25:21Z","receivedAt":"2009-10-13T19:25:21Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"\nmmsystem.h (included from windows.h) defines DRV_OK to 1. To avoid\nan error due to DRV_OK redefenition, this patch undefines the old\ndefinition (i.e the one from mmsystem.h) before defining DRV_OK.\n\nSigned-off-by: Erik Faye-Lund <kusmabite@gmail.com>\n---\n imap-send.c |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/imap-send.c b/imap-send.c\nindex dc3da98..07f86ce 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -94,6 +94,7 @@ struct msg_data {\n \tunsigned int crlf:1;\n };\n \n+#undef DRV_OK\n #define DRV_OK          0\n #define DRV_MSG_BAD     -1\n #define DRV_BOX_BAD     -2\n-- \n1.6.4\n"},{"id":"124870","messageId":"1255461925-2244-6-git-send-email-kusmabite@gmail.com","threadId":"21227","inReplyTo":"1255461925-2244-5-git-send-email-kusmabite@gmail.com","subject":"[PATCH v3 5/8] imap-send: build imap-send on Windows","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-13T19:25:22Z","receivedAt":"2009-10-13T19:25:22Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"\nSince the POSIX-specific tunneling code has been replaced\nby the run-command API (and a compile-error has been\ncleaned away), we can now enable imap-send on Windows\nbuilds.\n\nSigned-off-by: Erik Faye-Lund <kusmabite@gmail.com>\n---\n Makefile |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex fea237b..3ddb3b3 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -365,6 +365,7 @@ PROGRAMS += git-show-index$X\n PROGRAMS += git-unpack-file$X\n PROGRAMS += git-upload-pack$X\n PROGRAMS += git-var$X\n+PROGRAMS += git-imap-send$X\n \n # List built-in command $C whose implementation cmd_$C() is not in\n # builtin-$C.o but is linked in as part of some other command.\n@@ -1075,7 +1076,6 @@ EXTLIBS += -lz\n \n ifndef NO_POSIX_ONLY_PROGRAMS\n \tPROGRAMS += git-daemon$X\n-\tPROGRAMS += git-imap-send$X\n endif\n ifndef NO_OPENSSL\n \tOPENSSL_LIBSSL = -lssl\n-- \n1.6.4\n"},{"id":"124873","messageId":"1255461925-2244-7-git-send-email-kusmabite@gmail.com","threadId":"21227","inReplyTo":"1255461925-2244-6-git-send-email-kusmabite@gmail.com","subject":"[PATCH v3 6/8] mingw: wrap SSL_set_(w|r)fd to call _get_osfhandle","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-13T19:25:23Z","receivedAt":"2009-10-13T19:25:23Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"\nSSL_set_fd (and friends) expects a OS file handle on Windows, not\na file descriptor as on UNIX(-ish).\n\nThis patch makes the Windows version of SSL_set_fd behave like the\nUNIX versions, by calling _get_osfhandle on it's input.\n\nSigned-off-by: Erik Faye-Lund <kusmabite@gmail.com>\n---\n compat/mingw.h |   21 +++++++++++++++++++++\n 1 files changed, 21 insertions(+), 0 deletions(-)\n\ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex 5b5258b..6907345 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -124,6 +124,27 @@ static inline int waitpid(pid_t pid, int *status, unsigned options)\n \treturn -1;\n }\n \n+#ifndef NO_OPENSSL\n+#include <openssl/ssl.h>\n+static inline int mingw_SSL_set_fd(SSL *ssl, int fd)\n+{\n+\treturn SSL_set_fd(ssl, _get_osfhandle(fd));\n+}\n+#define SSL_set_fd mingw_SSL_set_fd\n+\n+static inline int mingw_SSL_set_rfd(SSL *ssl, int fd)\n+{\n+\treturn SSL_set_rfd(ssl, _get_osfhandle(fd));\n+}\n+#define SSL_set_rfd mingw_SSL_set_rfd\n+\n+static inline int mingw_SSL_set_wfd(SSL *ssl, int fd)\n+{\n+\treturn SSL_set_wfd(ssl, _get_osfhandle(fd));\n+}\n+#define SSL_set_wfd mingw_SSL_set_wfd\n+#endif\n+\n /*\n  * implementations of missing functions\n  */\n-- \n1.6.4\n"},{"id":"124872","messageId":"1255461925-2244-8-git-send-email-kusmabite@gmail.com","threadId":"21227","inReplyTo":"1255461925-2244-7-git-send-email-kusmabite@gmail.com","subject":"[PATCH v3 7/8] mingw: enable OpenSSL","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-13T19:25:24Z","receivedAt":"2009-10-13T19:25:24Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"\nSince we have OpenSSL in msysgit now, enable it to support SSL\nencryption for imap-send.\n\nSigned-off-by: Erik Faye-Lund <kusmabite@gmail.com>\n---\n Makefile |    1 -\n 1 files changed, 0 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 3ddb3b3..e416fdb 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -952,7 +952,6 @@ else\n ifneq (,$(findstring MINGW,$(uname_S)))\n \tpathsep = ;\n \tNO_PREAD = YesPlease\n-\tNO_OPENSSL = YesPlease\n \tNO_LIBGEN_H = YesPlease\n \tNO_SYMLINK_HEAD = YesPlease\n \tNO_IPV6 = YesPlease\n-- \n1.6.4\n"},{"id":"124874","messageId":"1255461925-2244-9-git-send-email-kusmabite@gmail.com","threadId":"21227","inReplyTo":"1255461925-2244-8-git-send-email-kusmabite@gmail.com","subject":"[PATCH v3 8/8] MSVC: Enable OpenSSL, and translate -lcrypto","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-13T19:25:25Z","receivedAt":"2009-10-13T19:25:25Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"\nFrom: Marius Storm-Olsen <mstormo@gmail.com>\n\nWe don't use crypto, but rather require libeay32 and\nssleay32. handle it in both the Makefile msvc linker\nscript, and the buildsystem generator.\n\nSigned-off-by: Marius Storm-Olsen <mstormo@gmail.com>\nSigned-off-by: Erik Faye-Lund <kusmabite@gmail.com>\n---\n Makefile                        |    1 -\n compat/vcbuild/scripts/clink.pl |    3 +++\n contrib/buildsystems/engine.pl  |    3 +++\n 3 files changed, 6 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex e416fdb..b39bed4 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -900,7 +900,6 @@ ifdef MSVC\n \tGIT_VERSION := $(GIT_VERSION).MSVC\n \tpathsep = ;\n \tNO_PREAD = YesPlease\n-\tNO_OPENSSL = YesPlease\n \tNO_LIBGEN_H = YesPlease\n \tNO_SYMLINK_HEAD = YesPlease\n \tNO_IPV6 = YesPlease\ndiff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl\nindex f9528c0..8a2112f 100644\n--- a/compat/vcbuild/scripts/clink.pl\n+++ b/compat/vcbuild/scripts/clink.pl\n@@ -29,6 +29,9 @@ while (@ARGV) {\n \t\tpush(@args, \"zlib.lib\");\n \t} elsif (\"$arg\" eq \"-liconv\") {\n \t\tpush(@args, \"iconv.lib\");\n+\t} elsif (\"$arg\" eq \"-lcrypto\") {\n+\t\tpush(@args, \"libeay32.lib\");\n+\t\tpush(@args, \"ssleay32.lib\");\n \t} elsif (\"$arg\" =~ /^-L/ && \"$arg\" ne \"-LTCG\") {\n \t\t$arg =~ s/^-L/-LIBPATH:/;\n \t\tpush(@args, $arg);\ndiff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl\nindex 20bd061..d506717 100644\n--- a/contrib/buildsystems/engine.pl\n+++ b/contrib/buildsystems/engine.pl\n@@ -315,6 +315,9 @@ sub handleLinkLine\n             $appout = shift @parts;\n         } elsif (\"$part\" eq \"-lz\") {\n             push(@libs, \"zlib.lib\");\n+\t} elsif (\"$part\" eq \"-lcrypto\") {\n+            push(@libs, \"libeay32.lib\");\n+            push(@libs, \"ssleay32.lib\");\n         } elsif ($part =~ /^-/) {\n             push(@lflags, $part);\n         } elsif ($part =~ /\\.(a|lib)$/) {\n-- \n1.6.4\n"},{"id":"124878","messageId":"200910132157.41279.j6t@kdbg.org","threadId":"21227","inReplyTo":"1255461925-2244-6-git-send-email-kusmabite@gmail.com","subject":"Re: [PATCH v3 5/8] imap-send: build imap-send on Windows","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2009-10-13T19:57:41Z","receivedAt":"2009-10-13T19:57:41Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"\nOn Dienstag, 13. Oktober 2009, Erik Faye-Lund wrote:\n>  PROGRAMS += git-unpack-file$X\n>  PROGRAMS += git-upload-pack$X\n>  PROGRAMS += git-var$X\n> +PROGRAMS += git-imap-send$X\n\nThis list is sorted. Please keep it so.\n\n-- Hannes\n"},{"id":"124880","messageId":"200910132159.11616.j6t@kdbg.org","threadId":"21227","inReplyTo":"1255461925-2244-4-git-send-email-kusmabite@gmail.com","subject":"Re: [PATCH v3 3/8] imap-send: use run-command API for tunneling","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2009-10-13T19:59:11Z","receivedAt":"2009-10-13T19:59:11Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"\nOn Dienstag, 13. Oktober 2009, Erik Faye-Lund wrote:\n> +\t\targv[0] = \"/bin/sh\";\n> +\t\targv[1] = \"-c\";\n> +\t\targv[2] = srvc->tunnel;\n> +\t\targv[3] = NULL;\n\nIs there a particular reason that you run \"/bin/sh\" with a path? I doubt that \nthis works on Windows.\n\n-- Hannes\n"},{"id":"124882","messageId":"40aa078e0910131316s308f2bc5h8d679c59c0d5b762@mail.gmail.com","threadId":"21227","inReplyTo":"200910132157.41279.j6t@kdbg.org","subject":"Re: [PATCH v3 5/8] imap-send: build imap-send on Windows","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-13T20:16:14Z","receivedAt":"2009-10-13T20:16:14Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"\nOn Tue, Oct 13, 2009 at 9:57 PM, Johannes Sixt <j6t@kdbg.org> wrote:\n> On Dienstag, 13. Oktober 2009, Erik Faye-Lund wrote:\n>>  PROGRAMS += git-unpack-file$X\n>>  PROGRAMS += git-upload-pack$X\n>>  PROGRAMS += git-var$X\n>> +PROGRAMS += git-imap-send$X\n>\n> This list is sorted. Please keep it so.\n>\n> -- Hannes\n>\n\nAha, I didn't notice! Thanks, I'll fix :)\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"124888","messageId":"40aa078e0910131327q682c7044x854fec4de60b0c43@mail.gmail.com","threadId":"21227","inReplyTo":"200910132159.11616.j6t@kdbg.org","subject":"Re: [PATCH v3 3/8] imap-send: use run-command API for tunneling","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-13T20:27:37Z","receivedAt":"2009-10-13T20:27:37Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"\nOn Tue, Oct 13, 2009 at 9:59 PM, Johannes Sixt <j6t@kdbg.org> wrote:\n> On Dienstag, 13. Oktober 2009, Erik Faye-Lund wrote:\n>> +             argv[0] = \"/bin/sh\";\n>> +             argv[1] = \"-c\";\n>> +             argv[2] = srvc->tunnel;\n>> +             argv[3] = NULL;\n>\n> Is there a particular reason that you run \"/bin/sh\" with a path? I doubt that\n> this works on Windows.\n>\n> -- Hannes\n>\n\nIt doesn't - I was being conservative. Getting tunneling to work on\nWindows hasn't been a part of  my priorities (even though I did\nbriefly test it at some point and got it working, provided a patch\nthat changed the path to sh to a windows-path). Changing it to \"sh -c\"\n(as was suggested earlier) could AFAIK break something for people who\nhave other 'sh's in path before /bin -- not that I think it would\nmatter terribly much.\n\nIf I were to fix this, I'd prefer not using sh at all on Windows. I've\nseen that connect.c doesn't prepend \"/bin/sh -c\" at all, requiring\ntunnels to be self-contained scripts or native binaries, unless I'm\nmistaken. I'm not sure if this works at all on Windows, though. I just\nthink that the assumption that sh is the shell that is going to run\nthe tunnel is wrong to make, especially on Windows.\n\nI'm really unsure if it's worth the hassle.\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"124898","messageId":"40aa078e0910131434u4240ea8fy480efcebdaa21a8f@mail.gmail.com","threadId":"21227","inReplyTo":"40aa078e0910131316s308f2bc5h8d679c59c0d5b762@mail.gmail.com","subject":"Re: [PATCH v3 5/8] imap-send: build imap-send on Windows","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-13T21:34:05Z","receivedAt":"2009-10-13T21:34:05Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"\nOn Tue, Oct 13, 2009 at 10:16 PM, Erik Faye-Lund\n<kusmabite@googlemail.com> wrote:\n> On Tue, Oct 13, 2009 at 9:57 PM, Johannes Sixt <j6t@kdbg.org> wrote:\n>> This list is sorted. Please keep it so.\n> Aha, I didn't notice! Thanks, I'll fix :)\n\nHere's the new (trivial) diff. I don't think it's worth a resend, at\nleast not yet.\n\n---\n\ndiff --git a/Makefile b/Makefile\nindex fea237b..0d13af3 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -354,6 +354,7 @@ EXTRA_PROGRAMS =\n PROGRAMS += $(EXTRA_PROGRAMS)\n PROGRAMS += git-fast-import$X\n PROGRAMS += git-hash-object$X\n+PROGRAMS += git-imap-send$X\n PROGRAMS += git-index-pack$X\n PROGRAMS += git-merge-index$X\n PROGRAMS += git-merge-tree$X\n@@ -1075,7 +1076,6 @@ EXTLIBS += -lz\n\n ifndef NO_POSIX_ONLY_PROGRAMS\n        PROGRAMS += git-daemon$X\n-       PROGRAMS += git-imap-send$X\n endif\n ifndef NO_OPENSSL\n        OPENSSL_LIBSSL = -lssl\n\n\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"125012","messageId":"200910142158.59073.j6t@kdbg.org","threadId":"21227","inReplyTo":"40aa078e0910131327q682c7044x854fec4de60b0c43@mail.gmail.com","subject":"Re: [PATCH v3 3/8] imap-send: use run-command API for tunneling","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2009-10-14T19:58:58Z","receivedAt":"2009-10-14T19:58:58Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"\nOn Dienstag, 13. Oktober 2009, Erik Faye-Lund wrote:\n> If I were to fix this, I'd prefer not using sh at all on Windows. I've\n> seen that connect.c doesn't prepend \"/bin/sh -c\" at all, requiring\n> tunnels to be self-contained scripts or native binaries, unless I'm\n> mistaken. I'm not sure if this works at all on Windows, though. I just\n> think that the assumption that sh is the shell that is going to run\n> the tunnel is wrong to make, especially on Windows.\n>\n> I'm really unsure if it's worth the hassle.\n\nWe already depend on the existence of a Bourne shell for our scripted \ncommands. There are already more places in the code that run \"sh\" \nthan \"/bin/sh\".\n\n-- Hannes\n"},{"id":"125180","messageId":"40aa078e0910160727g2ebc1e6qe0c3a00186e38569@mail.gmail.com","threadId":"21227","inReplyTo":"200910142158.59073.j6t@kdbg.org","subject":"Re: [PATCH v3 3/8] imap-send: use run-command API for tunneling","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-16T14:27:33Z","receivedAt":"2009-10-16T14:27:33Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"\nSorry about the late reply, lots of things to do.\nOn Wed, Oct 14, 2009 at 9:58 PM, Johannes Sixt <j6t@kdbg.org> wrote:\n> On Dienstag, 13. Oktober 2009, Erik Faye-Lund wrote:\n>> I'm really unsure if it's worth the hassle.\n>\n> We already depend on the existence of a Bourne shell for our scripted\n> commands. There are already more places in the code that run \"sh\"\n> than \"/bin/sh\".\n\nOK, you've got me convinced. I'll update the patch with this tweak.\n\n-- \nErik \"kusma\" Faye-Lund\n"}]}