From 15b9ef1565bcb4edeeec45589c47c96b24b73578 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Wed, 28 Feb 2018 16:26:14 +0200 Subject: [PATCH] Remove destination path if it exists (mostly for windows upgrade) Fix minor bug in dropper --- infection_monkey/dropper.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/infection_monkey/dropper.py b/infection_monkey/dropper.py index 3e0a8bff5..927ea7cf6 100644 --- a/infection_monkey/dropper.py +++ b/infection_monkey/dropper.py @@ -58,6 +58,9 @@ class MonkeyDrops(object): # we copy/move only in case path is different file_moved = (self._config['source_path'].lower() == self._config['destination_path'].lower()) + if not file_moved and os.path.exists(self._config['destination_path']): + os.remove(self._config['destination_path']) + # first try to move the file if not file_moved and WormConfiguration.dropper_try_move_first: try: @@ -105,8 +108,9 @@ class MonkeyDrops(object): except: LOG.warn("Cannot set reference date to destination file") + depth = int(self.opts.depth) if self.opts.depth is not None else None monkey_options = build_monkey_commandline_explicitly( - self.opts.parent, self.opts.tunnel, self.opts.server, int(self.opts.depth)) + self.opts.parent, self.opts.tunnel, self.opts.server, depth) if OperatingSystem.Windows == SystemInfoCollector.get_os(): monkey_cmdline = MONKEY_CMDLINE_WINDOWS % {'monkey_path': self._config['destination_path']} + monkey_options