diff options
author | Gilles Chehade <gilles@poolp.org> | 2019-11-17 21:17:23 +0100 |
---|---|---|
committer | Gilles Chehade <gilles@poolp.org> | 2019-11-17 21:17:23 +0100 |
commit | 34671dfe3ffc22a20d0032ceea5f96bc979ad917 (patch) | |
tree | f6af0cf86d575f31b7fa2e23eeec2aedfc82db7f | |
parent | missing AM_CONDITIONAL (diff) | |
download | OpenSMTPD-34671dfe3ffc22a20d0032ceea5f96bc979ad917.tar.xz OpenSMTPD-34671dfe3ffc22a20d0032ceea5f96bc979ad917.zip |
conditionally build progname
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | openbsd-compat/Makefile.am | 5 | ||||
-rw-r--r-- | openbsd-compat/bsd-misc.h | 14 | ||||
-rw-r--r-- | openbsd-compat/openbsd-compat.h | 18 | ||||
-rw-r--r-- | openbsd-compat/progname.c (renamed from openbsd-compat/bsd-misc.c) | 6 | ||||
-rw-r--r-- | smtpd/smtpctl.c | 2 | ||||
-rw-r--r-- | smtpd/smtpd.c | 6 |
7 files changed, 30 insertions, 23 deletions
diff --git a/configure.ac b/configure.ac index c98c2af4..2febfdfb 100644 --- a/configure.ac +++ b/configure.ac @@ -2057,6 +2057,8 @@ AM_CONDITIONAL([NEED_USLEEP], [test "x$ac_cv_func_usleep" != "xyes"]) AM_CONDITIONAL([NEED_ARC4RANDOM], [test "x$ac_cv_func_arc4random" != "xyes" -a "x$ac_cv_have_decl_LIBRESSL_VERSION_NUMBER" != "xyes"]) AM_CONDITIONAL([NEED_SSL_CTX_USE_CERTIFICATE_CHAIN_MEM], [test "x$ac_cv_have_decl_LIBRESSL_VERSION_NUMBER" != "xyes"]) + +AM_CONDITIONAL([NEED_PROGNAME], [test "x$ac_cv_libc_defines___progname" != "xyes"]) ## diff --git a/openbsd-compat/Makefile.am b/openbsd-compat/Makefile.am index 0c4b900f..9993ec3b 100644 --- a/openbsd-compat/Makefile.am +++ b/openbsd-compat/Makefile.am @@ -2,8 +2,9 @@ noinst_LIBRARIES = libopenbsd-compat.a libopenbsd_compat_a_SOURCES = empty.c -libopenbsd_compat_a_SOURCES += bsd-misc.c - +if NEED_PROGNAME +libopenbsd_compat_a_SOURCES += progname.c +endif if NEED_ARC4RANDOM libopenbsd_compat_a_SOURCES += arc4random.c diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h index d90653ab..c638462d 100644 --- a/openbsd-compat/bsd-misc.h +++ b/openbsd-compat/bsd-misc.h @@ -21,18 +21,4 @@ #include "includes.h" -char *ssh_get_progname(char *); - -#ifndef HAVE_SETSID -#define setsid() setpgrp(0, getpid()) -#endif /* !HAVE_SETSID */ - -#if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) -int seteuid(uid_t); -#endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */ - -#if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) -int setegid(uid_t); -#endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */ - #endif /* _BSD_MISC_H */ diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h index be9b90e1..b59ac6e8 100644 --- a/openbsd-compat/openbsd-compat.h +++ b/openbsd-compat/openbsd-compat.h @@ -308,6 +308,18 @@ struct timespec { int nanosleep(const struct timespec *, struct timespec *); #endif +#ifdef NEED_SETEGID +int setegid(uid_t); +#endif + +#ifdef NEED_SETEUID +int seteuid(uid_t); +#endif + +#ifdef NEED_SETSID +#define setsid() setpgrp(0, getpid()) +#endif + #ifdef NEED_SIGNAL typedef void (*mysig_t)(int); mysig_t mysignal(int sig, mysig_t act); @@ -322,4 +334,10 @@ const char *strerror(int); int usleep(unsigned int useconds); #endif +char *get_progname(char *); + + + + + #endif /* _OPENBSD_COMPAT_H */ diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/progname.c index 67a45351..b8b9ae30 100644 --- a/openbsd-compat/bsd-misc.c +++ b/openbsd-compat/progname.c @@ -32,15 +32,11 @@ #include <time.h> #include <unistd.h> -#ifndef HAVE___PROGNAME -char *__progname; -#endif - /* * NB. duplicate __progname in case it is an alias for argv[0] * Otherwise it may get clobbered by setproctitle() */ -char *ssh_get_progname(char *argv0) +char *get_progname(char *argv0) { char *retp; #ifdef HAVE___PROGNAME diff --git a/smtpd/smtpctl.c b/smtpd/smtpctl.c index 7ba9bfc1..81c6a17a 100644 --- a/smtpd/smtpctl.c +++ b/smtpd/smtpctl.c @@ -1065,7 +1065,9 @@ main(int argc, char **argv) int privileged; char *argv_mailq[] = { "show", "queue", NULL }; +#ifndef HAVE___PROGNAME __progname = ssh_get_progname(argv[0]); +#endif sendmail_compat(argc, argv); privileged = geteuid() == 0; diff --git a/smtpd/smtpd.c b/smtpd/smtpd.c index 38ab265f..f7f711d5 100644 --- a/smtpd/smtpd.c +++ b/smtpd/smtpd.c @@ -516,9 +516,12 @@ main(int argc, char *argv[]) char **save_argv = argv; char *rexec = NULL; struct smtpd *conf; - + +#ifndef HAVE___PROGNAME __progname = ssh_get_progname(argv[0]); +#endif +#ifndef HAVE_SETPROCTITLE /* Save argv. Duplicate so setproctitle emulation doesn't clobber it */ saved_argc = argc; saved_argv = xcalloc(argc + 1, sizeof(*saved_argv)); @@ -526,7 +529,6 @@ main(int argc, char *argv[]) saved_argv[i] = xstrdup(argv[i]); saved_argv[i] = NULL; -#ifndef HAVE_SETPROCTITLE /* Prepare for later setproctitle emulation */ compat_init_setproctitle(argc, argv); argv = saved_argv; |