diff --git a/checkin_notes b/checkin_notes index b0b3ac9817..e77dbd3e0b 100755 --- a/checkin_notes +++ b/checkin_notes @@ -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 diff --git a/clientgui/ViewWork.cpp b/clientgui/ViewWork.cpp index 618dc8e576..bdb8707eb3 100644 --- a/clientgui/ViewWork.cpp +++ b/clientgui/ViewWork.cpp @@ -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; diff --git a/clientgui/ViewWorkGrid.cpp b/clientgui/ViewWorkGrid.cpp index ba0c0ed5b2..3f9b873859 100644 --- a/clientgui/ViewWorkGrid.cpp +++ b/clientgui/ViewWorkGrid.cpp @@ -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(),