]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
nsenter: use clearenv() only when it is available
authorChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Mon, 30 Mar 2026 13:10:52 +0000 (09:10 -0400)
committerChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Tue, 31 Mar 2026 16:11:46 +0000 (12:11 -0400)
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
sys-utils/nsenter.c

index e10ba9cf90ab1950a7f486db12f477aa4a72bd52..245e1673e91f73d67bddfb3d562aa85cf14b0e78 100644 (file)
 # include <selinux/selinux.h>
 #endif
 
+#ifndef HAVE_ENVIRON_DECL
+extern char **environ;
+#endif
+
 #include "strutils.h"
 #include "nls.h"
 #include "c.h"
@@ -912,7 +916,11 @@ int main(int argc, char *argv[])
                ls = env_list_from_fd(env_fd);
                if (!ls && errno)
                        err(EXIT_FAILURE, _("failed to get environment variables"));
+#ifdef HAVE_CLEARENV
                clearenv();
+#else
+               environ = NULL;
+#endif
                if (ls && env_list_setenv(ls, 0) < 0)
                        err(EXIT_FAILURE, _("failed to set environment variables"));
                env_list_free(ls);