{"thread":{"id":"21281","subject":"[PATCH v4 1/8] imap-send: remove useless uid code","startedAt":"2009-10-19T15:42:01Z","lastAt":"2009-10-21T12:55:23Z","messageCount":14,"participants":["Erik Faye-Lund","Johannes Sixt"],"isPatch":true,"patchVersion":4,"patchTotal":8},"messages":[{"id":"125390","messageId":"1255966929-1280-1-git-send-email-kusmabite@gmail.com","threadId":"21281","inReplyTo":null,"subject":"[PATCH v4 0/8] imap-send: Windows support","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-19T15:42:01Z","receivedAt":"2009-10-19T15:42:01Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"\nHere's the 4th 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 the previous\nare as follows:\n - Patch 3/8 calls \"sh -c\" instead of \"/bin/sh -c\"\n - Patch 5/8 keeps the list sorted\n\nThanks to Johannes Sixt for reviewing v4\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":"125382","messageId":"1255966929-1280-2-git-send-email-kusmabite@gmail.com","threadId":"21281","inReplyTo":"1255966929-1280-1-git-send-email-kusmabite@gmail.com","subject":"[PATCH v4 1/8] imap-send: remove useless uid code","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-19T15:42:02Z","receivedAt":"2009-10-19T15:42:02Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"From: 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.5.15.g5f078\n"},{"id":"125383","messageId":"1255966929-1280-3-git-send-email-kusmabite@gmail.com","threadId":"21281","inReplyTo":"1255966929-1280-2-git-send-email-kusmabite@gmail.com","subject":"[PATCH v4 2/8] imap-send: use separate read and write fds","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-19T15:42:03Z","receivedAt":"2009-10-19T15:42:03Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"This 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.5.15.g5f078\n"},{"id":"125384","messageId":"1255966929-1280-4-git-send-email-kusmabite@gmail.com","threadId":"21281","inReplyTo":"1255966929-1280-3-git-send-email-kusmabite@gmail.com","subject":"[PATCH v4 3/8] imap-send: use run-command API for tunneling","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-19T15:42:04Z","receivedAt":"2009-10-19T15:42:04Z","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..72ed640 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] = \"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.5.15.g5f078\n"},{"id":"125387","messageId":"1255966929-1280-5-git-send-email-kusmabite@gmail.com","threadId":"21281","inReplyTo":"1255966929-1280-4-git-send-email-kusmabite@gmail.com","subject":"[PATCH v4 4/8] imap-send: fix compilation-error on Windows","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-19T15:42:05Z","receivedAt":"2009-10-19T15:42:05Z","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 72ed640..69e6142 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.5.15.g5f078\n"},{"id":"125388","messageId":"1255966929-1280-6-git-send-email-kusmabite@gmail.com","threadId":"21281","inReplyTo":"1255966929-1280-5-git-send-email-kusmabite@gmail.com","subject":"[PATCH v4 5/8] imap-send: build imap-send on Windows","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-19T15:42:06Z","receivedAt":"2009-10-19T15:42:06Z","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..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 \tPROGRAMS += git-daemon$X\n-\tPROGRAMS += git-imap-send$X\n endif\n ifndef NO_OPENSSL\n \tOPENSSL_LIBSSL = -lssl\n-- \n1.6.5.15.g5f078\n"},{"id":"125385","messageId":"1255966929-1280-7-git-send-email-kusmabite@gmail.com","threadId":"21281","inReplyTo":"1255966929-1280-6-git-send-email-kusmabite@gmail.com","subject":"[PATCH v4 6/8] mingw: wrap SSL_set_(w|r)fd to call _get_osfhandle","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-19T15:42:07Z","receivedAt":"2009-10-19T15:42:07Z","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.5.15.g5f078\n"},{"id":"125386","messageId":"1255966929-1280-8-git-send-email-kusmabite@gmail.com","threadId":"21281","inReplyTo":"1255966929-1280-7-git-send-email-kusmabite@gmail.com","subject":"[PATCH v4 7/8] mingw: enable OpenSSL","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-19T15:42:08Z","receivedAt":"2009-10-19T15:42:08Z","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 0d13af3..dbeaf2f 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.5.15.g5f078\n"},{"id":"125389","messageId":"1255966929-1280-9-git-send-email-kusmabite@gmail.com","threadId":"21281","inReplyTo":"1255966929-1280-8-git-send-email-kusmabite@gmail.com","subject":"[PATCH v4 8/8] MSVC: Enable OpenSSL, and translate -lcrypto","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-19T15:42:09Z","receivedAt":"2009-10-19T15:42:09Z","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 dbeaf2f..9db6c08 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.5.15.g5f078\n"},{"id":"125403","messageId":"200910192020.40179.j6t@kdbg.org","threadId":"21281","inReplyTo":"1255966929-1280-7-git-send-email-kusmabite@gmail.com","subject":"Re: [msysGit] [PATCH v4 6/8] mingw: wrap SSL_set_(w|r)fd to call _get_osfhandle","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2009-10-19T18:20:39Z","receivedAt":"2009-10-19T18:20:39Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Montag, 19. Oktober 2009, Erik Faye-Lund wrote:\n> SSL_set_fd (and friends) expects a OS file handle on Windows, not\n> a file descriptor as on UNIX(-ish).\n>\n> This patch makes the Windows version of SSL_set_fd behave like the\n> UNIX versions, by calling _get_osfhandle on it's input.\n>\n> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>\n\nAcked-by: Johannes Sixt <j6t@kdbg.org>\n\n-- Hannes\n"},{"id":"125404","messageId":"200910192020.44890.j6t@kdbg.org","threadId":"21281","inReplyTo":"1255966929-1280-8-git-send-email-kusmabite@gmail.com","subject":"Re: [msysGit] [PATCH v4 7/8] mingw: enable OpenSSL","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2009-10-19T18:20:44Z","receivedAt":"2009-10-19T18:20:44Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Montag, 19. Oktober 2009, Erik Faye-Lund wrote:\n> Since we have OpenSSL in msysgit now, enable it to support SSL\n> encryption for imap-send.\n>\n> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>\n\nAcked-by: Johannes Sixt <j6t@kdbg.org>\n\n-- Hannes\n"},{"id":"125589","messageId":"4ADEFB6D.9050501@viscovery.net","threadId":"21281","inReplyTo":"200910192020.44890.j6t@kdbg.org","subject":"Re: [msysGit] [PATCH v4 7/8] mingw: enable OpenSSL","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-10-21T12:15:41Z","receivedAt":"2009-10-21T12:15:41Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Johannes Sixt schrieb:\n> On Montag, 19. Oktober 2009, Erik Faye-Lund wrote:\n>> Since we have OpenSSL in msysgit now, enable it to support SSL\n>> encryption for imap-send.\n>>\n>> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>\n> \n> Acked-by: Johannes Sixt <j6t@kdbg.org>\n\nI seem to have ack'ed this one too early. After testing in my environment,\nI get:\n\nimap-send.o: In function `ssl_socket_perror':\nD:\\Src\\mingw-git/imap-send.c:241: undefined reference to `ERR_get_error'\nD:\\Src\\mingw-git/imap-send.c:241: undefined reference to `ERR_error_string'\n\nI need this patch in addition, and perhaps something similar is also\nneeded with MSVC:\n\ndiff --git a/Makefile b/Makefile\nindex c4b91d8..7e6a1c3 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -932,6 +932,7 @@ else\n ifneq (,$(findstring MINGW,$(uname_S)))\n \tpathsep = ;\n \tNO_PREAD = YesPlease\n+\tNEEDS_CRYPTO_WITH_SSL = YesPlease\n \tNO_LIBGEN_H = YesPlease\n \tNO_SYMLINK_HEAD = YesPlease\n \tNO_IPV6 = YesPlease\n"},{"id":"125592","messageId":"40aa078e0910210543t2dcc2af6ie16eb0e49895788f@mail.gmail.com","threadId":"21281","inReplyTo":"4ADEFB6D.9050501@viscovery.net","subject":"Re: [PATCH v4 7/8] mingw: enable OpenSSL","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-10-21T12:43:30Z","receivedAt":"2009-10-21T12:43:30Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"\nOn Wed, Oct 21, 2009 at 2:15 PM, Johannes Sixt <j.sixt@viscovery.net> wrote:\n> I seem to have ack'ed this one too early. After testing in my environment,\n> I get:\n>\n> imap-send.o: In function `ssl_socket_perror':\n> D:\\Src\\mingw-git/imap-send.c:241: undefined reference to `ERR_get_error'\n> D:\\Src\\mingw-git/imap-send.c:241: undefined reference to `ERR_error_string'\n>\n> I need this patch in addition, and perhaps something similar is also\n> needed with MSVC:\n\nAh, yes - thanks for that one. I traced it a bit, and I found that it\nworks for me without your patch because I'm using OpenSSL's sha1, so\n$(LIB_4_CRYPTO) is already included. Your fix is of course correct.\nI'll squash it in and resend.\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"125593","messageId":"4ADF04BB.10302@viscovery.net","threadId":"21281","inReplyTo":"40aa078e0910210543t2dcc2af6ie16eb0e49895788f@mail.gmail.com","subject":"Re: [msysGit] [PATCH v4 7/8] mingw: enable OpenSSL","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-10-21T12:55:23Z","receivedAt":"2009-10-21T12:55:23Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Erik Faye-Lund schrieb:\n> On Wed, Oct 21, 2009 at 2:15 PM, Johannes Sixt <j.sixt@viscovery.net> wrote:\n>> I seem to have ack'ed this one too early. After testing in my environment,\n>> I get:\n>>\n>> imap-send.o: In function `ssl_socket_perror':\n>> D:\\Src\\mingw-git/imap-send.c:241: undefined reference to `ERR_get_error'\n>> D:\\Src\\mingw-git/imap-send.c:241: undefined reference to `ERR_error_string'\n>>\n>> I need this patch in addition, and perhaps something similar is also\n>> needed with MSVC:\n> \n> Ah, yes - thanks for that one. I traced it a bit, and I found that it\n> works for me without your patch because I'm using OpenSSL's sha1, so\n> $(LIB_4_CRYPTO) is already included. Your fix is of course correct.\n> I'll squash it in and resend.\n\nIndeed, I observed the failure after I set BLK_SHA1=YesPlease. I did this\nexactly because it removes the dependency on libcrypto.dll from git.exe.\n\n-- Hannes\n"}]}