mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=10729
This commit is contained in:
parent
af77e5f367
commit
f7117a4c52
|
@ -7890,3 +7890,12 @@ Charlie 21 July 2006
|
||||||
buildcurl.sh
|
buildcurl.sh
|
||||||
buildjpeg.sh
|
buildjpeg.sh
|
||||||
setupForBOINC.sh
|
setupForBOINC.sh
|
||||||
|
|
||||||
|
Charlie 22 July 2006
|
||||||
|
-Mac: Installer checks for a file nologinitems.txt in BOINC Data directory. If
|
||||||
|
present, delete LoginItems for users listed in this file (one user name per
|
||||||
|
line), so that BOINC Manager won't launch automatically when these users
|
||||||
|
log in. This is a tool for system administrators.
|
||||||
|
|
||||||
|
mac_installer/
|
||||||
|
Postinstall.cpp
|
||||||
|
|
|
@ -43,7 +43,8 @@
|
||||||
void Initialize(void); /* function prototypes */
|
void Initialize(void); /* function prototypes */
|
||||||
int DeleteReceipt(void);
|
int DeleteReceipt(void);
|
||||||
OSStatus CheckLogoutRequirement(int *finalAction);
|
OSStatus CheckLogoutRequirement(int *finalAction);
|
||||||
void SetLoginItem(long brandID);
|
void SetLoginItem(long brandID, Boolean deleteLogInItem);
|
||||||
|
Boolean CheckDeleteFile(char *name);
|
||||||
void SetUIDBackToUser (void);
|
void SetUIDBackToUser (void);
|
||||||
OSErr UpdateAllVisibleUsers(long brandID);
|
OSErr UpdateAllVisibleUsers(long brandID);
|
||||||
long GetBrandID(void);
|
long GetBrandID(void);
|
||||||
|
@ -281,16 +282,9 @@ int main(int argc, char *argv[])
|
||||||
if (err_fsref == noErr)
|
if (err_fsref == noErr)
|
||||||
err = LSRegisterFSRef(&fileRef, true);
|
err = LSRegisterFSRef(&fileRef, true);
|
||||||
|
|
||||||
#ifdef SANDBOX
|
|
||||||
err = UpdateAllVisibleUsers(brandID);
|
err = UpdateAllVisibleUsers(brandID);
|
||||||
if (err != noErr)
|
if (err != noErr)
|
||||||
return err;
|
return err;
|
||||||
#else
|
|
||||||
// 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 ();
|
|
||||||
SetLoginItem(brandID);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -410,7 +404,7 @@ OSStatus CheckLogoutRequirement(int *finalAction)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SetLoginItem(long brandID)
|
void SetLoginItem(long brandID, Boolean deleteLogInItem)
|
||||||
{
|
{
|
||||||
Boolean Success;
|
Boolean Success;
|
||||||
int NumberOfLoginItems, Counter;
|
int NumberOfLoginItems, Counter;
|
||||||
|
@ -438,6 +432,9 @@ void SetLoginItem(long brandID)
|
||||||
Success = RemoveLoginItemAtIndex(kCurrentUser, Counter-1);
|
Success = RemoveLoginItemAtIndex(kCurrentUser, Counter-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (deleteLogInItem)
|
||||||
|
return;
|
||||||
|
|
||||||
if (brandID == 1)
|
if (brandID == 1)
|
||||||
Success = AddLoginItemWithPropertiesToUser(kCurrentUser,
|
Success = AddLoginItemWithPropertiesToUser(kCurrentUser,
|
||||||
"/Applications/GridRepublic Desktop.app", kDoNotHideOnLaunch);
|
"/Applications/GridRepublic Desktop.app", kDoNotHideOnLaunch);
|
||||||
|
@ -446,6 +443,33 @@ void SetLoginItem(long brandID)
|
||||||
"/Applications/BOINCManager.app", kDoNotHideOnLaunch);
|
"/Applications/BOINCManager.app", kDoNotHideOnLaunch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns true if the user name is in the nologinitems.txt, else false
|
||||||
|
Boolean CheckDeleteFile(char *name)
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
char buf[64];
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
f = fopen("/Library/Application Support/BOINC Data/nologinitems.txt", "r");
|
||||||
|
if (!f)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
*buf = '\0';
|
||||||
|
len = sizeof(buf);
|
||||||
|
fgets(buf, len, f);
|
||||||
|
if (feof(f)) break;
|
||||||
|
strip_cr(buf);
|
||||||
|
if (strcmp(buf, name) == 0) {
|
||||||
|
fclose(f);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(f);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void SetUIDBackToUser (void)
|
void SetUIDBackToUser (void)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
@ -470,13 +494,17 @@ OSErr UpdateAllVisibleUsers(long brandID)
|
||||||
passwd *pw;
|
passwd *pw;
|
||||||
uid_t saved_uid;
|
uid_t saved_uid;
|
||||||
short i;
|
short i;
|
||||||
|
Boolean deleteLoginItem;
|
||||||
OSErr err = noErr;
|
OSErr err = noErr;
|
||||||
|
|
||||||
|
#ifdef SANDBOX
|
||||||
grp = getgrnam("admin");
|
grp = getgrnam("admin");
|
||||||
if (grp == NULL) { // Should never happen
|
if (grp == NULL) { // Should never happen
|
||||||
puts("getgrnam(\"admin\") failed\n");
|
puts("getgrnam(\"admin\") failed\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
dirp = opendir("/Users");
|
dirp = opendir("/Users");
|
||||||
if (dirp == NULL) { // Should never happen
|
if (dirp == NULL) { // Should never happen
|
||||||
puts("opendir(\"/Users\") failed\n");
|
puts("opendir(\"/Users\") failed\n");
|
||||||
|
@ -495,6 +523,7 @@ OSErr UpdateAllVisibleUsers(long brandID)
|
||||||
if (pw == NULL) // "Deleted Users", "Shared", etc.
|
if (pw == NULL) // "Deleted Users", "Shared", etc.
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
#ifdef SANDBOX
|
||||||
i = 0;
|
i = 0;
|
||||||
while ((p = grp->gr_mem[i]) != NULL) { // Step through all users in group admin
|
while ((p = grp->gr_mem[i]) != NULL) { // Step through all users in group admin
|
||||||
if (strcmp(p, dp->d_name) == 0) {
|
if (strcmp(p, dp->d_name) == 0) {
|
||||||
|
@ -506,10 +535,12 @@ OSErr UpdateAllVisibleUsers(long brandID)
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
deleteLoginItem = CheckDeleteFile(dp->d_name);
|
||||||
saved_uid = geteuid();
|
saved_uid = geteuid();
|
||||||
seteuid(pw->pw_uid); // Temporarily set effective uid to this user
|
seteuid(pw->pw_uid); // Temporarily set effective uid to this user
|
||||||
SetLoginItem(brandID); // Set login item for this user
|
SetLoginItem(brandID, deleteLoginItem); // Set login item for this user
|
||||||
seteuid(saved_uid); // Set effective uid back to privileged user
|
seteuid(saved_uid); // Set effective uid back to privileged user
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,6 +764,17 @@ static OSErr QuitAppleEventHandler( const AppleEvent *appleEvt, AppleEvent* repl
|
||||||
return noErr;
|
return noErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void strip_cr(char *buf)
|
||||||
|
{
|
||||||
|
char *theCR;
|
||||||
|
|
||||||
|
theCR = strrchr(buf, '\n');
|
||||||
|
if (theCR)
|
||||||
|
*theCR = '\0';
|
||||||
|
theCR = strrchr(buf, '\r');
|
||||||
|
if (theCR)
|
||||||
|
*theCR = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
// For debugging
|
// For debugging
|
||||||
void print_to_log_file(const char *format, ...) {
|
void print_to_log_file(const char *format, ...) {
|
||||||
|
@ -769,18 +811,4 @@ void print_to_log_file(const char *format, ...) {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CREATE_LOG
|
|
||||||
void strip_cr(char *buf)
|
|
||||||
{
|
|
||||||
char *theCR;
|
|
||||||
|
|
||||||
theCR = strrchr(buf, '\n');
|
|
||||||
if (theCR)
|
|
||||||
*theCR = '\0';
|
|
||||||
theCR = strrchr(buf, '\r');
|
|
||||||
if (theCR)
|
|
||||||
*theCR = '\0';
|
|
||||||
}
|
|
||||||
#endif // CREATE_LOG
|
|
||||||
const char *BOINC_RCSID_c7abe0490e="$Id$";
|
const char *BOINC_RCSID_c7abe0490e="$Id$";
|
||||||
|
|
Loading…
Reference in New Issue