diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-06 11:09:26 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-06 11:09:26 +0000 |
commit | 7685837427e60770d7228cc1d3db97257521a606 (patch) | |
tree | 96d3b34eda6346f72c69eaf90d5c5ae86f4e0990 /process.c | |
parent | 96b96832c13b1ef127262cec1104bc7cb7524b69 (diff) |
* process.c (try_with_sh): take envp argument.
(exec_with_sh): ditto. use it for execve.
(proc_exec_v): provide envp for try_with_sh.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -1046,13 +1046,16 @@ security(const char *str) #if defined(HAVE_FORK) && !defined(__native_client__) /* try_with_sh and exec_with_sh should be async-signal-safe. */ -#define try_with_sh(prog, argv) ((saved_errno == ENOEXEC) ? exec_with_sh((prog), (argv)) : (void)0) +#define try_with_sh(prog, argv, envp) ((saved_errno == ENOEXEC) ? exec_with_sh((prog), (argv), (envp)) : (void)0) static void -exec_with_sh(const char *prog, char **argv) +exec_with_sh(const char *prog, char **argv, char **envp) { *argv = (char *)prog; *--argv = (char *)"sh"; - execv("/bin/sh", argv); /* async-signal-safe */ + if (envp) + execve("/bin/sh", argv, envp); /* async-signal-safe */ + else + execv("/bin/sh", argv); /* async-signal-safe */ } #define ARGV_COUNT(n) ((n)+1) @@ -1075,6 +1078,7 @@ proc_exec_v(const char *prog, VALUE argv_str, VALUE envp_str) #else char **argv; char fbuf[MAXPATHLEN]; + char **envp; # if defined(__EMX__) || defined(OS2) char **new_argv = NULL; # endif @@ -1118,11 +1122,12 @@ proc_exec_v(const char *prog, VALUE argv_str, VALUE envp_str) } # endif /* __EMX__ */ before_exec(); /* async-signal-safe if forked_child is true */ + envp = envp_str ? (char **)RSTRING_PTR(envp_str) : NULL; if (envp_str) - execve(prog, argv, (char **)RSTRING_PTR(envp_str)); /* async-signal-safe */ + execve(prog, argv, envp); /* async-signal-safe */ else execv(prog, argv); /* async-signal-safe */ - preserving_errno(try_with_sh(prog, argv); /* try_with_sh() is async-signal-safe. */ + preserving_errno(try_with_sh(prog, argv, envp); /* try_with_sh() is async-signal-safe. */ after_exec()); /* after_exec() is not async-signal-safe */ # if defined(__EMX__) || defined(OS2) if (new_argv) { |