summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6b60516)
raw | patch | inline | side by side (parent: 6b60516)
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | |
Fri, 2 Jul 2010 16:55:19 +0000 (12:55 -0400) | ||
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | |
Fri, 2 Jul 2010 16:55:19 +0000 (12:55 -0400) |
Some commands need the environment to function properly. One such
example is check_ssh and check_by_ssh when a SOCKS proxy is required.
This patch use setenv and extern char **environ to alter and pass the
new environment to the child process Those modules have been added to
Gnulib for portability.
example is check_ssh and check_by_ssh when a SOCKS proxy is required.
This patch use setenv and extern char **environ to alter and pass the
new environment to the child process Those modules have been added to
Gnulib for portability.
NEWS | patch | blob | history | |
lib/utils_cmd.c | patch | blob | history |
index 5cbb9027bdfaa572eefb21001badd12ace006f65..79ddc53527896de4a905f77ab955e1ef131839bc 100644 (file)
--- a/NEWS
+++ b/NEWS
Fix translations when extra-opts aren't enabled (Jan Wagner - #2832884)
Fix parsing of multi-line strings in check_snmp (broken in 1.4.14) and enhance output in such case (#2832451)
Fix detection of pst3 64-bit compile flags with Sun CC
+ Fix cmd_run overwriting the environment, which would break some commands that needed it
WARNINGS
Updated developer documentation to say that performance labels should not have an equals sign or
single quote in the label
diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c
index e10ab918845d3a125bbf0e4563ffddbf2a1d705a..0c853dcc687d99ba2479e43c40edfa5d37fa6f22 100644 (file)
--- a/lib/utils_cmd.c
+++ b/lib/utils_cmd.c
# include <sys/wait.h>
#endif
+/* used in _cmd_open to pass the environment to commands */
+extern char **environ;
+
/** macros **/
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
static int
_cmd_open (char *const *argv, int *pfd, int *pfderr)
{
- char *env[2];
pid_t pid;
#ifdef RLIMIT_CORE
struct rlimit limit;
if (!_cmd_pids)
CMD_INIT;
- env[0] = strdup ("LC_ALL=C");
- env[1] = '\0';
+ setenv("LC_ALL", "C", 1);
if (pipe (pfd) < 0 || pipe (pfderr) < 0 || (pid = fork ()) < 0)
return -1; /* errno set by the failing function */
if (_cmd_pids[i] > 0)
close (i);
- execve (argv[0], argv, env);
+ execve (argv[0], argv, environ);
_exit (STATE_UNKNOWN);
}