From: Timo Sirainen Date: Wed, 20 Jan 2021 18:51:56 +0000 (+0200) Subject: configure, lib: Remove workarounds for unsetenv() X-Git-Tag: 2.3.16~174 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d1f628e8b0fcc4636eadeb1ba0697e3478387e18;p=thirdparty%2Fdovecot%2Fcore.git configure, lib: Remove workarounds for unsetenv() It's in POSIX.1-2001 and available on all modern systems. --- diff --git a/configure.ac b/configure.ac index 4cbcef6c2a..5b7580c842 100644 --- a/configure.ac +++ b/configure.ac @@ -320,7 +320,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 unsetenv \ + strcasecmp stricmp vsyslog writev pread uname \ setrlimit setproctitle seteuid setreuid setegid setresgid \ getmntinfo setpriority quotactl getmntent kqueue kevent \ backtrace_symbols walkcontext dirfd clearenv \ @@ -487,8 +487,6 @@ DOVECOT_FD_PASSING DOVECOT_SENDFILE -DOVECOT_UNSETENV_RET_INT - DOVECOT_CRYPT_XPG6 DOVECOT_CRYPT diff --git a/m4/unsetenv.m4 b/m4/unsetenv.m4 deleted file mode 100644 index e02b57cf4b..0000000000 --- a/m4/unsetenv.m4 +++ /dev/null @@ -1,16 +0,0 @@ -AC_DEFUN([DOVECOT_UNSETENV_RET_INT], [ - AC_CACHE_CHECK([if unsetenv returns int],i_cv_unsetenv_ret_int,[ - AC_TRY_COMPILE([ - #include - ], [ - if (unsetenv("env") < 0) { } - ], [ - i_cv_unsetenv_ret_int=yes - ], [ - i_cv_unsetenv_ret_int=no - ]) - ]) - if test $i_cv_unsetenv_ret_int = yes; then - AC_DEFINE(UNSETENV_RET_INT,, [Define if unsetenv() returns int]) - fi -]) diff --git a/src/lib/env-util.c b/src/lib/env-util.c index 6c12970f43..490e4f6260 100644 --- a/src/lib/env-util.c +++ b/src/lib/env-util.c @@ -35,29 +35,8 @@ void env_put_array(const char *const *envs) void env_remove(const char *name) { -#ifdef HAVE_UNSETENV -#ifdef UNSETENV_RET_INT if (unsetenv(name) < 0) i_fatal("unsetenv(%s) failed: %m", name); -#else - unsetenv(name); -#endif -#else - extern char **environ; - size_t 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)