]> granicus.if.org Git - neomutt/commitdiff
build: make dotlock optional
authorRichard Russon <rich@flatcap.org>
Wed, 3 May 2017 13:38:10 +0000 (14:38 +0100)
committerRichard Russon <rich@flatcap.org>
Fri, 12 May 2017 13:05:59 +0000 (14:05 +0100)
Makefile.am
configure.ac
doc/makedoc_defs.h
dotlock.c
dotlock.h
globals.h
init.h
mx.c
version.c

index ab0a24c502b215ad5ed8a20c4cab53e855ce8969..4e23fbfbf365d2ca01cfd5f867fe62cf743987d0 100644 (file)
@@ -32,6 +32,9 @@ if BUILD_HCACHE
 HCVERSION = hcversion.h
 endif
 
+DOTLOCK_GROUP='mail'
+DOTLOCK_PERMISSION='2755'
+
 distdir = neo$(PACKAGE)-$(VERSION)
 
 BUILT_SOURCES = keymap_defs.h keymap_alldefs.h patchlist.c git_ver.h conststrings.c hcachever.sh $(HCVERSION)
index 497bc83ba2e38519d03a4b712fcbf67a5306b366..08caad5cfa198a05372c110e6e32a3839404867a 100644 (file)
@@ -461,6 +461,7 @@ AC_CHECK_FUNCS(futimens)
 
 AC_ARG_WITH(homespool,
        AS_HELP_STRING([--with-homespool@<:@=FILE@:>@],[File in user's directory where new mail is spooled]), with_homespool=${withval})
+
 if test x$with_homespool != x; then
        if test $with_homespool = yes; then
                with_homespool=mailbox
@@ -471,76 +472,17 @@ if test x$with_homespool != x; then
                MAILPATH should be set to the filename of the spool mailbox
                relative the the home directory.
                use: configure --with-homespool=FILE])
-       AC_DEFINE(USE_DOTLOCK,1,[ Define to use dotlocking for mailboxes. ])
-       mutt_cv_setgid=no
 else
        AC_ARG_WITH(mailpath, AS_HELP_STRING([--with-mailpath=DIR],[Directory where spool mailboxes are located]),
-               [mutt_cv_mailpath=$withval],
-               [ AC_CACHE_CHECK(where new mail is stored, mutt_cv_mailpath,
-                       [mutt_cv_mailpath=no
-                       if test -d /var/mail; then
-                               mutt_cv_mailpath=/var/mail
-                       elif test -d /var/spool/mail; then
-                               mutt_cv_mailpath=/var/spool/mail
-                       elif test -d /usr/spool/mail; then
-                               mutt_cv_mailpath=/usr/spool/mail
-                       elif test -d /usr/mail; then
-                               mutt_cv_mailpath=/usr/mail
-                       fi])
-               ])
-       if test "$mutt_cv_mailpath" = no; then
-               AC_MSG_ERROR("Could not determine where new mail is stored.")
-       fi
+               [mutt_cv_mailpath=$withval], [mutt_cv_mailpath=/var/mail])
        AC_DEFINE_UNQUOTED(MAILPATH,"$mutt_cv_mailpath",[ Where new mail is spooled. ])
-
-       AC_CACHE_CHECK(if $mutt_cv_mailpath is world writable, mutt_cv_worldwrite, [AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-int main (int argc, char **argv)
-{
-  struct stat s;
-  if (stat ("$mutt_cv_mailpath", &s)) exit (1);
-  if (s.st_mode & S_IWOTH) exit (0);
-  exit (1);
-}]])],[mutt_cv_worldwrite=yes],[mutt_cv_worldwrite=no],[mutt_cv_worldwrite=no])])
-
-       mutt_cv_setgid=no
-       if test $mutt_cv_worldwrite = yes; then
-               AC_DEFINE(USE_DOTLOCK,1,[ Define to use dotlocking for mailboxes. ])
-       else
-
-               AC_CACHE_CHECK(if $mutt_cv_mailpath is group writable, mutt_cv_groupwrite, [AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-int main (int argc, char **argv)
-{
-  struct stat s;
-  if (stat ("$mutt_cv_mailpath", &s)) exit (1);
-  if (s.st_mode & S_IWGRP) exit (0);
-  exit (1);
-}]])],[mutt_cv_groupwrite=yes],[mutt_cv_groupwrite=no],[mutt_cv_groupwrite=no])])
-
-               if test $mutt_cv_groupwrite = yes; then
-                       AC_DEFINE(USE_DOTLOCK,1,[ Define to use dotlocking for mailboxes. ])
-                       AC_DEFINE(USE_SETGID,1,[ Define if mutt should run setgid "mail". ])
-                       mutt_cv_setgid=yes
-               fi
-       fi
 fi
 
