From 6f1d0ba1f6552fcd35ad385ffb644bd5e3b2804b Mon Sep 17 00:00:00 2001 From: Petros Date: Thu, 13 Aug 2020 18:45:03 +0300 Subject: [PATCH] Handle symlinks when using 'cuckoo clean' When using `cuckoo clean`, if one of the directories under `$CWD/storage/` is a symlink, then an exception will be thrown and the files/directories that the symlink points to will not be deleted. The change here is one line of code and what it does is: - The real path of the directory (whether a regular dir or a soft link) is retrieved first and any files/directories will recursively be deleted afterwards. --- cuckoo/apps/apps.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cuckoo/apps/apps.py b/cuckoo/apps/apps.py index 545cf00260..b503fe7561 100644 --- a/cuckoo/apps/apps.py +++ b/cuckoo/apps/apps.py @@ -411,6 +411,8 @@ def cuckoo_clean(): for path in paths: if os.path.isdir(path): try: + # handle soft-links cases + path = os.path.realpath(path) shutil.rmtree(path) os.mkdir(path) except (IOError, OSError) as e: