From e82b72bdd72f0b3ab3f5bc67840cbd65e98ef443 Mon Sep 17 00:00:00 2001 From: Paul Eggert
Date: Thu, 16 Mar 2017 23:50:37 -0700 Subject: [PATCH] Emacs 'movemail' is now a configure-time option The new configure option --with-mailutils lets the builder say that Emacs should assume that GNU Mailutils is installed, instead of continuing to build and install its own limited and insecure substitute for 'movemail'. * INSTALL, etc/NEWS, etc/PROBLEMS: Mention --with-mailutils. * configure.ac: Add --with-mailutils option. (with_mailutils): New variable. Do not bother configuring 'movemail' when not building it. Warn about issues relating to --with-mailutils. * doc/emacs/rmail.texi (Movemail): Mention --with-mailutils. (Movemail, Remote Mailboxes): Document port numbers in POP and IMAP URLs. * lib-src/Makefile.in (with_mailutils): New macro. (UTILITIES): Use it. --- INSTALL | 22 +++++-- configure.ac | 177 ++++++++++++++++++++++++++++++--------------------- doc/emacs/rmail.texi | 82 ++++++++++++------------ etc/NEWS | 6 ++ etc/PROBLEMS | 1 + lib-src/Makefile.in | 6 +- 6 files changed, 175 insertions(+), 119 deletions(-) diff --git a/INSTALL b/INSTALL index 10b1756..a99f107 100644 --- a/INSTALL +++ b/INSTALL @@ -259,12 +259,23 @@ inconvenient for Emacs when running as daemon or running via a remote ssh connection. In order to completely prevent the use of D-Bus, configure Emacs with the options '--without-dbus --without-gconf --without-gsettings'. +To read email via a network protocol like IMAP or POP, you can +configure Emacs with the option '--with-mailutils', so that it always +uses the GNU Mailutils 'movemail' program to retrieve mail. Otherwise +the Emacs build procedure builds and installs an auxiliary 'movemail' +program, a limited and insecure substitute that Emacs can use when +Mailutils is not installed; when this happens, there are several +configure options such as --without-pop that provide fine-grained +control over Emacs 'movemail' construction. + The Emacs mail reader RMAIL is configured to be able to read mail from a POP3 server by default. Versions of the POP protocol older than -POP3 are not supported. For Kerberos-authenticated POP add -'--with-kerberos', for Hesiod support add '--with-hesiod'. While POP3 -is always enabled, whether Emacs actually uses POP is controlled by -individual users--see the Rmail chapter of the Emacs manual. +POP3 are not supported. While POP3 support is typically enabled, +whether Emacs actually uses POP3 is controlled by individual users; +see the Rmail chapter of the Emacs manual. Unless you configure +--with-mailutils, it is a good idea to configure --without-pop so that +users are less likely to inadvertently read email via insecure +channels. For image support you may have to download, build, and install the appropriate image support libraries for image types other than XBM and @@ -538,7 +549,8 @@ information on this. Emacs info files. 8) If your system uses lock files to interlock access to mailer inbox files, -then you might need to make the movemail program setuid or setgid +and if you did not configure --with-mailutils, then you might need to +make the Emacs-specific 'movemail' program setuid or setgid in order to enable it to write the lock files. We believe this is safe. 9) You are done! You can remove executables and object files from diff --git a/configure.ac b/configure.ac index 4d9ba96..47d0e5c 100644 --- a/configure.ac +++ b/configure.ac @@ -240,6 +240,18 @@ AC_DEFUN m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=$with_features])dnl ])dnl +# FIXME: The default options '--without-mailutils --with-pop' result +# in a movemail implementation that supports only unencrypted POP3 +# connections. Encrypted connections should be the default. + +OPTION_DEFAULT_OFF([mailutils], + [rely on GNU Mailutils being installed; this makes the options + --without-pop through --with-mailhost irrelevant)]) +if test "$with_mailutils" = no; then + with_mailutils= +fi +AC_SUBST([with_mailutils]) + OPTION_DEFAULT_ON([pop],[don't support POP mail retrieval with movemail]) if test "$with_pop" = yes; then AC_DEFINE(MAIL_USE_POP) @@ -3789,87 +3801,91 @@ AC_DEFUN AC_SUBST(LIBXML2_LIBS) AC_SUBST(LIBXML2_CFLAGS) -# Check for mail-locking functions in a "mail" library. Probably this should -# have the same check as for liblockfile below. -AC_CHECK_LIB(mail, maillock, have_mail=yes, have_mail=no) -if test $have_mail = yes; then - LIBS_MAIL=-lmail - AC_DEFINE(HAVE_LIBMAIL, 1, [Define to 1 if you have the 'mail' library (-lmail).]) - - OLD_LIBS=$LIBS - LIBS="$LIBS_MAIL $LIBS" - AC_CHECK_FUNCS(touchlock) - LIBS=$OLD_LIBS -else - LIBS_MAIL= -fi -dnl Debian, at least: -AC_CHECK_LIB(lockfile, maillock, have_lockfile=yes, have_lockfile=no) -if test $have_lockfile = yes; then - LIBS_MAIL=-llockfile - AC_DEFINE(HAVE_LIBLOCKFILE, 1, [Define to 1 if you have the 'lockfile' library (-llockfile).]) -else -# If we have the shared liblockfile, assume we must use it for mail -# locking (e.g. Debian). If we couldn't link against liblockfile -# (no liblockfile.a installed), ensure that we don't need to. - dnl This works for files generally, not just executables. - dnl Should we look elsewhere for it? Maybe examine /etc/ld.so.conf? - AC_CHECK_PROG(liblockfile, liblockfile.so, yes, no, - /usr/lib:/lib:/usr/local/lib:$LD_LIBRARY_PATH) - if test $ac_cv_prog_liblockfile = yes; then - AC_MSG_ERROR([Shared liblockfile found but can't link against it. +BLESSMAIL_TARGET= +LIBS_MAIL= +if test ! "$with_mailutils"; then + # Check for mail-locking functions in a "mail" library. Probably this should + # have the same check as for liblockfile below. + AC_CHECK_LIB([mail], [maillock], [have_mail=yes], [have_mail=no]) + if test $have_mail = yes; then + LIBS_MAIL=-lmail + AC_DEFINE([HAVE_LIBMAIL], [1], + [Define to 1 if you have the 'mail' library (-lmail).]) + + OLD_LIBS=$LIBS + LIBS="$LIBS_MAIL $LIBS" + AC_CHECK_FUNCS([touchlock]) + LIBS=$OLD_LIBS + fi + dnl Debian, at least: + AC_CHECK_LIB([lockfile], [maillock], [have_lockfile=yes], [have_lockfile=no]) + if test $have_lockfile = yes; then + LIBS_MAIL=-llockfile + AC_DEFINE([HAVE_LIBLOCKFILE], [1], + [Define to 1 if you have the 'lockfile' library (-llockfile).]) + else + # If we have the shared liblockfile, assume we must use it for mail + # locking (e.g. Debian). If we couldn't link against liblockfile + # (no liblockfile.a installed), ensure that we don't need to. + dnl This works for files generally, not just executables. + dnl Should we look elsewhere for it? Maybe examine /etc/ld.so.conf? + AC_CHECK_PROG([liblockfile], [liblockfile.so], [yes], [no], + [/usr/lib:/lib:/usr/local/lib:$LD_LIBRARY_PATH]) + if test "$ac_cv_prog_liblockfile" = yes; then + AC_MSG_ERROR([Shared liblockfile found but can't link against it. This probably means that movemail could lose mail. There may be a 'development' package to install containing liblockfile.]) + fi fi -fi -AC_CHECK_HEADERS_ONCE(maillock.h) -AC_SUBST(LIBS_MAIL) + AC_CHECK_HEADERS([maillock.h]) -## Define MAIL_USE_FLOCK (or LOCKF) if the mailer uses flock (or lockf) to -## interlock access to the mail spool. The alternative is a lock file named -## /usr/spool/mail/$USER.lock. -mail_lock=no -case "$opsys" in - aix4-2) mail_lock="lockf" ;; - - gnu|freebsd|dragonfly|netbsd|openbsd|darwin) mail_lock="flock" ;; - - ## On GNU/Linux systems, both methods are used by various mail programs. - ## I assume most people are using newer mailers that have heard of flock. - ## Change this if you need to. - ## Debian contains a patch which says: "On Debian/GNU/Linux systems, - ## configure gets the right answers, and that means *NOT* using flock. - ## Using flock is guaranteed to be the wrong thing. See Debian Policy - ## for details." and then uses '#ifdef DEBIAN'. Unfortunately the - ## Debian maintainer hasn't provided a clean fix for Emacs. - ## movemail.c will use 'maillock' when MAILDIR, HAVE_LIBMAIL and - ## HAVE_MAILLOCK_H are defined, so the following appears to be the - ## correct logic. -- fx - ## We must check for HAVE_LIBLOCKFILE too, as movemail does. - ## liblockfile is a Free Software replacement for libmail, used on - ## Debian systems and elsewhere. -rfr. - gnu-*) - mail_lock="flock" - if test $have_mail = yes || test $have_lockfile = yes; then - test $ac_cv_header_maillock_h = yes && mail_lock=no - fi - ;; + ## Define MAIL_USE_FLOCK (or LOCKF) if the mailer uses flock (or lockf) to + ## interlock access to the mail spool. The alternative is a lock file named + ## /usr/spool/mail/$USER.lock. + mail_lock=no + case $opsys in + aix4-2) mail_lock="lockf" ;; + + gnu|freebsd|dragonfly|netbsd|openbsd|darwin) mail_lock="flock" ;; + + ## On GNU/Linux systems, both methods are used by various mail programs. + ## I assume most people are using newer mailers that have heard of flock. + ## Change this if you need to. + ## Debian contains a patch which says: "On Debian/GNU/Linux systems, + ## configure gets the right answers, and that means *NOT* using flock. + ## Using flock is guaranteed to be the wrong thing. See Debian Policy + ## for details." and then uses '#ifdef DEBIAN'. Unfortunately the + ## Debian maintainer hasn't provided a clean fix for Emacs. + ## movemail.c will use 'maillock' when MAILDIR, HAVE_LIBMAIL and + ## HAVE_MAILLOCK_H are defined, so the following appears to be the + ## correct logic. -- fx + ## We must check for HAVE_LIBLOCKFILE too, as movemail does. + ## liblockfile is a Free Software replacement for libmail, used on + ## Debian systems and elsewhere. -rfr. + gnu-*) + mail_lock="flock" + if test $have_mail = yes || test $have_lockfile = yes; then + test $ac_cv_header_maillock_h = yes && mail_lock=no + fi ;; - mingw32) - mail_lock="none-needed" ;; -esac + mingw32) + mail_lock="none-needed" ;; + esac -BLESSMAIL_TARGET= -case "$mail_lock" in - flock) AC_DEFINE(MAIL_USE_FLOCK, 1, [Define if the mailer uses flock to interlock the mail spool.]) ;; + case $mail_lock in + flock) AC_DEFINE([MAIL_USE_FLOCK], [1], + [Define if the mailer uses flock to interlock the mail spool.]);; - lockf) AC_DEFINE(MAIL_USE_LOCKF, 1, [Define if the mailer uses lockf to interlock the mail spool.]) ;; + lockf) AC_DEFINE([MAIL_USE_LOCKF], [1], + [Define if the mailer uses lockf to interlock the mail spool.]);; - none-needed) ;; + none-needed) ;; - *) BLESSMAIL_TARGET="need-blessmail" ;; -esac -AC_SUBST(BLESSMAIL_TARGET) + *) BLESSMAIL_TARGET="need-blessmail" ;; + esac +fi +AC_SUBST([BLESSMAIL_TARGET]) +AC_SUBST([LIBS_MAIL]) OLD_LIBS=$LIBS LIBS="$LIB_PTHREAD $LIB_MATH $LIBS" @@ -5469,4 +5485,21 @@ AC_DEFUN AC_OUTPUT +if test ! "$with_mailutils"; then + emacs_use_mailutils="use '$0 --with-mailutils'" + case `(movemail --version) 2>/dev/null` in + *Mailutils*) ;; + *) emacs_use_mailutils="install GNU Mailutils +