diff options
author | Gilles Chehade <gilles@poolp.org> | 2016-09-14 09:23:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-14 09:23:27 +0200 |
commit | 08d91c173f2338084f6a17198bf67ffb2e51774c (patch) | |
tree | ef9fa105116792b132533e2f6d526f3018300e94 | |
parent | Merge branch 'master' into portable (diff) | |
parent | fix path-pidfile (diff) | |
download | OpenSMTPD-08d91c173f2338084f6a17198bf67ffb2e51774c.tar.xz OpenSMTPD-08d91c173f2338084f6a17198bf67ffb2e51774c.zip |
Merge pull request #718 from bsdsx/piddiropensmtpd-201609141253p1
Piddir
-rw-r--r-- | configure.ac | 48 | ||||
-rw-r--r-- | openbsd-compat/defines.h | 4 | ||||
-rw-r--r-- | openbsd-compat/pidfile.c | 6 |
3 files changed, 45 insertions, 13 deletions
diff --git a/configure.ac b/configure.ac index e28ee2f5..2cfecc42 100644 --- a/configure.ac +++ b/configure.ac @@ -1197,13 +1197,51 @@ AC_SUBST([sockdir]) #l4470 # Where to place smtpd.pid +piddir=/var/run +AC_RUN_IFELSE( + [ + AC_LANG_PROGRAM([[ +#include <stdio.h> +#include <stdlib.h> +#ifdef HAVE_PATHS_H +#include <paths.h> +#endif +#define DATA "conftest.piddir" + ]], + [[ +#ifdef _PATH_VARRUN +FILE *fd; +int rc; + +if ((fd = fopen(DATA,"w")) == NULL) { exit(1); } +if ((rc = fprintf(fd ,"%s\n", _PATH_VARRUN)) < 0) { exit(2); } +exit(0); +#else +exit(-1); +#endif + ]]) + ], [ + piddir=`cat conftest.piddir` + AC_MSG_RESULT([using $piddir from paths.h]) + ], + [ + AC_MSG_RESULT([using $piddir from default value]) + ] +) + AC_ARG_WITH([path-pidfile], - [ --with-path-pidfile=PATH Specify path to smtpd.pid directory (default=/var/run)], - [AS_IF([test "x$with_path-pidfile" != "xno" -a "x$with_path-pidfile" != "xyes"], - AC_DEFINE_UNQUOTED([_PATH_VARRUN], ["$with_path-pidfile"], ["path to pidfile directory"]) - )] + [ --with-path-pidfile=PATH Specify path to smtpd.pid directory (default=/var/run)], + [ + if test -n "$withval" && test "x$withval" != "xno" && \ + test "x${withval}" != "xyes"; then + piddir=$withval + fi + ] ) +AC_DEFINE_UNQUOTED([SMTPD_PIDDIR], ["$piddir"], [Specify location of smtpd.pid]) +AC_SUBST([piddir]) + CA_FILE=/etc/ssl/cert.pem AC_ARG_WITH([path-CAfile], [ --with-path-CAfile=FILE Specify path to CA certificate (default=/etc/ssl/cert.pem)], @@ -2095,6 +2133,7 @@ H=`eval echo ${sockdir}` ; H=`eval echo ${H}` I=`eval echo ${PRIVSEP_PATH}` ; I=`eval echo ${I}` J=`eval echo ${user_path}` ; J=`eval echo ${J}` K=`eval echo ${superuser_path}` ; K=`eval echo ${K}` +L=`eval echo ${piddir}` ; L=`eval echo ${L}` echo "" echo "OpenSMTPD has been configured with the following options:" @@ -2105,6 +2144,7 @@ echo " mail.local program: $E" echo " encrypt program: $F" echo " Manual pages: $G" echo " smtpd.sock dir: $H" +echo " smtpd.pid dir: $L" echo " Privilege separation chroot path: $I" echo " Manpage format: $MANTYPE" echo " Package libexecdir: ${pkglibexecdir}" diff --git a/openbsd-compat/defines.h b/openbsd-compat/defines.h index 8d913f4c..0a94d76e 100644 --- a/openbsd-compat/defines.h +++ b/openbsd-compat/defines.h @@ -497,10 +497,6 @@ typedef uint16_t in_port_t; #define FPARSELN_UNESCALL 0x0f #endif -#ifndef _PATH_VARRUN -#define _PATH_VARRUN "/var/run/" -#endif - #ifdef HAVE_M_DATA #undef M_DATA #endif diff --git a/openbsd-compat/pidfile.c b/openbsd-compat/pidfile.c index 386677e2..d6f83880 100644 --- a/openbsd-compat/pidfile.c +++ b/openbsd-compat/pidfile.c @@ -37,9 +37,6 @@ #include <sys/param.h> #include <errno.h> -#ifdef HAVE_PATHS_H -#include <paths.h> -#endif #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -66,8 +63,7 @@ pidfile(const char *basename) pidfile_path = NULL; } - /* _PATH_VARRUN includes trailing / */ - (void) asprintf(&pidfile_path, "%s%s.pid", _PATH_VARRUN, basename); + (void) asprintf(&pidfile_path, "%s/%s.pid", SMTPD_PIDDIR, basename); if (pidfile_path == NULL) return (-1); |