~ubuntu-branches/ubuntu/precise/boinc/precise

« back to all changes in this revision

Viewing changes to packages/generic/sea/secure.sh

Tags: 6.12.8+dfsg-1
* New upstream release.
* Simplified debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
 
 
3
# Berkeley Open Infrastructure for Network Computing
 
4
# http://boinc.berkeley.edu
 
5
# Copyright (C) 2006 University of California
 
6
#
 
7
# This is free software; you can redistribute it and/or
 
8
# modify it under the terms of the GNU Lesser General Public
 
9
# License as published by the Free Software Foundation;
 
10
# either version 2.1 of the License, or (at your option) any later version.
 
11
#
 
12
# This software is distributed in the hope that it will be useful,
 
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
15
# See the GNU Lesser General Public License for more details.
 
16
#
 
17
# To view the GNU Lesser General Public License visit
 
18
# http://www.gnu.org/copyleft/lesser.html
 
19
# or write to the Free Software Foundation, Inc.,
 
20
# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
21
 
 
22
# Make a BOINC installation "secure"
 
23
# Create groups and users, set file/dir ownership and protection
 
24
#
 
25
# Execute this as root in the BOINC directory
 
26
# You must have already run the installer script
 
27
# that creates the switcher/ and locale/ directories, and their contents
 
28
 
 
29
# In addition, you should add boinc_master and boinc_projects
 
30
# to the supplementary group list of users who will administer BOINC.
 
31
# e.g.:
 
32
# usermod -G boinc_master,boinc_projects -a mary
 
33
 
 
34
make_boinc_users() {
 
35
    groupadd boinc_master
 
36
    groupadd boinc_projects
 
37
    useradd boinc_master -g boinc_master
 
38
    useradd boinc_projects -g boinc_projects
 
39
}
 
40
 
 
41
check_login() {
 
42
    if [ `whoami` != 'root' ]
 
43
    then
 
44
        echo 'This script must be run as root'
 
45
        exit
 
46
    fi
 
47
}
 
48
 
 
49
# set_perm path user group perm
 
50
#   set a file or directory to the given ownership/permissions
 
51
set_perm() {
 
52
    chown $2:$3 "$1"
 
53
    chmod $4 "$1"
 
54
}
 
55
 
 
56
# same, but apply to all subdirs and files
 
57
#
 
58
set_perm_recursive() {
 
59
    chown -R $2:$3 "$1"
 
60
    chmod -R $4 "$1"
 
61
}
 
62
 
 
63
# same, but apply to items in the given dir
 
64
#
 
65
set_perm_dir() {
 
66
    for file in $(ls "$1")
 
67
    do
 
68
        path="$1/${file}"
 
69
        set_perm "${path}" $2 $3 $4
 
70
    done
 
71
}
 
72
 
 
73
update_nested_dirs() {
 
74
   chmod u+x,g+x,o+x "${1}"
 
75
   
 
76
   for file in $(ls "$1")
 
77
    do
 
78
        if [ -d "${1}/${file}" ] ; then
 
79
                update_nested_dirs "${1}/${file}"
 
80
        fi
 
81
    done
 
82
}
 
83
 
 
84
check_login
 
85
 
 
86
# If the user forgets to cd to the boinc data directory, this script can do serious damage
 
87
# so show the directory we are about to modify
 
88
echo "Changing directory $(pwd) file ownership to user and group boinc_master - OK? (y/n)"
 
89
read line
 
90
if [ "$line" != "y" ]
 
91
then
 
92
    exit
 
93
fi
 
94
 
 
95
# if the booinc client is not here, assume it is the wrong directory
 
96
if [ ! -f "boinc_client" ]
 
97
then
 
98
    echo "Can't find boinc_client in directory $(pwd); exiting"
 
99
    exit
 
100
fi
 
101
 
 
102
make_boinc_users
 
103
 
 
104
set_perm_recursive . boinc_master boinc_master u+rw,g+rw,o+r-w
 
105
set_perm . boinc_master boinc_master 0775
 
106
if [ -f gui_rpc_auth.cfg ] ; then
 
107
    set_perm gui_rpc_auth.cfg boinc_master boinc_master 0660
 
108
fi
 
109
 
 
110
if [ -d projects ] ; then
 
111
    set_perm_recursive projects boinc_master boinc_project u+rw,g+rw,o+r-w
 
112
    set_perm projects boinc_master boinc_master 0775
 
113
    update_nested_dirs projects
 
114
fi
 
115
 
 
116
if [ -d slots ] ; then
 
117
    set_perm_recursive slots boinc_master boinc_project u+rw,g+rw,o+r-w
 
118
    set_perm slots boinc_master boinc_master 0775
 
119
    update_nested_dirs slots
 
120
fi
 
121
 
 
122
set_perm switcher/switcher boinc_project boinc_project 6551
 
123
set_perm switcher/setprojectgrp boinc_master boinc_project 2500
 
124
set_perm switcher boinc_master boinc_master 0550
 
125
 
 
126
set_perm_recursive locale boinc_master boinc_master u+r-w,g+r-w,o-rwx
 
127
 
 
128
set_perm boinc_client boinc_master boinc_master 6555
 
129
set_perm boinc_manager boinc_master boinc_master 2555