Merge branch 'ob/imap-send-ssl-verify' into maint-1.8.1
authorJunio C Hamano <gitster@pobox.com>
Wed, 3 Apr 2013 15:35:33 +0000 (08:35 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 3 Apr 2013 15:35:33 +0000 (08:35 -0700)
* ob/imap-send-ssl-verify:
imap-send: support Server Name Indication (RFC4366)

1  2 
imap-send.c
diff --combined imap-send.c
index ef500111ec0bca6514e519d39e7a269a7342cddf,91671d6f41895dbb8c93fc2d8c0ca5d449fefc53..49ba841cbaabb6da9bfab1bf54f63a50c3069dd9
@@@ -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);