aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-11-16 13:27:31 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-11-16 13:27:31 +0000
commite1a73af0a8c25968e9e4c3bf6ba91bc94b3249af (patch)
tree35e4764ecc6291f9ec445776a630b36b49f3ace0
parentd907a95ac2e2cad6f7f65c4323f031f7931ae18b (diff)
downloadrspamd-e1a73af0a8c25968e9e4c3bf6ba91bc94b3249af.tar.gz
rspamd-e1a73af0a8c25968e9e4c3bf6ba91bc94b3249af.zip
[Minor] Preserve old environ on exit
-rw-r--r--src/libutil/util.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c
index 1c644c2cc..aa89e84c8 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -533,10 +533,16 @@ void rspamd_signals_init(struct sigaction *signals, void (*sig_handler)(gint))
static gchar *title_buffer = NULL;
static size_t title_buffer_size = 0;
static gchar *title_progname, *title_progname_full;
+gchar **old_environ = NULL;
static void
rspamd_title_dtor(gpointer d)
{
+ /* Restore old environment */
+ if (old_environ != NULL) {
+ environ = old_environ;
+ }
+
gchar **env = (gchar **) d;
guint i;
@@ -603,12 +609,14 @@ gint rspamd_init_title(rspamd_mempool_t *pool,
program_invocation_short_name = title_progname;
}
+ old_environ = environ;
environ = new_environ;
title_buffer = begin_of_buffer;
title_buffer_size = end_of_buffer - begin_of_buffer;
rspamd_mempool_add_destructor(pool,
- rspamd_title_dtor, new_environ);
+ rspamd_title_dtor,
+ new_environ);
#endif
return 0;