-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inconsistent behavior of removeDirectoryRecursive with symbolic links #15
Comments
removeDirectoryRecursive
with symbolic links
removeDirectoryRecursive
with symbolic links
The assertion has been made that the current code is correct (see here for one example), so, for the sake of future discussion, following is a demonstration of it showing different behavior than coreutils (with destructive results). First, create a user directory and put some dummy files in it.
Then, as a different user, create a test directory with the sticky bit containing a symlink to the original directory.
Coreutils behaves properly:
All files remain. Now, with System.Directory:
Note that the permissions error is given by Incidentally, this means that db88005 needs to be reverted prior to 7.10.1 and modified to state that |
New message in fd8c99d. |
The fact that Please take a look at the pull request, which fixes the inconsistency so that it will never* dereference symbolic links. It might be a good idea to expose I was wrote some preliminary tests to demonstrate that the problem is fixed. (Unfortunately to run these tests one would need a GHC repo on the side.) [*] barring unavoidable race conditions |
Passes the test that directory-1.2.1.0 fails. I don't see a real need to expose If this is tested on Windows, I'm in favor of pushing this in before the GHC 7.10 RC3 pull. I'd do it myself, but my Windows box lost a hard drive and is offline for the moment... |
The implementation of I'll test the patch on Windows tonight. Need to also check if |
Remove "|bcd123" from character set for tests (haskell#15)
The way
removeDirectoryRecursive dir
works right now is totally inconsistent:dir
itself is actually a directory-like symbolic link, it will recurse into it but fail to removedir
itself.The causes of these two problems are:
directoryExists
must necessarily be a directory. This is false, becausedirectoryExists
dereferences the symbolic link.getDirectoryContents
should not be called untildir
is verified to be a true directory.Note that there are two possible ways to handle the case where
dir
is not a true directory:rm -r
.shutil.rmtree
.See also:
The text was updated successfully, but these errors were encountered: