Review Request 109431: Prevent accidental deletion of home folder

Frank Reininghaus frank78ac at googlemail.com
Mon Mar 11 18:10:08 GMT 2013


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/109431/
-----------------------------------------------------------

Review request for Dolphin.


Description
-------

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.


This addresses bug 316300.
    http://bugs.kde.org/show_bug.cgi?id=316300


Diffs
-----

  dolphin/src/panels/terminal/terminalpanel.cpp f6d3a59 

Diff: http://git.reviewboard.kde.org/r/109431/diff/


Testing
-------

Could not reproduce the home directory deletion any more.


Thanks,

Frank Reininghaus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20130311/7c48d581/attachment.htm>


More information about the kfm-devel mailing list