From 6666a92105a033771819ff34e15e6a08828b88ed Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Thu, 7 Jul 2005 10:44:57 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=6550 --- checkin_notes | 12 +++++++++ mac_installer/BOINC.pmproj | Bin 1684 -> 1684 bytes mac_installer/PostInstall.cpp | 49 ++++++++++++++++++++++++++++++++-- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/checkin_notes b/checkin_notes index 302cff5314..c6ffa8f788 100755 --- a/checkin_notes +++ b/checkin_notes @@ -8965,3 +8965,15 @@ Rom 6 July 2005 Rom 6 July 2005 (boinc_public) - Tag for 4.70 release, all platforms boinc_core_release_4_70 + +Charlie 7 July 2005 + Mac installer: Installer used to set owner of all installed files + and directories to 501 (BOINCManager, Core Client, Screen Saver + and BOINC Data.) Changed this to set ownership to current user if + current user is member of group admin, otherwise use first member + of group admin other than root. Update installer version number + to 4.70. + + mac-installer/ + PostInstall.cpp + BOINC.pmproj diff --git a/mac_installer/BOINC.pmproj b/mac_installer/BOINC.pmproj index 59494c714c67e1701d48e92b2551df97d1711629..c0a8fd11e06430a80507d4e139e58211489f4199 100644 GIT binary patch delta 22 ccmbQjJB4?HHVc!v!DL+)2_UuEoyC_406{nf9RL6T delta 22 ccmbQjJB4?HHVc!9(PUi~2_UuEoyC_406`xG8vp +#include #include // getlogin #include // getpwname, getpwuid, getuid @@ -48,6 +49,8 @@ int main(int argc, char *argv[]) long response; ProcessSerialNumber ourProcess, installerPSN; short itemHit; + group *grp; + char s[256]; int NumberOfLoginItems, Counter, i; pid_t installerPID = 0; FSRef fileRef; @@ -55,8 +58,6 @@ int main(int argc, char *argv[]) Initialize(); - Success = false; - ::GetCurrentProcess (&ourProcess); QuitBOINCManager('BNC!'); // Quit any old instance of BOINC @@ -85,11 +86,55 @@ int main(int argc, char *argv[]) ExitToShell(); } + Success = false; + + // The BOINC Manager and Core Client have the set-user-ID-on-execution + // flag set, so their ownership is important and must match the + // ownership of the BOINC Data directory. + + // 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) { + Success = true; // Logged in user is a member of group admin + break; + } + ++i; + } + + // If currently logged in user is not admin, use first non-root admin user + if (!Success) { + i = 0; + while ((p = grp->gr_mem[i]) != NULL) { // Step through all users in group admin + if (strcmp(p, "root") != 0) + break; + ++i; + } + } + + // Set owner of BOINCManager and contents, including core client + sprintf(s, "chown -Rf %s /Applications/BOINCManager.app", p); + system (s); + + // Set owner of BOINC Screen Saver + sprintf(s, "chown -Rf %s /Library/Screen\\ Savers/BOINCSaver.saver", p); + system (s); + + // Set owner of BOINC Data + sprintf(s, "chown -Rf %s /Library/Application\\ Support/BOINC\\ Data", p); + system (s); + // Installer is running as root. We must setuid back to the logged in user // in order to add a startup item to the user's login preferences SetUIDBackToUser (); + Success = false; + NumberOfLoginItems = GetCountOfLoginItems(kCurrentUser); // Search existing login items in reverse order, deleting any duplicates of ours