[PATCH] permission checks for chdir need special treatment only on the last step