https://github.com/purplebooth/fix-compaudit
https://github.com/purplebooth/fix-compaudit
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/purplebooth/fix-compaudit
- Owner: PurpleBooth
- License: cc0-1.0
- Created: 2020-04-18T11:48:22.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2024-08-02T05:34:55.000Z (almost 2 years ago)
- Last Synced: 2025-01-30T10:44:18.962Z (over 1 year ago)
- Language: Rust
- Size: 245 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Fix Compaudit Issues
Correct the permissions problems that highlighted by `compaudit`. Fixing
these is kinda a pain to do manually.
Depends on having `chmod`, `chown`, `zsh` and `compaudit` available.
## Usage
``` bash
fix-compaudit
```
## Installing
First tap my homebrew repo
``` shell
brew tap PurpleBooth/repo
```
Next install the binary
``` shell
brew install PurpleBooth/repo/fix-compaudit
```
You can also download the [latest
release](https://github.com/PurpleBooth/fix-compaudit/releases/latest)
and run it.
## How does it work
Well here's a version of this in bash, if that makes it clearer
``` shell
#!/usr/bin/env bash
set -euo pipefail
mapfile -t AUDIT_PROBLEMS < <(zsh -c "autoload -U compaudit && compaudit" 2>/dev/null)
if [ "${#AUDIT_PROBLEMS[@]}" -eq 0 ]; then
exit 0
fi
for FILE in "${AUDIT_PROBLEMS[@]}"; do
if [ "$(gstat -c '%U' "$FILE")" != "$USER" ]; then
echo "gaining ownership: $FILE"
sudo chown -R "$USER" "$FILE"
fi
if [ "$(gstat -c '%U' "$FILE")" != "$USER" ]; then
echo "gaining ownership: $FILE"
sudo chown -R "$USER" "$FILE"
fi
if gstat -c "%A" "$FILE" | grep -qE '(.{2}w.{7}|.{5}w.{4})'; then
echo "removing non-user write: $FILE"
chmod -R go-w "$FILE"
fi
if gstat -c "%A" "$FILE" | grep -qE '(.{2}w.{7}|.{5}w.{4})'; then
echo "removing non-user write: $FILE"
chmod -R go-w "$FILE"
fi
done
```
## License
[CC0](LICENSE.md) - Public Domain