Mac MGR: Launch the graphics application using switcher to fix a potential security risk

svn path=/trunk/boinc/; revision=13598
This commit is contained in:
Charlie Fenton 2007-09-18 12:18:42 +00:00
parent 61ce18e6ca
commit 7fd15f2b5f
3 changed files with 81 additions and 19 deletions

View File

@ -8535,3 +8535,13 @@ Rytis 17 Sep 2007
html/inc/
result.inc
Charlie 18 Sept 2007
- Mac MGR: Launch the graphics application using switcher to fix
a potential security risk; I found another solution to the
"RegisterProcess failed (error = -50)" so no longer need to
use the UNIX system() api to launch the graphics application.
clientgui/
ViewWork.cpp
ViewWorkGrid.cpp

View File

@ -233,15 +233,43 @@ void CViewWork::OnWorkShowGraphics( wxCommandEvent& WXUNUSED(event) ) {
if (wxYES == iAnswer) {
RESULT* result = pDoc->result(m_pListPane->GetFirstSelected());
if (!result->graphics_exec_path.empty()) {
#ifdef __WXMAC__
// Launching the graphics application using fork() and execv()
// results in it getting "RegisterProcess failed (error = -50)"
// so we launch it via a shell using the system() api.
char cmd[1024];
sprintf(cmd, "cd \"%s\"; \"%s\" --graphics &", result->slot_path.c_str(), result->graphics_exec_path.c_str());
system(cmd);
#else
// V6 Graphics
#ifdef __WXMSW__
HANDLE id;
#else
int id;
#endif
#ifdef __WXMAC__
// For unknown reasons, the graphics application exits with
// "RegisterProcess failed (error = -50)" unless we pass its
// full path twice in the argument list to execv.
char* argv[5];
argv[0] = "switcher";
argv[1] = (char *)result->graphics_exec_path.c_str();
argv[2] = (char *)result->graphics_exec_path.c_str();
argv[3] = "--graphics";
argv[4] = 0;
if (g_use_sandbox) {
run_program(
result->slot_path.c_str(),
"../../switcher/switcher",
4,
argv,
0,
id
);
} else {
run_program(
result->slot_path.c_str(),
result->graphics_exec_path.c_str(),
3,
&argv[1],
0,
id
);
}
#else
char* argv[2];
argv[0] = "--graphics";
argv[1] = 0;

View File

@ -222,6 +222,7 @@ void CViewWorkGrid::OnWorkSuspend( wxCommandEvent& WXUNUSED(event) ) {
wxLogTrace(wxT("Function Start/End"), wxT("CViewWorkGrid::OnWorkSuspend - Function End"));
}
void CViewWorkGrid::OnWorkShowGraphics( wxCommandEvent& WXUNUSED(event) ) {
wxLogTrace(wxT("Function Start/End"), wxT("CViewWorkGrid::OnWorkShowGraphics - Function Begin"));
@ -260,23 +261,46 @@ void CViewWorkGrid::OnWorkShowGraphics( wxCommandEvent& WXUNUSED(event) ) {
wxString searchName = m_pGridPane->GetCellValue(m_pGridPane->GetFirstSelectedRow(),COLUMN_NAME).Trim(false);
RESULT* result = pDoc->result(searchName);
if (!result->graphics_exec_path.empty()) {
#ifdef __WXMAC__
// Launching the graphics application using fork() and execv()
// results in it getting "RegisterProcess failed (error = -50)"
// so we launch it via a shell using the system() api.
char cmd[1024];
sprintf(cmd, "cd \"%s\"; \"%s\" --graphics &", result->slot_path.c_str(), result->graphics_exec_path.c_str());
system(cmd);
#else
// V6 Graphics
char* argv[2];
argv[0] = "--graphics";
argv[1] = 0;
#ifdef __WXMSW__
HANDLE id;
#else
int id;
#endif
#ifdef __WXMAC__
// For unknown reasons, the graphics application exits with
// "RegisterProcess failed (error = -50)" unless we pass its
// full path twice in the argument list to execv.
char* argv[5];
argv[0] = "switcher";
argv[1] = (char *)result->graphics_exec_path.c_str();
argv[2] = (char *)result->graphics_exec_path.c_str();
argv[3] = "--graphics";
argv[4] = 0;
if (g_use_sandbox) {
run_program(
result->slot_path.c_str(),
"../../switcher/switcher",
4,
argv,
0,
id
);
} else {
run_program(
result->slot_path.c_str(),
result->graphics_exec_path.c_str(),
3,
&argv[1],
0,
id
);
}
#else
char* argv[2];
argv[0] = "--graphics";
argv[1] = 0;
run_program(
result->slot_path.c_str(),
result->graphics_exec_path.c_str(),