mirror of https://github.com/BOINC/boinc.git
Mac Uninstaller: Properly change screensaver settings under OS 10.6
svn path=/trunk/boinc/; revision=19922
This commit is contained in:
parent
e6295a9a44
commit
3cb29867e7
|
@ -10110,3 +10110,9 @@ David 15 Dec 2009
|
||||||
|
|
||||||
client/
|
client/
|
||||||
boinc_cmd.cpp
|
boinc_cmd.cpp
|
||||||
|
|
||||||
|
Charlie 16 Dec 2009
|
||||||
|
- Mac Uninstaller: Properly change screensaver settings under OS 10.6.
|
||||||
|
|
||||||
|
mac_installer/
|
||||||
|
uninstall.cpp
|
||||||
|
|
|
@ -359,17 +359,27 @@ static OSStatus CleanupAllVisibleUsers(void)
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
dirent *dp;
|
dirent *dp;
|
||||||
passwd *pw;
|
passwd *pw;
|
||||||
uid_t saved_uid;
|
uid_t saved_uid, saved_euid;
|
||||||
char s[1024];
|
char s[1024];
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
long OSVersion = 0;
|
||||||
|
OSStatus err;
|
||||||
Boolean changeSaver;
|
Boolean changeSaver;
|
||||||
|
|
||||||
|
err = Gestalt(gestaltSystemVersion, &OSVersion);
|
||||||
|
if (err != noErr) {
|
||||||
|
OSVersion = 0;
|
||||||
|
}
|
||||||
|
|
||||||
dirp = opendir("/Users");
|
dirp = opendir("/Users");
|
||||||
if (dirp == NULL) { // Should never happen
|
if (dirp == NULL) { // Should never happen
|
||||||
ShowMessage(false, "opendir(\"/Users\") failed");
|
ShowMessage(false, "opendir(\"/Users\") failed");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saved_uid = getuid();
|
||||||
|
saved_euid = geteuid();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
dp = readdir(dirp);
|
dp = readdir(dirp);
|
||||||
if (dp == NULL)
|
if (dp == NULL)
|
||||||
|
@ -393,7 +403,9 @@ static OSStatus CleanupAllVisibleUsers(void)
|
||||||
// ShowMessage(false, "Before seteuid(%d) for user %s, euid = %d", pw->pw_uid, dp->d_name, geteuid());
|
// ShowMessage(false, "Before seteuid(%d) for user %s, euid = %d", pw->pw_uid, dp->d_name, geteuid());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
saved_uid = geteuid();
|
if (OSVersion >= 0x1060) {
|
||||||
|
setuid(0);
|
||||||
|
}
|
||||||
seteuid(pw->pw_uid); // Temporarily set effective uid to this user
|
seteuid(pw->pw_uid); // Temporarily set effective uid to this user
|
||||||
|
|
||||||
DeleteLoginItem(); // Delete our login item(s) for this user
|
DeleteLoginItem(); // Delete our login item(s) for this user
|
||||||
|
@ -404,24 +416,44 @@ static OSStatus CleanupAllVisibleUsers(void)
|
||||||
// Set screensaver to "Computer Name" default screensaver only
|
// Set screensaver to "Computer Name" default screensaver only
|
||||||
// if it was BOINC, GridRepublic or Progress Thru Processors.
|
// if it was BOINC, GridRepublic or Progress Thru Processors.
|
||||||
changeSaver = false;
|
changeSaver = false;
|
||||||
f = popen("defaults -currentHost read com.apple.screensaver moduleName", "r");
|
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");
|
||||||
|
}
|
||||||
if (f) {
|
if (f) {
|
||||||
PersistentFGets(s, sizeof(s), f);
|
while (PersistentFGets(s, sizeof(s), f)) {
|
||||||
if (strstr(s, "BOINCSaver"))
|
if (strstr(s, "BOINCSaver")) {
|
||||||
changeSaver = true;
|
changeSaver = true;
|
||||||
if (strstr(s, "GridRepublic"))
|
break;
|
||||||
changeSaver = true;
|
}
|
||||||
if (strstr(s, "Progress Thru Processors"))
|
if (strstr(s, "GridRepublic")) {
|
||||||
changeSaver = true;
|
changeSaver = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (strstr(s, "Progress Thru Processors")) {
|
||||||
|
changeSaver = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
pclose(f);
|
pclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changeSaver) {
|
if (changeSaver) {
|
||||||
system ("defaults -currentHost write com.apple.screensaver moduleName \"Computer Name\"");
|
if (OSVersion < 0x1060) {
|
||||||
system ("defaults -currentHost write com.apple.screensaver modulePath \"/System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/Computer Name.saver\"");
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
seteuid(saved_uid); // Set effective uid back to privileged user
|
seteuid(saved_euid); // Set effective uid back to privileged user
|
||||||
#if TESTING
|
#if TESTING
|
||||||
// ShowMessage(false, "After seteuid(%d) for user %s, euid = %d, saved_uid = %d", pw->pw_uid, dp->d_name, geteuid(), saved_uid);
|
// ShowMessage(false, "After seteuid(%d) for user %s, euid = %d, saved_uid = %d", pw->pw_uid, dp->d_name, geteuid(), saved_uid);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue