3 # a library file for redoing file ownership and permissions as we feel is
4 # appropriate. this approach is a little bit specific to our way of doing
5 # things, but it does handle a lot of important fixes everyone would want,
6 # like making ~/.ssh really secure.
8 # cleans up the ownership and permissions for all of the important files and dirs.
9 function reapply_cool_permissions()
11 local cooluser="$1"; shift
13 # first build a list of dirs based on their location in /home/archives.
14 local arch_builder="archons basement codebarn games imaginations musix pooling prewar_toaster stuffing toaster walrus"
15 local ARCHIVE_HOME=/home/archives
18 for dirname in $arch_builder; do
19 arch_addin+="$ARCHIVE_HOME/$dirname "
21 #echo arch addin now is: $arch_addin
23 # special case that makes our software hierarchy folder, if it doesn't exist.
24 # everything else is only re-permed if it exists.
25 if [ ! -d "$DEFAULT_FEISTYMEOW_ORG_DIR" ]; then
26 sudo mkdir "$DEFAULT_FEISTYMEOW_ORG_DIR"
27 test_or_die "making directory: $DEFAULT_FEISTYMEOW_ORG_DIR"
30 # fix some permissions for important security considerations.
33 #hmmm: consider adding feisty meow apex to the list below.
34 # iterate across the list of dirs we want cooluser to own and change their ownership.
35 for dirname in $HOME $DEFAULT_FEISTYMEOW_ORG_DIR /usr/local/${cooluser} /home/games $arch_addin; do
36 if [ -d "$dirname" ]; then
37 echo "revising ownership on '$dirname'"
38 sudo chown -R ${cooluser}:${cooluser} "$dirname"
39 test_or_die "chowning for ${cooluser}: $dirname"
43 # special case for archives directory.
44 if [ -d /z/stuffing -o -L /z/stuffing ]; then
45 sudo chown ${cooluser}:${cooluser} /z
46 test_or_die "chowning /z for ${cooluser}"
47 sudo chmod g+rx,o+rx /z
48 test_or_die "chmodding /z/ for ${cooluser}"
49 sudo chown ${cooluser}:${cooluser} /z/stuffing
50 test_or_die "chowning /z/stuffing for ${cooluser}"
51 sudo chmod g+rx,o-rwx /z/stuffing
52 test_or_die "chmodding /z/stuffing for ${cooluser}"
53 pushd /z/stuffing &>/dev/null
54 if [ -d archives -o -L archives ]; then
55 sudo chown ${cooluser}:${cooluser} archives
56 test_or_die "chowning /z/stuffing/archives for ${cooluser}"
57 sudo chmod -R g+rwx archives
58 test_or_die "chmodding /z/stuffing/archives for ${cooluser}"
63 # make the logs readable by normal humans.
64 sudo bash $FEISTY_MEOW_SCRIPTS/security/normal_perm.sh /var/log
65 test_or_die "setting normal perms on /var/log"
68 # this block should execute when the script is actually run, rather
69 # than when it's just being sourced.
71 # this runs the cool permission applier on the current user.
72 if [[ $0 =~ .*reapply_cool_permissions\.sh.* ]]; then
73 THISDIR="$( \cd "$(\dirname "$0")" && /bin/pwd )"
74 source "$THISDIR/../core/launch_feisty_meow.sh"
75 test_or_die "sourcing the feisty meow launcher"
76 reapply_cool_permissions $(logname)
77 test_or_die "reapplying cool permissions on $(logname)"