Skip to content

Instantly share code, notes, and snippets.

@glarizza
Created September 19, 2012 03:45
Show Gist options
  • Save glarizza/3747543 to your computer and use it in GitHub Desktop.
Save glarizza/3747543 to your computer and use it in GitHub Desktop.
Dirty hacky world-writability check
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