diff --git a/CMakeLists.txt b/CMakeLists.txt index 3da3fbdc8..7fc09208e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,165 +1,165 @@ cmake_minimum_required(VERSION 3.0) set(PIM_VERSION "5.8.40") set(KDEPIM_RUNTIME_VERSION_NUMBER ${PIM_VERSION}) project(kdepim-runtime VERSION ${KDEPIM_RUNTIME_VERSION_NUMBER}) if (POLICY CMP0053) cmake_policy(SET CMP0053 NEW) endif() ############### KDEPIM-Runtime version ################ # KDEPIM_RUNTIME_VERSION # Version scheme: "x.y.z build". # # x is the version number. # y is the major release number. # z is the minor release number. # # "x.y.z" follow the kdelibs version kdepim is released with. # # If "z" is 0, it the version is "x.y" # # KDEPIM_DEV_VERSION # is empty for final versions. For development versions "build" is # something like "pre", "", "alpha2", "beta1", "beta2", "rc1", "rc2". # # Examples in chronological order: # # 3.0 # 3.0.1 # 3.1 # 3.1 beta1 # 3.1 beta2 # 3.1 rc1 # 3.1 # 3.1.1 # 3.2 pre # 3.2 set(KDEPIM_DEV_VERSION alpha) # add an extra space if(DEFINED KDEPIM_DEV_VERSION) set(KDEPIM_DEV_VERSION " ${KDEPIM_DEV_VERSION}") endif() set(KDEPIM_RUNTIME_VERSION "${KDEPIM_RUNTIME_VERSION_NUMBER}${KDEPIM_DEV_VERSION}") configure_file(kdepim-runtime-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/kdepim-runtime-version.h @ONLY) set(KF5_VERSION "5.44.0") find_package(ECM ${KF5_VERSION} CONFIG REQUIRED) set(CMAKE_MODULE_PATH ${kdepim-runtime_SOURCE_DIR}/cmake/ ${ECM_MODULE_PATH}) include(CMakePackageConfigHelpers) include(ECMSetupVersion) include(FeatureSummary) include(KDEInstallDirs) include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(ECMInstallIcons) include(ECMQtDeclareLoggingCategory) include(ECMCoverageOption) set(QT_REQUIRED_VERSION "5.8.0") set(KDEPIMRUNTIME_LIB_VERSION "${KDEPIM_RUNTIME_VERSION_NUMBER}") set(KDEPIMRUNTIME_LIB_SOVERSION "5") set(AKONADI_VERSION "5.8.0") set(KCONTACTS_LIB_VERSION "5.8.0") set(KCALENDARCORE_LIB_VERSION "5.8.0") set(IDENTITYMANAGEMENT_LIB_VERSION "5.8.0") set(KMAILTRANSPORT_LIB_VERSION "5.8.0") set(CALENDARUTILS_LIB_VERSION "5.8.0") set(KDAV_LIB_VERSION "5.8.0") set(KIMAP_LIB_VERSION "5.8.0") set(KMBOX_LIB_VERSION "5.8.0") set(AKONADICALENDAR_LIB_VERSION "5.8.0") set(KONTACTINTERFACE_LIB_VERSION "5.8.0") set(AKONADIKALARM_LIB_VERSION "5.8.0") set(KMIME_LIB_VERSION "5.8.0") set(XMLRPCCLIENT_LIB_VERSION "5.8.0") set(KCONTACTS_LIB_VERSION "5.8.0") set(AKONADIMIME_LIB_VERSION "5.8.0") set(AKONADICONTACT_LIB_VERSION "5.8.0") set(AKONADINOTE_LIB_VERSION "5.8.0") set(PIMCOMMON_LIB_VERSION "5.8.0") -set(KGAPI_LIB_VERSION "5.8.0") +set(KGAPI_LIB_VERSION "5.8.41") set( SharedMimeInfo_MINIMUM_VERSION "1.3" ) find_package(SharedMimeInfo ${SharedMimeInfo_MINIMUM_VERSION} REQUIRED) find_package(Sasl2) set_package_properties(Sasl2 PROPERTIES TYPE REQUIRED) # QT5 package find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Network Widgets Test XmlPatterns DBus WebEngineWidgets) find_package(Qt5 OPTIONAL_COMPONENTS TextToSpeech) if (NOT Qt5TextToSpeech_FOUND) message(STATUS "Qt5TextToSpeech not found, speech feature will be disabled") else() add_definitions(-DHAVE_TEXTTOSPEECH) endif() # KF5 package find_package(KF5Config ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5ConfigWidgets ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5NotifyConfig ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5KIO ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5ItemModels ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Codecs ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5WindowSystem ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5TextWidgets ${KF5_VERSION} CONFIG REQUIRED) # for KPluralHandlingSpinBox find_package(KF5Notifications ${KF5_VERSION} CONFIG REQUIRED) # pop3 find_package(KF5Holidays ${KF5_VERSION} CONFIG REQUIRED) # KdepimLibs package find_package(KF5Akonadi ${AKONADI_VERSION} CONFIG REQUIRED) find_package(KPimKDAV ${KDAV_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Mime ${KMIME_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiMime ${AKONADIMIME_LIB_VERSION} CONFIG REQUIRED) find_package(KF5MailTransportAkonadi ${KMAILTRANSPORT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5IdentityManagement ${IDENTITYMANAGEMENT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiContact ${AKONADICONTACT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Contacts ${KCONTACTS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AlarmCalendar ${AKONADIKALARM_LIB_VERSION} CONFIG REQUIRED) find_package(KF5CalendarCore ${KCALENDARCORE_LIB_VERSION} CONFIG REQUIRED) find_package(KF5CalendarUtils ${CALENDARUTILS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Mbox ${KMBOX_LIB_VERSION} CONFIG REQUIRED) find_package(KF5IMAP ${KIMAP_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiNotes ${AKONADINOTE_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiCalendar ${AKONADICALENDAR_LIB_VERSION} CONFIG REQUIRED) find_package(KF5PimCommon ${PIMCOMMON_LIB_VERSION} CONFIG REQUIRED) find_package(KPimGAPI ${KGAPI_LIB_VERSION} CONFIG REQUIRED) option(KDEPIM_RUN_ISOLATED_TESTS "Run the isolated tests." FALSE) add_definitions(-DQT_NO_CAST_FROM_ASCII) add_definitions(-DQT_NO_CAST_TO_ASCII) add_definitions(-DQT_NO_URL_CAST_FROM_STRING) add_definitions(-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT) #add_definitions( -DQT_DISABLE_DEPRECATED_BEFORE=0x060000 ) add_subdirectory(resources) add_subdirectory(agents) add_subdirectory(defaultsetup) add_subdirectory(kioslave) add_subdirectory(migration) add_subdirectory(doc) ## install the MIME type spec file for KDEPIM specific MIME types install(FILES kdepim-mime.xml DESTINATION ${KDE_INSTALL_MIMEDIR}) update_xdg_mimetypes(${KDE_INSTALL_MIMEDIR}) install( FILES kdepim-runtime.renamecategories kdepim-runtime.categories DESTINATION ${KDE_INSTALL_CONFDIR} ) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES ) diff --git a/resources/imap/CMakeLists.txt b/resources/imap/CMakeLists.txt index b9409c163..2a357d40d 100644 --- a/resources/imap/CMakeLists.txt +++ b/resources/imap/CMakeLists.txt @@ -1,139 +1,138 @@ add_definitions(-DTRANSLATION_DOMAIN=\"akonadi_imap_resource\") set(WITH_GMAIL_XOAUTH2 TRUE) -add_subdirectory(saslplugin) configure_file(config-imap.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-imap.h) ########### next target ############### set( imapresource_LIB_SRCS addcollectiontask.cpp additemtask.cpp batchfetcher.cpp changecollectiontask.cpp changeitemsflagstask.cpp changeitemtask.cpp expungecollectiontask.cpp highestmodseqattribute.cpp imapaccount.cpp imapflags.cpp imapresourcebase.cpp messagehelper.cpp movecollectiontask.cpp moveitemstask.cpp noselectattribute.cpp noinferiorsattribute.cpp passwordrequesterinterface.cpp removecollectionrecursivetask.cpp resourcestateinterface.cpp resourcetask.cpp retrievecollectionmetadatatask.cpp retrievecollectionstask.cpp retrieveitemtask.cpp retrieveitemstask.cpp searchtask.cpp sessionpool.cpp uidvalidityattribute.cpp uidnextattribute.cpp settings.cpp subscriptiondialog.cpp imapidlemanager.cpp resourcestate.cpp collectionmetadatahelper.cpp replacemessagejob.cpp utils.cpp ${AKONADI_COLLECTIONATTRIBUTES_SHARED_SOURCES} ${AKONADI_IMAPATTRIBUTES_SHARED_SOURCES} ) ecm_qt_declare_logging_category(imapresource_LIB_SRCS HEADER imapresource_debug.h IDENTIFIER IMAPRESOURCE_LOG CATEGORY_NAME org.kde.pim.imapresource) ecm_qt_declare_logging_category(imapresource_LIB_SRCS HEADER imapresource_trace.h IDENTIFIER IMAPRESOURCE_TRACE CATEGORY_NAME org.kde.pim.imapresource.trace ) kcfg_generate_dbus_interface( ${CMAKE_CURRENT_SOURCE_DIR}/imapresource.kcfg org.kde.Akonadi.Imap.Settings ) kconfig_add_kcfg_files(imapresource_LIB_SRCS settingsbase.kcfgc) qt5_add_dbus_adaptor( imapresource_LIB_SRCS ${CMAKE_CURRENT_BINARY_DIR}/org.kde.Akonadi.Imap.Settings.xml settings.h Settings ) qt5_generate_dbus_interface( ${CMAKE_CURRENT_SOURCE_DIR}/imapresourcebase.h org.kde.Akonadi.Imap.Resource.xml OPTIONS -a ) qt5_add_dbus_adaptor( imapresource_LIB_SRCS ${CMAKE_CURRENT_BINARY_DIR}/org.kde.Akonadi.Imap.Resource.xml imapresourcebase.h ImapResourceBase ) add_library(imapresource STATIC ${imapresource_LIB_SRCS}) target_link_libraries(imapresource Qt5::DBus Qt5::Network KF5::AkonadiCore KF5::IMAP KF5::MailTransport KF5::KIOWidgets KF5::Mime KF5::AkonadiMime KF5::IdentityManagement KF5::AkonadiAgentBase KF5::I18n KF5::WindowSystem akonadi-singlefileresource KF5::PimCommon ) ########### next target ############### set( akonadi_imap_resource_SRCS main.cpp imapresource.cpp resourcestate.cpp settingspasswordrequester.cpp setupserver.cpp serverinfodialog.cpp passwordrequester.cpp gmailpasswordrequester.cpp ) install( FILES imapresource.desktop DESTINATION "${KDE_INSTALL_DATAROOTDIR}/akonadi/agents" ) ki18n_wrap_ui(akonadi_imap_resource_SRCS setupserverview_desktop.ui) add_executable(akonadi_imap_resource ${akonadi_imap_resource_SRCS}) if( APPLE ) set_target_properties(akonadi_imap_resource PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/../Info.plist.template) set_target_properties(akonadi_imap_resource PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER "org.kde.Akonadi.Imap") set_target_properties(akonadi_imap_resource PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "KDE Akonadi IMAP Resource") endif () target_link_libraries(akonadi_imap_resource Qt5::DBus KF5::AkonadiCore KF5::IMAP akonadi-singlefileresource KF5::AkonadiWidgets KF5::MailTransport KF5::Mime KF5::AkonadiMime KF5::IdentityManagement KF5::I18n imapresource KF5::TextWidgets folderarchivesettings KPim::GAPICore ) install(TARGETS akonadi_imap_resource ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) add_subdirectory( wizard ) if(BUILD_TESTING) add_subdirectory( autotests ) add_subdirectory( tests ) endif() diff --git a/resources/imap/saslplugin/CMakeLists.txt b/resources/imap/saslplugin/CMakeLists.txt deleted file mode 100644 index 65a9a9bb3..000000000 --- a/resources/imap/saslplugin/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -if (NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD") - add_definitions(-D_POSIX_SOURCE) -endif() - -if (WIN32) - add_definitions(-DWIN32) -elseif (APPLE) - add_definitions(-Dmacintosh) -endif() - -set(kdexoauth2sasl_SRCS - xoauth2plugin.c - xoauth2plugin_init.c - plugin_common.c -) - -add_library(kdexoauth2 SHARED ${kdexoauth2sasl_SRCS}) -target_include_directories(kdexoauth2 PRIVATE ${Sasl2_INCLUDE_DIRS}) -set_target_properties(kdexoauth2 PROPERTIES - C_VISIBILITY_PRESET default - SOVERSION 3 - VERSION 3.0.0) - -install(TARGETS kdexoauth2 DESTINATION ${KDE_INSTALL_LIBDIR}/sasl2) diff --git a/resources/imap/saslplugin/config.h b/resources/imap/saslplugin/config.h deleted file mode 100644 index e897f12ad..000000000 --- a/resources/imap/saslplugin/config.h +++ /dev/null @@ -1,578 +0,0 @@ -/* config.h. Generated by configure. */ -/* config.h.in. Generated from configure.in by autoheader. */ - -/* acconfig.h - autoheader configuration input */ -/* - * Copyright (c) 1998-2003 Carnegie Mellon University. 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. The name "Carnegie Mellon University" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For permission or any other legal - * details, please contact - * Office of Technology Transfer - * Carnegie Mellon University - * 5000 Forbes Avenue - * Pittsburgh, PA 15213-3890 - * (412) 268-4387, fax: (412) 268-7395 - * tech-transfer@andrew.cmu.edu - * - * 4. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by Computing Services - * at Carnegie Mellon University (http://www.cmu.edu/computing/)." - * - * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE - * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef CONFIG_H -#define CONFIG_H - -/* Runtime config file location */ -#define CONFIGDIR "/usr/lib/sasl2:/etc/sasl2" - -/* Do we need a leading _ for dlsym? */ -/* #undef DLSYM_NEEDS_UNDERSCORE */ - -/* Should we build a shared plugin (via dlopen) library? */ -#define DO_DLOPEN - -/* should we support sasl_checkapop? */ -#define DO_SASL_CHECKAPOP - -/* should we support setpass() for SRP? */ -/* #undef DO_SRP_SETPASS */ - -/* should we mutex-wrap calls into the GSS library? */ -#define GSS_USE_MUTEXES - -/* Enable 'alwaystrue' password verifier? */ -/* #undef HAVE_ALWAYSTRUE */ - -/* Include support for Courier's authdaemond? */ -#define HAVE_AUTHDAEMON - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_DES_H */ - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#define HAVE_DIRENT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if you have the `dns_lookup' function. */ -/* #undef HAVE_DNS_LOOKUP */ - -/* Define to 1 if you have the `dn_expand' function. */ -#define HAVE_DN_EXPAND 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Do we have a getaddrinfo? */ -#define HAVE_GETADDRINFO - -/* Define to 1 if you have the `getdomainname' function. */ -#define HAVE_GETDOMAINNAME 1 - -/* Define to 1 if you have the `gethostname' function. */ -#define HAVE_GETHOSTNAME 1 - -/* Do we have a getnameinfo() function? */ -#define HAVE_GETNAMEINFO - -/* Define to 1 if you have the `getpwnam' function. */ -#define HAVE_GETPWNAM 1 - -/* Define to 1 if you have the `getspnam' function. */ -#define HAVE_GETSPNAM 1 - -/* do we have getsubopt()? */ -#define HAVE_GETSUBOPT - -/* Define to 1 if you have the `gettimeofday' function. */ -#define HAVE_GETTIMEOFDAY 1 - -/* Define if you have the gssapi.h header file */ -#define HAVE_GSSAPI_H - -/* Define to 1 if you have the `gsskrb5_register_acceptor_identity' function. - */ -/* #undef HAVE_GSSKRB5_REGISTER_ACCEPTOR_IDENTITY */ - -/* Define if your GSSAPI implimentation defines GSS_C_NT_HOSTBASED_SERVICE */ -#define HAVE_GSS_C_NT_HOSTBASED_SERVICE - -/* Define if your GSSAPI implimentation defines GSS_C_NT_USER_NAME */ -#define HAVE_GSS_C_NT_USER_NAME - -/* Define to 1 if you have the `inet_aton' function. */ -#define HAVE_INET_ATON 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the `jrand48' function. */ -#define HAVE_JRAND48 1 - -/* Do we have Kerberos 4 Support? */ -/* #undef HAVE_KRB */ - -/* Define to 1 if you have the `krb_get_err_text' function. */ -/* #undef HAVE_KRB_GET_ERR_TEXT */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LBER_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LDAP_H */ - -/* Define to 1 if you have the `resolv' library (-lresolv). */ -#define HAVE_LIBRESOLV 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MALLOC_H 1 - -/* Define to 1 if you have the `memcpy' function. */ -#define HAVE_MEMCPY 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `mkdir' function. */ -#define HAVE_MKDIR 1 - -/* Do we have mysql support? */ -/* #undef HAVE_MYSQL */ - -/* Define to 1 if you have the header file, and it defines `DIR'. */ -/* #undef HAVE_NDIR_H */ - -/* Do we have OpenSSL? */ -#define HAVE_OPENSSL - -/* Use OPIE for server-side OTP? */ -/* #undef HAVE_OPIE */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_PAM_PAM_APPL_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_PATHS_H 1 - -/* Do we have Postgres support? */ -/* #undef HAVE_PGSQL */ - -/* Include Support for pwcheck daemon? */ -/* #undef HAVE_PWCHECK */ - -/* Include support for saslauthd? */ -#define HAVE_SASLAUTHD - -/* Define to 1 if you have the header file. */ -#define HAVE_SECURITY_PAM_APPL_H 1 - -/* Define to 1 if you have the `select' function. */ -#define HAVE_SELECT 1 - -/* Does the system have snprintf()? */ -#define HAVE_SNPRINTF - -/* Does sockaddr have an sa_len? */ -/* #undef HAVE_SOCKADDR_SA_LEN */ - -/* Define to 1 if you have the `socket' function. */ -#define HAVE_SOCKET 1 - -/* Do we have a socklen_t? */ -#define HAVE_SOCKLEN_T - -/* Do we have SQLite support? */ -/* #undef HAVE_SQLITE */ - -/* Is there an ss_family in sockaddr_storage? */ -#define HAVE_SS_FAMILY - -/* Define to 1 if you have the header file. */ -#define HAVE_STDARG_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strchr' function. */ -#define HAVE_STRCHR 1 - -/* Define to 1 if you have the `strdup' function. */ -#define HAVE_STRDUP 1 - -/* Define to 1 if you have the `strerror' function. */ -#define HAVE_STRERROR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `strspn' function. */ -#define HAVE_STRSPN 1 - -/* Define to 1 if you have the `strstr' function. */ -#define HAVE_STRSTR 1 - -/* Define to 1 if you have the `strtol' function. */ -#define HAVE_STRTOL 1 - -/* Do we have struct sockaddr_stroage? */ -#define HAVE_STRUCT_SOCKADDR_STORAGE - -/* Define to 1 if you have the header file. */ -#define HAVE_SYSEXITS_H 1 - -/* Define to 1 if you have the `syslog' function. */ -#define HAVE_SYSLOG 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYSLOG_H 1 - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -/* #undef HAVE_SYS_DIR_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_FILE_H 1 - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -/* #undef HAVE_SYS_NDIR_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TIME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_UIO_H 1 - -/* Define to 1 if you have that is POSIX.1 compatible. */ -#define HAVE_SYS_WAIT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_VARARGS_H */ - -/* Does the system have vsnprintf()? */ -#define HAVE_VSNPRINTF - -/* define if your compiler has __attribute__ */ -/* #undef HAVE___ATTRIBUTE__ */ - -/* Should we keep handle to Berkeley DB open in SASLDB plugin? */ -/* #undef KEEP_DB_OPEN */ - -/* Ignore IP Address in Kerberos 4 tickets? */ -/* #undef KRB4_IGNORE_IP_ADDRESS */ - -/* Name of package */ -#define PACKAGE "cyrus-sasl" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Where do we look for Courier authdaemond's socket? */ -#define PATH_AUTHDAEMON_SOCKET "/dev/null" - -/* Where do we look for saslauthd's socket? */ -#define PATH_SASLAUTHD_RUNDIR "/var/state/saslauthd" - -/* Runtime plugin location */ -#define PLUGINDIR "/usr/lib/sasl2" - -/* Force a preferred mechanism */ -/* #undef PREFER_MECH */ - -/* Location of pwcheck socket */ -/* #undef PWCHECKDIR */ - -/* Define as the return type of signal handlers (`int' or `void'). */ -#define RETSIGTYPE void - -/* Use BerkeleyDB for SASLdb */ -#define SASL_BERKELEYDB - -/* Path to default SASLdb database */ -#define SASL_DB_PATH "/etc/sasldb2" - -/* File to use for source of randomness */ -#define SASL_DEV_RANDOM "/dev/random" - -/* Use GDBM for SASLdb */ -/* #undef SASL_GDBM */ - -/* Use NDBM for SASLdb */ -/* #undef SASL_NDBM */ - -/* The size of a `long', as computed by sizeof. */ -#define SIZEOF_LONG 4 - -/* Link ANONYMOUS Staticly */ -/* #undef STATIC_ANONYMOUS */ - -/* Link CRAM-MD5 Staticly */ -/* #undef STATIC_CRAMMD5 */ - -/* Link DIGEST-MD5 Staticly */ -/* #undef STATIC_DIGESTMD5 */ - -/* Link GSSAPI Staticly */ -#define STATIC_GSSAPIV2 - -/* User KERBEROS_V4 Staticly */ -/* #undef STATIC_KERBEROS4 */ - -/* Link ldapdb plugin Staticly */ -/* #undef STATIC_LDAPDB */ - -/* Link LOGIN Staticly */ -/* #undef STATIC_LOGIN */ - -/* Link NTLM Staticly */ -/* #undef STATIC_NTLM */ - -/* Link OTP Staticly */ -/* #undef STATIC_OTP */ - -/* Link PASSDSS Staticly */ -/* #undef STATIC_PASSDSS */ - -/* Link PLAIN Staticly */ -/* #undef STATIC_PLAIN */ - -/* Link OAUTH Staticly */ -/* #undef STATIC_OAUTH */ - -/* Link SASLdb Staticly */ -/* #undef STATIC_SASLDB */ - -/* Link SQL plugin staticly */ -/* #undef STATIC_SQL */ - -/* Link SRP Staticly */ -/* #undef STATIC_SRP */ - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define to 1 if you can safely include both and . */ -#define TIME_WITH_SYS_TIME 1 - -/* Should we try to dlopen() plugins while staticly compiled? */ -/* #undef TRY_DLOPEN_WHEN_STATIC */ - -/* use the doors IPC API for saslauthd? */ -/* #undef USE_DOORS */ - -/* Version number of package */ -#define VERSION "2.1.23" - -/* Use DES */ -#define WITH_DES - -/* Linking against dmalloc? */ -/* #undef WITH_DMALLOC */ - -/* Use internal RC4 implementation? */ -#define WITH_RC4 - -/* Use OpenSSL DES Implementation */ -#define WITH_SSL_DES - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define as `__inline' if that's what the C compiler calls it, or to nothing - if it is not supported. */ -/* #undef inline */ - -/* Define to `int' if does not define. */ -/* #undef mode_t */ - -/* Define to `int' if does not define. */ -/* #undef pid_t */ - -/* Create a struct iovec if we need one */ -#if !defined(_WIN32) && !defined(HAVE_SYS_UIO_H) -/* (win32 is handled in sasl.h) */ -struct iovec { - char *iov_base; - long iov_len; -}; -#else -#include -#include -#endif - -/* location of the random number generator */ -#ifdef DEV_RANDOM -/* #undef DEV_RANDOM */ -#endif -#define DEV_RANDOM SASL_DEV_RANDOM - -/* if we've got krb_get_err_txt, we might as well use it; - especially since krb_err_txt isn't in some newer distributions - (MIT Kerb for Mac 4 being a notable example). If we don't have - it, we fall back to the krb_err_txt array */ -#ifdef HAVE_KRB_GET_ERR_TEXT -#define get_krb_err_txt krb_get_err_text -#else -#define get_krb_err_txt(X) (krb_err_txt[(X)]) -#endif - -/* Make Solaris happy... */ -#ifndef __EXTENSIONS__ -#define __EXTENSIONS__ -#endif - -/* Make Linux happy... */ -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#ifndef HAVE___ATTRIBUTE__ -/* Can't use attributes... */ -#define __attribute__(foo) -#endif - -#define SASL_PATH_ENV_VAR "SASL_PATH" -#define SASL_CONF_PATH_ENV_VAR "SASL_CONF_PATH" - -#include -#include -#include -#ifndef WIN32 -# include -# ifdef HAVE_SYS_PARAM_H -# include -# endif -#else /* WIN32 */ -# include -#endif /* WIN32 */ -#include - -#include - -#ifndef HAVE_SOCKLEN_T -typedef unsigned int socklen_t; -#endif /* HAVE_SOCKLEN_T */ - -#ifndef HAVE_STRUCT_SOCKADDR_STORAGE -#define _SS_MAXSIZE 128 /* Implementation specific max size */ -#define _SS_PADSIZE (_SS_MAXSIZE - sizeof(struct sockaddr)) - -struct sockaddr_storage { - struct sockaddr ss_sa; - char __ss_pad2[_SS_PADSIZE]; -}; -# define ss_family ss_sa.sa_family -#endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */ - -#ifndef AF_INET6 -/* Define it to something that should never appear */ -#define AF_INET6 AF_MAX -#endif - -#ifndef HAVE_GETADDRINFO -#define getaddrinfo sasl_getaddrinfo -#define freeaddrinfo sasl_freeaddrinfo -#define gai_strerror sasl_gai_strerror -#endif - -#ifndef HAVE_GETNAMEINFO -#define getnameinfo sasl_getnameinfo -#endif - -#if !defined(HAVE_GETNAMEINFO) || !defined(HAVE_GETADDRINFO) -#include "gai.h" -#endif - -#ifndef AI_NUMERICHOST /* support glibc 2.0.x */ -#define AI_NUMERICHOST 4 -#define NI_NUMERICHOST 2 -#define NI_NAMEREQD 4 -#define NI_NUMERICSERV 8 -#endif - -/* Defined in RFC 1035. max strlen is only 253 due to length bytes. */ -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 255 -#endif - -#ifndef HAVE_SYSEXITS_H -#include "exits.h" -#else -#include "sysexits.h" -#endif - -/* Get the correct time.h */ -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -#ifndef HIER_DELIMITER -#define HIER_DELIMITER '/' -#endif - -#endif /* CONFIG_H */ diff --git a/resources/imap/saslplugin/plugin_common.c b/resources/imap/saslplugin/plugin_common.c deleted file mode 100644 index 73ad7a9a1..000000000 --- a/resources/imap/saslplugin/plugin_common.c +++ /dev/null @@ -1,969 +0,0 @@ -/* Generic SASL plugin utility functions - * Rob Siemborski - * $Id: plugin_common.c,v 1.22 2011/09/01 14:12:18 mel Exp $ - */ -/* - * Copyright (c) 1998-2003 Carnegie Mellon University. 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. The name "Carnegie Mellon University" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For permission or any other legal - * details, please contact - * Office of Technology Transfer - * Carnegie Mellon University - * 5000 Forbes Avenue - * Pittsburgh, PA 15213-3890 - * (412) 268-4387, fax: (412) 268-7395 - * tech-transfer@andrew.cmu.edu - * - * 4. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by Computing Services - * at Carnegie Mellon University (http://www.cmu.edu/computing/)." - * - * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE - * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#ifndef macintosh -#ifdef WIN32 -# include -#else -# include -# include -# include -# include -# include -# include -#endif /* WIN32 */ -#endif /* macintosh */ -#ifdef HAVE_UNISTD_H -#include -#endif -#include -#include -#include -#include - -#include -#include -#include - -#ifdef HAVE_INTTYPES_H -#include -#endif - -#include "plugin_common.h" - -/* translate IPv4 mapped IPv6 address to IPv4 address */ -static void sockaddr_unmapped( -#ifdef IN6_IS_ADDR_V4MAPPED - struct sockaddr *sa, socklen_t *len -#else - struct sockaddr *sa __attribute__((unused)), - socklen_t *len __attribute__((unused)) -#endif -) -{ -#ifdef IN6_IS_ADDR_V4MAPPED - struct sockaddr_in6 *sin6; - struct sockaddr_in *sin4; - uint32_t addr; - int port; - - if (sa->sa_family != AF_INET6) { - return; - } - sin6 = (struct sockaddr_in6 *)sa; - if (!IN6_IS_ADDR_V4MAPPED((&sin6->sin6_addr))) { - return; - } - sin4 = (struct sockaddr_in *)sa; - addr = *(uint32_t *)&sin6->sin6_addr.s6_addr[12]; - port = sin6->sin6_port; - memset(sin4, 0, sizeof(struct sockaddr_in)); - sin4->sin_addr.s_addr = addr; - sin4->sin_port = port; - sin4->sin_family = AF_INET; -#ifdef HAVE_SOCKADDR_SA_LEN - sin4->sin_len = sizeof(struct sockaddr_in); -#endif - *len = sizeof(struct sockaddr_in); -#else - return; -#endif -} - -int _plug_ipfromstring(const sasl_utils_t *utils, const char *addr, - struct sockaddr *out, socklen_t outlen) -{ - int i, j; - socklen_t len; - struct sockaddr_storage ss; - struct addrinfo hints, *ai = NULL; - char hbuf[NI_MAXHOST]; - - if (!utils || !addr || !out) { - if (utils) { - PARAMERROR(utils); - } - return SASL_BADPARAM; - } - - /* Parse the address */ - for (i = 0; addr[i] != '\0' && addr[i] != ';'; i++) { - if (i >= NI_MAXHOST) { - if (utils) { - PARAMERROR(utils); - } - return SASL_BADPARAM; - } - hbuf[i] = addr[i]; - } - hbuf[i] = '\0'; - - if (addr[i] == ';') { - i++; - } - /* XXX/FIXME: Do we need this check? */ - for (j = i; addr[j] != '\0'; j++) - if (!isdigit((int)(addr[j]))) { - PARAMERROR(utils); - return SASL_BADPARAM; - } - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; - - if (getaddrinfo(hbuf, &addr[i], &hints, &ai) != 0) { - PARAMERROR(utils); - return SASL_BADPARAM; - } - - len = ai->ai_addrlen; - memcpy(&ss, ai->ai_addr, len); - freeaddrinfo(ai); - sockaddr_unmapped((struct sockaddr *)&ss, &len); - if (outlen < len) { - PARAMERROR(utils); - return SASL_BUFOVER; - } - - memcpy(out, &ss, len); - - return SASL_OK; -} - -int _plug_iovec_to_buf(const sasl_utils_t *utils, const struct iovec *vec, - unsigned numiov, buffer_info_t **output) -{ - unsigned i; - int ret; - buffer_info_t *out; - char *pos; - - if (!utils || !vec || !output) { - if (utils) { - PARAMERROR(utils); - } - return SASL_BADPARAM; - } - - if (!(*output)) { - *output = utils->malloc(sizeof(buffer_info_t)); - if (!*output) { - MEMERROR(utils); - return SASL_NOMEM; - } - memset(*output, 0, sizeof(buffer_info_t)); - } - - out = *output; - - out->curlen = 0; - for (i = 0; i < numiov; i++) { - out->curlen += vec[i].iov_len; - } - - ret = _plug_buf_alloc(utils, &out->data, &out->reallen, out->curlen); - - if (ret != SASL_OK) { - MEMERROR(utils); - return SASL_NOMEM; - } - - memset(out->data, 0, out->reallen); - pos = out->data; - - for (i = 0; i < numiov; i++) { - memcpy(pos, vec[i].iov_base, vec[i].iov_len); - pos += vec[i].iov_len; - } - - return SASL_OK; -} - -/* Basically a conditional call to realloc(), if we need more */ -int _plug_buf_alloc(const sasl_utils_t *utils, char **rwbuf, - unsigned *curlen, unsigned newlen) -{ - if (!utils || !rwbuf || !curlen) { - PARAMERROR(utils); - return SASL_BADPARAM; - } - - if (!(*rwbuf)) { - *rwbuf = utils->malloc(newlen); - if (*rwbuf == NULL) { - *curlen = 0; - MEMERROR(utils); - return SASL_NOMEM; - } - *curlen = newlen; - } else if (*rwbuf && *curlen < newlen) { - size_t needed = 2 * (*curlen); - - while (needed < newlen) { - needed *= 2; - } - - *rwbuf = utils->realloc(*rwbuf, needed); - if (*rwbuf == NULL) { - *curlen = 0; - MEMERROR(utils); - return SASL_NOMEM; - } - *curlen = needed; - } - - return SASL_OK; -} - -/* copy a string */ -int _plug_strdup(const sasl_utils_t *utils, const char *in, - char **out, int *outlen) -{ - size_t len = strlen(in); - - if (!utils || !in || !out) { - if (utils) { - PARAMERROR(utils); - } - return SASL_BADPARAM; - } - - *out = utils->malloc(len + 1); - if (!*out) { - MEMERROR(utils); - return SASL_NOMEM; - } - - strcpy((char *) *out, in); - - if (outlen) { - *outlen = len; - } - - return SASL_OK; -} - -void _plug_free_string(const sasl_utils_t *utils, char **str) -{ - size_t len; - - if (!utils || !str || !(*str)) { - return; - } - - len = strlen(*str); - - utils->erasebuffer(*str, len); - utils->free(*str); - - *str = NULL; -} - -void _plug_free_secret(const sasl_utils_t *utils, sasl_secret_t **secret) -{ - if (!utils || !secret || !(*secret)) { - return; - } - - utils->erasebuffer((char *)(*secret)->data, (*secret)->len); - utils->free(*secret); - *secret = NULL; -} - -/* - * Tries to find the prompt with the lookingfor id in the prompt list - * Returns it if found. NULL otherwise - */ -sasl_interact_t *_plug_find_prompt(sasl_interact_t **promptlist, - unsigned int lookingfor) -{ - sasl_interact_t *prompt; - - if (promptlist && *promptlist) { - for (prompt = *promptlist; prompt->id != SASL_CB_LIST_END; ++prompt) { - if (prompt->id == lookingfor) { - return prompt; - } - } - } - - return NULL; -} - -/* - * Retrieve the simple string given by the callback id. - */ -int _plug_get_simple(const sasl_utils_t *utils, unsigned int id, int required, - const char **result, sasl_interact_t **prompt_need) -{ - - int ret = SASL_FAIL; - sasl_getsimple_t *simple_cb; - void *simple_context; - sasl_interact_t *prompt; - - *result = NULL; - - /* see if we were given the result in the prompt */ - prompt = _plug_find_prompt(prompt_need, id); - if (prompt != NULL) { - /* We prompted, and got.*/ - - if (required && !prompt->result) { - SETERROR(utils, "Unexpectedly missing a prompt result"); - return SASL_BADPARAM; - } - - *result = prompt->result; - return SASL_OK; - } - - /* Try to get the callback... */ - ret = utils->getcallback(utils->conn, id, (sasl_callback_ft *)&simple_cb, &simple_context); - - if (ret == SASL_FAIL && !required) { - return SASL_OK; - } - - if (ret == SASL_OK && simple_cb) { - ret = simple_cb(simple_context, id, result, NULL); - if (ret != SASL_OK) { - return ret; - } - - if (required && !*result) { - PARAMERROR(utils); - return SASL_BADPARAM; - } - } - - return ret; -} - -/* - * Retrieve the user password. - */ -int _plug_get_password(const sasl_utils_t *utils, sasl_secret_t **password, - unsigned int *iscopy, sasl_interact_t **prompt_need) -{ - int ret = SASL_FAIL; - sasl_getsecret_t *pass_cb; - void *pass_context; - sasl_interact_t *prompt; - - *password = NULL; - *iscopy = 0; - - /* see if we were given the password in the prompt */ - prompt = _plug_find_prompt(prompt_need, SASL_CB_PASS); - if (prompt != NULL) { - /* We prompted, and got.*/ - - if (!prompt->result) { - SETERROR(utils, "Unexpectedly missing a prompt result"); - return SASL_BADPARAM; - } - - /* copy what we got into a secret_t */ - *password = (sasl_secret_t *) utils->malloc(sizeof(sasl_secret_t) + - prompt->len + 1); - if (!*password) { - MEMERROR(utils); - return SASL_NOMEM; - } - - (*password)->len = prompt->len; - memcpy((*password)->data, prompt->result, prompt->len); - (*password)->data[(*password)->len] = 0; - - *iscopy = 1; - - return SASL_OK; - } - - /* Try to get the callback... */ - ret = utils->getcallback(utils->conn, SASL_CB_PASS, - (sasl_callback_ft *)&pass_cb, &pass_context); - - if (ret == SASL_OK && pass_cb) { - ret = pass_cb(utils->conn, pass_context, SASL_CB_PASS, password); - if (ret != SASL_OK) { - return ret; - } - - if (!*password) { - PARAMERROR(utils); - return SASL_BADPARAM; - } - } - - return ret; -} - -/* - * Retrieve the string given by the challenge prompt id. - */ -int _plug_challenge_prompt(const sasl_utils_t *utils, unsigned int id, - const char *challenge, const char *promptstr, - const char **result, sasl_interact_t **prompt_need) -{ - int ret = SASL_FAIL; - sasl_chalprompt_t *chalprompt_cb; - void *chalprompt_context; - sasl_interact_t *prompt; - - *result = NULL; - - /* see if we were given the password in the prompt */ - prompt = _plug_find_prompt(prompt_need, id); - if (prompt != NULL) { - /* We prompted, and got.*/ - - if (!prompt->result) { - SETERROR(utils, "Unexpectedly missing a prompt result"); - return SASL_BADPARAM; - } - - *result = prompt->result; - return SASL_OK; - } - - /* Try to get the callback... */ - ret = utils->getcallback(utils->conn, id, - (sasl_callback_ft *)&chalprompt_cb, &chalprompt_context); - - if (ret == SASL_OK && chalprompt_cb) { - ret = chalprompt_cb(chalprompt_context, id, - challenge, promptstr, NULL, result, NULL); - if (ret != SASL_OK) { - return ret; - } - - if (!*result) { - PARAMERROR(utils); - return SASL_BADPARAM; - } - } - - return ret; -} - -/* - * Retrieve the client realm. - */ -int _plug_get_realm(const sasl_utils_t *utils, const char **availrealms, - const char **realm, sasl_interact_t **prompt_need) -{ - int ret = SASL_FAIL; - sasl_getrealm_t *realm_cb; - void *realm_context; - sasl_interact_t *prompt; - - *realm = NULL; - - /* see if we were given the result in the prompt */ - prompt = _plug_find_prompt(prompt_need, SASL_CB_GETREALM); - if (prompt != NULL) { - /* We prompted, and got.*/ - - if (!prompt->result) { - SETERROR(utils, "Unexpectedly missing a prompt result"); - return SASL_BADPARAM; - } - - *realm = prompt->result; - return SASL_OK; - } - - /* Try to get the callback... */ - ret = utils->getcallback(utils->conn, SASL_CB_GETREALM, - (sasl_callback_ft *)&realm_cb, &realm_context); - - if (ret == SASL_OK && realm_cb) { - ret = realm_cb(realm_context, SASL_CB_GETREALM, availrealms, realm); - if (ret != SASL_OK) { - return ret; - } - - if (!*realm) { - PARAMERROR(utils); - return SASL_BADPARAM; - } - } - - return ret; -} - -/* - * Make the requested prompts. (prompt==NULL means we don't want it) - */ -int _plug_make_prompts(const sasl_utils_t *utils, - sasl_interact_t **prompts_res, - const char *user_prompt, const char *user_def, - const char *auth_prompt, const char *auth_def, - const char *pass_prompt, const char *pass_def, - const char *echo_chal, - const char *echo_prompt, const char *echo_def, - const char *realm_chal, - const char *realm_prompt, const char *realm_def) -{ - int num = 1; - int alloc_size; - sasl_interact_t *prompts; - - if (user_prompt) { - num++; - } - if (auth_prompt) { - num++; - } - if (pass_prompt) { - num++; - } - if (echo_prompt) { - num++; - } - if (realm_prompt) { - num++; - } - - if (num == 1) { - SETERROR(utils, "make_prompts() called with no actual prompts"); - return SASL_FAIL; - } - - alloc_size = sizeof(sasl_interact_t) * num; - prompts = utils->malloc(alloc_size); - if (!prompts) { - MEMERROR(utils); - return SASL_NOMEM; - } - memset(prompts, 0, alloc_size); - - *prompts_res = prompts; - - if (user_prompt) { - (prompts)->id = SASL_CB_USER; - (prompts)->challenge = "Authorization Name"; - (prompts)->prompt = user_prompt; - (prompts)->defresult = user_def; - - prompts++; - } - - if (auth_prompt) { - (prompts)->id = SASL_CB_AUTHNAME; - (prompts)->challenge = "Authentication Name"; - (prompts)->prompt = auth_prompt; - (prompts)->defresult = auth_def; - - prompts++; - } - - if (pass_prompt) { - (prompts)->id = SASL_CB_PASS; - (prompts)->challenge = "Password"; - (prompts)->prompt = pass_prompt; - (prompts)->defresult = pass_def; - - prompts++; - } - - if (echo_prompt) { - (prompts)->id = SASL_CB_ECHOPROMPT; - (prompts)->challenge = echo_chal; - (prompts)->prompt = echo_prompt; - (prompts)->defresult = echo_def; - - prompts++; - } - - if (realm_prompt) { - (prompts)->id = SASL_CB_GETREALM; - (prompts)->challenge = realm_chal; - (prompts)->prompt = realm_prompt; - (prompts)->defresult = realm_def; - - prompts++; - } - - /* add the ending one */ - (prompts)->id = SASL_CB_LIST_END; - (prompts)->challenge = NULL; - (prompts)->prompt = NULL; - (prompts)->defresult = NULL; - - return SASL_OK; -} - -void _plug_decode_init(decode_context_t *text, - const sasl_utils_t *utils, unsigned int in_maxbuf) -{ - memset(text, 0, sizeof(decode_context_t)); - - text->utils = utils; - text->needsize = 4; - text->in_maxbuf = in_maxbuf; -} - -/* - * Decode as much of the input as possible (possibly none), - * using decode_pkt() to decode individual packets. - */ -int _plug_decode(decode_context_t *text, - const char *input, unsigned inputlen, - char **output, /* output buffer */ - unsigned *outputsize, /* current size of output buffer */ - unsigned *outputlen, /* length of data in output buffer */ - int (*decode_pkt)(void *rock, - const char *input, unsigned inputlen, - char **output, unsigned *outputlen), - void *rock) -{ - unsigned int tocopy; - unsigned diff; - char *tmp; - unsigned tmplen; - int ret; - - *outputlen = 0; - - while (inputlen) { /* more input */ - if (text->needsize) { /* need to get the rest of the 4-byte size */ - - /* copy as many bytes (up to 4) as we have into size buffer */ - tocopy = (inputlen > text->needsize) ? text->needsize : inputlen; - memcpy(text->sizebuf + 4 - text->needsize, input, tocopy); - text->needsize -= tocopy; - - input += tocopy; - inputlen -= tocopy; - - if (!text->needsize) { /* we have the entire 4-byte size */ - memcpy(&(text->size), text->sizebuf, 4); - text->size = ntohl(text->size); - - if (!text->size) { /* should never happen */ - return SASL_FAIL; - } - - if (text->size > text->in_maxbuf) { - text->utils->log(NULL, SASL_LOG_ERR, - "encoded packet size too big (%d > %d)", - text->size, text->in_maxbuf); - return SASL_FAIL; - } - - if (!text->buffer) { - text->buffer = text->utils->malloc(text->in_maxbuf); - } - if (text->buffer == NULL) { - return SASL_NOMEM; - } - - text->cursize = 0; - } else { - /* We do NOT have the entire 4-byte size... - * wait for more data */ - return SASL_OK; - } - } - - diff = text->size - text->cursize; /* bytes needed for full packet */ - - if (inputlen < diff) { /* not a complete packet, need more input */ - memcpy(text->buffer + text->cursize, input, inputlen); - text->cursize += inputlen; - return SASL_OK; - } - - /* copy the rest of the packet */ - memcpy(text->buffer + text->cursize, input, diff); - input += diff; - inputlen -= diff; - - /* decode the packet (no need to free tmp) */ - ret = decode_pkt(rock, text->buffer, text->size, &tmp, &tmplen); - if (ret != SASL_OK) { - return ret; - } - - /* append the decoded packet to the output */ - ret = _plug_buf_alloc(text->utils, output, outputsize, - *outputlen + tmplen + 1); /* +1 for NUL */ - if (ret != SASL_OK) { - return ret; - } - - memcpy(*output + *outputlen, tmp, tmplen); - *outputlen += tmplen; - - /* protect stupid clients */ - *(*output + *outputlen) = '\0'; - - /* reset for the next packet */ - text->needsize = 4; - } - - return SASL_OK; -} - -void _plug_decode_free(decode_context_t *text) -{ - if (text->buffer) { - text->utils->free(text->buffer); - } -} - -/* returns the realm we should pretend to be in */ -int _plug_parseuser(const sasl_utils_t *utils, - char **user, char **realm, const char *user_realm, - const char *serverFQDN, const char *input) -{ - int ret; - char *r; - - if (!user || !serverFQDN) { - PARAMERROR(utils); - return SASL_BADPARAM; - } - - r = strchr(input, '@'); - if (!r) { - /* hmmm, the user didn't specify a realm */ - if (user_realm && user_realm[0]) { - ret = _plug_strdup(utils, user_realm, realm, NULL); - } else { - /* Default to serverFQDN */ - ret = _plug_strdup(utils, serverFQDN, realm, NULL); - } - - if (ret == SASL_OK) { - ret = _plug_strdup(utils, input, user, NULL); - } - } else { - r++; - ret = _plug_strdup(utils, r, realm, NULL); - *--r = '\0'; - *user = utils->malloc(r - input + 1); - if (*user) { - strncpy(*user, input, r - input + 1); - } else { - MEMERROR(utils); - ret = SASL_NOMEM; - } - *r = '@'; - } - - return ret; -} - -int _plug_make_fulluser(const sasl_utils_t *utils, - char **fulluser, - const char *useronly, - const char *realm) -{ - if (!fulluser || !useronly || !realm) { - PARAMERROR(utils); - return (SASL_BADPARAM); - } - - *fulluser = utils->malloc(strlen(useronly) + strlen(realm) + 2); - if (*fulluser == NULL) { - MEMERROR(utils); - return (SASL_NOMEM); - } - - strcpy(*fulluser, useronly); - strcat(*fulluser, "@"); - strcat(*fulluser, realm); - - return (SASL_OK); -} - -char *_plug_get_error_message(const sasl_utils_t *utils, -#ifdef WIN32 - DWORD error -#else - int error -#endif - ) -{ - char *return_value; -#ifdef WIN32 - LPVOID lpMsgBuf; - - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - error, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */ - (LPTSTR) &lpMsgBuf, - 0, - NULL - ); - - if (_plug_strdup(utils, lpMsgBuf, &return_value, NULL) != SASL_OK) { - return_value = NULL; - } - - LocalFree(lpMsgBuf); -#else /* !WIN32 */ - if (_plug_strdup(utils, strerror(error), &return_value, NULL) != SASL_OK) { - return_value = NULL; - } -#endif /* WIN32 */ - return (return_value); -} - -void _plug_snprintf_os_info(char *osbuf, int osbuf_len) -{ -#ifdef WIN32 - OSVERSIONINFOEX versioninfo; - char *sysname; - - /* : - DWORD dwOSVersionInfoSize; - DWORD dwMajorVersion; - DWORD dwMinorVersion; - DWORD dwBuildNumber; - TCHAR szCSDVersion[ 128 ]; - //Only NT SP 6 and later - WORD wServicePackMajor; - WORD wServicePackMinor; - WORD wSuiteMask; - BYTE wProductType; - */ - - versioninfo.dwOSVersionInfoSize = sizeof(versioninfo); - sysname = "Unknown Windows"; - - if (GetVersionEx((OSVERSIONINFO *) &versioninfo) == FALSE) { - snprintf(osbuf, osbuf_len, "%s", sysname); - goto SKIP_OS_INFO; - } - - switch (versioninfo.dwPlatformId) { - case VER_PLATFORM_WIN32s: /* Win32s on Windows 3.1 */ - sysname = "Win32s on Windows 3.1"; - /* I can't test if dwBuildNumber has any meaning on Win32s */ - break; - - case VER_PLATFORM_WIN32_WINDOWS: /* 95/98/ME */ - switch (versioninfo.dwMinorVersion) { - case 0: - sysname = "Windows 95"; - break; - case 10: - sysname = "Windows 98"; - break; - case 90: - sysname = "Windows Me"; - break; - default: - sysname = "Unknown Windows 9X/ME series"; - break; - } - /* Clear the high order word, as it contains major/minor version */ - versioninfo.dwBuildNumber &= 0xFFFF; - break; - - case VER_PLATFORM_WIN32_NT: /* NT/2000/XP/.NET */ - if (versioninfo.dwMinorVersion > 99) { - } else { - switch (versioninfo.dwMajorVersion * 100 + versioninfo.dwMinorVersion) { - case 351: - sysname = "Windows NT 3.51"; - break; - case 400: - sysname = "Windows NT 4.0"; - break; - case 500: - sysname = "Windows 2000"; - break; - case 501: - sysname = "Windows XP/.NET"; /* or Windows .NET Server */ - break; - default: - sysname = "Unknown Windows NT series"; - break; - } - } - break; - - default: - break; - } - - snprintf(osbuf, osbuf_len, - "%s %s (Build %u)", - sysname, - versioninfo.szCSDVersion, - versioninfo.dwBuildNumber - ); - -SKIP_OS_INFO: - ; - -#else /* !WIN32 */ - struct utsname os; - - uname(&os); - snprintf(osbuf, osbuf_len, "%s %s", os.sysname, os.release); -#endif /* WIN32 */ -} - -#if defined(WIN32) -unsigned int plug_sleep(unsigned int seconds) -{ - long dwSec = seconds * 1000; - Sleep(dwSec); - return 0; -} -#endif diff --git a/resources/imap/saslplugin/plugin_common.h b/resources/imap/saslplugin/plugin_common.h deleted file mode 100644 index 431e61451..000000000 --- a/resources/imap/saslplugin/plugin_common.h +++ /dev/null @@ -1,197 +0,0 @@ -/* Generic SASL plugin utility functions - * Rob Siemborski - * $Id: plugin_common.h,v 1.21 2006/01/17 12:18:21 mel Exp $ - */ -/* - * Copyright (c) 1998-2003 Carnegie Mellon University. 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. The name "Carnegie Mellon University" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For permission or any other legal - * details, please contact - * Office of Technology Transfer - * Carnegie Mellon University - * 5000 Forbes Avenue - * Pittsburgh, PA 15213-3890 - * (412) 268-4387, fax: (412) 268-7395 - * tech-transfer@andrew.cmu.edu - * - * 4. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by Computing Services - * at Carnegie Mellon University (http://www.cmu.edu/computing/)." - * - * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE - * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _PLUGIN_COMMON_H_ -#define _PLUGIN_COMMON_H_ - -#include - -#ifndef macintosh -#ifdef WIN32 -# include -#else -# include -# include -# include -# include -#endif /* WIN32 */ -#endif /* macintosh */ - -#include -#include -#include - -#ifdef WIN32 -#define PLUG_API __declspec(dllexport) -#else -#define PLUG_API extern -#endif - -#define SASL_CLIENT_PLUG_INIT(x) \ - extern sasl_client_plug_init_t x ## _client_plug_init; \ - PLUG_API int sasl_client_plug_init(const sasl_utils_t *utils, \ - int maxversion, int *out_version, \ - sasl_client_plug_t **pluglist, \ - int *plugcount) { \ - return x ## _client_plug_init(utils, maxversion, out_version, \ - pluglist, plugcount); \ - } - -#define SASL_SERVER_PLUG_INIT(x) \ - extern sasl_server_plug_init_t x ## _server_plug_init; \ - PLUG_API int sasl_server_plug_init(const sasl_utils_t *utils, \ - int maxversion, int *out_version, \ - sasl_server_plug_t **pluglist, \ - int *plugcount) { \ - return x ## _server_plug_init(utils, maxversion, out_version, \ - pluglist, plugcount); \ - } - -#define SASL_AUXPROP_PLUG_INIT(x) \ - extern sasl_auxprop_init_t x ## _auxprop_plug_init; \ - PLUG_API int sasl_auxprop_plug_init(const sasl_utils_t *utils, \ - int maxversion, int *out_version, \ - sasl_auxprop_plug_t **plug, \ - const char *plugname) { \ - return x ## _auxprop_plug_init(utils, maxversion, out_version, \ - plug, plugname); \ - } - -#define SASL_CANONUSER_PLUG_INIT(x) \ - extern sasl_canonuser_init_t x ## _canonuser_plug_init; \ - PLUG_API int sasl_canonuser_init(const sasl_utils_t *utils, \ - int maxversion, int *out_version, \ - sasl_canonuser_plug_t **plug, \ - const char *plugname) { \ - return x ## _canonuser_plug_init(utils, maxversion, out_version, \ - plug, plugname); \ - } - -/* note: msg cannot include additional variables, so if you want to - * do a printf-format string, then you need to call seterror yourself */ -#define SETERROR(utils, msg) (utils)->seterror((utils)->conn, 0, (msg)) - -#ifndef MEMERROR -#define MEMERROR(utils) \ - (utils)->seterror((utils)->conn, 0, \ - "Out of Memory in " __FILE__ " near line %d", __LINE__) -#endif - -#ifndef PARAMERROR -#define PARAMERROR(utils) \ - (utils)->seterror((utils)->conn, 0, \ - "Parameter Error in " __FILE__ " near line %d", __LINE__) -#endif - -#ifndef SASLINT_H -typedef struct buffer_info { - char *data; - unsigned curlen; /* Current length of data in buffer */ - unsigned reallen; /* total length of buffer (>= curlen) */ -} buffer_info_t; -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -int _plug_ipfromstring(const sasl_utils_t *utils, const char *addr, struct sockaddr *out, socklen_t outlen); -int _plug_iovec_to_buf(const sasl_utils_t *utils, const struct iovec *vec, unsigned numiov, buffer_info_t **output); -int _plug_buf_alloc(const sasl_utils_t *utils, char **rwbuf, unsigned *curlen, unsigned newlen); -int _plug_strdup(const sasl_utils_t *utils, const char *in, char **out, int *outlen); -void _plug_free_string(const sasl_utils_t *utils, char **str); -void _plug_free_secret(const sasl_utils_t *utils, sasl_secret_t **secret); - -#define _plug_get_userid(utils, result, prompt_need) \ - _plug_get_simple(utils, SASL_CB_USER, 0, result, prompt_need) -#define _plug_get_authid(utils, result, prompt_need) \ - _plug_get_simple(utils, SASL_CB_AUTHNAME, 1, result, prompt_need) -int _plug_get_simple(const sasl_utils_t *utils, unsigned int id, int required, const char **result, sasl_interact_t **prompt_need); - -int _plug_get_password(const sasl_utils_t *utils, sasl_secret_t **secret, unsigned int *iscopy, sasl_interact_t **prompt_need); - -int _plug_challenge_prompt(const sasl_utils_t *utils, unsigned int id, const char *challenge, const char *promptstr, const char **result, sasl_interact_t **prompt_need); - -int _plug_get_realm(const sasl_utils_t *utils, const char **availrealms, const char **realm, sasl_interact_t **prompt_need); - -int _plug_make_prompts(const sasl_utils_t *utils, sasl_interact_t **prompts_res, const char *user_prompt, const char *user_def, const char *auth_prompt, const char *auth_def, const char *pass_prompt, - const char *pass_def, const char *echo_chal, const char *echo_prompt, const char *echo_def, const char *realm_chal, const char *realm_prompt, const char *realm_def); - -typedef struct decode_context { - const sasl_utils_t *utils; - unsigned int needsize; /* How much of the 4-byte size do we need? */ - char sizebuf[4]; /* Buffer to accumulate the 4-byte size */ - unsigned int size; /* Absolute size of the encoded packet */ - char *buffer; /* Buffer to accumulate an encoded packet */ - unsigned int cursize; /* Amount of packet data in the buffer */ - unsigned int in_maxbuf; /* Maximum allowed size of an incoming encoded packet */ -} decode_context_t; - -void _plug_decode_init(decode_context_t *text, const sasl_utils_t *utils, unsigned int in_maxbuf); - -int _plug_decode(decode_context_t *text, const char *input, unsigned inputlen, char **output, unsigned *outputsize, unsigned *outputlen, int (*decode_pkt)(void *rock, - const char *input, unsigned inputlen, - char **output, - unsigned *outputlen), void *rock); - -void _plug_decode_free(decode_context_t *text); - -int _plug_parseuser(const sasl_utils_t *utils, char **user, char **realm, const char *user_realm, const char *serverFQDN, const char *input); - -int _plug_make_fulluser(const sasl_utils_t *utils, char **fulluser, const char *useronly, const char *realm); - -char *_plug_get_error_message(const sasl_utils_t *utils, -#ifdef WIN32 - DWORD error -#else - int error -#endif - ); -void _plug_snprintf_os_info(char *osbuf, int osbuf_len); - -#ifdef __cplusplus -} -#endif - -#endif /* _PLUGIN_COMMON_H_ */ diff --git a/resources/imap/saslplugin/xoauth2plugin.c b/resources/imap/saslplugin/xoauth2plugin.c deleted file mode 100644 index 652fb9658..000000000 --- a/resources/imap/saslplugin/xoauth2plugin.c +++ /dev/null @@ -1,246 +0,0 @@ -/* - Copyright (c) 2014 Daniel Vrátil - (c) 2016 Daniel Vrátil - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -/** - * This is a very simple and single-purpose implementation of XOAUTH2 protocol - * for SASL used by KDE's KIMAP and IMAP resource in order to support OAuth - * Gmail authentication. - * - * This plugin does not even have a server-side part, and the client-side makes - * assumptions about it's use related to how KIMAP's LoginJob is implemented, - * so it's unsuitable for general-purpose use. - * - * The plugin is called libkdexoauth2.so to avoid conflict in case anyone ever - * writes a proper XOAUTH2 plugin for SASL. - */ - -#include -#include -#include - -#include -#include -#include - -#include "plugin_common.h" - -typedef struct client_context { - char *out_buf; - unsigned out_buf_len; -} client_context_t; - -static int xoauth2_client_mech_new(void *glob_context, - sasl_client_params_t *params, - void **conn_context) -{ - client_context_t *context; - - /* Q_UNUSED */ - (void)glob_context; - - /* holds state are in */ - context = params->utils->malloc(sizeof(client_context_t)); - if (context == NULL) { - MEMERROR(params->utils); - return SASL_NOMEM; - } - - memset(context, 0, sizeof(client_context_t)); - - *conn_context = context; - - return SASL_OK; -} - -static int xoauth2_client_mech_step(void *conn_context, - sasl_client_params_t *params, - const char *serverin, - unsigned serverinlen, - sasl_interact_t **prompt_need, - const char **clientout, - unsigned *clientoutlen, - sasl_out_params_t *oparams) -{ - client_context_t *context = (client_context_t *) conn_context; - const sasl_utils_t *utils = params->utils; - const char *authid = NULL, *token = NULL; - int auth_result = SASL_OK; - int token_result = SASL_OK; - int result; - *clientout = NULL; - *clientoutlen = 0; - - /* Q_UNUSED */ - (void) serverin; - (void) serverinlen; - - if (params->props.min_ssf > params->external_ssf) { - SETERROR(params->utils, "SSF requested of XOAUTH2 plugin"); - return SASL_TOOWEAK; - } - - /* try to get the authid */ - if (oparams->authid == NULL) { - fprintf(stderr, "[SASL-XOAUTH2] - Requesting authID!"); - auth_result = _plug_get_authid(utils, &authid, prompt_need); - if ((auth_result != SASL_OK) && (auth_result != SASL_INTERACT)) { - fprintf(stderr, "[SASL-XOAUTH2] - _plug_get_authid FAILED\n!"); - return auth_result; - } - } - - /* try to get oauth token */ - if (token == NULL) { - fprintf(stderr, "[SASL-XOAUTH2] - Requesting token\n!"); - /* We don't use _plug_get_password because we don't really care much about - safety of the OAuth token */ - token_result = _plug_get_simple(utils, SASL_CB_PASS, 1, &token, prompt_need); - if ((token_result != SASL_OK) && (token_result != SASL_INTERACT)) { - fprintf(stderr, "[SASL-XOAUTH2] - _plug_get_simple FAILED\n!"); - return token_result; - } - } - - /* free prompts we got */ - if (prompt_need && *prompt_need) { - utils->free(*prompt_need); - *prompt_need = NULL; - } - - /* if there are prompts not filled in */ - if ((auth_result == SASL_INTERACT) || (token_result == SASL_INTERACT)) { - /* make the prompt list */ - fprintf(stderr, "[SASL-XOAUTH2] - filling prompts\n!"); - result = - _plug_make_prompts(utils, prompt_need, - NULL, NULL, - auth_result == SASL_INTERACT ? - "Please enter your authentication name" : NULL, - NULL, - token_result == SASL_INTERACT ? - "Please enter OAuth token" : NULL, NULL, - NULL, NULL, NULL, - NULL, NULL, NULL); - if (result != SASL_OK) { - fprintf(stderr, "[SASL-XOAUTH2] - filling prompts failed FAILED\n!"); - return result; - } - - return SASL_INTERACT; - } - - /* FIXME: Fail if username is missing too? */ - if (!token) { - PARAMERROR(params->utils); - return SASL_BADPARAM; - } - - result = params->canon_user(utils->conn, authid, 0, - SASL_CU_AUTHID | SASL_CU_AUTHZID, oparams); - if (result != SASL_OK) { - fprintf(stderr, "[SASL-XOAUTH2] - canon user FAILED\n!"); - return result; - } - - /* https://developers.google.com/gmail/xoauth2_protocol#the_sasl_xoauth2_mechanism */ - *clientoutlen = 5 /* user=*/ - + ((authid && *authid) ? strlen(authid) : 0) /* %s */ - + 1 /* \001 */ - + 12 /* auth=Bearer{space} */ - + ((token && *token) ? strlen(token) : 0) /* %s */ - + 2; /* \001\001 */ - - /* remember the extra NUL on the end for stupid clients */ - result = _plug_buf_alloc(params->utils, &(context->out_buf), - &(context->out_buf_len), *clientoutlen + 1); - if (result != SASL_OK) { - fprintf(stderr, "[SASL-XOAUTH2] - _plug_buf_alloc FAILED\n!"); - return result; - } - - snprintf(context->out_buf, context->out_buf_len, "user=%s\1auth=Bearer %s\1\1", authid, token); - - *clientout = context->out_buf; - - /* set oparams */ - oparams->doneflag = 1; - oparams->mech_ssf = 0; - oparams->maxoutbuf = 0; - oparams->encode_context = NULL; - oparams->encode = NULL; - oparams->decode_context = NULL; - oparams->decode = NULL; - oparams->param_version = 0; - - return SASL_OK; -} - -static void xoauth2_client_mech_dispose(void *conn_context, - const sasl_utils_t *utils) -{ - client_context_t *context = (client_context_t *) conn_context; - if (!context) { - return; - } - - if (context->out_buf) { - printf("%s", context->out_buf); - utils->free(context->out_buf); - } - utils->free(context); -} - -static sasl_client_plug_t xoauth2_client_plugins[] = { - { - "XOAUTH2", /* mech_name */ - 0, /* max_ssf */ - SASL_SEC_NOANONYMOUS - | SASL_SEC_PASS_CREDENTIALS, /* security_flags */ - SASL_FEAT_WANT_CLIENT_FIRST - | SASL_FEAT_ALLOWS_PROXY, /* features */ - NULL, /* required_prompts */ - NULL, /* glob_context */ - &xoauth2_client_mech_new, /* mech_new */ - &xoauth2_client_mech_step, /* mech_step */ - &xoauth2_client_mech_dispose, /* mech_dispose */ - NULL, /* mech_free */ - NULL, /* idle */ - NULL, /* spare */ - NULL /* spare */ - } -}; - -int xoauth2_client_plug_init(sasl_utils_t *utils, - int maxversion, - int *out_version, - sasl_client_plug_t **pluglist, - int *plugcount) -{ - if (maxversion < SASL_CLIENT_PLUG_VERSION) { - SETERROR(utils, "XOAUTH2 version mismatch"); - return SASL_BADVERS; - } - - *out_version = SASL_CLIENT_PLUG_VERSION; - *pluglist = xoauth2_client_plugins; - *plugcount = 1; - - return SASL_OK; -} diff --git a/resources/imap/saslplugin/xoauth2plugin_init.c b/resources/imap/saslplugin/xoauth2plugin_init.c deleted file mode 100644 index 091a7bec6..000000000 --- a/resources/imap/saslplugin/xoauth2plugin_init.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright (c) 2014 Daniel Vrátil - (c) 2016 Daniel Vrátil - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#include -#include -#include -#include -#ifndef macintosh -#include -#endif -#include -#include - -#include -#include -#include - -#include "plugin_common.h" - -#ifdef WIN32 -BOOL APIENTRY DllMain(HANDLE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved) -{ - switch (ul_reason_for_call) { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} -#endif - -SASL_CLIENT_PLUG_INIT(xoauth2)