Correct logging: open before changing user ID.