diff --git a/backend/services/shares.py b/backend/services/shares.py index e62ea8b..3d47f35 100644 --- a/backend/services/shares.py +++ b/backend/services/shares.py @@ -180,18 +180,21 @@ class SharesManager: return False def get_samba_global_config(self) -> Dict[str, Any]: - """Read Samba global configuration section as structured key-value pairs""" - if not SAMBA_CONFIG.exists(): - return {"parameters": []} - + """Read Samba global configuration from registry using 'net conf list'""" try: - with open(SAMBA_CONFIG, 'r') as f: - content = f.read() + result = subprocess.run( + ['net', 'conf', 'list'], + capture_output=True, + text=True, + timeout=10 + ) + + if result.returncode != 0: + return {"parameters": []} parameters = [] - lines = content.split('\n') in_global = False - for line in lines: + for line in result.stdout.split('\n'): if line.strip().startswith('[global]'): in_global = True continue @@ -210,7 +213,7 @@ class SharesManager: return {"parameters": parameters} except Exception as e: - logger.error(f"Error reading Samba global config: {e}") + logger.error(f"Error reading Samba registry config: {e}") return {"parameters": []} def set_samba_global_config(self, config_text: str) -> bool: