Created
September 19, 2012 03:45
-
-
Save glarizza/3747543 to your computer and use it in GitHub Desktop.
Dirty hacky world-writability check
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
| def world_writable?(write_bit) | |
| if write_bit > 3 | |
| write_bit -= 4 | |
| return false if write_bit == 0 | |
| write_bit % 2 == 0 ? true : false | |
| elsif write_bit < 4 | |
| return false if write_bit == 0 | |
| write_bit % 2 == 0 ? true : false | |
| end | |
| end | |
| file_write_bit = Integer(sprintf("%o", File.stat('/path/to/file').mode)[-1,1]) | |
| world_writable?(file_write_bit) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment