From 8e3a02cbb552b595fb66df1511a985a09e877c0b Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Tue, 27 Feb 2007 09:52:01 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=12163 --- checkin_notes | 20 ++++++++++++++++++++ client/hostinfo_unix.C | 15 +++++++++++---- lib/hostinfo.h | 4 ++++ mac_build/Mac_SA_Insecure.sh | 20 +++++++++++++++----- mac_build/Mac_SA_Secure.sh | 24 +++++++++++++++++------- 5 files changed, 67 insertions(+), 16 deletions(-) diff --git a/checkin_notes b/checkin_notes index 3659e2b241..44ce6e043f 100755 --- a/checkin_notes +++ b/checkin_notes @@ -2060,3 +2060,23 @@ Charlie 26 Feb 2007 clientgui/ mac/ SetupSecurity.cpp + +Charlie 27 Feb 2007 + Mac: Add an optional argument to HOST_INFO::users_idle() to allow + returning the actual idle time. This change is __APPLE__ only. + Mac: Fix serious bugs in Mac_SA_Insecure.sh and Mac_SA_Secure.sh + scripts when run under OS 10.3.x. They sometimes created bad + users and groups with IDs that were duplicates of other users + and groups. They ran correctly under OS 10.4.x. + Users who ran an older version of either script under OS 10.3.x + should first run the current version of Mac_SA_Insecure.sh to + delete the bad entries and then run Mac_SA_Secure.sh to create + new good entries. + + client/ + hostinf_unix.C + lib/ + hostinfo.h + mac_build/ + Mac_SA_Insecure.sh + Mac_SA_Secure.sh diff --git a/client/hostinfo_unix.C b/client/hostinfo_unix.C index 1360b3cfdd..d80f1d9ce5 100644 --- a/client/hostinfo_unix.C +++ b/client/hostinfo_unix.C @@ -814,7 +814,16 @@ static double GetOSXIdleTime(void) { // return (double)NXIdleTime(gEventHandle); // Very old and very slow API } #endif // ! __i386__ -#endif // __APPLE__ + +bool HOST_INFO::users_idle(bool check_all_logins, double idle_time_to_run, double *actual_idle_time) { + double idleTime = GetOSXIdleTime(); + + if (actual_idle_time) + *actual_idle_time = idleTime; + return (idleTime > (60 * idle_time_to_run)); +} + +#else // ! __APPLE__ bool HOST_INFO::users_idle(bool check_all_logins, double idle_time_to_run) { #ifdef HAVE__DEV_TTY1 @@ -834,12 +843,10 @@ bool HOST_INFO::users_idle(bool check_all_logins, double idle_time_to_run) { #ifdef HAVE__DEV_TTY1 && (check_all_logins || all_tty_idle(idle_time, device_tty, '1', 7)) #endif -#ifdef __APPLE__ - && (GetOSXIdleTime() > (60 * idle_time_to_run)) -#endif // __APPLE__ ; } +#endif // ! __APPLE__ const char *BOINC_RCSID_2cf92d205b = "$Id$"; diff --git a/lib/hostinfo.h b/lib/hostinfo.h index 5d7f34ebf9..16a7b8681e 100644 --- a/lib/hostinfo.h +++ b/lib/hostinfo.h @@ -69,7 +69,11 @@ public: void print(); bool host_is_running_on_batteries(); +#ifdef __APPLE__ + bool users_idle(bool check_all_logins, double idle_time_to_run, double *actual_idle_time=NULL); +#else bool users_idle(bool check_all_logins, double idle_time_to_run); +#endif int get_host_info(); int get_local_network_info(); void clear_host_info(); diff --git a/mac_build/Mac_SA_Insecure.sh b/mac_build/Mac_SA_Insecure.sh index ffda6fb3bc..03035e6b09 100755 --- a/mac_build/Mac_SA_Insecure.sh +++ b/mac_build/Mac_SA_Insecure.sh @@ -25,33 +25,43 @@ # - Set file/dir ownership to the specified user and group # - Remove BOINC groups and users # +# If you ran an older version of either script under OS 10.3.x, you should +# first run the current version of Mac_SA_Insecure.sh to delete the bad +# entries and then run Mac_SA_Secure.sh to create new good entries. +# +# # Execute this as root in the BOINC directory: # cd {path_to_boinc_directory} # sudo sh {path}/Mac_SA_Insecure.sh user group # +# IMPORTANT NOTE: earlier versions of the Mac_SA_Insecure.sh and +# Mac_SA_Secure.sh scripts had serious problems when run under OS 10.3.x. +# They sometimes created bad users and groups with IDs that were duplicates +# of other users and groups. They ran correctly under OS 10.4.x +# # After running this script, the boinc client must be run with # the --insecure option. # NOTE: running BOINC with security disabled is not recommended. # -# Last updated 9/21/06 +# Last updated 2/27/07 function remove_boinc_users() { - name=$(dscl . search /users RecordName boinc_master | cut -f1 -) + name=$(dscl . search /users RecordName boinc_master | cut -f1 -s) if [ "$name" = "boinc_master" ] ; then sudo dscl . -delete /users/boinc_master fi - name=$(dscl . search /groups RecordName boinc_master | cut -f1 -) + name=$(dscl . search /groups RecordName boinc_master | cut -f1 -s) if [ "$name" = "boinc_master" ] ; then sudo dscl . -delete /groups/boinc_master fi - name=$(dscl . search /users RecordName boinc_project | cut -f1 -) + name=$(dscl . search /users RecordName boinc_project | cut -f1 -s) if [ "$name" = "boinc_project" ] ; then sudo dscl . -delete /users/boinc_project fi - name=$(dscl . search /groups RecordName boinc_project | cut -f1 -) + name=$(dscl . search /groups RecordName boinc_project | cut -f1 -s) if [ "$name" = "boinc_project" ] ; then sudo dscl . -delete /groups/boinc_project fi diff --git a/mac_build/Mac_SA_Secure.sh b/mac_build/Mac_SA_Secure.sh index f19309ce11..9004c0e720 100755 --- a/mac_build/Mac_SA_Secure.sh +++ b/mac_build/Mac_SA_Secure.sh @@ -28,6 +28,16 @@ # # Create groups and users, set file/dir ownership and protection # +# IMPORTANT NOTE: earlier versions of the Mac_SA_Insecure.sh and +# Mac_SA_Secure.sh scripts had serious problems when run under OS 10.3.x. +# They sometimes created bad users and groups with IDs that were duplicates +# of other users and groups. They ran correctly under OS 10.4.x +# +# If you ran an older version of either script under OS 10.3.x, you should +# first run the current version of Mac_SA_Insecure.sh to delete the bad +# entries and then run Mac_SA_Secure.sh to create new good entries. +# +# # Execute this as root in the BOINC directory: # cd {path_to_boinc_directory} # sudo sh {path}/Mac_SA_Secure.sh @@ -54,18 +64,18 @@ # sudo dscl . -delete /groups/boinc_master users mary # -# Last updated 9/21/06 +# Last updated 2/27/07 function make_boinc_user() { # Check whether group already exists - name=$(dscl . search /groups RecordName $1 | cut -f1 -) + name=$(dscl . search /groups RecordName $1 | cut -f1 -s) if [ "$name" = "$1" ] ; then - gid=$(dscl . read /groups/$1 PrimaryGroupID | cut -d" " -f2 -) + gid=$(dscl . read /groups/$1 PrimaryGroupID | cut -d" " -f2 -s) else # Find an unused group ID gid="25" while true; do - name=$(dscl . search /groups PrimaryGroupID $gid | cut -f1 -) + name=$(dscl . search /groups PrimaryGroupID $gid | cut -f1 -s) if [ -z "$name" ] ; then break fi @@ -76,17 +86,17 @@ function make_boinc_user() { fi # Check whether user already exists - name=$(dscl . search /users RecordName $1 | cut -f1 -) + name=$(dscl . search /users RecordName $1 | cut -f1 -s) if [ -z "$name" ] ; then # Is uid=gid available? uid=$gid - name=$(dscl . search /users UniqueID $uid | cut -f1 -) + name=$(dscl . search /users UniqueID $uid | cut -f1 -s) if [ -n "$name" ] ; then # uid=gid already in use, so find an unused user ID uid="25" while true; do - name=$(dscl . search /groups UniqueID $uid | cut -f1 -) + name=$(dscl . search /groups UniqueID $uid | cut -f1 -s) if [ -z "$name" ] ; then break fi