From: Jeremy Harris Date: Tue, 8 Mar 2016 23:57:37 +0000 (+0000) Subject: Fix build for HP-UX and older Solaris: (un)setenv. Bug 1578 X-Git-Tag: exim-4_87_RC7~24 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/dfe7d917154afce0e4016a60f142bd540677930f?ds=sidebyside Fix build for HP-UX and older Solaris: (un)setenv. Bug 1578 Broken-by: bc3c7bb7d4ab --- diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index a36633d21..d36b731cd 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -190,6 +190,10 @@ JH/46 Multiple issues raised by Coverity. Some were obvious or plausible bugs. Many were false-positives and ignorable, but it's worth fixing the former class. +JH/47 Fix build on HP-UX and older Solaris, which need (un)setenv now also + for the new environment-manipulation done at startup. Move the routines + from being local to tls.c to being global via the os.c file. + Exim version 4.86 diff --git a/src/OS/Makefile-Base b/src/OS/Makefile-Base index e0bdeecfd..ff4a83e2c 100644 --- a/src/OS/Makefile-Base +++ b/src/OS/Makefile-Base @@ -623,7 +623,7 @@ spool_out.o: $(HDRS) spool_out.c std-crypto.o: $(HDRS) std-crypto.c store.o: $(HDRS) store.c string.o: $(HDRS) string.c -tls.o: $(HDRS) tls.c setenv.c \ +tls.o: $(HDRS) tls.c \ tls-gnu.c tlscert-gnu.c \ tls-openssl.c tlscert-openssl.c tod.o: $(HDRS) tod.c diff --git a/src/OS/Makefile-HP-UX b/src/OS/Makefile-HP-UX index 073d67aba..e00940f32 100644 --- a/src/OS/Makefile-HP-UX +++ b/src/OS/Makefile-HP-UX @@ -22,4 +22,6 @@ EXIMON_TEXTPOP= DBMLIB=-lndbm RANLIB=@true +os.o: setenv.c + # End diff --git a/src/OS/Makefile-SunOS5 b/src/OS/Makefile-SunOS5 index e60a6c088..351b43ad1 100644 --- a/src/OS/Makefile-SunOS5 +++ b/src/OS/Makefile-SunOS5 @@ -19,4 +19,6 @@ XINCLUDE=-I$(X11)/include XLFLAGS=-L$(X11)/lib -R$(X11)/lib X11LIB=$(X11)/lib +os.o: setenv.c + # End diff --git a/src/OS/os.c-HP-UX b/src/OS/os.c-HP-UX new file mode 100644 index 000000000..1b78d7eb8 --- /dev/null +++ b/src/OS/os.c-HP-UX @@ -0,0 +1,14 @@ +/************************************************* +* Exim - an Internet mail transport agent * +*************************************************/ + +/* Copyright (c) University of Cambridge 2016 */ +/* Copyright (c) Jeremy Harris 2016 */ +/* See the file NOTICE for conditions of use and distribution. */ + +/* HP-UX-specific code. This is concatenated onto the generic +src/os.c file. */ + +#include "setenv.c" + +/* End of os.c-SunHP-UX */ diff --git a/src/OS/os.c-SunOS5 b/src/OS/os.c-SunOS5 new file mode 100644 index 000000000..e298f6d54 --- /dev/null +++ b/src/OS/os.c-SunOS5 @@ -0,0 +1,16 @@ +/************************************************* +* Exim - an Internet mail transport agent * +*************************************************/ + +/* Copyright (c) University of Cambridge 2016 */ +/* Copyright (c) Jeremy Harris 2016 */ +/* See the file NOTICE for conditions of use and distribution. */ + +/* Solaris-specific code. This is concatenated onto the generic +src/os.c file. */ + +#ifdef MISSING_UNSETENV_3 +# include "setenv.c" +#endif + +/* End of os.c-SunOS5 */ diff --git a/src/OS/os.h-HP-UX b/src/OS/os.h-HP-UX index 1b599231d..4998734f6 100644 --- a/src/OS/os.h-HP-UX +++ b/src/OS/os.h-HP-UX @@ -10,7 +10,6 @@ #define FSCALE 1.0 #define HAVE_SYS_STATVFS_H -#define MISSING_UNSETENV_3 #define F_FREESP O_TRUNC #define NEED_H_ERRNO 1 diff --git a/src/src/setenv.c b/src/src/setenv.c index eefbec09b..18d1519b6 100644 --- a/src/src/setenv.c +++ b/src/src/setenv.c @@ -3,14 +3,14 @@ *************************************************/ /* Copyright (c) Michael Haardt 2015 */ -/* Copyright (c) Jeremy Harris 2015 */ +/* Copyright (c) Jeremy Harris 2015 - 2016 */ /* See the file NOTICE for conditions of use and distribution. */ /* This module provides (un)setenv routines for those environments -lacking them in libraries. */ +lacking them in libraries. It is #include'd by OS/os.c-foo files. */ -static int +int setenv(const char * name, const char * val, int overwrite) { uschar * s; @@ -20,7 +20,7 @@ if (overwrite || !getenv(name)) return 0; } -static int +int unsetenv(const char *name) { size_t len; diff --git a/src/src/tls.c b/src/src/tls.c index 5958dfc1c..0406a10f9 100644 --- a/src/src/tls.c +++ b/src/src/tls.c @@ -84,26 +84,23 @@ return TRUE; * Timezone environment flipping * *************************************************/ -#ifdef MISSING_UNSETENV_3 -# include "setenv.c" -#endif - static uschar * to_tz(uschar * tz) { - uschar * old = US getenv("TZ"); - (void) setenv("TZ", CCS tz, 1); - tzset(); - return old; +uschar * old = US getenv("TZ"); +(void) setenv("TZ", CCS tz, 1); +tzset(); +return old; } + static void restore_tz(uschar * tz) { - if (tz) - (void) setenv("TZ", CCS tz, 1); - else - (void) unsetenv("TZ"); - tzset(); +if (tz) + (void) setenv("TZ", CCS tz, 1); +else + (void) unsetenv("TZ"); +tzset(); } /*************************************************