Created
April 5, 2023 13:00
-
-
Save petergi/b772377c72cdcfaccc512b5ed5e268ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Check ownership and permissions of a file | |
| function checkPermissions() { | |
| file="$1" | |
| expectedOwner="$2" | |
| expectedPermissions="$3" | |
| expectedUid=`id -u "$expectedOwner"` | |
| uid=`stat -f "%u" "$file"` | |
| permissions=`stat -f "%Sp" "$file"` | |
| if [ "$uid" -ne "$expectedUid" ]; then | |
| return -1 | |
| fi | |
| if [ "$permissions" != "$expectedPermissions" ]; then | |
| return -1 | |
| fi | |
| return 0 | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment