Prevent accidental deletion of home folder
Review Request #109431 - Created March 11, 2013 and submitted
It turns out that there is at least one corner case where the protection against severe data loss when entering "rm -rf" in the Terminal Panel and then changing the directory does not work. Normally, we send a SIGINT to the terminal when the URL changes, but not in the following case (when testing, use a new user!!!): 1. Open Dolphin, enable Terminal Panel. 2. Enter "cd bin" in the panel (or any other subfolder of ~). 3. Enter "rm -rf", do not press Enter. 4. Click "Home" in the Places Panel 5. The contents of ~ are removed. I think the problem is the following: TerminalPanel has the member m_clearTerminal, which is true initially, and which clears the very first "cd" command from the panel. This command is issued when the panel is shown and can be quite distracting. After this first "cd" is suppressed, m_clearTerminal is set to false. The data loss-protection code only runs if m_clearTerminal is false, i.e., not for the first "cd" that is issued when opening the panel (and this is necessary - I first tried removing that check and got a crashing bash). However, in the described use case, no automatic "cd" is issued when the Terminal Panel is opened because its URL is ~ already, so m_clearTerminal is still true when clicking the "Home" place. Then the "cd /home/test" is just appended to the existing command line, which then reads "rm -rf cd /home/test". I propose to fix this by setting m_clearTerminal to false even if TerminalPanel::sendCdToTerminal returns early. So it should be guaranteed that m_clearTerminal is false after the panel is initialised, such that the data loss-protection is always effective. Does anyone see another use case where data loss would occur and my analysis is incorrect? If not, I'd like to push this soon.
Could not reproduce the home directory deletion any more.