From be2b680f1dea401125e28ca8b2481b6b7685066d Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Fri, 16 Jan 2009 06:41:52 +0000 Subject: [PATCH] client: fix boinc_copy (again); Mac Mgr: fix bugs showing Mgr when minimized to Dock; fix XCode project for moved src file. svn path=/trunk/boinc/; revision=16929 --- checkin_notes | 20 +++++++++++++++++++ client/app_start.cpp | 3 +++ clientgui/BOINCBaseFrame.cpp | 6 +++++- clientgui/BOINCGUIApp.h | 2 ++ clientgui/BOINCTaskBar.cpp | 11 ++++++++++- lib/filesys.cpp | 37 +++++++++++++++++++++++++++++++++--- 6 files changed, 74 insertions(+), 5 deletions(-) diff --git a/checkin_notes b/checkin_notes index 8fe17465e8..4ddaf5c4b6 100644 --- a/checkin_notes +++ b/checkin_notes @@ -451,3 +451,23 @@ Eric 15 Jan 2009 example_app/ Makefile +Charlie Jan 15 2009 + - client: boinc_copy ownership fix of 1/6/09 didn't work because it used + system(cp ...) call, which invokes a shell, and POSIX specifies that + shells run from an application use the real UID and GID not the + effective UID and GID. Changed boinc_copy to copy file directly. + - MGR: On Mac, fix problems showing Manager window when it was minimized + to Dock, especially if window was closed using Dock menu. + - Mac: Fix XCode project for boinc_cmd.cpp moved to client/ from lib/. + + client/ + app_start.cpp + clientgui/ + BOINCBaseFrame.cpp + BOINCGUIApp.h + BOINCTaskBar.cpp + lib/ + filesys.cpp + mac_build/ + boinc.xcodeproj/ + project.pbxproj diff --git a/client/app_start.cpp b/client/app_start.cpp index a97d0d3a49..a1ae46687e 100644 --- a/client/app_start.cpp +++ b/client/app_start.cpp @@ -283,6 +283,9 @@ static int setup_file( ); return retval; } +#ifdef SANDBOX + return set_to_project_group(link_path); +#endif } return 0; } diff --git a/clientgui/BOINCBaseFrame.cpp b/clientgui/BOINCBaseFrame.cpp index 75b75cd557..dd31498766 100644 --- a/clientgui/BOINCBaseFrame.cpp +++ b/clientgui/BOINCBaseFrame.cpp @@ -305,7 +305,11 @@ void CBOINCBaseFrame::OnClose(wxCloseEvent& event) { wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::OnClose - Function Begin")); #if defined(__WXMSW__) || defined(__WXMAC__) - if (!event.CanVeto()) { + if (!event.CanVeto() +#ifdef __WXMAC__ + || IsIconized() +#endif + ) { wxGetApp().FrameClosed(); Destroy(); } else { diff --git a/clientgui/BOINCGUIApp.h b/clientgui/BOINCGUIApp.h index 7c8da6af93..7a67773f49 100644 --- a/clientgui/BOINCGUIApp.h +++ b/clientgui/BOINCGUIApp.h @@ -159,6 +159,8 @@ public: bool SetActiveGUI(int iGUISelection, bool bShowWindow = true); + bool ShowCurrentGUI() { return SetActiveGUI(m_iGUISelected, true); } + void OnRPCFinished( CRPCFinishedEvent& event ); int ConfirmExit(); diff --git a/clientgui/BOINCTaskBar.cpp b/clientgui/BOINCTaskBar.cpp index eb398cf3eb..23bbb75bc2 100644 --- a/clientgui/BOINCTaskBar.cpp +++ b/clientgui/BOINCTaskBar.cpp @@ -169,7 +169,11 @@ void CTaskBarIcon::OnOpen(wxCommandEvent& WXUNUSED(event)) { if (pFrame) { pFrame->Show(); -#ifndef __WXMAC__ +#ifdef __WXMAC__ + if (pFrame->IsIconized()) { + pFrame->Iconize(false); + } +#else if (pFrame->IsMaximized()) { pFrame->Maximize(true); } else { @@ -183,6 +187,11 @@ void CTaskBarIcon::OnOpen(wxCommandEvent& WXUNUSED(event)) { ::SetForegroundWindow((HWND)pFrame->GetHandle()); #endif } +#ifdef __WXMAC__ + else { + wxGetApp().ShowCurrentGUI(); + } +#endif } diff --git a/lib/filesys.cpp b/lib/filesys.cpp index 8b8455cb6d..ab43a0aa1a 100644 --- a/lib/filesys.cpp +++ b/lib/filesys.cpp @@ -504,9 +504,40 @@ int boinc_copy(const char* orig, const char* newf) { sprintf(cmd, "copy \"%s\" \"%s\"", orig, newf); return system(cmd); #else - char cmd[1024]; - sprintf(cmd, "cp -p \"%s\" \"%s\"", orig, newf); - return system(cmd); + // POSIX requires that shells run from an application will use the + // real UID and GID if different from the effective UID and GID. + // Mac OS 10.4 did not enforce this, but OS 10.5 does. Since + // system() invokes a shell, it may not properly copy the file's + // ownership or permissions when called from the BOINC Client + // under sandbox security, so we copy the file directly. + FILE *src, *dst; + int m, n; + int retval = 0; + struct stat sbuf; + unsigned char buf[65536]; + src = boinc_fopen(orig, "r"); + if (!src) return ERR_FOPEN; + dst = boinc_fopen(newf, "w"); + if (!dst) { + fclose(src); + return ERR_FOPEN; + } + while (1) { + n = fread(buf, 1, sizeof(buf), src); + if (n <= 0) break; + m = fwrite(buf, 1, n, dst); + if (m != n) { + retval = ERR_FWRITE; + break; + } + } + fclose(src); + fclose(dst); + // Copy file's ownership, permissions to the extent we are allowed + lstat(orig, &sbuf); // Get source file's info + chown(newf, sbuf.st_uid, sbuf.st_gid); + chmod(newf, sbuf.st_mode); + return retval; #endif }