aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek.le-blansch.pv@renesas.com>2025-10-15 08:25:21 +0200
committerLoek Le Blansch <loek.le-blansch.pv@renesas.com>2025-10-15 08:25:21 +0200
commitf90ce1e3a2fe48eb766abd624ef1729d87eec834 (patch)
treeb98e1caa85ab6f8cfe6ec84069036b0caf50cddc
parente8f200337975e9f8b8d57a5a0a3a2b25395cee88 (diff)
password retrieval working
-rw-r--r--nmpass/main.py34
1 files changed, 21 insertions, 13 deletions
diff --git a/nmpass/main.py b/nmpass/main.py
index e969e13..9c756c6 100644
--- a/nmpass/main.py
+++ b/nmpass/main.py
@@ -2,7 +2,7 @@ from __future__ import annotations
from asyncio import new_event_loop
from sdbus_async.networkmanager import NetworkManagerSecretAgentInterfaceAsync, NetworkManagerAgentManager, NetworkManagerConnectionProperties
-from sdbus_async.networkmanager.settings import ConnectionProfile
+from sdbus_async.networkmanager.settings import ConnectionProfile, EapolSettings, WirelessSecuritySettings
from typing import Any
import sdbus
@@ -15,22 +15,29 @@ class NetworkManagerPasswordStoreAgent(NetworkManagerSecretAgentInterfaceAsync):
async def get_secrets(
self,
connection: NetworkManagerConnectionProperties,
- _connection_path: str,
+ connection_path: str,
setting_name: str,
- _hints: list[str],
- _flags: int,
+ hints: list[str],
+ flags: int,
) -> dict[str, dict[str, tuple[str, Any]]]:
profile = ConnectionProfile.from_dbus(connection)
+ if profile.wireless is None:
+ return {}
+ assert profile.wireless.ssid is not None
+ ssid = profile.wireless.ssid.decode()
+
+ pass_name = f"net/{ssid}/passwd"
+ password = self.store.retrieve(pass_name)
+ if password is None:
+ return {}
- printf(setting_name)
if setting_name == '802-11-wireless-security':
- ssid = profile.wireless.ssid.decode()
- pass_name = f"net/{ssid}/passwd"
- password = self.store.retrieve(pass_name)
- printf(f"SSID: {ssid} PASSWORD: {password}")
- if password != None:
- profile.wireless_security.psk = password
- return profile.wireless_security.psk.to_dbus()
+ # TODO: set psk-flags=1
+ return { setting_name: WirelessSecuritySettings(psk=password).to_dbus() }
+
+ if setting_name == '802-1x':
+ # TODO: set password-flags=1
+ return { setting_name: EapolSettings(password=password).to_dbus()}
return {}
@@ -38,8 +45,9 @@ class NetworkManagerPasswordStoreAgent(NetworkManagerSecretAgentInterfaceAsync):
async def save_secrets(
self,
connection: NetworkManagerConnectionProperties,
- _connection_path: str,
+ connection_path: str,
) -> None:
+ print("save secrets!")
profile = ConnectionProfile.from_dbus(connection)
print(profile)
raise NotImplementedError