{"thread":{"id":"52823","subject":"Re: Facing error in git-imap-send while compiling Git","startedAt":"2020-02-17T09:31:05Z","lastAt":"2020-02-17T09:31:05Z","messageCount":1,"participants":["Abhishek Kumar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"391913","messageId":"CAHk66fvt-1RaLK8E7SDpocWM9OMAcA-gP5hjHq6r5N_FbATNgA@mail.gmail.com","threadId":"52823","inReplyTo":null,"subject":"Re: Facing error in git-imap-send while compiling Git","fromName":"Abhishek Kumar","fromEmail":"abhishekkumar8222@gmail.com","sentAt":"2020-02-17T09:30:00Z","receivedAt":"2020-02-17T09:31:05Z","isPatch":false,"sender":{"key":"abhishekkumar8222@gmail.com","avatar":"https://avatars.githubusercontent.com/u/31231064?v=4"},"body":"Greetings Nirmal\n\n> what imap-send does (in words simpler than ones in manpages).\n\nIMAP is a protocol that stores email messages on a mail server but\nallows end-user to view and manipulate them as local files.\n\nimap-send sends a collection of patches from stdin to an IMAP folder.\nYou create patches using `git format-patch`, edit them and once\nsatisfied, send them to your drafts folder using `git imap-send`.\n\n**Note**: This does not mean that they are sent out, but rather they\nare (usually) in your email service's draft folder.\n\nAs for your diff, I have some suggestions -\n---\ndiff --git a/imap-send.c b/imap-send.c\nindex 6c54d8c29d..3248bc2123 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -41,7 +41,9 @@ typedef void *SSL;\n /* We don't have curl, so continue to use the historical implementation */\n #define USE_CURL_DEFAULT 0\n #endif\n-\n> +#ifndef SSL_library_init\n> +       #define SSL_library_init();\n> +#endif\n\nIf the macro does not exist, you define it to - nothing, really. You\nmight have meant this. [1]\n```\n#ifndef SSL_libary_init\n#define SSL_library_init() OPENSSL_init_ssl(0, null)\n#endif\n```\nRegardless, you do check below for the version (hence indirectly\nwhether the macro exists). You can safely remove these lines.\n\n static int ssl_socket_connect(struct imap_socket *sock, int\nuse_tls_only, int verify)\n {\n-#if (OPENSSL_VERSION_NUMBER >= 0x10000000L)\n-       const SSL_METHOD *meth;\n-#else\n-       SSL_METHOD *meth;\n-#endif\n-       SSL_CTX *ctx;\n-       int ret;\n-       X509 *cert;\n-\n-       SSL_library_init();\n-       SSL_load_error_strings();\n> +       #if (OPENSSL_VERSION_NUMBER >= 0x10000000L)\n> +               const SSL_METHOD *meth;\n> +       #else\n> +               SSL_METHOD *meth;\n> +       #endif\n\nMaintain zero indentation for macros for consistency.\nAlso define `METHOD_NAME` as `SSLv23_method` and `TLS_method` to\nreduce noise below.\n\n+               SSL_CTX *ctx;\n+               int ret;\n+               X509 *cert;\n+\n> +       #if OPENSSL_VERSION_NUMBER >= 0x10100000L ||\n> + defined(LIBRESSL_VERSION_NUMBER)\n> +               OPENSSL_init_ssl(0, NULL);\n\nThis will be executed if openssl version >= 1.1 or has libressl\ninstalled - which means it will *also* be executed for\nopenssl < 1.1 and libressl installed. OPENSSL_init_ssl hasn't been\ndefined for older versions and will throw an undefined reference as well. [2]\n+               meth = TLS_method();\n+       #else\n+               SSL_library_init();\n+               SSL_load_error_strings();\n+               meth = SSLv23_method();\n+       #endif\n\n-       meth = SSLv23_method();\n        if (!meth) {\n-               ssl_socket_perror(\"SSLv23_method\");\n> +       #if (OPENSSL_VERSION_NUMBER >= 0x10100000L)\n> +                       ssl_socket_perror(\"TLS_method\");\n> +       #else\n> +                       ssl_socket_perror(\"SSLv23_method\");\n> +       #endif\n\nUse `METHOD_NAME` defined above.\n\n                return -1;\n        }\n\nAs a general note for this patch - I would rather make OpenSSL 1.1 the\ncommon case, using directives to make it compatible with the older\nversions. Do consult with Junio and Johannes over the larger picture\nhere.\n---\n\nRegards\nAbhishek\n\n[1]: https://github.com/openssl/openssl/blob/8083fd3a183d4c881d6b15727cbc6cb7faeb3280/include/openssl/ssl.h#L1995\n[2]: https://www.openssl.org/docs/man1.1.0/man3/OPENSSL_init_ssl.html\n"}]}