Hello community, here is the log from the commit of package libetpan for openSUSE:Factory checked in at 2019-11-26 16:50:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libetpan (Old) and /work/SRC/openSUSE:Factory/.libetpan.new.26869 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libetpan" Tue Nov 26 16:50:52 2019 rev:27 rq:743296 version:1.9.3 Changes: -------- --- /work/SRC/openSUSE:Factory/libetpan/libetpan.changes 2018-10-04 19:02:25.651144528 +0200 +++ /work/SRC/openSUSE:Factory/.libetpan.new.26869/libetpan.changes 2019-11-26 16:51:14.924273512 +0100 @@ -1,0 +2,11 @@ +Wed Sep 25 20:10:15 UTC 2019 - [email protected] + +- update to version 1.9.3 + * Added IMAP CLIENTID / SMTP CLIENTID support + * Use Cyrus SASL 2.1.27 +- update to version 1.9.2 + * Support of TLS SNI + * LMDB for cache DB + * Fixed build with recent versions of curl + +------------------------------------------------------------------- Old: ---- 1.9.1.tar.gz New: ---- 1.9.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libetpan.spec ++++++ --- /var/tmp/diff_new_pack.kSzjMu/_old 2019-11-26 16:51:18.200272327 +0100 +++ /var/tmp/diff_new_pack.kSzjMu/_new 2019-11-26 16:51:18.200272327 +0100 @@ -1,7 +1,7 @@ # # spec file for package libetpan # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %define sover 20 Name: libetpan -Version: 1.9.1 +Version: 1.9.3 Release: 0 Summary: Mail Handling Library License: BSD-3-Clause ++++++ 1.9.1.tar.gz -> 1.9.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/.travis.yml new/libetpan-1.9.3/.travis.yml --- old/libetpan-1.9.1/.travis.yml 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/.travis.yml 2019-01-22 20:40:22.000000000 +0100 @@ -4,4 +4,3 @@ language: c before_script: travis/before-script.sh script: travis/script.sh -osx_image: xcode7 Binary files old/libetpan-1.9.1/build-mac/dependencies/packages/cyrus-sasl-2.1.25.tar.gz and new/libetpan-1.9.3/build-mac/dependencies/packages/cyrus-sasl-2.1.25.tar.gz differ Binary files old/libetpan-1.9.1/build-mac/dependencies/packages/cyrus-sasl-2.1.27.tar.gz and new/libetpan-1.9.3/build-mac/dependencies/packages/cyrus-sasl-2.1.27.tar.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/build-mac/dependencies/prepare-cyrus-sasl.sh new/libetpan-1.9.3/build-mac/dependencies/prepare-cyrus-sasl.sh --- old/libetpan-1.9.1/build-mac/dependencies/prepare-cyrus-sasl.sh 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/build-mac/dependencies/prepare-cyrus-sasl.sh 2019-01-22 20:40:22.000000000 +0100 @@ -2,12 +2,14 @@ export PATH=/usr/bin:/bin:/usr/sbin:/sbin -version=2.1.26 +version=2.1.27 ARCHIVE=cyrus-sasl-$version ARCHIVE_NAME=$ARCHIVE.tar.gz ARCHIVE_PATCH=$ARCHIVE.patch #url=ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/$ARCHIVE_NAME -url=ftp://ftp.cyrusimap.org/cyrus-sasl/$ARCHIVE_NAME +#url=ftp://ftp.cyrusimap.org/cyrus-sasl/$ARCHIVE_NAME +#url=https://www.cyrusimap.org/releases/$ARCHIVE_NAME +url=https://github.com/cyrusimap/cyrus-sasl/releases/download/$ARCHIVE/$ARCHIVE_NAME patchfile=cyrus-2.1.25-libetpan.patch scriptdir="`pwd`" @@ -40,10 +42,10 @@ : else echo "download source package - $url" - + mkdir -p "$current_dir/packages" cd "$current_dir/packages" - curl -O "$url" + curl -L -O "$url" if test x$? != x0 ; then echo fetch of $ARCHIVE_NAME failed exit 1 @@ -72,9 +74,9 @@ patch -p1 < $current_dir/$patchfile # patch source files cd "$srcdir/$ARCHIVE/include" -sed -E 's/\.\/makemd5 /.\/makemd5i386 /' < Makefile.am > Makefile.am.new +sed -E 's/\.\/\$< /.\/\$<i386 /' < Makefile.am > Makefile.am.new mv Makefile.am.new Makefile.am -sed -E 's/\.\/makemd5 /.\/makemd5i386 /' < Makefile.in > Makefile.in.new +sed -E 's/\.\/\$< /.\/\$<i386 /' < Makefile.in > Makefile.in.new mv Makefile.in.new Makefile.in cd "$srcdir/$ARCHIVE/lib" sed -E 's/\$\(AR\) cru \.libs\/\$@ \$\(SASL_STATIC_OBJS\)/&; \$\(RANLIB\) .libs\/\$@/' < Makefile.in > Makefile.in.new @@ -127,7 +129,7 @@ SYSROOT="$(xcodebuild -version -sdk "$SDK_ID" 2>/dev/null | egrep '^Path: ' | cut -d ' ' -f 2)" case $TARGET in - (iPhoneOS) + (iPhoneOS) ARCH=arm MARCHS="armv7 armv7s arm64" EXTRA_FLAGS="$BITCODE_FLAGS -miphoneos-version-min=$SDK_IOS_MIN_VERSION" @@ -138,11 +140,11 @@ EXTRA_FLAGS="-miphoneos-version-min=$SDK_IOS_MIN_VERSION" ;; esac - + for MARCH in $MARCHS; do echo "building for $TARGET - $MARCH" echo "*** building for $TARGET - $MARCH ***" >> "$logfile" 2>&1 - + PREFIX=${BUILD_DIR}/${LIB_NAME}/${TARGET}${SDK_IOS_VERSION}${MARCH} rm -rf $PREFIX diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/build-mac/libetpan.xcodeproj/project.pbxproj new/libetpan-1.9.3/build-mac/libetpan.xcodeproj/project.pbxproj --- old/libetpan-1.9.1/build-mac/libetpan.xcodeproj/project.pbxproj 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/build-mac/libetpan.xcodeproj/project.pbxproj 2019-01-22 20:40:22.000000000 +0100 @@ -542,12 +542,10 @@ C6F9ED2D105335BD0059C3BA /* mailsmtp_socket.c in Sources */ = {isa = PBXBuildFile; fileRef = C6F9EAB4105335BC0059C3BA /* mailsmtp_socket.c */; }; C6F9ED2F105335BD0059C3BA /* mailsmtp_ssl.c in Sources */ = {isa = PBXBuildFile; fileRef = C6F9EAB6105335BC0059C3BA /* mailsmtp_ssl.c */; }; C6F9ED39105335BD0059C3BA /* libetpan_version.c in Sources */ = {isa = PBXBuildFile; fileRef = C6F9EAC2105335BD0059C3BA /* libetpan_version.c */; }; - C6F9ED9E105339200059C3BA /* libssl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C6F9ED9D105339200059C3BA /* libssl.dylib */; }; C6F9EDA6105339380059C3BA /* libsasl2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C6F9EDA5105339380059C3BA /* libsasl2.dylib */; }; C6F9EDAB1053394C0059C3BA /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C6F9EDAA1053394C0059C3BA /* libiconv.dylib */; }; C6F9EDAD1053395A0059C3BA /* libexpat.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C6F9EDAC1053395A0059C3BA /* libexpat.dylib */; }; C6F9EDB2105339650059C3BA /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C6F9EDB1105339650059C3BA /* libcurl.dylib */; }; - C6F9EDBE105339EA0059C3BA /* libcrypto.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C6F9EDBD105339EA0059C3BA /* libcrypto.dylib */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -985,12 +983,10 @@ buildActionMask = 2147483647; files = ( C69BA86017DF63CA00D601B7 /* libz.dylib in Frameworks */, - C6F9ED9E105339200059C3BA /* libssl.dylib in Frameworks */, C6F9EDA6105339380059C3BA /* libsasl2.dylib in Frameworks */, C6F9EDAB1053394C0059C3BA /* libiconv.dylib in Frameworks */, C6F9EDAD1053395A0059C3BA /* libexpat.dylib in Frameworks */, C6F9EDB2105339650059C3BA /* libcurl.dylib in Frameworks */, - C6F9EDBE105339EA0059C3BA /* libcrypto.dylib in Frameworks */, C6EFB8AE1433F58500F805C0 /* CoreFoundation.framework in Frameworks */, C6EFB8B41433F5A400F805C0 /* CoreServices.framework in Frameworks */, C6ED6CF717A185FD00A4A14C /* Security.framework in Frameworks */, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/build-windows/README.md new/libetpan-1.9.3/build-windows/README.md --- old/libetpan-1.9.1/build-windows/README.md 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/build-windows/README.md 2019-01-22 20:40:22.000000000 +0100 @@ -15,25 +15,36 @@ - [OpenSSL](http://d.etpan.org/mailcore2-deps/misc-win32/) - [SASL](http://d.etpan.org/mailcore2-deps/cyrus-sasl-win32/) -### Build using Visual Studio 2013 ### +### Build using Visual Studio ### -You'll need all the dependencies, download the most recent binary builds in: +1. You need a working installation of Visual Studio 2013, 2015 or 2017. A community +edition is enough. + +2. Clone repository/or download the a .zip and unpack it. The direcory where +the content of the repository lays in will from now on referenced as `libetpan`. +This `README.md` should be at `libetpan/build-windows/README.md`. + +3. You'll need all the dependencies, download the most recent binary builds in: - [zlib](http://d.etpan.org/mailcore2-deps/zlib-win32/) - [OpenSSL](http://d.etpan.org/mailcore2-deps/misc-win32/) - [SASL](http://d.etpan.org/mailcore2-deps/cyrus-sasl-win32/) -#### Instructions for zlib #### - -- copy `include`, `lib` and `lib64` folders to `libetpan/third-party`. - -#### openssl #### +4. Create the `libetpan/third-party` folder. -- copy `bin`, `bin64`, `include`, `lib` and `lib64` to `mailcore2/Externals`. +5. Inside all the downloaded archives you should find `bin`, `bin64`, `include`, +`lib`, `lib64` or `ssl` folders. Copy all of them to `libetpan/third-party`. If you're unsure just copy +all of those folders to `libetpan/third-party`. + +6. As a result, in `libetpan/third-party` folder, you should have the following folders: +- `include` +- `lib` +- `lib64` +- `bin` +- `bin64` +- `ssl` -As a result, in `Externals` folder, you should have the following folders: `include`, `lib`, `lib64`, `bin` and `bin64`. +7. In `libetpan/build-windows`, using Visual Studio, open `libetpan.sln`. -In `libetpan/build-windows`, using Visual Studio 2013, open `libetpan.sln`. -Then, build. +8. Build the solution -Public headers will be located in `libetpan/build-windows/include`. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/configure.ac new/libetpan-1.9.3/configure.ac --- old/libetpan-1.9.1/configure.ac 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/configure.ac 2019-01-22 20:40:22.000000000 +0100 @@ -3,8 +3,8 @@ m4_define([maj_version], [1]) m4_define([min_version], [9]) -m4_define([mic_version], [1]) -m4_define([api_current], [22]) +m4_define([mic_version], [3]) +m4_define([api_current], [24]) m4_define([api_revision], [0]) m4_define([api_compatibility], [20]) dnl API version @@ -355,9 +355,23 @@ DBLIB="" AC_ARG_ENABLE(db, [AC_HELP_STRING([--disable-db], [disable Berkeley DB (default=try to detect DB)])],[enable_db=$enableval],[enable_db=yes]) +AC_ARG_ENABLE(lmdb, [AC_HELP_STRING([--enable-lmdb], [enable lmdb as cache DB instead of BerkeleyDB (default=disable)])],[enable_lmdb=$enableval],[enable_lmdb=no]) +if test "x$enable_lmdb" = "xyes"; then + AC_CHECK_HEADER(lmdb.h, [LMDB="yes"]) + if test "x$LMDB" = "x"; then + AC_MSG_WARN(lmdb.h not found cache support disabled) + else + AC_CHECK_LIB(lmdb, mdb_env_create, [DBLIB="-llmdb"; DBLINKED=1], []) + if test "$DBLINKED" = 1; then + AC_DEFINE([LMDB], [1], [Enable support for lmdb cache]) + enable_db="no" + else + AC_MSG_WARN(liblmdb not found cache support disabled) + fi + fi dnl Check for a presence of Berkeley DB header -if test "x$enable_db" != "xyes"; then +elif test "x$enable_db" != "xyes"; then AC_MSG_WARN(cache support disabled) else AC_CHECK_HEADER(db.h, [DB_HEADER=1], [DB_HEADER=0]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/doc/API.sgml new/libetpan-1.9.3/doc/API.sgml --- old/libetpan-1.9.1/doc/API.sgml 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/doc/API.sgml 2019-01-22 20:40:22.000000000 +0100 @@ -1213,6 +1213,22 @@ <command>mailstream_ssl_open()</command> will open a TLS/SSL socket. </para> + + <programlisting role="C"> +int mailstream_ssl_set_server_name(struct mailstream_ssl_context * ssl_context, + char * hostname) + </programlisting> + + <para> + <command>mailstream_ssl_set_server_name()</command> allows the client + to enable the use of the Server Name Indication TLS extension upon + opening a TLS stream, by providing the domain name to be indicated + to server as the desired destination. <command>ssl_context</command> + is the context pointer passed to the client-supplied callback + function by <command>mailstream_ssl_open_with_callback()</command> + etc. Note that <command>hostname</command> must be a domain name, not + a string representation of an IP address. + </para> </sect2> </sect1> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/src/data-types/Makefile.am new/libetpan-1.9.3/src/data-types/Makefile.am --- old/libetpan-1.9.1/src/data-types/Makefile.am 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/src/data-types/Makefile.am 2019-01-22 20:40:22.000000000 +0100 @@ -47,7 +47,7 @@ mailstream_low.c mailstream.c mailstream_socket.c \ mailstream_ssl.c carray.c clist.c chash.c \ charconv.c maillock.c base64.c mail_cache_db_types.h \ - mail_cache_db.h mail_cache_db.c mailsem.c mailsasl.h \ + mail_cache_db.h mail_cache_db.c mail_cache_lmdb.c mailsem.c mailsasl.h \ mailsasl.c mailstream_cancel_types.h mailstream_cancel.h \ mailstream_cancel.c timeutils.h timeutils.c \ mmapstring_private.h mailstream_ssl_private.h \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/src/data-types/mail_cache_db.c new/libetpan-1.9.3/src/data-types/mail_cache_db.c --- old/libetpan-1.9.1/src/data-types/mail_cache_db.c 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/src/data-types/mail_cache_db.c 2019-01-22 20:40:22.000000000 +0100 @@ -37,6 +37,8 @@ # include <config.h> #endif +#ifndef LMDB + #include "mail_cache_db.h" #include <sys/types.h> @@ -498,3 +500,5 @@ return -1; } #endif + +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/src/data-types/mail_cache_lmdb.c new/libetpan-1.9.3/src/data-types/mail_cache_lmdb.c --- old/libetpan-1.9.1/src/data-types/mail_cache_lmdb.c 1970-01-01 01:00:00.000000000 +0100 +++ new/libetpan-1.9.3/src/data-types/mail_cache_lmdb.c 2019-01-22 20:40:22.000000000 +0100 @@ -0,0 +1,391 @@ +/* + * libEtPan! -- a mail stuff library + * + * Copyright (C) 2001, 2005 - DINH Viet Hoa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the libEtPan! project nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * $Id: mail_cache_lmdb.c,v 1.20 2018/10/12 13:39:40 lay Exp $ + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#ifdef LMDB + +#include "mail_cache_db.h" + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdlib.h> +#include <string.h> +#include <lmdb.h> + +#include "libetpan-config.h" + +#include "maillock.h" + + +static struct mail_cache_db * mail_cache_lmdb_new(MDB_env *env) +{ + struct mail_cache_db * cache_db; + + cache_db = malloc(sizeof(* cache_db)); + if (cache_db == NULL) + return NULL; + cache_db->internal_database = env; + + return cache_db; +} + +static void mail_cache_db_free(struct mail_cache_db * cache_db) +{ + free(cache_db); +} + + +void mail_cache_db_close(struct mail_cache_db * cache_db) +{ + MDB_env *env; + + env = cache_db->internal_database; + mdb_env_close(env); + mail_cache_db_free(cache_db); +} + +int mail_cache_db_open(const char * filename, + struct mail_cache_db ** pcache_db) +{ + int r; + struct mail_cache_db * cache_db; + MDB_env *env; + + r = mdb_env_create(&env); + if (r != 0) + return -1; + + r = mdb_env_set_mapsize(env, 512*1024*1024 /*max mmap and file size*/); + if (r != 0) + return -1; + + r = mdb_env_open(env, filename, MDB_NOSUBDIR, 0660); + if (r != 0) + goto close_db; + + cache_db = mail_cache_lmdb_new(env); + if (cache_db == NULL) + goto close_db; + + * pcache_db = cache_db; + + return 0; + + close_db: + mdb_env_close(env); + return -1; + +} + +int mail_cache_db_open_lock(const char * filename, + struct mail_cache_db ** pcache_db) +{ + int r; + struct mail_cache_db * cache_db; + + r = maillock_write_lock(filename, -1); + if (r < 0) + goto err; + r = mail_cache_db_open(filename, &cache_db); + if (r < 0) + goto unlock; + + * pcache_db = cache_db; + + return 0; + + unlock: + maillock_write_unlock(filename, -1); + err: + return -1; +} + +void mail_cache_db_close_unlock(const char * filename, + struct mail_cache_db * cache_db) +{ + mail_cache_db_close(cache_db); + maillock_write_unlock(filename, -1); +} + + +int mail_cache_db_put(struct mail_cache_db * cache_db, + const void * key, size_t key_len, const void * value, size_t value_len) +{ + int r; + MDB_env *env; + MDB_txn *txn; + MDB_dbi dbi; + MDB_val mdb_key; + MDB_val mdb_val; + + env = cache_db->internal_database; + + mdb_key.mv_size = key_len; + mdb_key.mv_data = (void *) key; + mdb_val.mv_size = value_len; + mdb_val.mv_data = (void *) value; + + r = mdb_txn_begin(env, NULL, 0, &txn); + if (r != 0) + return -1; + r = mdb_dbi_open(txn, NULL, 0, &dbi); + if (r != 0) + goto error; + + r = mdb_put(txn, dbi, &mdb_key, &mdb_val, 0); + if (r != 0) + goto error; + + mdb_txn_commit(txn); + return 0; + + error: + mdb_txn_abort(txn); + return -1; +} + +int mail_cache_db_get(struct mail_cache_db * cache_db, + const void * key, size_t key_len, void ** pvalue, size_t * pvalue_len) +{ + int r; + MDB_env *env; + MDB_txn *txn; + MDB_dbi dbi; + MDB_val mdb_key; + MDB_val mdb_val; + + env = cache_db->internal_database; + + mdb_key.mv_size = key_len; + mdb_key.mv_data = (void *) key; + + r = mdb_txn_begin(env, NULL, 0, &txn); + if (r != 0) + return -1; + r = mdb_dbi_open(txn, NULL, 0, &dbi); + if (r != 0) + goto error; + + r = mdb_get(txn, dbi, &mdb_key, &mdb_val); + if (r != 0) + goto error; + + * pvalue = mdb_val.mv_data; + * pvalue_len = mdb_val.mv_size; + mdb_txn_commit(txn); + return 0; + + error: + mdb_txn_abort(txn); + return -1; +} + +int mail_cache_db_del(struct mail_cache_db * cache_db, + const void * key, size_t key_len) +{ + int r; + MDB_env *env; + MDB_txn *txn; + MDB_dbi dbi; + MDB_val mdb_key; + + env = cache_db->internal_database; + + mdb_key.mv_size = key_len; + mdb_key.mv_data = (void *) key; + + r = mdb_txn_begin(env, NULL, 0, &txn); + if (r != 0) + return -1; + r = mdb_dbi_open(txn, NULL, 0, &dbi); + if (r != 0) + goto error; + + r = mdb_del(txn, dbi, &mdb_key, NULL); + if (r != 0) + goto error; + + return 0; + + error: + mdb_txn_abort(txn); + return -1; +} + +int mail_cache_db_clean_up(struct mail_cache_db * cache_db, + chash * exist) +{ + int r; + MDB_env *env; + MDB_txn *txn; + MDB_dbi dbi; + MDB_cursor *cursor; + MDB_val mdb_key; + MDB_val mdb_val; + + env = cache_db->internal_database; + + r = mdb_txn_begin(env, NULL, 0, &txn); + if (r != 0) + return -1; + r = mdb_dbi_open(txn, NULL, 0, &dbi); + if (r != 0) + goto error; + + r = mdb_cursor_open(txn, dbi, &cursor); + if (r != 0) + goto error; + + r = mdb_cursor_get(cursor, &mdb_key, &mdb_val, MDB_FIRST); + if (r != 0) + goto cursor_error; + + while (r == 0) { + chashdatum hash_key; + chashdatum hash_data; + + hash_key.data = mdb_key.mv_data; + hash_key.len = (unsigned int) mdb_key.mv_size; + + r = chash_get(exist, &hash_key, &hash_data); + if (r < 0) { + r = mdb_cursor_del(cursor, 0); + if (r != 0) + goto cursor_error; + } + r = mdb_cursor_get(cursor, &mdb_key, &mdb_val, MDB_NEXT); + } + + mdb_txn_commit(txn); + return 0; + cursor_error: + mdb_cursor_close(cursor); + error: + mdb_txn_abort(txn); + return -1; +} + +int mail_cache_db_get_size(struct mail_cache_db * cache_db, + const void * key, size_t key_len, size_t * pvalue_len) +{ + int r; + MDB_env *env; + MDB_txn *txn; + MDB_dbi dbi; + MDB_val mdb_key; + MDB_val mdb_val; + + env = cache_db->internal_database; + + mdb_key.mv_size = key_len; + mdb_key.mv_data = (void *) key; + + r = mdb_txn_begin(env, NULL, 0, &txn); + if (r != 0) + return -1; + r = mdb_dbi_open(txn, NULL, 0, &dbi); + if (r != 0) + goto error; + + r = mdb_get(txn, dbi, &mdb_key, &mdb_val); + if (r != 0) + goto error; + + * pvalue_len = mdb_val.mv_size; + mdb_txn_commit(txn); + return 0; + + error: + mdb_txn_abort(txn); + return -1; +} + +int mail_cache_db_get_keys(struct mail_cache_db * cache_db, + chash * keys) +{ + int r; + MDB_env *env; + MDB_txn *txn; + MDB_dbi dbi; + MDB_cursor *cursor; + MDB_val mdb_key; + MDB_val mdb_val; + + env = cache_db->internal_database; + + r = mdb_txn_begin(env, NULL, 0, &txn); + if (r != 0) + return -1; + r = mdb_dbi_open(txn, NULL, 0, &dbi); + if (r != 0) + goto error; + + r = mdb_cursor_open(txn, dbi, &cursor); + if (r != 0) + goto error; + + r = mdb_cursor_get(cursor, &mdb_key, &mdb_val, MDB_FIRST); + if (r != 0) + goto cursor_error; + + while (r == 0) { + chashdatum hash_key; + chashdatum hash_data; + + hash_key.data = mdb_key.mv_data; + hash_key.len = (unsigned int) mdb_key.mv_size; + hash_data.data = NULL; + hash_data.len = 0; + + r = chash_set(keys, &hash_key, &hash_data, NULL); + if (r != 0) + goto cursor_error; + r = mdb_cursor_get(cursor, &mdb_key, &mdb_val, MDB_NEXT); + } + + mdb_txn_commit(txn); + return 0; + + cursor_error: + mdb_cursor_close(cursor); + error: + mdb_txn_abort(txn); + return -1; +} +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/src/data-types/mailstream_ssl.c new/libetpan-1.9.3/src/data-types/mailstream_ssl.c --- old/libetpan-1.9.1/src/data-types/mailstream_ssl.c 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/src/data-types/mailstream_ssl.c 2019-01-22 20:40:22.000000000 +0100 @@ -113,6 +113,9 @@ SSL_CTX * openssl_ssl_ctx; X509* client_x509; EVP_PKEY *client_pkey; +# if (OPENSSL_VERSION_NUMBER >= 0x10000000L) + char * server_name; +# endif /* (OPENSSL_VERSION_NUMBER >= 0x10000000L) */ #else gnutls_session session; gnutls_x509_crt client_x509; @@ -437,7 +440,7 @@ SSL_CTX * tmp_ctx; struct mailstream_cancel * cancel; struct mailstream_ssl_context * ssl_context = NULL; -#ifdef SSL_MODE_RELEASE_BUFFERS +#if SSL_MODE_RELEASE_BUFFERS long mode = 0; #endif @@ -456,14 +459,22 @@ SSL_CTX_set_client_cert_cb(tmp_ctx, mailstream_openssl_client_cert_cb); ssl_conn = (SSL *) SSL_new(tmp_ctx); -#ifdef SSL_MODE_RELEASE_BUFFERS +#if SSL_MODE_RELEASE_BUFFERS mode = SSL_get_mode(ssl_conn); SSL_set_mode(ssl_conn, mode | SSL_MODE_RELEASE_BUFFERS); #endif if (ssl_conn == NULL) goto free_ctx; - + +#if (OPENSSL_VERSION_NUMBER >= 0x10000000L) + if (ssl_context != NULL && ssl_context->server_name != NULL) { + SSL_set_tlsext_host_name(ssl_conn, ssl_context->server_name); + free(ssl_context->server_name); + ssl_context->server_name = NULL; + } +#endif /* (OPENSSL_VERSION_NUMBER >= 0x10000000L) */ + if (SSL_set_fd(ssl_conn, fd) == 0) goto free_ssl_conn; @@ -1361,6 +1372,47 @@ #endif /* USE_SSL */ } +LIBETPAN_EXPORT +int mailstream_ssl_set_server_name(struct mailstream_ssl_context * ssl_context, + char * hostname) +{ + int r = -1; + +#ifdef USE_SSL +# ifdef USE_GNUTLS + if (hostname != NULL) { + r = gnutls_server_name_set(ssl_context->session, GNUTLS_NAME_DNS, hostname, strlen(hostname)); + } + else { + r = gnutls_server_name_set(ssl_context->session, GNUTLS_NAME_DNS, "", 0U); + } +# else /* !USE_GNUTLS */ +# if (OPENSSL_VERSION_NUMBER >= 0x10000000L) + if (hostname != NULL) { + /* Unfortunately we can't set this in the openssl session yet since it + * hasn't been created yet; we only have the openssl context at this point. + * We will set it in the openssl session when we create it, soon after the + * client callback that we expect to be calling us (since it is the way the + * client gets our mailstream_ssl_context) returns (see + * ssl_data_new_full()) but we cannot rely on the client persisting it. We + * must therefore take a temporary copy here, which we free once we've set + * it in the openssl session. */ + ssl_context->server_name = strdup(hostname); + } + else { + if (ssl_context->server_name != NULL) { + free(ssl_context->server_name); + } + ssl_context->server_name = NULL; + } + r = 0; +# endif /* (OPENSSL_VERSION_NUMBER >= 0x10000000L) */ +# endif /* !USE_GNUTLS */ +#endif /* USE_SSL */ + + return r; +} + #ifdef USE_SSL #ifndef USE_GNUTLS static struct mailstream_ssl_context * mailstream_ssl_context_new(SSL_CTX * open_ssl_ctx, int fd) @@ -1374,6 +1426,9 @@ ssl_ctx->openssl_ssl_ctx = open_ssl_ctx; ssl_ctx->client_x509 = NULL; ssl_ctx->client_pkey = NULL; +#if (OPENSSL_VERSION_NUMBER >= 0x10000000L) + ssl_ctx->server_name = NULL; +#endif /* (OPENSSL_VERSION_NUMBER >= 0x10000000L) */ ssl_ctx->fd = fd; return ssl_ctx; @@ -1381,8 +1436,14 @@ static void mailstream_ssl_context_free(struct mailstream_ssl_context * ssl_ctx) { - if (ssl_ctx) + if (ssl_ctx != NULL) { +#if (OPENSSL_VERSION_NUMBER >= 0x10000000L) + if (ssl_ctx->server_name != NULL) { + free(ssl_ctx->server_name); + } +#endif /* (OPENSSL_VERSION_NUMBER >= 0x10000000L) */ free(ssl_ctx); + } } #else static struct mailstream_ssl_context * mailstream_ssl_context_new(gnutls_session session, int fd) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/src/data-types/mailstream_ssl.h new/libetpan-1.9.3/src/data-types/mailstream_ssl.h --- old/libetpan-1.9.1/src/data-types/mailstream_ssl.h 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/src/data-types/mailstream_ssl.h 2019-01-22 20:40:22.000000000 +0100 @@ -124,6 +124,10 @@ char * CAfile, char * CApath); LIBETPAN_EXPORT +int mailstream_ssl_set_server_name(struct mailstream_ssl_context * ssl_context, + char * hostname); + +LIBETPAN_EXPORT void * mailstream_ssl_get_openssl_ssl_ctx(struct mailstream_ssl_context * ssl_context); LIBETPAN_EXPORT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/src/data-types/mmapstring.h new/libetpan-1.9.3/src/data-types/mmapstring.h --- old/libetpan-1.9.1/src/data-types/mmapstring.h 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/src/data-types/mmapstring.h 2019-01-22 20:40:22.000000000 +0100 @@ -147,7 +147,10 @@ LIBETPAN_EXPORT void mmap_string_set_ceil(size_t ceil); +LIBETPAN_EXPORT int mmap_string_ref(MMAPString * string); + +LIBETPAN_EXPORT int mmap_string_unref(char * str); #ifdef __cplusplus diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/src/low-level/feed/newsfeed.c new/libetpan-1.9.3/src/low-level/feed/newsfeed.c --- old/libetpan-1.9.1/src/low-level/feed/newsfeed.c 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/src/low-level/feed/newsfeed.c 2019-01-22 20:40:22.000000000 +0100 @@ -535,7 +535,9 @@ case CURLE_SSL_ENGINE_SETFAILED: case CURLE_SSL_CERTPROBLEM: case CURLE_SSL_CIPHER: +#if LIBCURL_VERSION_NUM < 0x073e00 case CURLE_SSL_CACERT: +#endif case CURLE_FTP_SSL_FAILED: case CURLE_SSL_ENGINE_INITFAILED: return NEWSFEED_ERROR_SSL; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/src/low-level/imap/Makefile.am new/libetpan-1.9.3/src/low-level/imap/Makefile.am --- old/libetpan-1.9.1/src/low-level/imap/Makefile.am 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/src/low-level/imap/Makefile.am 2019-01-22 20:40:22.000000000 +0100 @@ -48,7 +48,8 @@ qresync.h qresync_types.h \ mailimap_sort.h mailimap_sort_types.h \ mailimap_compress.h \ - mailimap_oauth2.h + mailimap_oauth2.h \ + clientid.h AM_CPPFLAGS = -I$(top_builddir)/include \ -I$(top_srcdir)/src/data-types @@ -101,4 +102,6 @@ mailimap_sort.c mailimap_sort.h \ mailimap_sort_types.c mailimap_sort_types.h \ mailimap_compress.c mailimap_compress.h \ - mailimap_oauth2.c mailimap_oauth2.h + mailimap_oauth2.c mailimap_oauth2.h \ + clientid_sender.c clientid_sender.h \ + clientid.c clientid.h diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/src/low-level/imap/clientid.c new/libetpan-1.9.3/src/low-level/imap/clientid.c --- old/libetpan-1.9.1/src/low-level/imap/clientid.c 1970-01-01 01:00:00.000000000 +0100 +++ new/libetpan-1.9.3/src/low-level/imap/clientid.c 2019-01-22 20:40:22.000000000 +0100 @@ -0,0 +1,90 @@ +/* + * libEtPan! -- a mail stuff library + * + * Copyright (C) 2018, 2019 - LinuxMagic + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the libEtPan! project nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include "mailimap_sender.h" +#include "clientid_sender.h" +#include "clientid.h" + +LIBETPAN_EXPORT +int mailimap_clientid(mailimap * session, + const char * type, const char * clientid) +{ + struct mailimap_response * response; + int r; + int error_code; + + if (session->imap_state != MAILIMAP_STATE_NON_AUTHENTICATED) + return MAILIMAP_ERROR_BAD_STATE; + + r = mailimap_send_current_tag(session); + if (r != MAILIMAP_NO_ERROR) + return r; + + r = mailimap_clientid_send(session->imap_stream, type, clientid); + if (r != MAILIMAP_NO_ERROR) + return r; + + r = mailimap_crlf_send(session->imap_stream); + if (r != MAILIMAP_NO_ERROR) + return r; + + if (mailstream_flush(session->imap_stream) == -1) + return MAILIMAP_ERROR_STREAM; + + if (mailimap_read_line(session) == NULL) + return MAILIMAP_ERROR_STREAM; + + r = mailimap_parse_response(session, &response); + if (r != MAILIMAP_NO_ERROR) + return r; + + error_code = response->rsp_resp_done->rsp_data.rsp_tagged->rsp_cond_state->rsp_type; + + mailimap_response_free(response); + + switch (error_code) { + case MAILIMAP_RESP_COND_STATE_OK: + return MAILIMAP_NO_ERROR; + + default: + return MAILIMAP_ERROR_CLIENTID; + } +} + +LIBETPAN_EXPORT +int mailimap_has_clientid(mailimap * session) +{ + return mailimap_has_extension(session, "CLIENTID"); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/src/low-level/imap/clientid.h new/libetpan-1.9.3/src/low-level/imap/clientid.h --- old/libetpan-1.9.1/src/low-level/imap/clientid.h 1970-01-01 01:00:00.000000000 +0100 +++ new/libetpan-1.9.3/src/low-level/imap/clientid.h 2019-01-22 20:40:22.000000000 +0100 @@ -0,0 +1,66 @@ +/* + * libEtPan! -- a mail stuff library + * + * Copyright (C) 2018, 2019 - LinuxMagic + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the libEtPan! project nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef CLIENTID_H + +#define CLIENTID_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "mailimap.h" + +/* + mailimap_clientid() + + This function will perform the clientid command. + + @param session IMAP session + @param type the clientid type + @param clientid the client identifier + + @return the return code is one of MAILIMAP_ERROR_XXX or + MAILIMAP_NO_ERROR codes +*/ + +LIBETPAN_EXPORT +int mailimap_clientid(mailimap * session, + const char * type, const char * clientid); + +LIBETPAN_EXPORT +int mailimap_has_clientid(mailimap * session); + +#ifdef __cplusplus +} +#endif + +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/src/low-level/imap/clientid_sender.c new/libetpan-1.9.3/src/low-level/imap/clientid_sender.c --- old/libetpan-1.9.1/src/low-level/imap/clientid_sender.c 1970-01-01 01:00:00.000000000 +0100 +++ new/libetpan-1.9.3/src/low-level/imap/clientid_sender.c 2019-01-22 20:40:22.000000000 +0100 @@ -0,0 +1,70 @@ +/* + * libEtPan! -- a mail stuff library + * + * Copyright (C) 2018, 2019 - LinuxMagic + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the libEtPan! project nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include "mailstream.h" +#include "mailimap_sender.h" +#include "clientid_sender.h" + +/* +=> clientid = "CLIENTID" SP type SP clientid +*/ + +int mailimap_clientid_send(mailstream * fd, + const char * type, const char * clientid) +{ + int r; + + r = mailimap_token_send(fd, "CLIENTID"); + if (r != MAILIMAP_NO_ERROR) + return r; + + r = mailimap_space_send(fd); + if (r != MAILIMAP_NO_ERROR) + return r; + + r = mailimap_astring_send(fd, type); + if (r != MAILIMAP_NO_ERROR) + return r; + + r = mailimap_space_send(fd); + if (r != MAILIMAP_NO_ERROR) + return r; + + r = mailimap_astring_send(fd, clientid); + if (r != MAILIMAP_NO_ERROR) + return r; + + return MAILIMAP_NO_ERROR; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/src/low-level/imap/clientid_sender.h new/libetpan-1.9.3/src/low-level/imap/clientid_sender.h --- old/libetpan-1.9.1/src/low-level/imap/clientid_sender.h 1970-01-01 01:00:00.000000000 +0100 +++ new/libetpan-1.9.3/src/low-level/imap/clientid_sender.h 2019-01-22 20:40:22.000000000 +0100 @@ -0,0 +1,49 @@ +/* + * libEtPan! -- a mail stuff library + * + * Copyright (C) 2018, 2019 - LinuxMagic + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the libEtPan! project nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef CLIENTID_SENDER_H + +#define CLIENTID_SENDER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "mailstream.h" + +int mailimap_clientid_send(mailstream * fd, + const char * type, const char * clientid); + +#ifdef __cplusplus +} +#endif + +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/src/low-level/imap/mailimap_parser.c new/libetpan-1.9.3/src/low-level/imap/mailimap_parser.c --- old/libetpan-1.9.1/src/low-level/imap/mailimap_parser.c 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/src/low-level/imap/mailimap_parser.c 2019-01-22 20:40:22.000000000 +0100 @@ -49,6 +49,12 @@ #include "mail.h" #include "timeutils.h" +#ifdef _WIN32 +# ifdef _MSC_VER +# include "win_etpan.h" +# endif +#endif + #ifndef UNSTRICT_SYNTAX #define UNSTRICT_SYNTAX #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/src/low-level/imap/mailimap_types.h new/libetpan-1.9.3/src/low-level/imap/mailimap_types.h --- old/libetpan-1.9.1/src/low-level/imap/mailimap_types.h 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/src/low-level/imap/mailimap_types.h 2019-01-22 20:40:22.000000000 +0100 @@ -3570,7 +3570,8 @@ MAILIMAP_ERROR_SASL, MAILIMAP_ERROR_SSL, MAILIMAP_ERROR_NEEDS_MORE_DATA, - MAILIMAP_ERROR_CUSTOM_COMMAND + MAILIMAP_ERROR_CUSTOM_COMMAND, + MAILIMAP_ERROR_CLIENTID, }; /* information about parser context */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/src/low-level/smtp/mailsmtp.c new/libetpan-1.9.3/src/low-level/smtp/mailsmtp.c --- old/libetpan-1.9.1/src/low-level/smtp/mailsmtp.c 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/src/low-level/smtp/mailsmtp.c 2019-01-22 20:40:22.000000000 +0100 @@ -610,6 +610,9 @@ } /* TODO: grab optionnal max size */ } + else if (!strncasecmp(response, "CLIENTID", 8) && isdelim(response[8])) { + session->esmtp |= MAILSMTP_ESMTP_CLIENTID; + } else if (!strncasecmp(response, "PIPELINING", 10) && isdelim(response[10])) { session->esmtp |= MAILSMTP_ESMTP_PIPELINING; } @@ -1065,6 +1068,32 @@ } } +int mailesmtp_clientid(mailsmtp * session, + const char * type, const char * clientid) { + char command[SMTP_STRING_SIZE]; + int r; + + if (!(session->esmtp & MAILSMTP_ESMTP_CLIENTID)) + return MAILSMTP_ERROR_CLIENTID_NOT_SUPPORTED; + + snprintf(command, SMTP_STRING_SIZE, "CLIENTID %s %s\r\n", + type, clientid); + + r = send_command(session, command); + if (r == -1) + return MAILSMTP_ERROR_STREAM; + r = read_response(session); + + switch (r) { + case 250: + return MAILSMTP_NO_ERROR; + case 501: // syntax error + case 503: // duplicate clientid or not permitted because of policy + default: + return MAILSMTP_ERROR_UNEXPECTED_CODE; + } +} + /* TODO: add mailesmtp_etrn, mailssmtp_expn */ int mailesmtp_starttls(mailsmtp * session) @@ -1234,6 +1263,8 @@ return "TLS not supported by server"; case MAILSMTP_ERROR_AUTH_LOGIN: return "Login failed"; + case MAILSMTP_ERROR_CLIENTID_NOT_SUPPORTED: + return "ClientID not supported by server"; default: return "Unknown error code"; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/src/low-level/smtp/mailsmtp.h new/libetpan-1.9.3/src/low-level/smtp/mailsmtp.h --- old/libetpan-1.9.1/src/low-level/smtp/mailsmtp.h 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/src/low-level/smtp/mailsmtp.h 2019-01-22 20:40:22.000000000 +0100 @@ -150,6 +150,11 @@ const char * orcpt); LIBETPAN_EXPORT +int mailesmtp_clientid(mailsmtp * session, + const char * type, + const char * clientid); + +LIBETPAN_EXPORT int mailesmtp_starttls(mailsmtp * session); LIBETPAN_EXPORT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/src/low-level/smtp/mailsmtp_types.h new/libetpan-1.9.3/src/low-level/smtp/mailsmtp_types.h --- old/libetpan-1.9.1/src/low-level/smtp/mailsmtp_types.h 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/src/low-level/smtp/mailsmtp_types.h 2019-01-22 20:40:22.000000000 +0100 @@ -72,7 +72,8 @@ MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED, MAILSMTP_ERROR_CONNECTION_REFUSED, MAILSMTP_ERROR_AUTH_AUTHENTICATION_FAILED, - MAILSMTP_ERROR_SSL + MAILSMTP_ERROR_SSL, + MAILSMTP_ERROR_CLIENTID_NOT_SUPPORTED }; enum { @@ -96,7 +97,8 @@ MAILSMTP_ESMTP_ETRN = 16, MAILSMTP_ESMTP_STARTTLS = 32, MAILSMTP_ESMTP_DSN = 64, - MAILSMTP_ESMTP_PIPELINING = 128 + MAILSMTP_ESMTP_PIPELINING = 128, + MAILSMTP_ESMTP_CLIENTID = 256 }; typedef struct mailsmtp mailsmtp; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/tests/frm-simple.c new/libetpan-1.9.3/tests/frm-simple.c --- old/libetpan-1.9.1/tests/frm-simple.c 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/tests/frm-simple.c 2019-01-22 20:40:22.000000000 +0100 @@ -59,7 +59,7 @@ strip_crlf(dsp_subject); - snprintf(output, MAX_OUTPUT, "%3i: %-21.21s %-53.53s\n", + snprintf(output, MAX_OUTPUT, "%3i: %-21.21s %-52.52s\n", msg->msg_index % 1000, dsp_from, dsp_subject); printf("%s\n", output); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libetpan-1.9.1/travis/script.sh new/libetpan-1.9.3/travis/script.sh --- old/libetpan-1.9.1/travis/script.sh 2018-09-12 13:54:16.000000000 +0200 +++ new/libetpan-1.9.3/travis/script.sh 2019-01-22 20:40:22.000000000 +0100 @@ -16,12 +16,12 @@ make imap-sample else echo Building library for iPhoneOS - xctool -project build-mac/libetpan.xcodeproj -sdk iphoneos$IOSSDK -scheme "libetpan ios" build ARCHS="armv7 armv7s arm64" + xcodebuild -project build-mac/libetpan.xcodeproj -sdk iphoneos$IOSSDK -scheme "libetpan ios" build ARCHS="armv7 armv7s arm64" > /dev/null echo Building library for iPhoneSimulator - xctool -project build-mac/libetpan.xcodeproj -sdk iphonesimulator$IOSSDK -scheme "libetpan ios" build ARCHS="i386 x86_64" + xcodebuild -project build-mac/libetpan.xcodeproj -sdk iphonesimulator$IOSSDK -scheme "libetpan ios" build ARCHS="i386 x86_64" > /dev/null echo Building library for Mac - xctool -project build-mac/libetpan.xcodeproj -sdk macosx$OSXSDK -scheme "static libetpan" build + xcodebuild -project build-mac/libetpan.xcodeproj -sdk macosx$OSXSDK -scheme "static libetpan" build > /dev/null echo Building framework for Mac - xctool -project build-mac/libetpan.xcodeproj -sdk macosx$OSXSDK -scheme "libetpan" build + xcodebuild -project build-mac/libetpan.xcodeproj -sdk macosx$OSXSDK -scheme "libetpan" build > /dev/null fi
