summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--lib/utils_cmd.c9
2 files changed, 6 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index 5cbb902..79ddc53 100644
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,7 @@ This file documents the major additions and syntax changes between releases.
29 Fix translations when extra-opts aren't enabled (Jan Wagner - #2832884) 29 Fix translations when extra-opts aren't enabled (Jan Wagner - #2832884)
30 Fix parsing of multi-line strings in check_snmp (broken in 1.4.14) and enhance output in such case (#2832451) 30 Fix parsing of multi-line strings in check_snmp (broken in 1.4.14) and enhance output in such case (#2832451)
31 Fix detection of pst3 64-bit compile flags with Sun CC 31 Fix detection of pst3 64-bit compile flags with Sun CC
32 Fix cmd_run overwriting the environment, which would break some commands that needed it
32 WARNINGS 33 WARNINGS
33 Updated developer documentation to say that performance labels should not have an equals sign or 34 Updated developer documentation to say that performance labels should not have an equals sign or
34 single quote in the label 35 single quote in the label
diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c
index e10ab91..0c853dc 100644
--- a/lib/utils_cmd.c
+++ b/lib/utils_cmd.c
@@ -48,6 +48,9 @@
48# include <sys/wait.h> 48# include <sys/wait.h>
49#endif 49#endif
50 50
51/* used in _cmd_open to pass the environment to commands */
52extern char **environ;
53
51/** macros **/ 54/** macros **/
52#ifndef WEXITSTATUS 55#ifndef WEXITSTATUS
53# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) 56# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
@@ -122,7 +125,6 @@ cmd_init (void)
122static int 125static int
123_cmd_open (char *const *argv, int *pfd, int *pfderr) 126_cmd_open (char *const *argv, int *pfd, int *pfderr)
124{ 127{
125 char *env[2];
126 pid_t pid; 128 pid_t pid;
127#ifdef RLIMIT_CORE 129#ifdef RLIMIT_CORE
128 struct rlimit limit; 130 struct rlimit limit;
@@ -137,8 +139,7 @@ _cmd_open (char *const *argv, int *pfd, int *pfderr)
137 if (!_cmd_pids) 139 if (!_cmd_pids)
138 CMD_INIT; 140 CMD_INIT;
139 141
140 env[0] = strdup ("LC_ALL=C"); 142 setenv("LC_ALL", "C", 1);
141 env[1] = '\0';
142 143
143 if (pipe (pfd) < 0 || pipe (pfderr) < 0 || (pid = fork ()) < 0) 144 if (pipe (pfd) < 0 || pipe (pfderr) < 0 || (pid = fork ()) < 0)
144 return -1; /* errno set by the failing function */ 145 return -1; /* errno set by the failing function */
@@ -169,7 +170,7 @@ _cmd_open (char *const *argv, int *pfd, int *pfderr)
169 if (_cmd_pids[i] > 0) 170 if (_cmd_pids[i] > 0)
170 close (i); 171 close (i);
171 172
172 execve (argv[0], argv, env); 173 execve (argv[0], argv, environ);
173 _exit (STATE_UNKNOWN); 174 _exit (STATE_UNKNOWN);
174 } 175 }
175 176