Skip to content

Commit

Permalink
Remove another place where we check for the existence of the config f…
Browse files Browse the repository at this point in the history
…ile.

Let the Config class handle raising those types of errors.
  • Loading branch information
Tommy Beadle committed Mar 20, 2024
1 parent c38397a commit d7b91aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
4 changes: 3 additions & 1 deletion lib/cuckoo/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from lib.cuckoo.common.colors import bold, red
from lib.cuckoo.common.constants import CUCKOO_ROOT, CUSTOM_CONF_DIR
from lib.cuckoo.common.dictionary import Dictionary
from lib.cuckoo.common.exceptions import CuckooOperationalError
from lib.cuckoo.common.exceptions import CuckooCriticalError, CuckooOperationalError


def parse_options(options: str) -> Dict[str, str]:
Expand Down Expand Up @@ -115,6 +115,8 @@ def _get_files_to_read(self, fname_base):
files.extend(sorted(glob.glob(os.path.join(CUCKOO_ROOT, "conf", f"{fname_base}.conf.d", "*.conf"))))
files.append(os.path.join(CUSTOM_CONF_DIR, f"{fname_base}.conf"))
files.extend(sorted(glob.glob(os.path.join(CUSTOM_CONF_DIR, f"{fname_base}.conf.d", "*.conf"))))
if not files:
raise CuckooCriticalError(f"No {fname_base} config files could be found!")
return files


Expand Down
8 changes: 0 additions & 8 deletions lib/cuckoo/core/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,14 +878,6 @@ def initialize(self):
# Initialize the machine manager.
machinery = plugin()

# Find its configuration file.
conf = os.path.join(CUCKOO_ROOT, "conf", f"{machinery_name}.conf")

if not path_exists(conf):
raise CuckooCriticalError(
f'The configuration file for machine manager "{machinery_name}" does not exist at path: {conf}'
)

# Provide a dictionary with the configuration options to the
# machine manager instance.
machinery.set_options(Config(machinery_name))
Expand Down

0 comments on commit d7b91aa

Please sign in to comment.