From: Junio C Hamano Date: Wed, 3 Apr 2013 15:35:33 +0000 (-0700) Subject: Merge branch 'ob/imap-send-ssl-verify' into maint-1.8.1 X-Git-Tag: v1.8.1.6~12 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/d7df695d85c28cc21680947b822bcc3bcbddd48d?ds=inline;hp=-c Merge branch 'ob/imap-send-ssl-verify' into maint-1.8.1 * ob/imap-send-ssl-verify: imap-send: support Server Name Indication (RFC4366) --- d7df695d85c28cc21680947b822bcc3bcbddd48d diff --combined imap-send.c index ef500111ec,91671d6f41..49ba841cba --- a/imap-send.c +++ b/imap-send.c @@@ -25,7 -25,6 +25,7 @@@ #include "cache.h" #include "exec_cmd.h" #include "run-command.h" +#include "prompt.h" #ifdef NO_OPENSSL typedef void *SSL; #else @@@ -140,6 -139,7 +140,6 @@@ static struct imap_server_conf server struct imap_store_conf { struct store_conf gen; struct imap_server_conf *server; - unsigned use_namespace:1; }; #define NIL (void *)0x1 @@@ -370,6 -370,17 +370,17 @@@ static int ssl_socket_connect(struct im return -1; } + #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME + /* + * SNI (RFC4366) + * OpenSSL does not document this function, but the implementation + * returns 1 on success, 0 on failure after calling SSLerr(). + */ + ret = SSL_set_tlsext_host_name(sock->ssl, server.host); + if (ret != 1) + warning("SSL_set_tlsext_host_name(%s) failed.", server.host); + #endif + ret = SSL_connect(sock->ssl); if (ret <= 0) { socket_perror("SSL_connect", sock, ret); @@@ -1085,7 -1096,7 +1096,7 @@@ static int auth_cram_md5(struct imap_st ret = socket_write(&ctx->imap->buf.sock, response, strlen(response)); if (ret != strlen(response)) - return error("IMAP error: sending response failed\n"); + return error("IMAP error: sending response failed"); free(response); @@@ -1249,10 -1260,13 +1260,10 @@@ static struct store *imap_open_store(st goto bail; } if (!srvc->pass) { - char prompt[80]; - sprintf(prompt, "Password (%s@%s): ", srvc->user, srvc->host); - arg = git_getpass(prompt); - if (!arg) { - perror("getpass"); - exit(1); - } + struct strbuf prompt = STRBUF_INIT; + strbuf_addf(&prompt, "Password (%s@%s): ", srvc->user, srvc->host); + arg = git_getpass(prompt.buf); + strbuf_release(&prompt); if (!*arg) { fprintf(stderr, "Skipping account %s@%s, no password\n", srvc->user, srvc->host); goto bail; @@@ -1576,8 -1590,6 +1587,8 @@@ int main(int argc, char **argv git_extract_argv0_path(argv[0]); + git_setup_gettext(); + if (argc != 1) usage(imap_send_usage);