shell-things/chmod

47 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# This script removes permissions from other people than the owner to
# files/folders that they don't have access to and where they don't need
# access.
set -x
# You don't want to make this verbose.
chmod g-rwx,o-rwx "$HOME" -R
touch ~/.oidentd.conf
chmod -v u+rw,g-wx+r,o-wx+r ~/.oidentd.conf
touch ~/.ICEauthority
chmod -v o-rw+x,g-rw+x ~
mkdir -p ~/public_html/
chmod -v -R 755 ~/public_html/
touch ~/.face
touch ~/.forward
touch ~/.netrc
chmod -v a+r-wx,u+rw ~/.face
chmod -v a+r-wx,u+rw ~/.forward
chmod -v 600 ~/.netrc
mkdir -p ~/.ssh
chmod -v 700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod -v 600 ~/.ssh/authorized_keys
# if we have support for setting ACL, some of this becomes easier (although maybe redundant)
if hash setfacl 2> /dev/null; then
setfacl --modify u:$(id -un):rw,g:$(id -gn):r,o:r ~/.oidentd.conf
# The execute permission is a bit silly to apply recursively, but it's
# needed for cd and ls. so perhaps there should be some responsibility
# given to others too...
setfacl --recursive --modify u:$(id -un):rw,g:$(id -gn):rx,o:rx ~/public_html/
# Enabling laziness pt. …
if [[ -d ~/.shell-things ]]; then
setfacl --recursive --modify u:$(id -un):rw,g:$(id -gn):rx,o:rx ~/.shell-things/
fi
fi
set +x