From: Ken Hornstein Date: Tue, 6 Sep 2016 00:32:03 +0000 (-0400) Subject: Merge branch 'xoauth' X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/6b6847272dc5d21ca6fcd23bf20e16193b226c0a?ds=inline;hp=-c Merge branch 'xoauth' --- 6b6847272dc5d21ca6fcd23bf20e16193b226c0a diff --combined .gitignore index 0452577e,9fb36a8a..7bb004eb --- a/.gitignore +++ b/.gitignore @@@ -60,6 -60,7 +60,6 @@@ a.out.dSYM /mts/libmts.a /sbr/*.a /sbr/ctype-checked.* -/sbr/sigmsg.h /sbr/addrparse.tab.c /sbr/addrparse.tab.h /sbr/addrparse.output @@@ -84,6 -85,7 +84,7 @@@ /uip/mhical /uip/mhl /uip/mhlist + /uip/mhlogin /uip/mhn /uip/mhparam /uip/mhpath @@@ -114,6 -116,7 +115,7 @@@ /uip/whatnow /uip/whom /uip/*.exe + /test/fakehttp /test/fakepop /test/fakesmtp /test/getcanon diff --combined Makefile.am index aaa0e557,c4de7d1c..cc0f477b --- a/Makefile.am +++ b/Makefile.am @@@ -36,6 -36,9 +36,9 @@@ nmhlibexecdir = @libexecdir@/nm ## nmh _does_ have a test suite! ## TESTS_ENVIRONMENT = MH_OBJ_DIR="@abs_builddir@" \ + MH_VERSION="$(VERSION)" \ + OAUTH_SUPPORT='@OAUTH_SUPPORT@' \ + CURL_USER_AGENT='@CURL_USER_AGENT@' \ MH_TEST_DIR=`cd "@abs_builddir@" && pwd -P`/test/testdir \ nmhlibexecdir="$(nmhlibexecdir)" bindir="$(bindir)" \ mandir="$(mandir)" nmhetcdir="$(nmhetcdir)" \ @@@ -84,6 -87,8 +87,8 @@@ TESTS = test/ali/test-ali test/anno/tes test/mhshow/test-subpart test/mhshow/test-msg-buffer-boundaries \ test/mhstore/test-mhstore test/mkstemp/test-mkstemp \ test/new/test-basic test/pick/test-pick test/pick/test-stderr \ + test/oauth/test-mhlogin test/oauth/test-mhparam test/oauth/test-send \ + test/oauth/test-sendfrom test/oauth/test-inc test/oauth/test-share \ test/post/test-post-aliases test/post/test-post-basic \ test/post/test-post-multiple test/post/test-post-bcc \ test/post/test-post-dcc test/post/test-post-fcc \ @@@ -106,7 -111,7 +111,7 @@@ check_SCRIPTS = test/common.sh check_PROGRAMS = test/getfullname test/getcanon test/fakepop test/fakesmtp \ - test/getcwidth + test/getcwidth test/fakehttp ## The location of installed nmhetcdir is, for all purposes except ## distcheck, $nmhetcdir. For distcheck, prepend $MH_INST_DIR (from @@@ -146,7 -151,7 +151,7 @@@ superclean: maintainer-clea ## ## Files that need to be built before everything else ## -BUILT_SOURCES = sbr/sigmsg.h sbr/ctype-checked.c +BUILT_SOURCES = sbr/ctype-checked.c ## ## This is a list of all programs that get installed in the "bin" directory @@@ -159,7 -164,7 +164,7 @@@ bin_PROGRAMS = uip/ali uip/anno uip/bur uip/mhparam uip/mhpath uip/mhshow uip/mhstore uip/msgchk \ uip/new uip/packf uip/pick uip/prompter uip/refile \ uip/repl uip/rmf uip/rmm uip/scan uip/send uip/show uip/sortm \ - uip/whatnow uip/whom + uip/whatnow uip/whom uip/mhlogin bin_SCRIPTS = uip/mhmail etc/sendfiles @@@ -194,7 -199,8 +199,8 @@@ noinst_HEADERS = h/addrsbr.h h/aliasbr. h/mh.h h/mhcachesbr.h h/mhparse.h h/mime.h \ h/mts.h h/nmh.h h/picksbr.h h/popsbr.h h/prototypes.h \ h/rcvmail.h h/scansbr.h h/signals.h h/tws.h h/utils.h \ - mts/smtp/smtp.h sbr/ctype-checked.h + mts/smtp/smtp.h sbr/ctype-checked.h h/oauth.h \ + thirdparty/jsmn/jsmn.h ## ## Extra files we need to install in various places @@@ -254,7 -260,7 +260,7 @@@ man_MANS = man/ali.1 man/anno.1 man/ap. man/prompter.1 man/rcvdist.1 man/rcvpack.1 man/rcvstore.1 \ man/rcvtty.1 man/refile.1 man/repl.1 man/rmf.1 man/rmm.1 \ man/scan.1 man/send.1 man/sendfiles.1 man/show.1 man/slocal.1 \ - man/sortm.1 man/unseen.1 man/whatnow.1 man/whom.1 + man/sortm.1 man/unseen.1 man/whatnow.1 man/whom.1 man/mhlogin.1 ## ## Sources for our man pages @@@ -276,13 -282,13 +282,13 @@@ man_SRCS = man/ali.man man/anno.man man man/rcvstore.man man/rcvtty.man man/refile.man man/repl.man \ man/rmf.man man/rmm.man man/scan.man man/send.man \ man/sendfiles.man man/show.man man/slocal.man man/sortm.man \ - man/unseen.man man/whatnow.man man/whom.man + man/unseen.man man/whatnow.man man/whom.man man/mhlogin.man ## ## Files we need to include in the distribution which aren't found by ## Automake using the automatic rules ## -EXTRA_DIST = autogen.sh config/version.sh sbr/sigmsg.awk sbr/icalparse.h \ +EXTRA_DIST = autogen.sh config/version.sh sbr/icalparse.h \ etc/mts.conf.in etc/mhn.defaults.sh etc/sendfiles \ $(MHNSEARCHPROG) DATE MACHINES \ docs/ChangeLog_MH-3_to_MH-6.6 \ @@@ -295,6 -301,7 +301,7 @@@ test/mhbuild/nulls \ test/mhbuild/textplain \ test/post/test-post-common.sh test/send/README \ + test/oauth/common.sh \ test/valgrind.supp uip/mhmail \ SPECS/nmh.spec SPECS/build-nmh-cygwin $(man_SRCS) @@@ -335,7 -342,7 +342,7 @@@ uip_forw_SOURCES = uip/forw.c uip/whatn uip_forw_LDADD = $(LDADD) $(READLINELIB) $(TERMLIB) $(ICONVLIB) $(POSTLINK) uip_inc_SOURCES = uip/inc.c uip/scansbr.c uip/dropsbr.c uip/popsbr.c - uip_inc_LDADD = $(LDADD) $(TERMLIB) $(ICONVLIB) $(SASLLIB) $(POSTLINK) + uip_inc_LDADD = $(LDADD) $(TERMLIB) $(ICONVLIB) $(SASLLIB) $(CURLLIB) $(POSTLINK) uip_install_mh_SOURCES = uip/install-mh.c uip_install_mh_LDADD = $(LDADD) $(POSTLINK) @@@ -382,7 -389,7 +389,7 @@@ uip_mhstore_SOURCES = uip/mhstore.c uip uip_mhstore_LDADD = $(LDADD) $(TERMLIB) $(ICONVLIB) $(POSTLINK) uip_msgchk_SOURCES = uip/msgchk.c uip/popsbr.c - uip_msgchk_LDADD = $(LDADD) $(SASLLIB) $(POSTLINK) + uip_msgchk_LDADD = $(LDADD) $(SASLLIB) $(CURLLIB) $(POSTLINK) uip_new_SOURCES = uip/new.c uip_new_LDADD = $(LDADD) $(POSTLINK) @@@ -424,7 -431,8 +431,7 @@@ uip_sortm_LDADD = $(LDADD) $(POSTLINK uip_whatnow_SOURCES = uip/whatnow.c uip/whatnowsbr.c uip/sendsbr.c \ uip/annosbr.c uip/distsbr.c -uip_whatnow_LDADD = $(LDADD) $(READLINELIB) $(TERMLIB) $(ICONVLIB) \ - $(POSTLINK) +uip_whatnow_LDADD = $(LDADD) $(READLINELIB) $(TERMLIB) $(ICONVLIB) $(POSTLINK) uip_whom_SOURCES = uip/whom.c uip/distsbr.c uip_whom_LDADD = $(LDADD) $(POSTLINK) @@@ -448,11 -456,15 +455,15 @@@ uip_fmttest_LDADD = $(LDADD) $(TERMLIB uip_mhl_SOURCES = uip/mhl.c uip/mhlsbr.c uip_mhl_LDADD = $(LDADD) $(TERMLIB) $(ICONVLIB) $(POSTLINK) + uip_mhlogin_SOURCES = uip/mhlogin.c + uip_mhlogin_LDADD = mts/libmts.a $(LDADD) $(CURLLIB) $(POSTLINK) + uip_mkstemp_SOURCES = uip/mkstemp.c uip_mkstemp_LDADD = $(LDADD) $(POSTLINK) uip_post_SOURCES = uip/post.c uip/aliasbr.c - uip_post_LDADD = mts/libmts.a $(LDADD) $(SASLLIB) $(TLSLIB) $(POSTLINK) + uip_post_LDADD = mts/libmts.a $(LDADD) $(SASLLIB) $(CURLLIB) $(TLSLIB) \ + $(POSTLINK) uip_rcvdist_SOURCES = uip/rcvdist.c uip/distsbr.c uip_rcvdist_LDADD = $(LDADD) $(TERMLIB) $(ICONVLIB) $(POSTLINK) @@@ -473,22 -485,25 +484,25 @@@ uip_viamail_SOURCES = uip/viamail.c uip uip/annosbr.c uip/distsbr.c uip_viamail_LDADD = $(LDADD) $(TERMLIB) $(ICONVLIB) $(POSTLINK) - test_getfullname_SOURCES = test/getfullname.c - test_getfullname_LDADD = $(LDADD) $(POSTLINK) - ## ## Other program definitions ## + test_getfullname_SOURCES = test/getfullname.c + test_getfullname_LDADD = $(LDADD) $(POSTLINK) + test_getcanon_SOURCES = test/getcanon.c test_getcanon_LDADD = $(POSTLINK) - test_fakepop_SOURCES = test/fakepop.c + test_fakepop_SOURCES = test/fakepop.c test/server.c test_fakepop_LDADD = $(POSTLINK) - test_fakesmtp_SOURCES = test/fakesmtp.c + test_fakesmtp_SOURCES = test/fakesmtp.c test/server.c test_fakesmtp_LDADD = $(POSTLINK) + test_fakehttp_SOURCES = test/fakehttp.c test/server.c + test_fakehttp_LDADD = $(POSTLINK) + test_getcwidth_SOURCES = test/getcwidth.c test_getcwidth_LDADD = $(POSTLINK) @@@ -505,6 -520,9 +519,6 @@@ etc_gen_ctype_checked_LDADD = $(POSTLIN config/version.c: Makefile $(srcdir)/config/version.sh env srcdir="$(srcdir)" sh $(srcdir)/config/version.sh $(VERSION) > ./config/version.c -sbr/sigmsg.h: $(srcdir)/sbr/sigmsg.awk $(SIGNAL_H) - $(AWK) -f $(srcdir)/sbr/sigmsg.awk $(SIGNAL_H) > $@ - sbr/ctype-checked.h: etc/gen-ctype-checked etc/gen-ctype-checked @@@ -583,7 -601,8 +597,8 @@@ sbr_libmh_a_SOURCES = sbr/addrsbr.c sbr sbr/folder_addmsg.c sbr/folder_delmsgs.c \ sbr/folder_free.c sbr/folder_pack.c \ sbr/folder_read.c sbr/folder_realloc.c sbr/read_switch.c \ - sbr/read_switch_multiword.c sbr/read_yes_or_no_if_tty.c sbr/getarguments.c \ + sbr/read_switch_multiword.c sbr/read_switch_multiword_via_readline.c \ + sbr/read_yes_or_no_if_tty.c sbr/getarguments.c \ sbr/getcpy.c sbr/geteditor.c sbr/getfolder.c \ sbr/getpass.c sbr/read_line.c \ sbr/fmt_addr.c sbr/fmt_compile.c sbr/fmt_new.c \ @@@ -609,8 -628,9 +624,9 @@@ sbr/trimcpy.c sbr/unquote.c \ sbr/uprf.c sbr/vfgets.c \ sbr/mf.c sbr/utils.c sbr/ctype-checked.c \ - sbr/m_mktemp.c sbr/read_switch_multiword_via_readline.c sbr/vector.c \ - config/config.c config/version.c + sbr/m_mktemp.c sbr/vector.c sbr/oauth.c sbr/oauth_prof.c \ + config/config.c config/version.c \ + thirdparty/jsmn/jsmn.c ## ## Because these files use the definitions in the libmh rule below, diff --combined configure.ac index ecba1395,94b2ec03..f8e69119 --- a/configure.ac +++ b/configure.ac @@@ -40,6 -40,10 +40,10 @@@ AS_IF([test x"$with_cyrus_sasl" != x - AC_MSG_WARN([Please pass the appropriate arguments to CPPFLAGS/LDFLAGS])]) sasl_support=yes], [sasl_support=no]) + dnl Do you want client-side support for using OAuth2 for SMTP authentication? + AC_ARG_WITH([oauth], AS_HELP_STRING([--with-oauth], + [Enable OAuth2 support in SMTP auth])) + dnl Do you want client-side support for encryption with TLS? AC_ARG_WITH([tls], AS_HELP_STRING([--with-tls], [Enable TLS support])) AS_IF([test x"$with_tls" != x"no"],[ @@@ -480,6 -484,49 +484,49 @@@ AS_IF([test x"$tls_support" = x"yes"], [TLSLIB=]) AC_SUBST([TLSLIB]) + dnl ----------------- + dnl CHECK FOR CURL + dnl ----------------- + dnl Look for curl if oauth not disabled (--without-oauth). + AC_PATH_PROG([curl_config], [curl-config]) + AS_IF([test "x$with_oauth" != xno && test -n "$curl_config"], [ + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS `$curl_config --cflags`" + AC_CHECK_HEADER([curl/curl.h], [ + HAVE_CURL_H=1 + AC_CHECK_LIB([curl], [curl_easy_init], [ + CURLLIB="`$curl_config --libs`" + AC_SUBST([CURLLIB]) + CURL_USER_AGENT="`$curl_config --version | sed 's|^libcurl *|libcurl/|; q'`" + AS_IF([test "x$CURL_USER_AGENT" != "x`echo $CURL_USER_AGENT | sed 's/ //'`"], + [AC_MSG_WARN([unexpected curl-config --version: $CURL_USER_AGENT]) + CURL_USER_AGENT=libcurl/UNKNOWN]) + echo "HEYEPG ($CURL_USER_AGENT)" + AC_SUBST([CURL_USER_AGENT]) + ]) + ], [ + CFLAGS="$save_CFLAGS" + ]) + ]) + + dnl ----------------- + dnl Enable OAuth? + dnl ----------------- + dnl By default (with_oauth=''), enable OAuth if curl is found. + dnl If OAuth requested (--with-oauth with_oauth=yes), error if curl not found. + dnl If OAuth disabled (--without-oauth with_oauth=no), don't enable it. + oauth_support=no + OAUTH_SUPPORT=0 + AC_SUBST([OAUTH_SUPPORT]) + AS_IF([test "x$with_oauth" = xyes && test "x$HAVE_CURL_H" = x], + [AC_MSG_ERROR([OAuth requested but curl/curl.h not found])], + [test "x$with_oauth" = xyes && test "x$CURLLIB" = x], + [AC_MSG_ERROR([OAuth requested but curl library not found])], + [test "x$with_oauth" != xno && test "x$HAVE_CURL_H" = x1 && test "x$CURLLIB" != x], + [AC_DEFINE([OAUTH_SUPPORT], [1], [Support OAuth2 in SMTP auth.]) + OAUTH_SUPPORT=1 + oauth_support=yes]) + dnl ---------------- dnl CHECK FLEX FIXUP dnl ---------------- @@@ -512,6 -559,24 +559,6 @@@ AC_CHECK_MEMBERS([struct tm.tm_gmtoff], AC_STRUCT_DIRENT_D_TYPE -dnl Where is located? Needed as input for signames.awk -AC_CACHE_CHECK(where signal.h is located, nmh_cv_path_signal_h, -[for SIGNAL_H in /usr/include/bsd/sys/signal.h dnl Next - /usr/include/asm/signal.h dnl Linux 1.3.0 and above - /usr/include/asm/signum.h dnl some versions of Linux/Alpha - /usr/include/linux/signal.h dnl Linux up to 1.2.11 - /usr/include/sys/signal.h dnl Almost everybody else - /dev/null; dnl Just in case we fall through -do - test -f $SIGNAL_H && \ - grep '#[ ]*define[ ][ ]*SIG[0-9A-Z]*[ ]*[0-9][0-9]*' $SIGNAL_H > /dev/null && \ - break -done -nmh_cv_path_signal_h=$SIGNAL_H -]) -SIGNAL_H=$nmh_cv_path_signal_h -AC_SUBST(SIGNAL_H)dnl - dnl dnl Sigh, this is required because under the new world order autoconf has dnl nothing to create in a few of the build directories when doing an object @@@ -560,6 -625,7 +607,7 @@@ spool default locking type : ${with_loc default smtp servers : ${smtpservers} SASL support : ${sasl_support} TLS support : ${tls_support} + OAuth support : ${oauth_support} ])])dnl dnl --------------- diff --combined test/common.sh.in index ae916194,7a4fc7aa..b2c7a7d7 --- a/test/common.sh.in +++ b/test/common.sh.in @@@ -11,6 -11,7 +11,7 @@@ test -d "$MH_OBJ_DIR/test/testdir" | test -z "$MH_TEST_DIR" && MH_TEST_DIR=`cd "$MH_OBJ_DIR/test/testdir" && pwd -P` export MH_TEST_DIR test -z "$MH_INST_DIR" && MH_INST_DIR="${MH_TEST_DIR}/inst" + test -z "$MH_VERSION" && MH_VERSION="@VERSION@" test -z "$prefix" && prefix=@prefix@ test -z "$datarootdir" && datarootdir=@datarootdir@ test -z "$exec_prefix" && exec_prefix=@exec_prefix@ @@@ -25,14 -26,16 +26,23 @@@ test -z "$supported_locks" && support test -z "$default_locking" && default_locking="@default_locking@" test -z "$MULTIBYTE_ENABLED" && MULTIBYTE_ENABLED="@MULTIBYTE_ENABLED@" test -z "$ICONV_ENABLED" && ICONV_ENABLED="@ICONV_ENABLED@" + test -z "$OAUTH_SUPPORT" && OAUTH_SUPPORT="@OAUTH_SUPPORT@" + test -z "$CURL_USER_AGENT" && CURL_USER_AGENT="@CURL_USER_AGENT@" + + #### If w3m is used, HOME needs to be set, assuming default w3m config. + #### So make sure that HOME is set to avoid run-time warning about not + #### being able to create config directory. + test -z "$HOME" && HOME=$MH_TEST_DIR + HOME=$MH_TEST_DIR + export HOME +#### If w3m is used, HOME needs to be set, assuming default w3m config. +#### So make sure that HOME is set to avoid run-time warning about not +#### being able to create config directory. +test -z "$HOME" && HOME=$MH_TEST_DIR +HOME=$MH_TEST_DIR +export HOME + unset MAILDROP MHBUILD MHCONTEXT MHMTSUSERCONF MHN MHSHOW MHSTORE unset MHLDEBUG MHPDEBUG MHWDEBUG PAGER #### Set LC_ALL in individual tests as needed. Unset these so