Skip to content

Instantly share code, notes, and snippets.

@kirrie
Created May 10, 2019 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kirrie/3d17363b1533b62641d43842d9baf1ed to your computer and use it in GitHub Desktop.
Save kirrie/3d17363b1533b62641d43842d9baf1ed to your computer and use it in GitHub Desktop.
#!/bin/sh
sysdirs="
/bin
/etc
/lib
/sbin
/usr
"
# Remove world-writable permissions.
# This breaks apps that need to write to /tmp,
# such as ssh-agent.
find / -xdev -type d -perm +0002 -exec chmod o-w {} +
find / -xdev -type f -perm +0002 -exec chmod o-w {} +
# Ensure system dirs are owned by root and not writable by anybody else.
find $sysdirs -xdev -type d \
-exec chown root:root {} \; \
-exec chmod 0755 {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment