wxFileName::Rmdir() incorrectly follows symbolic links to directories and thus does not work correctly
|Reported by:||jdagresta||Owned by:|
|Keywords:||wxFileName::Rmdir UNIX needs-work||Cc:||jdagresta@…, dghart@…|
|Blocked By:||#14542, #14542, #14542, #14542, #14542, #14542||Blocking:|
On platforms where symbolic links are supported (e.g. Solaris, AIX, Linux), if you do wxFileDialog::Rmdir() on a directory that is a symbolic link to another directory, or you do wxFileDialog::Rmdir(wxPATH_RMDIR_RECURSIVE) on a directory that contains a symbolic link to another directory, the Rmdir() fails because it is "following" the directory symbolic link instead of just deleting the symbolic link itself.
The result can be disasterous, for example if the contained directory symbolic link points to a directory in the OS - it can result in the OS files in the linked directory being deleted (rather than just the symbolic link being deleted).
I've attached the source for a program (demo_rmdir_problem.cpp) that can be used to demonstrate the problem (on these platforms). It brings up a dialog with two buttons. The first button is used to create (set up) sample directories and directory symbolic links in /tmp. The second button is then used to do a wxFileName::Rmdir(0) and a second wxFileName::Rmdir(wxPATH_RMDIR_RECURSIVE) to demonstrate the problems that occur. The program writes messages to a text control to show what is happening. When the program is exited/closed, it will clean up the stuff it created in /tmp.
Attached are patches for three files to fix this problem: filenamecpp.patch (for src/common/filename.cpp), filenameh.patch (for include/wx/filename.h), and interface.patch (for interface/wx/filename.h).
Rather than get bogged down in very old discussions that have already occurred as to whether IsDir() should return true for symbolic links, I've taken the approach to just fix the problems in Rmdir().
There was no existing wxFileName::IsLink() method so I used some code in filectrlg.cpp dealing with symbolic links as a pattern to create this method, and then I used the new method to determine when to do something different in Rmdir().
Change History (44)
comment:16 Changed 4 years ago by vadz
- Blocked By 14542 removed
- Keywords needs-work added; Solaris AIX Linux removed
Changed 4 years ago by dghart
comment:37 Changed 4 years ago by VZ
- Resolution set to fixed
- Status changed from confirmed to closed