* please see the file GPL in the top level source directory.
*/
-/*
- * 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.
- */
-
#if HAVE_CONFIG_H
# include "config.h"
#endif
#define MAXLINKS 1024 /* maximum link depth */
-#ifdef DL_STANDALONE
-
# define LONG_STRING 1024
# define MAXLOCKATTEMPT 5
extern int snprintf (char *, size_t, const char *, ...);
# 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 */
-
#include <lib-lib/str.h>
static int DotlockFlags;
static int Retry = MAXLOCKATTEMPT;
-#ifdef DL_STANDALONE
static char *Hostname;
-#endif
#ifdef USE_SETGID
static gid_t UserGid;
static int dotlock_check_stats (struct stat *, struct stat *);
static int dotlock_dispatch (const char *, int fd);
-#ifdef DL_STANDALONE
static int dotlock_init_privs (void);
static void usage (const char *);
-#endif
static void dotlock_expand_link (char *, const char *, const char *);
static void BEGIN_PRIVILEGED (void);
static int dotlock_lock (const char *);
-#ifdef DL_STANDALONE
-
#define check_flags(a) if (a & DL_FL_ACTIONS) usage (argv[0])
int main (int argc, char **argv)
}
-#else /* 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 */
-
-
static int dotlock_dispatch (const char *f, int fd)
{
char realpath[_POSIX_PATH_MAX];
#endif
}
-#ifdef DL_STANDALONE
-
/*
* Usage information.
*
exit (DL_EX_ERROR);
}
-#endif
-
/*
* Access checking: Let's avoid to lock other users' mail
* spool files if we aren't permitted to read them.