|
24 | 24 | // [1] allow non-administrative users to run the BOINC Manager |
25 | 25 | // (asked only if this Mac has any non-administrative users) |
26 | 26 | // [2] set BOINC as the screensaver for all users who can run BOINC |
27 | | -// (asked only if BOINC screensaver is not already set for them) |
| 27 | +// (only for MacOS < 14.0 Sonoma and only if BOINC screensaver is |
| 28 | +// not already set for them.) |
28 | 29 | // |
29 | 30 | // The installer can also be run from the command line. This is useful |
30 | 31 | // for installation on remote Macs. However, there is no way to respond |
31 | 32 | // to dialogs during a command-line install. |
32 | 33 | // |
33 | 34 | // Apple's command-line installer sets the following environment variable: |
34 | 35 | // COMMAND_LINE_INSTALL=1 |
35 | | -// The postinstall script, postupgrade script, and this Postinstall.app |
36 | | -// detect this environment variable and do the following: |
37 | | -// * Redirect the Postinstall.app log output to a file |
38 | | -// /tmp/BOINCInstallLog.txt |
| 36 | +// The postinstall script, postupgrade script, this Postinstall.app and |
| 37 | +// BOINC_Finish_Install.app detect this environment variable and do the |
| 38 | +// following: |
39 | 39 | // * Suppress the 2 dialogs |
40 | 40 | // * test for the existence of a file /tmp/nonadminusersok.txt; if the |
41 | 41 | // file exists, allow non-administrative users to run BOINC Manager |
42 | 42 | // * test for the existence of a file /tmp/setboincsaver.txt; if the |
43 | 43 | // file exists, set BOINC as the screensaver for all BOINC users. |
| 44 | +// (available only for MacOS < 14.0 Sonoma.) |
44 | 45 | // |
45 | 46 | // The BOINC installer package to be used for command line installs can |
46 | 47 | // be found embedded inside the GUI BOINC Installer application at: |
@@ -219,6 +220,8 @@ int main(int argc, char *argv[]) |
219 | 220 | } |
220 | 221 |
|
221 | 222 | // getlogin() gives unreliable results under OS 10.6.2, so use environment |
| 223 | + // Note: command-line installer must be run as root, so loginName will |
| 224 | + // always be root for command-line installs |
222 | 225 | strncpy(loginName, getenv("USER"), sizeof(loginName)-1); |
223 | 226 | if (loginName[0] == '\0') { |
224 | 227 | ShowMessage(false, (char *)_("Could not get user login name")); |
@@ -786,6 +789,10 @@ Boolean IsRestartNeeded() { |
786 | 789 | FILE *restartNeededFile; |
787 | 790 | int value; |
788 | 791 |
|
| 792 | + if (compareOSVersionTo(10, 9) >= 0) { |
| 793 | + return false; |
| 794 | + } |
| 795 | + |
789 | 796 | snprintf(s, sizeof(s), "/tmp/%s/BOINC_restart_flag", tempDirName); |
790 | 797 | restartNeededFile = fopen(s, "r"); |
791 | 798 | if (restartNeededFile) { |
@@ -1020,12 +1027,15 @@ Boolean SetLoginItemLaunchAgent(long brandID, long oldBrandID, Boolean deleteLog |
1020 | 1027 | #if COPY_FINISH_INSTALL_TO_USER_DIRECTORY |
1021 | 1028 | fprintf(f, "\t\t<string>/Users/%s/Library/Application Support/BOINC/%s_Finish_Install.app/Contents/MacOS/%s_Finish_Install</string>\n", pw->pw_name, brandName[brandID], brandName[brandID]); |
1022 | 1029 | #else |
1023 | | - // For a reason I do't understand, setting the screensaver under MacOS 26 |
| 1030 | + // For a reason I don't understand, setting the screensaver under MacOS 26 |
1024 | 1031 | // works if we use the BOINC_Finish_Install in the BOINC Data directory |
1025 | 1032 | // but not one at /Users/%s/Library/Application Support/BOINC/ so we no |
1026 | 1033 | // longer put one in the usr's directory tree. |
1027 | 1034 | fprintf(f, "\t\t<string>/Library/Application Support/BOINC Data/%s_Finish_Install.app/Contents/MacOS/%s_Finish_Install</string>\n", brandName[brandID], brandName[brandID]); |
1028 | 1035 | #endif |
| 1036 | + if (gCommandLineInstall) { |
| 1037 | + fprintf(f, "\t\t<string>-c</string>\n"); |
| 1038 | + } |
1029 | 1039 | if (deleteLogInItem) { |
1030 | 1040 | fprintf(f, "\t\t<string>-d</string>\n"); |
1031 | 1041 | fprintf(f, "\t\t<string>%d</string>\n", (int)oldBrandID); |
@@ -1558,17 +1568,20 @@ OSErr UpdateAllVisibleUsers(long brandID, long oldBrandID) |
1558 | 1568 | currentUserCanRunBOINC = true; |
1559 | 1569 | } |
1560 | 1570 |
|
1561 | | - err = GetCurrentScreenSaverSelection(pw, s, sizeof(s) -1); |
1562 | | - if (err == noErr) { |
1563 | | - if (strcmp(s, saverName[brandID])) { |
1564 | | - saverAlreadySetForAll = false; |
| 1571 | + if (compareOSVersionTo(14, 0) < 0) { |
| 1572 | + // As of MacOS 14.0 Sonoma, this code no longer |
| 1573 | + // will detect the current screensaver, |
| 1574 | + err = GetCurrentScreenSaverSelection(pw, s, sizeof(s) -1); |
| 1575 | + if (err == noErr) { |
| 1576 | + if (strcmp(s, saverName[brandID])) { |
| 1577 | + saverAlreadySetForAll = false; |
| 1578 | + } |
1565 | 1579 | } |
| 1580 | + printf("[1] Current Screensaver Selection for user %s is: \"%s\"\n", pw->pw_name, s); |
| 1581 | + fflush(stdout); |
1566 | 1582 | } |
1567 | | - printf("[1] Current Screensaver Selection for user %s is: \"%s\"\n", pw->pw_name, s); |
1568 | | - fflush(stdout); |
1569 | 1583 | } // End if (isGroupMember) |
1570 | 1584 | } // End for (userIndex=0; userIndex< human_user_names.size(); ++userIndex) |
1571 | | - |
1572 | 1585 | ResynchDSSystem(); |
1573 | 1586 |
|
1574 | 1587 | if (allNonAdminUsersAreSet) { |
@@ -1726,6 +1739,8 @@ OSErr UpdateAllVisibleUsers(long brandID, long oldBrandID) |
1726 | 1739 | // Set login item for this user |
1727 | 1740 | bool useOSASript = false; |
1728 | 1741 |
|
| 1742 | + // Note: command-line installer must be run as root, so |
| 1743 | + // loginName will be root if this is a commmand-line install |
1729 | 1744 | if ((compareOSVersionTo(10, 13) < 0) |
1730 | 1745 | || (strcmp(loginName, human_user_name) == 0) |
1731 | 1746 | || (strcmp(loginName, pw->pw_name) == 0) |
|
0 commit comments