Last active
February 23, 2016 17:21
-
-
Save Atticuss/d93d52d3e7505c6e345b 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
import sys,os | |
from stat import * | |
if len(sys.argv) < 2: | |
print('Usage: python fileperms.py <dir>') | |
sys.exit(1) | |
flist=[] | |
for (dirpath,dirname,filenames) in os.walk(sys.argv[1]): | |
flist.extend(['%s/%s'%(dirpath,filename) for filename in filenames]) | |
readable=0 | |
writable=0 | |
executable=0 | |
for f in flist: | |
if os.stat(f)[ST_MODE] & 4 != 0: | |
print('world readable file: %s'%f) | |
readable += 1 | |
if os.stat(f)[ST_MODE] & 2 != 0: | |
print('world writable file: %s'%f) | |
writable += 1 | |
if os.stat(f)[ST_MODE] & 1 != 0: | |
print('world executable file: %s'%f) | |
executable += 1 | |
print('\nTotal files: %s'%len(flist)) | |
print('World readable: %s'%readable) | |
print('World writable: %s'%writable) | |
print('World executable: %s'%executable) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment