diff --git a/checkin_notes b/checkin_notes index 9238eb0cda..b3536683d2 100644 --- a/checkin_notes +++ b/checkin_notes @@ -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 diff --git a/mac_build/boinc.xcodeproj/project.pbxproj b/mac_build/boinc.xcodeproj/project.pbxproj index 1383eff931..44202bb419 100755 --- a/mac_build/boinc.xcodeproj/project.pbxproj +++ b/mac_build/boinc.xcodeproj/project.pbxproj @@ -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 = ""; }; 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; }; diff --git a/mac_installer/PostInstall.cpp b/mac_installer/PostInstall.cpp index 316dc85524..92e28add75 100755 --- a/mac_installer/PostInstall.cpp +++ b/mac_installer/PostInstall.cpp @@ -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; igr_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;