From: Richard Russon Date: Wed, 3 May 2017 13:38:10 +0000 (+0100) Subject: build: make dotlock optional X-Git-Tag: neomutt-20170526~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=693fad755043f57744570fcecc8782a364a3c60c;p=neomutt build: make dotlock optional --- diff --git a/Makefile.am b/Makefile.am index ab0a24c50..4e23fbfbf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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) diff --git a/configure.ac b/configure.ac index 497bc83ba..08caad5cf 100644 --- a/configure.ac +++ b/configure.ac @@ -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 -#include -#include -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 -#include -#include -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 diff --git a/doc/makedoc_defs.h b/doc/makedoc_defs.h index 19225e58d..a0a62c5a9 100644 --- a/doc/makedoc_defs.h +++ b/doc/makedoc_defs.h @@ -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 diff --git a/dotlock.c b/dotlock.c index 12a6f5823..d2506bea5 100644 --- a/dotlock.c +++ b/dotlock.c @@ -16,13 +16,6 @@ * this program. If not, see . */ -/* - * 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 #include @@ -40,14 +33,10 @@ #ifndef _POSIX_PATH_MAX #include #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 @@ -74,23 +63,10 @@ #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 diff --git a/dotlock.h b/dotlock.h index 50304fd14..d7bdfc5bd 100644 --- 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 */ diff --git a/globals.h b/globals.h index 9d250336e..1b6014c14 100644 --- 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 af9e6eea9..02a0f27c8 100644 --- 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 a6bb9713b..07b96b029 100644 --- 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; diff --git a/version.c b/version.c index 0554038ad..2967bdc3f 100644 --- 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