git-imap-send: Add support for SSL.
Subsystems (2)
PATCH 2/4 git-imap-send: Add support for SSL.
From: Robert Shearman <[email protected]>
Allow SSL to be used when a imaps:// URL is used for the host name.
Also, automatically use TLS when not using imaps:// by using the IMAP STARTTLS command, if the server supports it.
Tested with Courier and Gimap IMAP servers.
--- Documentation/git-imap-send.txt | 3 +- Makefile | 4 +- imap-send.c | 166 +++++++++++++++++++++++++++++++++++---- 3 files changed, 156 insertions(+), 17 deletions(-)
Documentation/git-imap-send.txt +2 -1
@@ -37,10 +37,11 @@ configuration file (shown with examples): Tunnel = "ssh -q [email protected] /usr/bin/imapd ./Maildir 2> /dev/null" [imap] - Host = imap.server.com + Host = imap://imap.example.com User = bob Pass = pwd Port = 143 + sslverify = false ..........................
Makefile +3 -1
@@ -1193,7 +1193,9 @@ endif git-%$X: %.o $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) -git-imap-send$X: imap-send.o $(LIB_FILE) +git-imap-send$X: imap-send.o $(GITLIBS) + $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ + $(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL) http.o http-walker.o http-push.o transport.o: http.h
imap-send.c +151 -15
279 lines not on this page · raw message
Signature · 1 line
1.5.6.2.224.g26efb.dirty
Quoted 7 lines · Robert Shearman
From: Robert Shearman <[email protected]>
Allow SSL to be used when a imaps:// URL is used for the host name.
Also, automatically use TLS when not using imaps:// by using the IMAP STARTTLS command, if the server supports it.
Tested with Courier and Gimap IMAP servers.
Please do an alternative implementation using GnuTLS. Why ? Because curl can be built against openssl or gnutls, and it would be sad if git ended up depending on both indirectly.
Mike
Quoted 5 lines · Robert Shearman
imap-send.c +0
-0
imap-send.c line 31
Quoted 9 lines
imap-send.c +6
-0@@ -23,6 +23,12 @@*/ #include "cache.h" +#ifdef NO_OPENSSL +typedef void *SSL ; +#else +# include <openssl/ssl.h> +# include <openssl/err.h> +#endif
This unfortunately is causing compilation issues. <openssl/ssl.h> wants to include <ctype.h> and gets upset by seeing our isalpha() and friends that are defined indirectly in "cache.h" expanded.
In <ctype.h> (on FC9), isCHARACTERISTC() are defined like this:
#define __exctype(name) extern int name (int) __THROW
...
__exctype (isalnum);
__exctype (isalpha);but we have been using our own locale agonistic and signed-chars safe macros defined in git-compat-util.h. Including <ctype.h> breaks at the syntax level, but more importantly if the system <ctype.h> redefines isalpha() and friends as macro, then it would break _our_ code that expect these macros are the sane_ctype[] based ones we have.
A hack like the one attached below would make it "work" but it is too ugly. Probably we need to bite the bullet and rename ours not to collide, so that external library headers can safely include <ctype.h>.
Sigh...
git-compat-util.h +1 -0
@@ -302,6 +302,7 @@ static inline int has_extension(const char *filename, const char *ext) }/* Sane ctype - no locale, and works with signed chars */ +#define _CTYPE_H#undef isspace#undef isdigit#undef isalpha
Quoted 4 lines · Junio C Hamano
A hack like the one attached below would make it "work" but it is too ugly. Probably we need to bite the bullet and rename ours not to collide, so that external library headers can safely include <
ctype.h>.
We should be able to safely include <ctype.h> as-is.
It should just happen _before_ including git-compat-util.h. That's why git-compat-util.h does all those #undef's - exactly because ctype.h does get included on various systems by various header files when git-compat-util.h includes all those other files.
So the problem with Robert's patch is that it happens after "cache.h". The system headers should be included at the top of git-compat-util.h, or before it.
Linus
Quoted 6 lines · Linus Torvalds
We should be able to safely include <
ctype.h> as-is.It should just happen _before_ including
git-compat-util.h. That's whygit-compat-util.hdoes all those #undef's - exactly becausectype.hdoes get included on various systems by various header files whengit-compat-util.hincludes all those other files.
Eh, that's true,... although I am not convinced we should keep doing this.
With and without NO_OPENSSL, on top of Robert's patch, these seem to pass compile test.
--
git-compat-util.h | 5 +++++ imap-send.c | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-)
git-compat-util.h +5 -0
@@ -99,6 +99,11 @@#include <iconv.h> #endif +#ifndef NO_OPENSSL +#include <openssl/ssl.h> +#include <openssl/err.h> +#endif +/* On most systems <limits.h> would have given us this, but * not on some systems (e.g. GNU/Hurd). */
imap-send.c +0 -3
@@ -25,9 +25,6 @@#include "cache.h" #ifdef NO_OPENSSL typedef void *SSL ; -#else -# include <openssl/ssl.h> -# include <openssl/err.h> #endif typedef struct store_conf {