2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2007-06-06 12:52:37 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2007-06-06 12:52:37 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2007-06-06 12:52:37 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2007-06-06 12:52:37 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2007-06-06 12:52:37 +00:00
|
|
|
|
|
|
|
/* uninstall.cpp */
|
|
|
|
|
|
|
|
#define TESTING 0 /* for debugging */
|
|
|
|
|
|
|
|
#include <Carbon/Carbon.h>
|
|
|
|
#include <Security/Authorization.h>
|
|
|
|
#include <Security/AuthorizationTags.h>
|
|
|
|
|
|
|
|
#include <grp.h>
|
|
|
|
|
|
|
|
#include <unistd.h> // geteuid, seteuid
|
|
|
|
#include <pwd.h> // passwd, getpwnam
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <sys/param.h> // for MAXPATHLEN
|
|
|
|
|
2011-09-24 12:43:19 +00:00
|
|
|
#include "LoginItemAPI.h"
|
|
|
|
|
2007-06-06 12:52:37 +00:00
|
|
|
static OSStatus DoUninstall(void);
|
2007-06-07 12:24:29 +00:00
|
|
|
static OSStatus GetpathToBOINCManagerApp(char* path, int maxLen, FSRef *theFSRef);
|
|
|
|
static OSStatus CleanupAllVisibleUsers(void);
|
|
|
|
static OSStatus DeleteOurBundlesFromDirectory(CFStringRef bundleID, char *extension, char *dirPath);
|
2007-06-06 12:52:37 +00:00
|
|
|
static OSStatus GetAuthorization(AuthorizationRef * authRef, const char *pathToTool, char *brandName);
|
|
|
|
static OSStatus DoPrivilegedExec(char *brandName, const char *pathToTool, char *arg1, char *arg2, char *arg3, char *arg4, char *arg5);
|
2011-09-24 12:43:19 +00:00
|
|
|
static void DeleteLoginItemOSAScript(char* user, char* appName);
|
|
|
|
static void DeleteLoginItemAPI(void);
|
2007-06-06 12:52:37 +00:00
|
|
|
static char * PersistentFGets(char *buf, size_t buflen, FILE *f);
|
|
|
|
static pid_t FindProcessPID(char* name, pid_t thePID);
|
2007-06-07 12:24:29 +00:00
|
|
|
static OSStatus QuitBOINCManager(OSType signature);
|
2007-10-25 09:34:16 +00:00
|
|
|
//static void SleepTicks(UInt32 ticksToSleep);
|
2007-06-08 11:16:48 +00:00
|
|
|
static Boolean ShowMessage(Boolean allowCancel, const char *format, ...);
|
2007-06-06 12:52:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
char pathToSelf[MAXPATHLEN], appName[256], *p;
|
|
|
|
ProcessSerialNumber ourPSN;
|
|
|
|
FSRef ourFSRef;
|
2007-06-08 11:16:48 +00:00
|
|
|
Boolean cancelled = false;
|
2007-06-06 12:52:37 +00:00
|
|
|
OSStatus err = noErr;
|
|
|
|
|
|
|
|
// Determine whether this is the intial launch or the relaunch with privileges
|
|
|
|
if ( (argc == 2) && (strcmp(argv[1], "--privileged") == 0) ) {
|
|
|
|
if (geteuid() != 0) { // Confirm that we are running as root
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "Permission error after relaunch");
|
2007-06-06 12:52:37 +00:00
|
|
|
return permErr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DoUninstall();
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is the initial launch. Authenticate and relaunch ourselves with privileges.
|
|
|
|
|
|
|
|
// Get the full path to our executable inside this application's bundle
|
|
|
|
err = GetCurrentProcess (&ourPSN);
|
|
|
|
if (err == noErr) {
|
|
|
|
err = GetProcessBundleLocation(&ourPSN, &ourFSRef);
|
|
|
|
}
|
|
|
|
if (err == noErr) {
|
|
|
|
err = FSRefMakePath (&ourFSRef, (UInt8*)pathToSelf, sizeof(pathToSelf));
|
|
|
|
}
|
|
|
|
if (err != noErr) {
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "Couldn't get path to self. Error %d", err);
|
2007-06-06 12:52:37 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
// To allow for branding, assume name of executable inside bundle is same as name of bundle
|
|
|
|
p = strrchr(pathToSelf, '/'); // Assume name of executable inside bundle is same as name of bundle
|
|
|
|
if (p == NULL)
|
|
|
|
p = pathToSelf - 1;
|
|
|
|
strlcpy(appName, p+1, sizeof(appName));
|
|
|
|
p = strrchr(appName, '.'); // Strip off bundle extension (".app")
|
|
|
|
if (p)
|
|
|
|
*p = '\0';
|
|
|
|
|
|
|
|
strlcat(pathToSelf, "/Contents/MacOS/", sizeof(pathToSelf));
|
|
|
|
strlcat(pathToSelf, appName, sizeof(pathToSelf));
|
|
|
|
|
2007-06-07 12:24:29 +00:00
|
|
|
p = strchr(appName, ' ');
|
2007-06-06 12:52:37 +00:00
|
|
|
p += 1; // Point to brand name following "Uninstall "
|
|
|
|
|
2007-09-06 01:40:05 +00:00
|
|
|
if (GetResource('ALRT', 128)) {
|
|
|
|
// BOINC uses custom dialog with custom PICT
|
|
|
|
cancelled = (Alert(128, NULL) == cancel);
|
|
|
|
} else {
|
|
|
|
// Grid Republic uses generic dialog with Uninstall application's icon
|
2009-06-13 00:54:29 +00:00
|
|
|
cancelled = ! ShowMessage(true, "Are you sure you want to completely remove %s from your computer?\n\n"
|
2009-06-30 06:17:55 +00:00
|
|
|
"This will remove the executables but will not touch %s data files.", p, p);
|
2007-09-06 01:40:05 +00:00
|
|
|
}
|
2007-06-08 11:16:48 +00:00
|
|
|
|
|
|
|
if (! cancelled)
|
|
|
|
err = DoPrivilegedExec(p, pathToSelf, "--privileged", NULL, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
if (cancelled || (err == errAuthorizationCanceled)) {
|
|
|
|
ShowMessage(false, "Canceled: %s has not been touched.", p);
|
2007-06-06 12:52:37 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if TESTING
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "DoPrivilegedExec returned %d", err);
|
2007-06-06 12:52:37 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (err)
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "An error occurred: error code %d", err);
|
2007-06-06 12:52:37 +00:00
|
|
|
else
|
2009-06-13 00:54:29 +00:00
|
|
|
ShowMessage(false, "Removal completed.\n\n You may want to remove the following remaining items using the Finder: \n"
|
2009-06-30 05:52:43 +00:00
|
|
|
"\"/Library/Application Support/BOINC Data\" directory\n\nfor each user, the file\n"
|
2009-06-13 00:54:29 +00:00
|
|
|
"\"/Users/[username]/Library/Preferences/BOINC Manager Preferences\".");
|
2007-06-06 12:52:37 +00:00
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static OSStatus DoUninstall(void) {
|
|
|
|
pid_t coreClientPID = 0;
|
2007-06-07 12:24:29 +00:00
|
|
|
char myRmCommand[MAXPATHLEN+10], plistRmCommand[MAXPATHLEN+10], *p;
|
|
|
|
char notBoot[] = "/Volumes/";
|
2009-11-19 10:41:47 +00:00
|
|
|
char cmd[1024];
|
2007-06-07 12:24:29 +00:00
|
|
|
FSRef theFSRef;
|
|
|
|
int pathOffset, i;
|
2009-11-19 10:41:47 +00:00
|
|
|
passwd *pw;
|
2007-06-07 12:24:29 +00:00
|
|
|
OSStatus err = noErr;
|
2007-06-06 12:52:37 +00:00
|
|
|
|
|
|
|
#if TESTING
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "Permission OK after relaunch");
|
2007-06-06 12:52:37 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
QuitBOINCManager('BNC!'); // Quit any old instance of BOINC manager
|
|
|
|
sleep(2);
|
|
|
|
|
|
|
|
// Core Client may still be running if it was started without Manager
|
|
|
|
coreClientPID = FindProcessPID("boinc", 0);
|
|
|
|
if (coreClientPID)
|
|
|
|
kill(coreClientPID, SIGTERM); // boinc catches SIGTERM & exits gracefully
|
|
|
|
|
2007-06-07 12:24:29 +00:00
|
|
|
// Phase 1: try to find all our applications using LaunchServices
|
|
|
|
for (i=0; i<100; i++) {
|
|
|
|
strlcpy(myRmCommand, "rm -rf \"", 10);
|
|
|
|
pathOffset = strlen(myRmCommand);
|
|
|
|
|
|
|
|
err = GetpathToBOINCManagerApp(myRmCommand+pathOffset, MAXPATHLEN, &theFSRef);
|
|
|
|
if (err)
|
|
|
|
break;
|
|
|
|
|
|
|
|
strlcat(myRmCommand, "\"", sizeof(myRmCommand));
|
|
|
|
|
|
|
|
#if TESTING
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "manager: %s", myRmCommand);
|
2007-06-07 12:24:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
p = strstr(myRmCommand, notBoot);
|
|
|
|
|
|
|
|
if (p == myRmCommand+pathOffset) {
|
|
|
|
#if TESTING
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "Not on boot volume: %s", myRmCommand);
|
2007-06-07 12:24:29 +00:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// First delete just the application's info.plist file and update the
|
2009-06-13 00:54:29 +00:00
|
|
|
// LaunchServices Database; otherwise LSFindApplicationForInfo might
|
2007-06-07 12:24:29 +00:00
|
|
|
// return this application again after it's been deleted.
|
|
|
|
strlcpy(plistRmCommand, myRmCommand, sizeof(plistRmCommand));
|
|
|
|
strlcat(plistRmCommand, "/Contents/info.plist", sizeof(plistRmCommand));
|
|
|
|
#if TESTING
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "Deleting info.plist: %s", plistRmCommand);
|
2007-06-07 12:24:29 +00:00
|
|
|
#endif
|
|
|
|
system(plistRmCommand);
|
|
|
|
err = LSRegisterFSRef(&theFSRef, true);
|
|
|
|
#if TESTING
|
|
|
|
if (err)
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "LSRegisterFSRef returned error %d", err);
|
2007-06-07 12:24:29 +00:00
|
|
|
#endif
|
|
|
|
system(myRmCommand);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Phase 2: step through default Applications directory searching for our applications
|
|
|
|
err = DeleteOurBundlesFromDirectory(CFSTR("edu.berkeley.boinc"), "app", "/Applications");
|
|
|
|
|
|
|
|
// Phase 3: step through default Screen Savers directory searching for our screen savers
|
|
|
|
err = DeleteOurBundlesFromDirectory(CFSTR("edu.berkeley.boincsaver"), "saver", "/Library/Screen Savers");
|
|
|
|
|
|
|
|
// Phase 4: Delete our files and directories at our installer's default locations
|
2011-08-11 10:20:25 +00:00
|
|
|
// Remove everything we've installed, whether BOINC, GridRepublic, Progress Thru Processors or
|
|
|
|
// Charity Engine
|
2007-06-07 12:24:29 +00:00
|
|
|
// These first 4 should already have been deleted by the above code, but do them anyway for safety
|
2007-06-06 12:52:37 +00:00
|
|
|
system ("rm -rf /Applications/BOINCManager.app");
|
|
|
|
system ("rm -rf \"/Library/Screen Savers/BOINCSaver.saver\"");
|
|
|
|
|
|
|
|
system ("rm -rf \"/Applications/GridRepublic Desktop.app\"");
|
|
|
|
system ("rm -rf \"/Library/Screen Savers/GridRepublic.saver\"");
|
2009-06-10 10:49:46 +00:00
|
|
|
|
2009-06-11 01:57:35 +00:00
|
|
|
system ("rm -rf \"/Applications/Progress\\ Thru\\ Processors\\ Desktop.app\"");
|
|
|
|
system ("rm -rf \"/Library/Screen Savers/Progress\\ Thru\\ Processors.saver\"");
|
2011-08-11 10:20:25 +00:00
|
|
|
|
|
|
|
system ("rm -rf \"/Applications/Charity\\ Engine\\ Desktop.app\"");
|
|
|
|
system ("rm -rf \"/Library/Screen Savers/Charity\\ Engine.saver\"");
|
|
|
|
|
2011-02-15 11:02:40 +00:00
|
|
|
// Delete any receipt from an older installer (which had
|
|
|
|
// a wrapper application around the installer package.)
|
2007-06-06 12:52:37 +00:00
|
|
|
system ("rm -rf /Library/Receipts/GridRepublic.pkg");
|
2009-06-11 01:57:35 +00:00
|
|
|
system ("rm -rf /Library/Receipts/Progress\\ Thru\\ Processors.pkg");
|
2011-08-11 10:20:25 +00:00
|
|
|
system ("rm -rf /Library/Receipts/Charity\\ Engine.pkg");
|
2007-06-07 12:24:29 +00:00
|
|
|
system ("rm -rf /Library/Receipts/BOINC.pkg");
|
2007-06-06 12:52:37 +00:00
|
|
|
|
2011-02-15 11:02:40 +00:00
|
|
|
// Delete any receipt from a newer installer (a bare package.)
|
|
|
|
system ("rm -rf /Library/Receipts/GridRepublic\\ Installer.pkg");
|
|
|
|
system ("rm -rf /Library/Receipts/Progress\\ Thru\\ Processors\\ Installer.pkg");
|
2011-08-11 10:20:25 +00:00
|
|
|
system ("rm -rf /Library/Receipts/Charity\\ Engine\\ Installer.pkg");
|
2011-02-15 11:02:40 +00:00
|
|
|
system ("rm -rf /Library/Receipts/BOINC\\ Installer.pkg");
|
|
|
|
|
2009-11-19 10:41:47 +00:00
|
|
|
// Phase 5: Set BOINC Data owner and group to logged in user
|
2007-06-06 12:52:37 +00:00
|
|
|
// We don't customize BOINC Data directory name for branding
|
2009-06-13 00:54:29 +00:00
|
|
|
// system ("rm -rf \"/Library/Application Support/BOINC Data\"");
|
2009-11-19 10:41:47 +00:00
|
|
|
p = getlogin();
|
|
|
|
pw = getpwnam(p);
|
|
|
|
sprintf(cmd, "chown -R %d:%d \"/Library/Application Support/BOINC Data\"", pw->pw_uid, pw->pw_gid);
|
|
|
|
system (cmd);
|
|
|
|
system("chmod -R u+rw-s,g+r-w-s,o+r-w \"/Library/Application Support/BOINC Data\"");
|
|
|
|
system("chmod 600 \"/Library/Application Support/BOINC Data/gui_rpc_auth.cfg\"");
|
|
|
|
|
|
|
|
// Phase 6: step through all users and do user-specific cleanup
|
2007-06-06 12:52:37 +00:00
|
|
|
CleanupAllVisibleUsers();
|
|
|
|
|
|
|
|
system ("dscl . -delete /users/boinc_master");
|
|
|
|
system ("dscl . -delete /groups/boinc_master");
|
|
|
|
system ("dscl . -delete /users/boinc_project");
|
|
|
|
system ("dscl . -delete /groups/boinc_project");
|
2009-11-19 10:41:47 +00:00
|
|
|
|
|
|
|
|
2007-10-25 09:34:16 +00:00
|
|
|
return 0;
|
2007-06-07 12:24:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static OSStatus GetpathToBOINCManagerApp(char* path, int maxLen, FSRef *theFSRef)
|
|
|
|
{
|
|
|
|
CFStringRef bundleID = CFSTR("edu.berkeley.boinc");
|
|
|
|
OSType creator = 'BNC!';
|
|
|
|
OSStatus status = noErr;
|
|
|
|
|
|
|
|
status = LSFindApplicationForInfo(creator, bundleID, NULL, theFSRef, NULL);
|
|
|
|
if (status) {
|
|
|
|
#if TESTING
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "LSFindApplicationForInfo returned error %d", status);
|
2007-06-07 12:24:29 +00:00
|
|
|
#endif
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
status = FSRefMakePath(theFSRef, (unsigned char *)path, maxLen);
|
|
|
|
#if TESTING
|
|
|
|
if (status)
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "GetpathToBOINCManagerApp FSRefMakePath returned error %d, %s", status, path);
|
2007-06-07 12:24:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static OSStatus DeleteOurBundlesFromDirectory(CFStringRef bundleID, char *extension, char *dirPath) {
|
|
|
|
DIR *dirp;
|
|
|
|
dirent *dp;
|
|
|
|
CFStringRef urlStringRef = NULL;
|
|
|
|
int index;
|
|
|
|
CFStringRef thisID = NULL;
|
|
|
|
CFBundleRef thisBundle = NULL;
|
|
|
|
CFURLRef bundleURLRef = NULL;
|
|
|
|
char myRmCommand[MAXPATHLEN+10], *p;
|
|
|
|
int pathOffset;
|
|
|
|
|
|
|
|
dirp = opendir(dirPath);
|
|
|
|
if (dirp == NULL) { // Should never happen
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "opendir(\"%s\") failed", dirPath);
|
2007-06-07 12:24:29 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-06 12:52:37 +00:00
|
|
|
|
2007-06-07 12:24:29 +00:00
|
|
|
index = -1;
|
|
|
|
while (true) {
|
|
|
|
index++;
|
|
|
|
|
|
|
|
dp = readdir(dirp);
|
|
|
|
if (dp == NULL)
|
|
|
|
break; // End of list
|
|
|
|
|
|
|
|
p = strrchr(dp->d_name, '.');
|
|
|
|
if (p == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (strcmp(p+1, extension))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
strlcpy(myRmCommand, "rm -rf \"", 10);
|
|
|
|
pathOffset = strlen(myRmCommand);
|
|
|
|
strlcat(myRmCommand, dirPath, sizeof(myRmCommand));
|
|
|
|
strlcat(myRmCommand, "/", sizeof(myRmCommand));
|
|
|
|
strlcat(myRmCommand, dp->d_name, sizeof(myRmCommand));
|
|
|
|
urlStringRef = CFStringCreateWithCString(kCFAllocatorDefault, myRmCommand+pathOffset, CFStringGetSystemEncoding());
|
|
|
|
if (urlStringRef) {
|
|
|
|
bundleURLRef = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, urlStringRef, kCFURLPOSIXPathStyle, false);
|
|
|
|
if (bundleURLRef) {
|
|
|
|
thisBundle = CFBundleCreate( kCFAllocatorDefault, bundleURLRef );
|
|
|
|
if (thisBundle) {
|
|
|
|
thisID = CFBundleGetIdentifier(thisBundle);
|
|
|
|
if (thisID) {
|
|
|
|
strlcat(myRmCommand, "\"", sizeof(myRmCommand));
|
|
|
|
if (CFStringCompare(thisID, bundleID, 0) == kCFCompareEqualTo) {
|
|
|
|
#if TESTING
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "Bundles: %s", myRmCommand);
|
2007-06-07 12:24:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
system(myRmCommand);
|
|
|
|
} else {
|
|
|
|
#if TESTING
|
2007-06-08 11:16:48 +00:00
|
|
|
// ShowMessage(false, "Bundles: Not deleting %s", myRmCommand+pathOffset);
|
2007-06-07 12:24:29 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // if (thisID)
|
|
|
|
#if TESTING
|
|
|
|
else
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "CFBundleGetIdentifier failed for index %d", index);
|
2007-06-07 12:24:29 +00:00
|
|
|
#endif
|
|
|
|
CFRelease(thisBundle);
|
|
|
|
} //if (thisBundle)
|
|
|
|
#if TESTING
|
|
|
|
else
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "CFBundleCreate failed for index %d", index);
|
2007-06-07 12:24:29 +00:00
|
|
|
#endif
|
|
|
|
CFRelease(bundleURLRef);
|
|
|
|
} // if (bundleURLRef)
|
|
|
|
#if TESTING
|
|
|
|
else
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "CFURLCreateWithFileSystemPath failed");
|
2007-06-07 12:24:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
CFRelease(urlStringRef);
|
|
|
|
} // if (urlStringRef)
|
|
|
|
#if TESTING
|
|
|
|
else
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "CFStringCreateWithCString failed");
|
2007-06-07 12:24:29 +00:00
|
|
|
#endif
|
|
|
|
} // while true
|
2007-06-06 12:52:37 +00:00
|
|
|
|
2007-06-07 12:24:29 +00:00
|
|
|
closedir(dirp);
|
|
|
|
|
|
|
|
return noErr;
|
2007-06-06 12:52:37 +00:00
|
|
|
}
|
|
|
|
|
2007-06-07 12:24:29 +00:00
|
|
|
|
2007-06-06 12:52:37 +00:00
|
|
|
// Find all visible users and delete their login item to launch BOINC Manager.
|
|
|
|
// Remove each user from groups boinc_master and boinc_project.
|
2009-06-13 00:54:29 +00:00
|
|
|
// For now, don't delete user's BOINC Preferences file.
|
2007-06-07 12:24:29 +00:00
|
|
|
static OSStatus CleanupAllVisibleUsers(void)
|
2007-06-06 12:52:37 +00:00
|
|
|
{
|
|
|
|
DIR *dirp;
|
|
|
|
dirent *dp;
|
|
|
|
passwd *pw;
|
2009-12-16 12:50:40 +00:00
|
|
|
uid_t saved_uid, saved_euid;
|
2007-06-06 12:52:37 +00:00
|
|
|
char s[1024];
|
|
|
|
FILE *f;
|
2009-12-16 12:50:40 +00:00
|
|
|
long OSVersion = 0;
|
|
|
|
OSStatus err;
|
2007-06-06 12:52:37 +00:00
|
|
|
Boolean changeSaver;
|
|
|
|
|
2009-12-16 12:50:40 +00:00
|
|
|
err = Gestalt(gestaltSystemVersion, &OSVersion);
|
|
|
|
if (err != noErr) {
|
|
|
|
OSVersion = 0;
|
|
|
|
}
|
|
|
|
|
2007-06-06 12:52:37 +00:00
|
|
|
dirp = opendir("/Users");
|
|
|
|
if (dirp == NULL) { // Should never happen
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "opendir(\"/Users\") failed");
|
2007-06-06 12:52:37 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-12-16 12:50:40 +00:00
|
|
|
saved_uid = getuid();
|
|
|
|
saved_euid = geteuid();
|
|
|
|
|
2007-06-06 12:52:37 +00:00
|
|
|
while (true) {
|
|
|
|
dp = readdir(dirp);
|
|
|
|
if (dp == NULL)
|
|
|
|
break; // End of list
|
|
|
|
|
|
|
|
if (dp->d_name[0] == '.')
|
|
|
|
continue; // Ignore names beginning with '.'
|
|
|
|
|
|
|
|
pw = getpwnam(dp->d_name);
|
|
|
|
if (pw == NULL) // "Deleted Users", "Shared", etc.
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Remove user from groups boinc_master and boinc_project
|
|
|
|
sprintf(s, "dscl . -delete /groups/boinc_master users %s", dp->d_name);
|
|
|
|
system (s);
|
|
|
|
|
|
|
|
sprintf(s, "dscl . -delete /groups/boinc_project users %s", dp->d_name);
|
|
|
|
system (s);
|
|
|
|
|
|
|
|
#if TESTING
|
2007-06-08 11:16:48 +00:00
|
|
|
// ShowMessage(false, "Before seteuid(%d) for user %s, euid = %d", pw->pw_uid, dp->d_name, geteuid());
|
2007-06-06 12:52:37 +00:00
|
|
|
#endif
|
|
|
|
|
2009-12-16 12:50:40 +00:00
|
|
|
if (OSVersion >= 0x1060) {
|
|
|
|
setuid(0);
|
|
|
|
}
|
2007-06-06 12:52:37 +00:00
|
|
|
seteuid(pw->pw_uid); // Temporarily set effective uid to this user
|
|
|
|
|
2011-08-11 10:20:25 +00:00
|
|
|
// Delete our login item(s) for this user
|
2011-09-24 12:43:19 +00:00
|
|
|
if (OSVersion >= 0x1070) {
|
2011-09-24 13:42:55 +00:00
|
|
|
DeleteLoginItemOSAScript(dp->d_name, "BOINCManager");
|
2011-09-24 12:43:19 +00:00
|
|
|
DeleteLoginItemOSAScript(dp->d_name, "GridRepublic Desktop");
|
|
|
|
DeleteLoginItemOSAScript(dp->d_name, "Progress Thru Processors Desktop");
|
|
|
|
DeleteLoginItemOSAScript(dp->d_name, "Charity Engine Desktop");
|
|
|
|
} else {
|
|
|
|
DeleteLoginItemAPI();
|
|
|
|
}
|
2009-06-13 00:54:29 +00:00
|
|
|
// sprintf(s, "rm -f \"/Users/%s/Library/Preferences/BOINC Manager Preferences\"", dp->d_name);
|
|
|
|
// system (s);
|
2007-06-06 12:52:37 +00:00
|
|
|
|
2009-06-10 10:49:46 +00:00
|
|
|
// Set screensaver to "Computer Name" default screensaver only
|
2011-08-11 10:20:25 +00:00
|
|
|
// if it was BOINC, GridRepublic, Progress Thru Processors or Charity Engine.
|
2007-06-06 12:52:37 +00:00
|
|
|
changeSaver = false;
|
2009-12-16 12:50:40 +00:00
|
|
|
if (OSVersion < 0x1060) {
|
|
|
|
f = popen("defaults -currentHost read com.apple.screensaver moduleName", "r");
|
|
|
|
} else {
|
|
|
|
sprintf(s, "sudo -u %s defaults -currentHost read com.apple.screensaver moduleDict -dict",
|
|
|
|
dp->d_name);
|
|
|
|
f = popen(s, "r");
|
|
|
|
}
|
2007-06-06 12:52:37 +00:00
|
|
|
if (f) {
|
2009-12-16 12:50:40 +00:00
|
|
|
while (PersistentFGets(s, sizeof(s), f)) {
|
|
|
|
if (strstr(s, "BOINCSaver")) {
|
|
|
|
changeSaver = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (strstr(s, "GridRepublic")) {
|
|
|
|
changeSaver = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (strstr(s, "Progress Thru Processors")) {
|
|
|
|
changeSaver = true;
|
|
|
|
break;
|
|
|
|
}
|
2011-08-11 10:20:25 +00:00
|
|
|
if (strstr(s, "Charity Engine")) {
|
|
|
|
changeSaver = true;
|
|
|
|
break;
|
|
|
|
}
|
2009-12-16 12:50:40 +00:00
|
|
|
}
|
2007-06-06 12:52:37 +00:00
|
|
|
pclose(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changeSaver) {
|
2009-12-16 12:50:40 +00:00
|
|
|
if (OSVersion < 0x1060) {
|
|
|
|
system ("defaults -currentHost write com.apple.screensaver moduleName \"Computer Name\"");
|
|
|
|
system ("defaults -currentHost write com.apple.screensaver modulePath \"/System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/Computer Name.saver\"");
|
|
|
|
} else {
|
|
|
|
sprintf(s,
|
|
|
|
"sudo -u %s defaults -currentHost write com.apple.screensaver moduleDict -dict moduleName \"Computer Name\" path \"/System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/Computer Name.saver\"",
|
|
|
|
dp->d_name);
|
|
|
|
system (s);
|
|
|
|
}
|
2007-06-06 12:52:37 +00:00
|
|
|
}
|
|
|
|
|
2009-12-16 12:50:40 +00:00
|
|
|
seteuid(saved_euid); // Set effective uid back to privileged user
|
2007-06-06 12:52:37 +00:00
|
|
|
#if TESTING
|
2007-06-08 11:16:48 +00:00
|
|
|
// ShowMessage(false, "After seteuid(%d) for user %s, euid = %d, saved_uid = %d", pw->pw_uid, dp->d_name, geteuid(), saved_uid);
|
2007-06-06 12:52:37 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
closedir(dirp);
|
|
|
|
return noErr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static OSStatus GetAuthorization(AuthorizationRef * authRef, const char *pathToTool, char *brandName) {
|
|
|
|
static Boolean sIsAuthorized = false;
|
|
|
|
AuthorizationRights ourAuthRights;
|
|
|
|
AuthorizationFlags ourAuthFlags;
|
|
|
|
AuthorizationItem ourAuthRightsItem[1];
|
|
|
|
AuthorizationEnvironment ourAuthEnvironment;
|
|
|
|
AuthorizationItem ourAuthEnvItem[1];
|
|
|
|
char prompt[256];
|
|
|
|
OSStatus err = noErr;
|
|
|
|
|
|
|
|
if (sIsAuthorized)
|
|
|
|
return noErr;
|
|
|
|
|
|
|
|
sprintf(prompt, "Enter administrator password to completely remove %s from you computer.\n\n", brandName);
|
|
|
|
|
|
|
|
ourAuthRights.count = 0;
|
|
|
|
ourAuthRights.items = NULL;
|
|
|
|
|
|
|
|
err = AuthorizationCreate (&ourAuthRights, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, authRef);
|
|
|
|
if (err != noErr) {
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "AuthorizationCreate returned error %d", err);
|
2007-06-06 12:52:37 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
ourAuthRightsItem[0].name = kAuthorizationRightExecute;
|
|
|
|
ourAuthRightsItem[0].value = (void *)pathToTool;
|
|
|
|
ourAuthRightsItem[0].valueLength = strlen (pathToTool);
|
|
|
|
ourAuthRightsItem[0].flags = 0;
|
|
|
|
ourAuthRights.count = 1;
|
|
|
|
ourAuthRights.items = ourAuthRightsItem;
|
|
|
|
|
|
|
|
ourAuthEnvItem[0].name = kAuthorizationEnvironmentPrompt;
|
|
|
|
ourAuthEnvItem[0].value = prompt;
|
|
|
|
ourAuthEnvItem[0].valueLength = strlen (prompt);
|
|
|
|
ourAuthEnvItem[0].flags = 0;
|
|
|
|
|
|
|
|
ourAuthEnvironment.count = 1;
|
|
|
|
ourAuthEnvironment.items = ourAuthEnvItem;
|
|
|
|
|
|
|
|
|
|
|
|
ourAuthFlags = kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights;
|
|
|
|
|
|
|
|
// When this is called from the installer, the installer has already authenticated.
|
|
|
|
// In that case we are already running with full root privileges so AuthorizationCopyRights()
|
|
|
|
// does not request a password from the user again.
|
|
|
|
err = AuthorizationCopyRights (*authRef, &ourAuthRights, &ourAuthEnvironment, ourAuthFlags, NULL);
|
|
|
|
|
|
|
|
if (err == noErr)
|
|
|
|
sIsAuthorized = true;
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static OSStatus DoPrivilegedExec(char *brandName, const char *pathToTool, char *arg1, char *arg2, char *arg3, char *arg4, char *arg5) {
|
|
|
|
AuthorizationRef authRef = NULL;
|
|
|
|
short i;
|
|
|
|
char *args[8];
|
|
|
|
OSStatus err;
|
|
|
|
FILE *ioPipe;
|
|
|
|
char *p, junk[256];
|
|
|
|
|
|
|
|
err = GetAuthorization(&authRef, pathToTool, brandName);
|
|
|
|
if (err != noErr) {
|
|
|
|
if (err != errAuthorizationCanceled)
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "GetAuthorization returned error %d", err);
|
2007-06-06 12:52:37 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i<5; i++) { // Retry 5 times if error
|
|
|
|
args[0] = arg1;
|
|
|
|
args[1] = arg2;
|
|
|
|
args[2] = arg3;
|
|
|
|
args[3] = arg4;
|
|
|
|
args[4] = arg5;
|
|
|
|
args[5] = NULL;
|
|
|
|
|
|
|
|
err = AuthorizationExecuteWithPrivileges (authRef, pathToTool, 0, args, &ioPipe);
|
|
|
|
// We use the pipe to signal us when the command has completed
|
|
|
|
if (ioPipe) {
|
|
|
|
do {
|
|
|
|
p = fgets(junk, sizeof(junk), ioPipe);
|
|
|
|
} while (p);
|
|
|
|
|
|
|
|
fclose (ioPipe);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (err == noErr)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (err != noErr)
|
2007-06-08 11:16:48 +00:00
|
|
|
ShowMessage(false, "\"%s %s %s %s %s %s\" returned error %d", pathToTool,
|
2007-06-06 12:52:37 +00:00
|
|
|
arg1 ? arg1 : "", arg2 ? arg2 : "", arg3 ? arg3 : "",
|
|
|
|
arg4 ? arg4 : "", arg5 ? arg5 : "", err);
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-24 12:43:19 +00:00
|
|
|
static void DeleteLoginItemOSAScript(char* user, char* appName)
|
2007-06-06 12:52:37 +00:00
|
|
|
{
|
2011-08-11 10:20:25 +00:00
|
|
|
char cmd[2048];
|
|
|
|
OSErr err;
|
2007-06-06 12:52:37 +00:00
|
|
|
|
2011-09-24 13:42:55 +00:00
|
|
|
sprintf(cmd, "sudo -u %s osascript -e 'tell application \"System Events\"' -e 'delete (every login item whose name contains \"%s\")' -e 'end tell'", user, appName);
|
2011-08-11 10:20:25 +00:00
|
|
|
err = system(cmd);
|
|
|
|
if (err) {
|
|
|
|
printf("[2] Delete login item containing %s for user %s returned error %d\n", appName, user, err);
|
2007-06-06 12:52:37 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-24 12:43:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void DeleteLoginItemAPI(void)
|
|
|
|
{
|
|
|
|
Boolean Success;
|
|
|
|
int NumberOfLoginItems, Counter;
|
|
|
|
char *p, *q;
|
|
|
|
|
|
|
|
Success = false;
|
|
|
|
|
|
|
|
NumberOfLoginItems = GetCountOfLoginItems(kCurrentUser);
|
|
|
|
|
|
|
|
// Search existing login items in reverse order, deleting ours
|
|
|
|
for (Counter = NumberOfLoginItems ; Counter > 0 ; Counter--)
|
|
|
|
{
|
|
|
|
p = ReturnLoginItemPropertyAtIndex(kCurrentUser, kApplicationNameInfo, Counter-1);
|
|
|
|
q = p;
|
|
|
|
while (*q)
|
|
|
|
{
|
|
|
|
// It is OK to modify the returned string because we "own" it
|
|
|
|
*q = toupper(*q); // Make it case-insensitive
|
|
|
|
q++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(p, "BOINCMANAGER.APP") == 0)
|
|
|
|
Success = RemoveLoginItemAtIndex(kCurrentUser, Counter-1);
|
|
|
|
if (strcmp(p, "GRIDREPUBLIC DESKTOP.APP") == 0)
|
|
|
|
Success = RemoveLoginItemAtIndex(kCurrentUser, Counter-1);
|
|
|
|
if (strcmp(p, "PROGRESS THRU PROCESSORS DESKTOP.APP") == 0)
|
|
|
|
Success = RemoveLoginItemAtIndex(kCurrentUser, Counter-1);
|
|
|
|
if (strcmp(p, "CHARITY ENGINE DESKTOP.APP") == 0)
|
|
|
|
Success = RemoveLoginItemAtIndex(kCurrentUser, Counter-1);
|
|
|
|
}
|
|
|
|
}
|
2007-06-06 12:52:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
static char * PersistentFGets(char *buf, size_t buflen, FILE *f) {
|
|
|
|
char *p = buf;
|
|
|
|
size_t len = buflen;
|
|
|
|
size_t datalen = 0;
|
|
|
|
|
|
|
|
*buf = '\0';
|
|
|
|
while (datalen < (buflen - 1)) {
|
|
|
|
fgets(p, len, f);
|
|
|
|
if (feof(f)) break;
|
|
|
|
if (ferror(f) && (errno != EINTR)) break;
|
|
|
|
if (strchr(buf, '\n')) break;
|
|
|
|
datalen = strlen(buf);
|
|
|
|
p = buf + datalen;
|
|
|
|
len -= datalen;
|
|
|
|
}
|
|
|
|
return (buf[0] ? buf : NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static pid_t FindProcessPID(char* name, pid_t thePID)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
char buf[1024];
|
|
|
|
size_t n = 0;
|
|
|
|
pid_t aPID;
|
|
|
|
|
|
|
|
if (name != NULL) // Search ny name
|
|
|
|
n = strlen(name);
|
|
|
|
|
|
|
|
f = popen("ps -a -x -c -o command,pid", "r");
|
|
|
|
if (f == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
while (PersistentFGets(buf, sizeof(buf), f))
|
|
|
|
{
|
|
|
|
if (name != NULL) { // Search by name
|
|
|
|
if (strncmp(buf, name, n) == 0)
|
|
|
|
{
|
|
|
|
aPID = atol(buf+16);
|
|
|
|
pclose(f);
|
|
|
|
return aPID;
|
|
|
|
}
|
|
|
|
} else { // Search by PID
|
|
|
|
aPID = atol(buf+16);
|
|
|
|
if (aPID == thePID) {
|
|
|
|
pclose(f);
|
|
|
|
return aPID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pclose(f);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-07 12:24:29 +00:00
|
|
|
static OSStatus QuitBOINCManager(OSType signature) {
|
2007-06-06 12:52:37 +00:00
|
|
|
bool done = false;
|
|
|
|
ProcessSerialNumber thisPSN;
|
|
|
|
ProcessInfoRec thisPIR;
|
2007-06-07 12:24:29 +00:00
|
|
|
OSStatus err = noErr;
|
2007-06-06 12:52:37 +00:00
|
|
|
Str63 thisProcessName;
|
|
|
|
AEAddressDesc thisPSNDesc;
|
|
|
|
AppleEvent thisQuitEvent, thisReplyEvent;
|
|
|
|
|
|
|
|
|
|
|
|
thisPIR.processInfoLength = sizeof (ProcessInfoRec);
|
|
|
|
thisPIR.processName = thisProcessName;
|
|
|
|
thisPIR.processAppSpec = nil;
|
|
|
|
|
|
|
|
thisPSN.highLongOfPSN = 0;
|
|
|
|
thisPSN.lowLongOfPSN = kNoProcess;
|
|
|
|
|
|
|
|
while (done == false) {
|
|
|
|
err = GetNextProcess(&thisPSN);
|
|
|
|
if (err == procNotFound)
|
|
|
|
done = true; // apparently the demo app isn't running. Odd but not impossible
|
|
|
|
else {
|
|
|
|
err = GetProcessInformation(&thisPSN,&thisPIR);
|
|
|
|
if (err != noErr)
|
|
|
|
goto bail;
|
|
|
|
|
|
|
|
if (thisPIR.processSignature == signature) { // is it or target process?
|
|
|
|
err = AECreateDesc(typeProcessSerialNumber, (Ptr)&thisPSN,
|
|
|
|
sizeof(thisPSN), &thisPSNDesc);
|
|
|
|
if (err != noErr)
|
|
|
|
goto bail;
|
|
|
|
|
|
|
|
// Create the 'quit' Apple event for this process.
|
|
|
|
err = AECreateAppleEvent(kCoreEventClass, kAEQuitApplication, &thisPSNDesc,
|
|
|
|
kAutoGenerateReturnID, kAnyTransactionID, &thisQuitEvent);
|
|
|
|
if (err != noErr) {
|
|
|
|
AEDisposeDesc (&thisPSNDesc);
|
|
|
|
goto bail; // don't know how this could happen, but limp gamely onward
|
|
|
|
}
|
|
|
|
|
|
|
|
// send the event
|
|
|
|
err = AESend(&thisQuitEvent, &thisReplyEvent, kAEWaitReply,
|
|
|
|
kAENormalPriority, kAEDefaultTimeout, 0L, 0L);
|
|
|
|
AEDisposeDesc (&thisQuitEvent);
|
|
|
|
AEDisposeDesc (&thisPSNDesc);
|
|
|
|
#if 0
|
|
|
|
if (err == errAETimeout) {
|
|
|
|
pid_t thisPID;
|
|
|
|
|
|
|
|
err = GetProcessPID(&thisPSN , &thisPID);
|
|
|
|
if (err == noErr)
|
|
|
|
err = kill(thisPID, SIGKILL);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
done = true; // we've killed the process, presumably
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bail:
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2007-10-25 09:34:16 +00:00
|
|
|
#if 0
|
2007-06-06 12:52:37 +00:00
|
|
|
// Uses usleep to sleep for full duration even if a signal is received
|
|
|
|
static void SleepTicks(UInt32 ticksToSleep) {
|
|
|
|
UInt32 endSleep, timeNow, ticksRemaining;
|
|
|
|
|
|
|
|
timeNow = TickCount();
|
|
|
|
ticksRemaining = ticksToSleep;
|
|
|
|
endSleep = timeNow + ticksToSleep;
|
|
|
|
while ( (timeNow < endSleep) && (ticksRemaining <= ticksToSleep) ) {
|
|
|
|
usleep(16667 * ticksRemaining);
|
|
|
|
timeNow = TickCount();
|
|
|
|
ticksRemaining = endSleep - timeNow;
|
|
|
|
}
|
|
|
|
}
|
2007-10-25 09:34:16 +00:00
|
|
|
#endif
|
2007-06-06 12:52:37 +00:00
|
|
|
|
|
|
|
|
2007-06-08 11:16:48 +00:00
|
|
|
static Boolean ShowMessage(Boolean allowCancel, const char *format, ...) {
|
2007-06-06 12:52:37 +00:00
|
|
|
va_list args;
|
|
|
|
char s[1024];
|
|
|
|
short itemHit;
|
|
|
|
AlertStdAlertParamRec alertParams;
|
|
|
|
|
|
|
|
ProcessSerialNumber ourProcess;
|
|
|
|
|
|
|
|
va_start(args, format);
|
|
|
|
s[0] = vsprintf(s+1, format, args);
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
alertParams.movable = true;
|
|
|
|
alertParams.helpButton = false;
|
2007-06-07 12:24:29 +00:00
|
|
|
alertParams.filterProc = NULL;
|
2007-06-08 11:16:48 +00:00
|
|
|
alertParams.defaultText = (StringPtr)-1;
|
|
|
|
alertParams.cancelText = allowCancel ? (StringPtr)-1 : NULL;
|
2007-06-06 12:52:37 +00:00
|
|
|
alertParams.otherText = NULL;
|
|
|
|
alertParams.defaultButton = kAlertStdAlertOKButton;
|
2007-06-08 11:16:48 +00:00
|
|
|
alertParams.cancelButton = allowCancel ? kAlertStdAlertCancelButton : 0;
|
2007-06-06 12:52:37 +00:00
|
|
|
alertParams.position = kWindowDefaultPosition;
|
|
|
|
|
|
|
|
::GetCurrentProcess (&ourProcess);
|
|
|
|
::SetFrontProcess(&ourProcess);
|
|
|
|
|
2007-06-08 11:16:48 +00:00
|
|
|
StandardAlert (kAlertNoteAlert, (StringPtr)s, NULL, &alertParams, &itemHit);
|
|
|
|
|
|
|
|
return (itemHit == kAlertStdAlertOKButton);
|
2007-06-06 12:52:37 +00:00
|
|
|
}
|