I think this will leak the fd in the event the error is hit:
fd = os.open(path, os.O_NOFOLLOW | os.O_RDONLY | os.O_NONBLOCK)
st = os.fstat(fd)
+ # make sure there are no symlinks in the full path
+ real_path = os.path.realpath(path)
+ if st.st_ino != os.stat(real_path).st_ino or path != real_path:
+ return 'Error: path contained symlinks.'
I think this will leak the fd in the event the error is hit:
fd = os.open(path, os.O_NOFOLLOW | os.O_RDONLY | os.O_NONBLOCK) realpath( path) real_path) .st_ino or path != real_path:
st = os.fstat(fd)
+ # make sure there are no symlinks in the full path
+ real_path = os.path.
+ if st.st_ino != os.stat(
+ return 'Error: path contained symlinks.'
Thanks