Skip to content

Commit

Permalink
client: fix boinc_copy (again); Mac Mgr: fix bugs showing Mgr when mi…
Browse files Browse the repository at this point in the history
…nimized to Dock; fix XCode project for moved src file.

svn path=/trunk/boinc/; revision=16929
  • Loading branch information
Charlie Fenton committed Jan 16, 2009
1 parent 9a2868e commit be2b680
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 5 deletions.
20 changes: 20 additions & 0 deletions checkin_notes
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions client/app_start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ static int setup_file(
);
return retval;
}
#ifdef SANDBOX
return set_to_project_group(link_path);
#endif
}
return 0;
}
Expand Down
6 changes: 5 additions & 1 deletion clientgui/BOINCBaseFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions clientgui/BOINCGUIApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ class CBOINCGUIApp : public wxApp {

bool SetActiveGUI(int iGUISelection, bool bShowWindow = true);

bool ShowCurrentGUI() { return SetActiveGUI(m_iGUISelected, true); }

void OnRPCFinished( CRPCFinishedEvent& event );

int ConfirmExit();
Expand Down
11 changes: 10 additions & 1 deletion clientgui/BOINCTaskBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -183,6 +187,11 @@ void CTaskBarIcon::OnOpen(wxCommandEvent& WXUNUSED(event)) {
::SetForegroundWindow((HWND)pFrame->GetHandle());
#endif
}
#ifdef __WXMAC__
else {
wxGetApp().ShowCurrentGUI();
}
#endif
}


Expand Down
37 changes: 34 additions & 3 deletions lib/filesys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit be2b680

Please sign in to comment.