From: Timo Sirainen Date: Thu, 8 Jan 2009 16:52:21 +0000 (-0500) Subject: env_remove(): Implement a fallback method if unsetenv() doesn't exist. X-Git-Tag: 1.2.beta1~143 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=730839fc072a49bb88c01fbf984157c93a90300f;p=thirdparty%2Fdovecot%2Fcore.git env_remove(): Implement a fallback method if unsetenv() doesn't exist. Fixes compiling at least with Solaris 8. --HG-- branch : HEAD --- diff --git a/configure.in b/configure.in index eff71750bc..38795f09e7 100644 --- a/configure.in +++ b/configure.in @@ -368,7 +368,7 @@ AC_DEFINE(PACKAGE_WEBPAGE, "http://www.dovecot.org/", Support URL) dnl * after -lsocket and -lnsl tests, inet_aton() may be in them AC_CHECK_FUNCS(fcntl flock lockf inet_aton sigaction getpagesize madvise \ - strcasecmp stricmp vsyslog writev pread uname \ + strcasecmp stricmp vsyslog writev pread uname unsetenv \ setrlimit setproctitle seteuid setreuid setegid setresgid \ strtoull strtoll strtouq strtoq \ setpriority quotactl getmntent kqueue kevent backtrace_symbols \ diff --git a/src/lib/env-util.c b/src/lib/env-util.c index 60e70f5ddb..2b2c916a06 100644 --- a/src/lib/env-util.c +++ b/src/lib/env-util.c @@ -19,7 +19,24 @@ void env_put(const char *env) void env_remove(const char *name) { +#ifdef HAVE_UNSETENV unsetenv(name); +#else + extern char **environ; + unsigned int len; + char **envp; + + len = strlen(name); + for (envp = environ; *envp != NULL; envp++) { + if (strncmp(name, *envp, len) == 0 && + (*envp)[len] == '=') { + do { + envp[0] = envp[1]; + } while (*++envp != NULL); + break; + } + } +#endif } void env_clean(void)