Mac: Update XCode project; fix installer not starting Manager on OS 10.6

svn path=/trunk/boinc/; revision=19787
This commit is contained in:
Charlie Fenton 2009-12-05 11:01:03 +00:00
parent a13800e285
commit ac4a74a994
3 changed files with 53 additions and 33 deletions

View File

@ -9764,3 +9764,15 @@ David 4 Dec 2009
net_stats.cpp
lib/
proxy_info.cpp,h
Charlie 5 Dec 2009
- Mac: Update XCode project for new files cs_proxy.cpp,h.
- Mac installer: fix a bug where installer would not start Maanger
because getlogin() is not reliable under OS 10.6 when running
with authentication; use getenv("USER") instead.
mac_build/
boinc.xcodeproj/
project.pbxproj
mac_installer/
PostInstall.cpp

View File

@ -36,6 +36,7 @@
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
DD0052F910CA6F1D0067570C /* cs_proxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD0052F710CA6F1D0067570C /* cs_proxy.cpp */; };
DD01B6790C16723C0023A806 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 20286C33FDCF999611CA2CEA /* Carbon.framework */; };
DD01B7120C16723D0023A806 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD1929D80918A2F100C31BCF /* Security.framework */; };
DD0A06F50869A2D2007CD86E /* prefs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD344BE407C5B1670043025C /* prefs.cpp */; };
@ -607,6 +608,8 @@
AA8B6B1C046C364400A80164 /* app_ipc.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = app_ipc.h; path = ../lib/app_ipc.h; sourceTree = SOURCE_ROOT; };
AAA31C97042157A800A80164 /* shmem.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = shmem.cpp; sourceTree = "<group>"; };
AAA31C98042157A800A80164 /* shmem.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = shmem.h; path = ../lib/shmem.h; sourceTree = SOURCE_ROOT; };
DD0052F710CA6F1D0067570C /* cs_proxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cs_proxy.cpp; path = ../client/cs_proxy.cpp; sourceTree = SOURCE_ROOT; };
DD0052F810CA6F1D0067570C /* cs_proxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cs_proxy.h; path = ../client/cs_proxy.h; sourceTree = SOURCE_ROOT; };
DD04BE1A0EDD836A006D5603 /* TermsOfUsePage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TermsOfUsePage.h; path = ../clientgui/TermsOfUsePage.h; sourceTree = SOURCE_ROOT; };
DD0C5A8A0816711400CEC5D7 /* boinc.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; name = boinc.jpg; path = ../clientscr/res/boinc.jpg; sourceTree = SOURCE_ROOT; };
DD1277B3081F3D67007B5DE1 /* PostInstall.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PostInstall.app; sourceTree = BUILT_PRODUCTS_DIR; };
@ -1592,6 +1595,8 @@
F54B8FC802AC0A0C01FB7237 /* cs_files.cpp */,
DDBE74380C03B1C600453BB8 /* cs_platforms.cpp */,
DD344B8D07C5ADFA0043025C /* cs_prefs.cpp */,
DD0052F710CA6F1D0067570C /* cs_proxy.cpp */,
DD0052F810CA6F1D0067570C /* cs_proxy.h */,
F54B8FC902AC0A0C01FB7237 /* cs_scheduler.cpp */,
DD344B9307C5AE2E0043025C /* cs_statefile.cpp */,
DD344B9407C5AE2E0043025C /* cs_trickle.cpp */,
@ -2813,6 +2818,7 @@
DD9AB0340EB7D5DE00AF1616 /* rr_sim.cpp in Sources */,
DDAD31D90EC26B14002DA09D /* mac_address.cpp in Sources */,
DDC06AB810A3E97700C8D9A5 /* url.cpp in Sources */,
DD0052F910CA6F1D0067570C /* cs_proxy.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -69,7 +69,13 @@ extern int check_security(char *bundlePath, char *dataPath, int use_sandbox, int
#define NUMBRANDS 3
static Boolean gQuitFlag = false; /* global */
/* globals */
static Boolean gQuitFlag = false;
static Boolean currentUserCanRunBOINC = false;
static char loginName[256];
static long OSVersion = 0;
static char *saverName[NUMBRANDS];
static char *saverNameEscaped[NUMBRANDS];
@ -96,7 +102,6 @@ enum { launchWhenDone,
int main(int argc, char *argv[])
{
Boolean Success;
long OSVersion;
ProcessSerialNumber ourProcess, installerPSN;
short itemHit;
long brandID = 0;
@ -136,6 +141,15 @@ int main(int argc, char *argv[])
saverNameEscaped[2] = "Progress\\ Thru\\ Processors";
receiptNameEscaped[2] = "/Library/Receipts/Progress\\ Thru\\ Processors.pkg";
::GetCurrentProcess (&ourProcess);
// getlogin() gives unreliable results under OS 10.6.2, so use environment
strncpy(loginName, getenv("USER"), sizeof(loginName)-1);
err = Gestalt(gestaltSystemVersion, &OSVersion);
if (err != noErr)
return err;
for (i=0; i<argc; i++) {
if (strcmp(argv[i], "-part2") == 0)
return DeleteReceipt();
@ -143,8 +157,6 @@ int main(int argc, char *argv[])
Initialize();
::GetCurrentProcess (&ourProcess);
QuitBOINCManager('BNC!'); // Quit any old instance of BOINC manager
sleep(2);
@ -163,15 +175,11 @@ int main(int argc, char *argv[])
brandID = 0;
}
err = Gestalt(gestaltSystemVersion, &OSVersion);
if (err != noErr)
return err;
if (OSVersion < 0x1039) {
if (OSVersion < 0x1040) {
::SetFrontProcess(&ourProcess);
// Remove everything we've installed
// "\pSorry, this version of GridRepublic requires system 10.3.9 or higher."
s[0] = sprintf(s+1, "Sorry, this version of %s requires system 10.3.9 or higher.", brandName[brandID]);
// "\pSorry, this version of GridRepublic requires system 10.4.0 or higher."
s[0] = sprintf(s+1, "Sorry, this version of %s requires system 10.4.0 or higher.", brandName[brandID]);
StandardAlert (kAlertStopAlert, (StringPtr)s, NULL, NULL, &itemHit);
// "rm -rf /Applications/GridRepublic\\ Desktop.app"
@ -247,12 +255,10 @@ int main(int argc, char *argv[])
// Find an appropriate admin user to set as owner of installed files
// First, try the user currently logged in
q = getlogin();
grp = getgrnam("admin");
i = 0;
while ((p = grp->gr_mem[i]) != NULL) { // Step through all users in group admin
if (strcmp(p, q) == 0) {
if (strcmp(p, loginName) == 0) {
Success = true; // Logged in user is a member of group admin
break;
}
@ -470,7 +476,7 @@ OSStatus CheckLogoutRequirement(int *finalAction)
CFStringRef errorString = NULL;
OSStatus err = noErr;
#ifdef SANDBOX
char *p, *loginName = NULL;
char *p;
group *grp = NULL;
int i;
Boolean isMember = false;
@ -478,8 +484,11 @@ OSStatus CheckLogoutRequirement(int *finalAction)
*finalAction = restartRequired;
if (OSVersion < 0x1040) {
return noErr; // Always reuire restart on OS 10.3.9
}
#ifdef SANDBOX
loginName = getlogin();
grp = getgrnam("boinc_master");
if (loginName && grp) {
i = 0;
@ -492,7 +501,7 @@ OSStatus CheckLogoutRequirement(int *finalAction)
}
}
if (!isMember) {
if (!isMember && !currentUserCanRunBOINC) {
*finalAction = nothingrequired;
return noErr;
}
@ -606,7 +615,7 @@ void CheckUserAndGroupConflicts()
}
if (entryCount > 1) {
system ("dscl . -delete /groups/boinc_project");
system ("dscl . -delete /groups/boinc_project");
// User boinc_project must have group boinc_project as its primary group.
// Since this group no longer exists, delete the user as well.
system ("dscl . -delete /users/boinc_project");
@ -790,12 +799,10 @@ Boolean CheckDeleteFile(char *name)
void SetEUIDBackToUser (void)
{
char *p;
uid_t login_uid;
passwd *pw;
p = getlogin();
pw = getpwnam(p);
pw = getpwnam(loginName);
login_uid = pw->pw_uid;
setuid(login_uid);
@ -879,16 +886,11 @@ OSErr UpdateAllVisibleUsers(long brandID)
Boolean found = false;
FILE *f;
OSStatus err;
long OSVersion;
Boolean isGroupMember;
#ifdef SANDBOX
char *p;
short i;
err = Gestalt(gestaltSystemVersion, &OSVersion);
if (err != noErr)
return err;
err = getgrnam_r("admin", &grpAdmin, adminBuf, sizeof(adminBuf), &grpAdminPtr);
if (err) { // Should never happen unless buffer too small
puts("getgrnam(\"admin\") failed\n");
@ -957,6 +959,10 @@ OSErr UpdateAllVisibleUsers(long brandID)
#endif // SANDBOX
if (isGroupMember) {
if (strcmp(loginName, dp->d_name) == 0) {
currentUserCanRunBOINC = true;
}
saved_uid = geteuid();
seteuid(pw->pw_uid); // Temporarily set effective uid to this user
@ -1004,6 +1010,7 @@ OSErr UpdateAllVisibleUsers(long brandID)
brandName[brandID], brandName[brandID])
) {
allowNonAdminUsersToRunBOINC = true;
currentUserCanRunBOINC = true;
saverAlreadySetForAll = false;
}
}
@ -1153,13 +1160,9 @@ int TestRPCBind()
static OSStatus ResynchSystem() {
SInt32 response;
OSStatus err = noErr;
err = Gestalt(gestaltSystemVersion, &response);
if (err) return err;
if (response >= 0x1050) {
if (OSVersion >= 0x1050) {
// OS 10.5
err = system("dscacheutil -flushcache");
err = system("dsmemberutil flushcache");
@ -1168,8 +1171,7 @@ static OSStatus ResynchSystem() {
err = system("lookupd -flushcache");
err = Gestalt(gestaltSystemVersion, &response);
if ((err == noErr) && (response >= 0x1040))
if (OSVersion >= 0x1040)
err = system("memberd -r"); // Available only in OS 10.4
return noErr;