rapid7/metasploit-framework — pull request #4410 by zeroSteiner (2014-12-17 14:25:54+00:00)
Title: Do not delete files that do not exist in rm_f

Once @bcook-r7's changes are landed from rapid7/meterpreter#106 the Linux meterpreter will throw errors correctly when trying to delete a file which does not exist. This is already the behavior of the Python and Windows meterpreters. The ```rm_f``` function should check that the file exists before trying to delete it to avoid throwing an error. This is more intuitive to what the shell command ```rm -f``` does (exiting with status 0 if the file does not exist). I opted to check with ```exists?``` because the shell version will fail when a directory is specified.

Without this change, calls to rm_f to delete files which do not exist, will throw unnecessary errors. See [sock_sendpage](https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/linux/local/sock_sendpage.rb#L446) for an example.

Verification steps:
- [ ] Open a Python meterpreter (or Linux meterpreter if the aforementioned PR is landed first)
- [ ] Use the ```linux/local/sock_sendpage``` exploit module
- [ ] Do **not** get an error when the module calls rm_f and the file does not exist
- [ ] The exploit will continue to work as intended