Revert "[hhvm] proc_open should inherit g_context->m_envs"

This reverts commit 0a03e2fdd8cfa1c7dd0a1f9b836443a6464d69b2.
Esse commit está contido em:
Drew Paroski
2013-05-28 11:44:19 -07:00
commit de sgolemon
commit 13c4c29555
4 arquivos alterados com 11 adições e 48 exclusões
-2
Ver Arquivo
@@ -318,8 +318,6 @@ public:
*/
String getenv(CStrRef name) const;
void setenv(CStrRef name, CStrRef value);
Array getEnvs() const { return m_envs; }
String getTimeZone() const { return m_timezone;}
void setTimeZone(CStrRef timezone) { m_timezone = timezone;}
String getDefaultTimeZone() const { return m_timezoneDefault;}
+11 -18
Ver Arquivo
@@ -761,17 +761,6 @@ Variant f_proc_open(CStrRef cmd, CArrRef descriptorspec, VRefParam pipes,
scwd = g_context->getCwd().c_str();
}
Array enva;
if (env.isNull()) {
// Default to the current environment from the execution context
// rather than leaving it unspecified so that we pick up local
// changes made via putenv()
enva = g_context->getEnvs();
} else {
enva = env.toArray();
}
pid_t child;
if (LightProcess::Available()) {
@@ -787,7 +776,7 @@ Variant f_proc_open(CStrRef cmd, CArrRef descriptorspec, VRefParam pipes,
}
std::vector<std::string> envs;
for (ArrayIter iter(enva); iter; ++iter) {
for (ArrayIter iter(env.toArray()); iter; ++iter) {
StringBuffer nvpair;
nvpair += iter.first().toString();
nvpair += '=';
@@ -798,7 +787,7 @@ Variant f_proc_open(CStrRef cmd, CArrRef descriptorspec, VRefParam pipes,
child = LightProcess::proc_open(cmd.c_str(), created, intended,
scwd.c_str(), envs);
assert(child);
return post_proc_open(cmd, pipes, enva, items, child);
return post_proc_open(cmd, pipes, env, items, child);
} else {
/* the unix way */
Lock lock(DescriptorItem::s_mutex);
@@ -806,7 +795,7 @@ Variant f_proc_open(CStrRef cmd, CArrRef descriptorspec, VRefParam pipes,
child = fork();
if (child) {
// the parent process
return post_proc_open(cmd, pipes, enva, items, child);
return post_proc_open(cmd, pipes, env, items, child);
}
}
@@ -822,10 +811,14 @@ Variant f_proc_open(CStrRef cmd, CArrRef descriptorspec, VRefParam pipes,
if (scwd.length() > 0 && chdir(scwd.c_str())) {
// chdir failed, the working directory remains unchanged
}
vector<String> senvs; // holding those char *
char **envp = build_envp(enva, senvs);
execle("/bin/sh", "sh", "-c", cmd.data(), NULL, envp);
free(envp);
if (!env.isNull()) {
vector<String> senvs; // holding those char *
char **envp = build_envp(env.toArray(), senvs);
execle("/bin/sh", "sh", "-c", cmd.data(), NULL, envp);
free(envp);
} else {
execl("/bin/sh", "sh", "-c", cmd.data(), NULL);
}
_exit(127);
}
-27
Ver Arquivo
@@ -49,7 +49,6 @@ bool TestExtProcess::RunTests(const std::string &which) {
RUN_TEST(test_proc_open);
RUN_TEST(test_proc_terminate);
RUN_TEST(test_proc_close);
RUN_TEST(test_proc_open_env_inh);
RUN_TEST(test_proc_get_status);
RUN_TEST(test_proc_nice);
RUN_TEST(test_escapeshellarg);
@@ -80,7 +79,6 @@ bool TestExtProcess::RunTests(const std::string &which) {
RUN_TEST(test_proc_open);
RUN_TEST(test_proc_terminate);
RUN_TEST(test_proc_close);
RUN_TEST(test_proc_open_env_inh);
RUN_TEST(test_proc_get_status);
RUN_TEST(test_proc_nice);
LightProcess::Close();
@@ -286,31 +284,6 @@ bool TestExtProcess::test_system() {
return Count(true);
}
bool TestExtProcess::test_proc_open_env_inh() {
Array descriptorspec =
CREATE_MAP3(0, CREATE_VECTOR2("pipe", "r"),
1, CREATE_VECTOR2("pipe", "w"),
2, CREATE_VECTOR3("file", "/tmp/error-output.txt", "a"));
Variant pipes;
g_context->setenv("inherit_me", "please");
Variant process = f_proc_open("echo $inherit_me", descriptorspec, ref(pipes));
VERIFY(!same(process, false));
{
File *f = pipes[1].toObject().getTyped<File>();
VERIFY(f->valid());
StringBuffer sbuf;
sbuf.read(f);
f->close();
VS(sbuf.detach(), "please\n");
}
VS(f_proc_close(process.toObject()), 0);
return Count(true);
}
bool TestExtProcess::test_proc_open() {
Array descriptorspec =
CREATE_MAP3(0, CREATE_VECTOR2("pipe", "r"),
-1
Ver Arquivo
@@ -49,7 +49,6 @@ class TestExtProcess : public TestCppExt {
bool test_proc_open();
bool test_proc_terminate();
bool test_proc_close();
bool test_proc_open_env_inh();
bool test_proc_get_status();
bool test_proc_nice();
bool test_escapeshellarg();