]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
env_remove(): Implement a fallback method if unsetenv() doesn't exist.
authorTimo Sirainen <tss@iki.fi>
Thu, 8 Jan 2009 16:52:21 +0000 (11:52 -0500)
committerTimo Sirainen <tss@iki.fi>
Thu, 8 Jan 2009 16:52:21 +0000 (11:52 -0500)
Fixes compiling at least with Solaris 8.

--HG--
branch : HEAD

configure.in
src/lib/env-util.c

index eff71750bc20d928b17a3aa5ee0801f82a1b63e6..38795f09e7300b13b247da01dd57ded375062842 100644 (file)
@@ -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 \
index 60e70f5ddbb2efe0c916d7bbb1e53db04cf6455a..2b2c916a066a02d1af9f037054175866ea0cf94c 100644 (file)
@@ -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)