Skip to content

Commit

Permalink
Update code
Browse files Browse the repository at this point in the history
  • Loading branch information
D3vil0p3r committed Nov 25, 2024
1 parent 564fd2e commit 708ff79
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
22 changes: 11 additions & 11 deletions empire/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,20 @@ def check_config_permission(config_dict: dict, config_type: str):
# Define paths to check based on config type
if config_type == "server":
paths_to_check = {
("api", "cert_path"): config_dict["api"]["cert_path"],
("database", "sqlite", "location"): config_dict["database"]["sqlite"][
"location"
],
("starkiller", "directory"): config_dict["starkiller"]["directory"],
("logging", "directory"): config_dict["logging"]["directory"],
("debug", "last_task", "file"): config_dict["debug"]["last_task"]["file"],
("directories", "downloads"): config_dict["directories"].get("downloads"),
("api", "cert_path"): config_dict.get("api", {}).get("cert_path"),
("database", "sqlite", "location"): config_dict.get("database", {}).get("sqlite", {}).get("location"),
("starkiller", "directory"): config_dict.get("starkiller", {}).get("directory"),
("logging", "directory"): config_dict.get("logging", {}).get("directory"),
("debug", "last_task", "file"): config_dict.get("debug", {}).get("last_task", {}).get("file"),
("directories", "downloads"): config_dict.get("directories", {}).get("downloads"),
}
config_path = CONFIG_SERVER_PATH # Use the server config path

elif config_type == "client":
paths_to_check = {
("logging", "directory"): config_dict["logging"]["directory"],
("directories", "downloads"): config_dict["directories"].get("downloads"),
("directories", "generated-stagers"): config_dict["directories"].get(
("logging", "directory"): config_dict.get("logging", {}).get("directory"),
("directories", "downloads"): config_dict.get("directories", {}).get("downloads"),
("directories", "generated-stagers"): config_dict.get("directories", {}).get(
"generated-stagers"
),
}
Expand All @@ -70,6 +68,8 @@ def check_config_permission(config_dict: dict, config_type: str):

# Check permissions and update paths as needed
for keys, dir_path in paths_to_check.items():
if dir_path is None:
continue
if not os.access(dir_path, os.W_OK):
log.info(
"No write permission for %s. Switching to fallback directory.", dir_path
Expand Down
3 changes: 0 additions & 3 deletions empire/server/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,6 @@ def set_yaml(location: str):
if loaded_config:
config_dict = loaded_config

#tmp_config_dict = EmpireConfig(config_dict).model_dump()
#print(tmp_config_dict)
# Change this function to return back the updated dict after it writes out the file
config_dict = config_manager.check_config_permission(config_dict, "server")
print(config_dict)
empire_config = EmpireConfig(config_dict)

0 comments on commit 708ff79

Please sign in to comment.