mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* process.c (rb_execarg_parent_start1): new macro ALWAYS_NEED_ENVP
to generate envp_str anytime on Solaris 10 (or earlier version of Solaris) to avoid calling execv() which is async-signal unsafe on Solaris 10. [Bug #11265] [ruby-dev:49089] * process.c (exec_with_sh, proc_exec_cmd): On Solaris 10, because ALWAYS_NEED_ENVP is 1 and envp_str is always generated, execv() in exec_with_sh() and proc_exec_cmd() are never called. To guarantee this, execv() is replaced by a macro to print out error message on Solaris 10. * process.c (proc_exec_sh): Because proc_exec_sh() may be called by rb_proc_exec() with envp_str = Qfalse, execl() is replaced by a macro that calls execle() with "extern char **environ" traditional global variable on Solaris 10. TODO: This may be unsafe and sholud be changed in the future. Although rb_proc_exec() is not used from inside current version of ruby, it may be called by third-party extensions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
21bc6f9023
commit
f59356a85a
2 changed files with 34 additions and 4 deletions
21
ChangeLog
21
ChangeLog
|
@ -1,3 +1,24 @@
|
|||
Sat Jun 20 02:03:53 2015 Naohisa Goto <ngotogenome@gmail.com>
|
||||
|
||||
* process.c (rb_execarg_parent_start1): new macro ALWAYS_NEED_ENVP
|
||||
to generate envp_str anytime on Solaris 10 (or earlier version
|
||||
of Solaris) to avoid calling execv() which is async-signal unsafe
|
||||
on Solaris 10. [Bug #11265] [ruby-dev:49089]
|
||||
|
||||
* process.c (exec_with_sh, proc_exec_cmd): On Solaris 10,
|
||||
because ALWAYS_NEED_ENVP is 1 and envp_str is always generated,
|
||||
execv() in exec_with_sh() and proc_exec_cmd() are never called.
|
||||
To guarantee this, execv() is replaced by a macro to print
|
||||
out error message on Solaris 10.
|
||||
|
||||
* process.c (proc_exec_sh): Because proc_exec_sh() may be called
|
||||
by rb_proc_exec() with envp_str = Qfalse, execl() is replaced
|
||||
by a macro that calls execle() with "extern char **environ"
|
||||
traditional global variable on Solaris 10.
|
||||
TODO: This may be unsafe and sholud be changed in the future.
|
||||
Although rb_proc_exec() is not used from inside current version
|
||||
of ruby, it may be called by third-party extensions.
|
||||
|
||||
Sat Jun 20 01:10:13 2015 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
|
||||
|
||||
* NEWS: mention about $SAFE.
|
||||
|
|
17
process.c
17
process.c
|
@ -285,6 +285,15 @@ static ID id_hertz;
|
|||
extern ID ruby_static_id_status;
|
||||
#define id_status ruby_static_id_status
|
||||
|
||||
/* execv and execl are async-signal-safe since SUSv4 (POSIX.1-2008, XPG7) */
|
||||
#if defined(__sun) && !defined(_XPG7) /* Solaris 10, 9, ... */
|
||||
#define execv(path, argv) (rb_async_bug_errno("unreachable: async-signal-unsafe execv() is called", 0))
|
||||
#define execl(path, arg0, arg1, arg2, term) do { extern char **environ; execle((path), (arg0), (arg1), (arg2), (term), (environ)); } while (0)
|
||||
#define ALWAYS_NEED_ENVP 1
|
||||
#else
|
||||
#define ALWAYS_NEED_ENVP 0
|
||||
#endif
|
||||
|
||||
/*#define DEBUG_REDIRECT*/
|
||||
#if defined(DEBUG_REDIRECT)
|
||||
|
||||
|
@ -1201,7 +1210,7 @@ exec_with_sh(const char *prog, char **argv, char **envp)
|
|||
if (envp)
|
||||
execve("/bin/sh", argv, envp); /* async-signal-safe */
|
||||
else
|
||||
execv("/bin/sh", argv); /* async-signal-safe */
|
||||
execv("/bin/sh", argv); /* async-signal-safe (since SUSv4) */
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -1261,7 +1270,7 @@ proc_exec_cmd(const char *prog, VALUE argv_str, VALUE envp_str)
|
|||
if (envp_str)
|
||||
execve(prog, argv, envp); /* async-signal-safe */
|
||||
else
|
||||
execv(prog, argv); /* async-signal-safe */
|
||||
execv(prog, argv); /* async-signal-safe (since SUSv4) */
|
||||
preserving_errno(try_with_sh(prog, argv, envp)); /* try_with_sh() is async-signal-safe. */
|
||||
# if defined(__EMX__) || defined(OS2)
|
||||
if (new_argv) {
|
||||
|
@ -1312,7 +1321,7 @@ proc_exec_sh(const char *str, VALUE envp_str)
|
|||
if (envp_str)
|
||||
execle("/bin/sh", "sh", "-c", str, (char *)NULL, (char **)RSTRING_PTR(envp_str)); /* async-signal-safe */
|
||||
else
|
||||
execl("/bin/sh", "sh", "-c", str, (char *)NULL); /* async-signal-safe */
|
||||
execl("/bin/sh", "sh", "-c", str, (char *)NULL); /* async-signal-safe (since SUSv4) */
|
||||
#endif
|
||||
return -1;
|
||||
#endif /* _WIN32 */
|
||||
|
@ -2360,7 +2369,7 @@ rb_execarg_parent_start1(VALUE execarg_obj)
|
|||
|
||||
unsetenv_others = eargp->unsetenv_others_given && eargp->unsetenv_others_do;
|
||||
envopts = eargp->env_modification;
|
||||
if (unsetenv_others || envopts != Qfalse) {
|
||||
if (ALWAYS_NEED_ENVP || unsetenv_others || envopts != Qfalse) {
|
||||
VALUE envtbl, envp_str, envp_buf;
|
||||
char *p, *ep;
|
||||
if (unsetenv_others) {
|
||||
|
|
Loading…
Reference in a new issue