Merge pull request #11 from samply/feature/checkOwner

Check directory ownership.
This commit is contained in:
patrickskowronekdkfz 2022-05-17 10:51:50 +02:00 committed by GitHub
commit 4ba956e45f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 6 deletions

View File

@ -2,16 +2,22 @@
source lib/functions.sh source lib/functions.sh
## Check for file permissions checkOwner(){
## Check for file permissions
COUNT=$(find $1 ! -user $2 |wc -l)
if [ $COUNT -gt 0 ]; then
log ERROR "$COUNT files in $1 are not owned by user $2. Run find $1 ! -user $2 to see them, chown -R $2 $1 to correct this issue."
exit 1
fi
}
if ! id "bridgehead" &>/dev/null; then if ! id "bridgehead" &>/dev/null; then
log ERROR "User bridgehead does not exist. Please consult readme for installation." log ERROR "User bridgehead does not exist. Please consult readme for installation."
exit 1 exit 1
fi fi
COUNT=$(find . ! -user bridgehead |wc -l)
if [ $COUNT -gt 0 ]; then checkOwner . bridgehead
log ERROR "$COUNT files in $(pwd) are not owned by user bridgehead. Run find $(pwd) ! -user bridgehead to see them, chown -R bridgehead $(pwd) to correct this issue." checkOwner /etc/bridgehead bridgehead
exit 1
fi
## Check if user is a su ## Check if user is a su
log INFO "Checking if all prerequisites are met ..." log INFO "Checking if all prerequisites are met ..."