Ensure's proper ownership and permissions before returning an open file handle.