From: Heiko Schlittermann (HS12-RIPE) Date: Wed, 23 Mar 2016 20:19:56 +0000 (+0100) Subject: Add os_unsetenv() X-Git-Tag: exim-4_87_RC7~5 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/271019bd0730f90f81d44ea0946707588df242d6 Add os_unsetenv() BSDI: void unsetenv(const char*) Other: int unsetenv(const char*) --- diff --git a/src/OS/os.c-BSDI b/src/OS/os.c-BSDI new file mode 100644 index 000000000..43e5bb147 --- /dev/null +++ b/src/OS/os.c-BSDI @@ -0,0 +1,19 @@ +/************************************************* +* Exim - an Internet mail transport agent * +*************************************************/ + +/* Copyright (c) 2016 Heiko Schlittermann */ +/* See the file NOTICE for conditions of use and distribution. */ + +/* BSDI-specific code. This is concatenated onto the generic +src/os.c file. */ + +#ifndef OS_UNSETENV +#define OS_UNSETENV + +int +os_unsetenv(const char *name) +{ + unsetenv(name); + return 0; +} diff --git a/src/OS/os.h-BSDI b/src/OS/os.h-BSDI index 6e16722fd..a1705ec95 100644 --- a/src/OS/os.h-BSDI +++ b/src/OS/os.h-BSDI @@ -5,6 +5,7 @@ #define HAVE_MMAP #define HAVE_SYS_MOUNT_H #define SIOCGIFCONF_GIVES_ADDR +#define OS_UNSETENV typedef struct flock flock_t; diff --git a/src/src/environment.c b/src/src/environment.c index 8542dc0d2..b768a0fd6 100644 --- a/src/src/environment.c +++ b/src/src/environment.c @@ -51,7 +51,7 @@ else if (Ustrcmp(keep_environment, "*") != 0) uschar *name = string_copyn(*p, eqp - *p); if (OK != match_isinlist(name, CUSS &keep_environment, 0, NULL, NULL, MCL_NOEXPAND, FALSE, NULL)) - if (unsetenv(CS name) < 0) return FALSE; + if (os_unsetenv(name) < 0) return FALSE; else p = USS environ; /* RESTART from the beginning */ else p++; store_reset(name); diff --git a/src/src/os.c b/src/src/os.c index ee754f9f2..d9ca589ee 100644 --- a/src/src/os.c +++ b/src/src/os.c @@ -833,9 +833,25 @@ os_get_dns_resolver_res(void) #endif /* OS_GET_DNS_RESOLVER_RES */ - /* ----------------------------------------------------------------------- */ +/*********************************************************** +* unsetenv() * +***********************************************************/ + +/* Most modern systems define int unsetenv(const char*), +* some don't. */ + +#if !defined(OS_UNSETENV) +int +os_unsetenv(const char *name) +{ + return unsetenv(name); +} +#endif + + +/* ----------------------------------------------------------------------- */ diff --git a/src/src/osfunctions.h b/src/src/osfunctions.h index 552712744..3d1914acb 100644 --- a/src/src/osfunctions.h +++ b/src/src/osfunctions.h @@ -32,5 +32,8 @@ extern const char *os_strexit(int); /* char to match os_strsignal */ #ifndef os_strsignal extern const char *os_strsignal(int); /* char to match strsignal in some OS */ #endif +#ifndef os_unsetenv +extern int os_unsetenv(const char *); +#endif /* End of osfunctions.h */ diff --git a/src/src/tls.c b/src/src/tls.c index 0406a10f9..858caa227 100644 --- a/src/src/tls.c +++ b/src/src/tls.c @@ -89,7 +89,7 @@ to_tz(uschar * tz) { uschar * old = US getenv("TZ"); (void) setenv("TZ", CCS tz, 1); -tzset(); +tzset(); return old; } @@ -99,8 +99,8 @@ restore_tz(uschar * tz) if (tz) (void) setenv("TZ", CCS tz, 1); else - (void) unsetenv("TZ"); -tzset(); + (void) os_unsetenv("TZ"); +tzset(); } /*************************************************