-AC_ARG_ENABLE(external_dotlock, AS_HELP_STRING([--enable-external-dotlock],[Force use of an external dotlock program]),
-       [mutt_cv_external_dotlock="$enableval"])
-
-if test "x$mutt_cv_setgid" = "xyes" || test "x$mutt_cv_fchdir" = "xno" \
-       || test "x$mutt_cv_external_dotlock" = "xyes"; then
-       AC_DEFINE(DL_STANDALONE,1,[ Define if you want to use an external dotlocking program. ])
+AC_ARG_ENABLE(dotlock, AS_HELP_STRING([--enable-dotlock],[Define to build mutt_dotlock.]), [build_dotlock=$enableval])
+if test "x$build_dotlock" = "xyes"; then
+       AC_DEFINE(USE_DOTLOCK,1, [ Define to use dotlock to lock mailboxes. ])
        DOTLOCK_TARGET="mutt_dotlock\$(EXEEXT)"
-else
-       MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS dotlock.o"
 fi
-
 AC_SUBST(DOTLOCK_TARGET)
 
 dnl autoconf <2.60 compatibility
@@ -559,16 +501,6 @@ if test -z "$docdir" -o -n "$with_docdir"; then
 fi
 AC_SUBST(docdir)
 
-if test x$mutt_cv_setgid = xyes; then
-       DOTLOCK_GROUP='mail'
-       DOTLOCK_PERMISSION=2755
-else
-       DOTLOCK_GROUP=''
-       DOTLOCK_PERMISSION=755
-fi
-AC_SUBST(DOTLOCK_GROUP)
-AC_SUBST(DOTLOCK_PERMISSION)
-
 AC_ARG_WITH(domain, AS_HELP_STRING([--with-domain=DOMAIN],[Specify your DNS domain name]),
        [if test $withval != yes; then
                if test $withval != no; then
index 19225e58db2a32235174e440f4394b6c017e6daa..a0a62c5a931cc7a803e0f940771c990d8f5e0351 100644 (file)
@@ -52,9 +52,6 @@
 #ifndef USE_DOTLOCK
 #define USE_DOTLOCK
 #endif
-#ifndef DL_STANDALONE
-#define DL_STANDALONE
-#endif
 #ifndef USE_HCACHE
 #define USE_HCACHE
 #endif
index 12a6f58235ab1fc13223a6aefb6a7154af130750..d2506bea5915c8c2c9199a3180b5694744e0aa3d 100644 (file)
--- a/dotlock.c
+++ b/dotlock.c
  * this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/*
- * This module either be compiled into Mutt, or it can be
- * built as a separate program. For building it
- * separately, define the DL_STANDALONE preprocessor
- * macro.
- */
-
 #include "config.h"
 #include <dirent.h>
 #include <errno.h>
 #ifndef _POSIX_PATH_MAX
 #include <limits.h>
 #endif
-#ifdef DL_STANDALONE
 #include "git_ver.h"
-#endif
 
 #define MAXLINKS 1024 /* maximum link depth */
 
-#ifdef DL_STANDALONE
-
 #define LONG_STRING 1024
 #define MAXLOCKATTEMPT 5
 
 
 #endif
 
-#else /* DL_STANDALONE */
-
-#ifdef USE_SETGID
-#error Do not try to compile dotlock as a mutt module when requiring egid switching!
-#endif
-
-#include "mutt.h"
-#include "mx.h"
-
-#endif /* DL_STANDALONE */
-
 static int DotlockFlags;
 static int Retry = MAXLOCKATTEMPT;
 
-#ifdef DL_STANDALONE
 struct utsname utsname;
-#endif
 
 #ifdef USE_SETGID
 static gid_t UserGid;
@@ -103,7 +79,6 @@ static gid_t MailGid;
  * return value.
  */
 
-#ifdef DL_STANDALONE
 /*
  * Determine our effective group ID, and drop
  * privileges.
@@ -128,7 +103,6 @@ static int dotlock_init_privs(void)
 
   return 0;
 }
-#endif /* DL_STANDALONE */
 
 /*
  * Get privileges
@@ -174,7 +148,6 @@ static void END_PRIVILEGED(void)
 #endif
 }
 
-#ifdef DL_STANDALONE
 /*
  * Usage information.
  *
@@ -201,7 +174,6 @@ static void usage(const char *av0)
 
   exit(DL_EX_ERROR);
 }
-#endif
 
 /*
  * Access checking: Let's avoid to lock other users' mail
@@ -449,12 +421,7 @@ static int dotlock_lock(const char *realpath)
   time_t t;
 
   snprintf(nfslockfile, sizeof(nfslockfile), "%s.%s.%d", realpath,
-#ifdef DL_STANDALONE
-           utsname.nodename,
-#else
-           Hostname,
-#endif
-           (int) getpid());
+           utsname.nodename, (int) getpid());
   snprintf(lockfile, sizeof(lockfile), "%s.lock", realpath);
 
   BEGIN_PRIVILEGED();
@@ -605,38 +572,6 @@ static int dotlock_dispatch(const char *f, int fd)
     return dotlock_lock(realpath);
 }
 
-#ifndef DL_STANDALONE
-/*
- * This function is intended to be invoked from within
- * mutt instead of mx.c's invoke_dotlock ().
- */
-int dotlock_invoke(const char *path, int fd, int flags, int retry)
-{
-  int currdir;
-  int r;
-
-  DotlockFlags = flags;
-
-  if ((currdir = open(".", O_RDONLY)) == -1)
-    return DL_EX_ERROR;
-
-  if (!(DotlockFlags & DL_FL_RETRY) || retry)
-    Retry = MAXLOCKATTEMPT;
-  else
-    Retry = 0;
-
-  r = dotlock_dispatch(path, fd);
-
-  fchdir(currdir);
-  close(currdir);
-
-  return r;
-}
-#endif /* !DL_STANDALONE */
-
-
-#ifdef DL_STANDALONE
-
 #define check_flags(a)                                                         \
   if (a & DL_FL_ACTIONS)                                                       \
   usage(argv[0])
@@ -700,4 +635,3 @@ int main(int argc, char **argv)
 
   return dotlock_dispatch(argv[optind], -1);
 }
-#endif
index 50304fd144f650fc946fb9326314c9b7b462b204..d7bdfc5bdff757046210e215607933719825ea4b 100644 (file)
--- a/dotlock.h
+++ b/dotlock.h
@@ -38,8 +38,4 @@
 
 #define DL_FL_ACTIONS (DL_FL_TRY | DL_FL_UNLOCK | DL_FL_UNLINK)
 
-#ifndef DL_STANDALONE
-int dotlock_invoke(const char *, int, int, int);
-#endif
-
 #endif /* _MUTT_DOTLOCK_H */
index 9d250336ecee2ef004a1e73306273d0d62c073ee..1b6014c145e71c8671c67cf2c36f15a4358daecf 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -26,7 +26,7 @@ WHERE CONTEXT *Context;
 WHERE char Errorbuf[STRING];
 WHERE char AttachmentMarker[STRING];
 
-#if defined(DL_STANDALONE) && defined(USE_DOTLOCK)
+#ifdef USE_DOTLOCK
 WHERE char *MuttDotlock;
 #endif
 
diff --git a/init.h b/init.h
index af9e6eea9a8a9b48291d381393827c162b609efa..02a0f27c8e59f7ac91bd2c036ad9c8faa979b8e9 100644 (file)
--- a/init.h
+++ b/init.h
@@ -712,7 +712,7 @@ struct option_t MuttVars[] = {
   ** is viewed it is passed as standard input to $$display_filter, and the
   ** filtered message is read from the standard output.
   */
-#if defined(DL_STANDALONE) && defined(USE_DOTLOCK)
+#ifdef USE_DOTLOCK
   { "dotlock_program",  DT_PATH, R_NONE, UL &MuttDotlock, UL BINDIR "/mutt_dotlock" },
   /*
   ** .pp
diff --git a/mx.c b/mx.c
index a6bb9713bff365d4487c7e5c8644cf19630a93eb..07b96b0296412439d1dc4147b3340f86920ff491 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -103,9 +103,6 @@ struct mx_ops *mx_get_ops(int magic)
  * path - file to lock
  * retry - should retry if unable to lock?
  */
-
-#ifdef DL_STANDALONE
-
 static int invoke_dotlock(const char *path, int dummy, int flags, int retry)
 {
   char cmd[LONG_STRING + _POSIX_PATH_MAX];
@@ -125,12 +122,6 @@ static int invoke_dotlock(const char *path, int dummy, int flags, int retry)
   return mutt_system(cmd);
 }
 
-#else
-
-#define invoke_dotlock dotlock_invoke
-
-#endif
-
 static int dotlock_file(const char *path, int fd, int retry)
 {
   int r;
index 0554038ad96596a6a50b54fa01c51e68b7c13747..2967bdc3fe4aa53b11f08837b738646f3101fd62 100644 (file)
--- a/version.c
+++ b/version.c
@@ -114,11 +114,6 @@ static struct compile_options comp_opts[] = {
 #else
   { "DEBUG", 0 },
 #endif
-#ifdef DL_STANDALONE
-  { "DL_STANDALONE", 1 },
-#else
-  { "DL_STANDALONE", 0 },
-#endif
 #ifdef ENABLE_NLS
   { "ENABLE_NLS", 1 },
 #else