2006-07-26 11:40:38 +00:00
|
|
|
#! /bin/sh
|
|
|
|
|
2009-02-21 02:42:50 +00:00
|
|
|
# This file is part of BOINC.
|
2006-07-26 11:40:38 +00:00
|
|
|
# http://boinc.berkeley.edu
|
2009-02-21 02:42:50 +00:00
|
|
|
# Copyright (C) 2008 University of California
|
2006-07-26 11:40:38 +00:00
|
|
|
#
|
2009-02-21 02:42:50 +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.
|
2006-07-26 11:40:38 +00:00
|
|
|
#
|
2009-02-21 02:42:50 +00:00
|
|
|
# BOINC is distributed in the hope that it will be useful,
|
2006-07-26 11:40:38 +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.
|
|
|
|
#
|
2009-02-21 02:42:50 +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/>.
|
2006-07-26 11:40:38 +00:00
|
|
|
|
|
|
|
# Make a BOINC installation "secure" on a Macintosh with stand-alone BOINC Client
|
2006-07-27 08:55:59 +00:00
|
|
|
# The BOINC installer does this for a Macintosh installation with BOINC Manager;
|
2006-09-22 02:54:27 +00:00
|
|
|
# the BOINC Manager contains the BOINC client embedded in its bundle.
|
|
|
|
# if you ran the BOINC installer, you do not need to use this script unless you
|
|
|
|
# wish to run a separate copy of the stand-alone client in the BOINC Data
|
|
|
|
# directory.
|
2006-07-26 11:40:38 +00:00
|
|
|
#
|
|
|
|
# Create groups and users, set file/dir ownership and protection
|
|
|
|
#
|
2007-02-27 09:52:01 +00:00
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
#
|
2006-07-27 08:55:59 +00:00
|
|
|
# Execute this as root in the BOINC directory:
|
|
|
|
# cd {path_to_boinc_directory}
|
|
|
|
# sudo sh {path}/Mac_SA_Secure.sh
|
|
|
|
#
|
|
|
|
# Hint: you can enter the path to a directory or file by dragging its
|
|
|
|
# icon from the Finder onto the Terminal window.
|
|
|
|
#
|
2006-09-22 02:54:27 +00:00
|
|
|
# You must have already put all necessary files into the boinc directory,
|
|
|
|
# including the boinc client, boinc_cmd application, ca-bundle.crt, plus
|
|
|
|
# the switcher/ directory and its contents.
|
2006-07-27 08:55:59 +00:00
|
|
|
#
|
|
|
|
# This script also assumes that the user who runs it will be authorized
|
|
|
|
# to administer BOINC. For convenience in administering BOINC, this script
|
|
|
|
# adds the logged-in user to groups boinc_master and boinc_project
|
|
|
|
# (i.e., adds these groups to the user's supplementary groups list.)
|
|
|
|
#
|
|
|
|
# In addition, you should add any other users who will administer BOINC
|
|
|
|
# to groups boinc_master and boinc_project; e.g. for user mary:
|
|
|
|
#
|
2011-08-12 11:07:24 +00:00
|
|
|
# sudo dscl . -merge /groups/boinc_master GroupMembership mary
|
|
|
|
# sudo dscl . -merge /groups/boinc_project GroupMembership mary
|
2006-07-27 08:55:59 +00:00
|
|
|
#
|
|
|
|
# To remove user mary from group boinc_master:
|
2011-08-12 11:07:24 +00:00
|
|
|
# sudo dscl . -delete /groups/boinc_master GroupMembership mary
|
2006-07-27 08:55:59 +00:00
|
|
|
#
|
2006-07-26 11:40:38 +00:00
|
|
|
|
2011-08-12 11:07:24 +00:00
|
|
|
# Updated 1/28/10 for BOINC version 6.8.20, 6.10.30 and 6.11.1
|
2011-10-24 09:16:02 +00:00
|
|
|
# Last updated 10/24/11 for OS 10.7.2 Lion
|
2009-10-31 07:45:44 +00:00
|
|
|
# WARNING: do not use this script with versions of BOINC older
|
2010-01-28 10:30:22 +00:00
|
|
|
# than 6.8.20 and 6.10.30
|
2006-09-22 02:54:27 +00:00
|
|
|
|
2006-07-26 11:40:38 +00:00
|
|
|
function make_boinc_user() {
|
|
|
|
# Check whether group already exists
|
2007-02-27 09:52:01 +00:00
|
|
|
name=$(dscl . search /groups RecordName $1 | cut -f1 -s)
|
2006-07-26 12:47:52 +00:00
|
|
|
if [ "$name" = "$1" ] ; then
|
2007-02-27 09:52:01 +00:00
|
|
|
gid=$(dscl . read /groups/$1 PrimaryGroupID | cut -d" " -f2 -s)
|
2006-07-26 12:47:52 +00:00
|
|
|
else
|
2006-07-26 11:40:38 +00:00
|
|
|
# Find an unused group ID
|
|
|
|
gid="25"
|
|
|
|
while true; do
|
2007-02-27 09:52:01 +00:00
|
|
|
name=$(dscl . search /groups PrimaryGroupID $gid | cut -f1 -s)
|
2006-07-26 11:40:38 +00:00
|
|
|
if [ -z "$name" ] ; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
gid=$[$gid +1]
|
|
|
|
done
|
|
|
|
dscl . -create /groups/$1
|
|
|
|
dscl . -create /groups/$1 gid $gid
|
|
|
|
fi
|
2006-07-26 12:47:52 +00:00
|
|
|
|
2006-07-26 11:40:38 +00:00
|
|
|
# Check whether user already exists
|
2007-02-27 09:52:01 +00:00
|
|
|
name=$(dscl . search /users RecordName $1 | cut -f1 -s)
|
2006-07-26 12:47:52 +00:00
|
|
|
if [ -z "$name" ] ; then
|
2006-07-26 11:40:38 +00:00
|
|
|
|
|
|
|
# Is uid=gid available?
|
|
|
|
uid=$gid
|
2007-02-27 09:52:01 +00:00
|
|
|
name=$(dscl . search /users UniqueID $uid | cut -f1 -s)
|
2006-07-26 11:40:38 +00:00
|
|
|
if [ -n "$name" ] ; then
|
|
|
|
# uid=gid already in use, so find an unused user ID
|
|
|
|
uid="25"
|
|
|
|
while true; do
|
2011-10-24 09:16:02 +00:00
|
|
|
name=$(dscl . search /users UniqueID $uid | cut -f1 -s)
|
2006-07-26 11:40:38 +00:00
|
|
|
if [ -z "$name" ] ; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
uid=$[$uid +1]
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
dscl . -create /users/$1
|
|
|
|
dscl . -create /users/$1 uid $uid
|
|
|
|
dscl . -create /users/$1 shell /usr/bin/false
|
|
|
|
dscl . -create /users/$1 home /var/empty
|
|
|
|
dscl . -create /users/$1 gid $gid
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function make_boinc_users() {
|
|
|
|
make_boinc_user boinc_master
|
|
|
|
make_boinc_user boinc_project
|
|
|
|
}
|
|
|
|
|
|
|
|
function check_login() {
|
|
|
|
if [ `whoami` != 'root' ]
|
|
|
|
then
|
|
|
|
echo 'This script must be run as root'
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# set_perm path user group perm
|
|
|
|
# set a file or directory to the given ownership/permissions
|
|
|
|
function set_perm() {
|
|
|
|
chown $2:$3 "$1"
|
|
|
|
chmod $4 "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
# same, but apply to all subdirs and files
|
|
|
|
#
|
|
|
|
function set_perm_recursive() {
|
|
|
|
chown -R $2:$3 "$1"
|
|
|
|
chmod -R $4 "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
# same, but apply to items in the given dir
|
|
|
|
#
|
|
|
|
function set_perm_dir() {
|
|
|
|
for file in $(ls "$1")
|
|
|
|
do
|
|
|
|
path="$1/${file}"
|
|
|
|
set_perm "${path}" $2 $3 $4
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function update_nested_dirs() {
|
|
|
|
for file in $(ls "$1")
|
|
|
|
do
|
|
|
|
if [ -d "${1}/${file}" ] ; then
|
2010-01-27 07:38:29 +00:00
|
|
|
chmod u+x,g+x,o+x "${1}/${file}"
|
2006-07-26 11:40:38 +00:00
|
|
|
update_nested_dirs "${1}/${file}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
check_login
|
|
|
|
|
2006-07-26 13:39:59 +00:00
|
|
|
echo "Changing directory $(pwd) file ownership to user and group boinc_master - OK? (y/n)"
|
2006-07-26 11:40:38 +00:00
|
|
|
read line
|
|
|
|
if [ "$line" != "y" ]
|
|
|
|
then
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2006-09-22 02:54:27 +00:00
|
|
|
if [ ! -x "switcher/switcher" ]
|
2006-07-26 13:39:59 +00:00
|
|
|
then
|
2006-09-22 02:54:27 +00:00
|
|
|
echo "Can't find switcher application in directory $(pwd); exiting"
|
2006-07-26 13:39:59 +00:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2006-07-26 11:40:38 +00:00
|
|
|
make_boinc_users
|
|
|
|
|
2011-08-12 11:07:24 +00:00
|
|
|
# Check whether user is already a member of group boinc_master
|
|
|
|
#dscl . -read /Groups/boinc_master GroupMembership | grep -wq "$(LOGNAME)"
|
2011-08-13 02:29:51 +00:00
|
|
|
#if [ $? -ne 0 ]; then
|
2011-08-12 11:07:24 +00:00
|
|
|
dscl . -merge /groups/boinc_master GroupMembership "$(LOGNAME)"
|
|
|
|
#fi
|
|
|
|
|
|
|
|
# Check whether user is already a member of group boinc_project
|
|
|
|
#dscl . -read /Groups/boinc_project GroupMembership | grep -wq "$(LOGNAME)"
|
2011-08-13 02:29:51 +00:00
|
|
|
#if [ $? -ne 0 ]; then
|
2011-08-12 11:07:24 +00:00
|
|
|
dscl . -merge /groups/boinc_project GroupMembership "$(LOGNAME)"
|
|
|
|
#fi
|
2006-07-27 08:55:59 +00:00
|
|
|
|
2010-01-22 12:34:04 +00:00
|
|
|
# Set permissions of BOINC Data directory's contents:
|
|
|
|
# ss_config.xml is world-readable so screensaver coordinator can read it
|
|
|
|
# all other *.xml are not world-readable to keep authenticators private
|
|
|
|
# gui_rpc_auth.cfg is not world-readable to keep RPC password private
|
|
|
|
# all other files are world-readable so default screensaver can read them
|
2009-11-05 01:44:05 +00:00
|
|
|
set_perm_recursive . boinc_master boinc_master u+rw,g+rw,o+r-w
|
2006-07-26 11:40:38 +00:00
|
|
|
if [ -f gui_rpc_auth.cfg ] ; then
|
|
|
|
set_perm gui_rpc_auth.cfg boinc_master boinc_master 0660
|
|
|
|
fi
|
2010-01-22 12:34:04 +00:00
|
|
|
chmod 0660 *.xml
|
|
|
|
if [ -f ss_config.xml ] ; then
|
|
|
|
set_perm ss_config.xml boinc_master boinc_master 0661
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Set permissions of BOINC Data directory itself
|
|
|
|
set_perm . boinc_master boinc_master 0771
|
2006-07-26 11:40:38 +00:00
|
|
|
|
|
|
|
if [ -d projects ] ; then
|
|
|
|
set_perm_recursive projects boinc_master boinc_project u+rw,g+rw,o+r-w
|
2010-01-27 07:38:29 +00:00
|
|
|
set_perm projects boinc_master boinc_project 0770
|
2006-07-26 11:40:38 +00:00
|
|
|
update_nested_dirs projects
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d slots ] ; then
|
|
|
|
set_perm_recursive slots boinc_master boinc_project u+rw,g+rw,o+r-w
|
2010-01-27 07:38:29 +00:00
|
|
|
set_perm slots boinc_master boinc_project 0770
|
2006-07-26 11:40:38 +00:00
|
|
|
update_nested_dirs slots
|
|
|
|
fi
|
|
|
|
|
2007-03-01 07:40:36 +00:00
|
|
|
# AppStats application must run setuid root (used in BOINC 5.7 through 5.8.14 only)
|
2006-09-25 22:32:09 +00:00
|
|
|
if [ -f switcher/AppStats ] ; then
|
2006-09-25 10:49:39 +00:00
|
|
|
set_perm switcher/AppStats root boinc_master 4550
|
2006-09-25 22:32:09 +00:00
|
|
|
fi
|
2006-09-25 10:49:39 +00:00
|
|
|
|
2007-10-02 09:32:20 +00:00
|
|
|
set_perm switcher/switcher root boinc_master 04050
|
2006-07-26 11:40:38 +00:00
|
|
|
set_perm switcher/setprojectgrp boinc_master boinc_project 2500
|
|
|
|
set_perm switcher boinc_master boinc_master 0550
|
|
|
|
|
2006-09-22 02:54:27 +00:00
|
|
|
if [ -d locale ] ; then
|
2009-10-31 07:45:44 +00:00
|
|
|
set_perm_recursive locale boinc_master boinc_master +X
|
|
|
|
set_perm_recursive locale boinc_master boinc_master u+r-w,g+r-w,o+r-w
|
2006-09-22 02:54:27 +00:00
|
|
|
fi
|
2006-07-26 11:40:38 +00:00
|
|
|
|
2006-09-22 02:54:27 +00:00
|
|
|
if [ -f boinc ] ; then
|
|
|
|
set_perm boinc boinc_master boinc_master 6555 # boinc client
|
|
|
|
fi
|
2006-08-01 12:36:19 +00:00
|
|
|
|
2009-04-02 10:25:16 +00:00
|
|
|
if [ -f boinccmd ] ; then
|
|
|
|
set_perm boinccmd boinc_master boinc_master 0550
|
2006-09-22 02:54:27 +00:00
|
|
|
fi
|
2006-08-01 12:36:19 +00:00
|
|
|
|
2009-02-05 07:44:26 +00:00
|
|
|
if [ -f ss_config.xml ] ; then
|
|
|
|
set_perm ss_config.xml boinc_master boinc_master 0664
|
|
|
|
fi
|
|
|
|
|
2006-08-01 12:36:19 +00:00
|
|
|
if [ -x /Applications/BOINCManager.app/Contents/MacOS/BOINCManager ] ; then
|
2009-09-02 02:32:30 +00:00
|
|
|
set_perm /Applications/BOINCManager.app/Contents/MacOS/BOINCManager boinc_master boinc_master 0555
|
2006-08-01 12:36:19 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -x /Applications/BOINCManager.app/Contents/Resources/boinc ] ; then
|
|
|
|
set_perm /Applications/BOINCManager.app/Contents/Resources/boinc boinc_master boinc_master 6555
|
|
|
|
fi
|
|
|
|
|
2008-02-27 02:12:09 +00:00
|
|
|
# Version 6 screensaver has its own embedded switcher application, but older versions don't.
|
|
|
|
if [ -x "/Library/Screen Savers/BOINCSaver.saver/Contents/Resources/gfx_switcher" ] ; then
|
|
|
|
set_perm "/Library/Screen Savers/BOINCSaver.saver/Contents/Resources/gfx_switcher" root boinc_master 4555
|
|
|
|
fi
|