You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.
I am analysing a large number of binaries and so I created a symlink for the analyses directory. Everything works fine, but when using 'cuckoo clean', the function shutil.rmtree($CWD/storage/analyses/) will throw an Exception:
[cuckoo.apps.apps] WARNING: Error removing directory /home/user/.cuckoo/storage/analyses: Cannot call rmtree on a symbolic link
Cuckoo version and OS:
Cuckoo 2.0.7 & Ubuntu 18.04
This can be reproduced by:
Create a soft link for a directory (e.g. 'analyses'): sudo ln -s /preferred_location/analyses/ /$CWD/storage/analyses
Execute cuckoo clean
This can be easily fixed by:
One line of code.
In the cuckoo_clean() function (located in the file cuckoo/cuckoo/apps/apps.py), there is a for-loop that deletes various files and directories:
# Delete the various files and directories. In case of directories, keep
# the parent directories, so to keep the state of the CWD in tact.
for path in paths:
if os.path.isdir(path):
try:
shutil.rmtree(path)
os.mkdir(path)
except (IOError, OSError) as e:
log.warning("Error removing directory %s: %s", path, e)
elif os.path.isfile(path):
try:
os.unlink(path)
except (IOError, OSError) as e:
log.warning("Error removing file %s: %s", path, e)
Just before calling rmtree(), you could use os.path.realpath() to get the absolute path in case of a symlink. See below:
# Delete the various files and directories. In case of directories, keep
# the parent directories, so to keep the state of the CWD in tact.
for path in paths:
if os.path.isdir(path):
try:
path = os.path.realpath(path) # This gracefully handles cases with soft links!
shutil.rmtree(path)
os.mkdir(path)
except (IOError, OSError) as e:
log.warning("Error removing directory %s: %s", path, e)
elif os.path.isfile(path):
try:
os.unlink(path)
except (IOError, OSError) as e:
log.warning("Error removing file %s: %s", path, e)
I have tested the above solution and it works beautifully.
The text was updated successfully, but these errors were encountered:
I am analysing a large number of binaries and so I created a symlink for the analyses directory. Everything works fine, but when using 'cuckoo clean', the function shutil.rmtree($CWD/storage/analyses/) will throw an Exception:
[cuckoo.apps.apps] WARNING: Error removing directory /home/user/.cuckoo/storage/analyses: Cannot call rmtree on a symbolic link
Cuckoo version and OS:
Cuckoo 2.0.7 & Ubuntu 18.04
This can be reproduced by:
sudo ln -s /preferred_location/analyses/ /$CWD/storage/analyses
cuckoo clean
This can be easily fixed by:
One line of code.
In the cuckoo_clean() function (located in the file cuckoo/cuckoo/apps/apps.py), there is a
for-loop
that deletes various files and directories:Just before calling
rmtree()
, you could use os.path.realpath() to get the absolute path in case of a symlink. See below:I have tested the above solution and it works beautifully.
The text was updated successfully, but these errors were encountered: