Skip to content

Commit 0e38705

Browse files
refactor: load configuration strictly from system path, removing multiple search paths.
1 parent e78f9e0 commit 0e38705

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

udwall

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -197,23 +197,13 @@ def load_rules_from_file():
197197
Returns:
198198
list: The list of rule dictionaries loaded from the configuration file.
199199
"""
200-
possible_paths = [
201-
os.path.join(os.getcwd(), UDWALL_CONF_FILE),
202-
os.path.join(os.path.dirname(os.path.abspath(__file__)), UDWALL_CONF_FILE),
203-
UDWALL_SYSTEM_CONF_PATH
204-
]
205-
206-
file_path = None
207-
for path in possible_paths:
208-
if os.path.exists(path):
209-
file_path = path
210-
break
211-
212-
if not file_path:
200+
# STRICTLY load from system path only
201+
file_path = UDWALL_SYSTEM_CONF_PATH
202+
203+
if not os.path.exists(file_path):
213204
script_name = os.path.basename(sys.argv[0])
214205
# Use print to stderr for this specific, user-facing error message
215-
print(f"❌ ERROR: udwall.conf not found.", file=sys.stderr)
216-
print(f"Searched in: {', '.join(possible_paths)}", file=sys.stderr)
206+
print(f"❌ ERROR: udwall.conf not found at {file_path}", file=sys.stderr)
217207
print(f"ℹ️ INFO: You can create one from your current UFW rules by running `sudo {script_name} --create`", file=sys.stderr)
218208
sys.exit(1)
219209

0 commit comments

Comments
 (0)