/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "env-util.h"
#ifdef __APPLE__
# include <crt_externs.h>
#endif
struct env_backup {
const char **strings;
};
{
2048);
}
}
{
#ifdef HAVE_UNSETENV
#ifdef UNSETENV_RET_INT
#else
#endif
#else
extern char **environ;
char **envp;
do {
break;
}
}
#endif
}
void env_clean(void)
{
#ifdef HAVE_CLEARENV
if (clearenv() < 0)
i_fatal("clearenv() failed");
#else
char ***environ_p = env_get_environ_p();
/* Try to clear the environment.
a) environ = NULL crashes on OS X.
b) *environ = NULL doesn't work on FreeBSD 7.0.
c) environ = emptyenv doesn't work on Haiku OS
d) environ = calloc() should work everywhere
*/
#endif
}
{
unsigned int i;
for (i = 0; preserve_envs[i] != NULL; i++) {
}
}
/* Note that if the original environment was set with env_put(), the
environment strings will be invalid after env_clean(). That's why
we t_strconcat() them above. */
env_clean();
}
{
T_BEGIN {
} T_END;
}
{
unsigned int i, count;
for (i = 0; i < count; i++)
return env;
}
{
unsigned int i;
env_clean();
}
{
}
char ***env_get_environ_p(void)
{
#ifdef __APPLE__
return _NSGetEnviron();
#else
extern char **environ;
return &environ;
#endif
}
void env_deinit(void)
{
}