eiwd/src/e_mod_main.c
Pierre-Olivier Mercier 0ab9561d2b security: wipe passphrases, bind hidden stash to SSID, re-register agent
Wipe passphrase memory in the auth and hidden-network dialogs (explicit_bzero
on owned copies plus overwriting the elm_entry buffer before destruction) so
secrets don't linger on the heap. Bind the hidden-network passphrase stash to
its SSID with a 30s timeout, so a typo'd or out-of-range hidden connect can't
leak its passphrase to an unrelated network whose RequestPassphrase happens
to land first. Re-RegisterAgent on iwd NameOwnerChanged so PSK connects
survive systemctl restart iwd instead of silently hanging.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 11:24:45 +07:00

59 lines
1.1 KiB
C

#include "e_mod_main.h"
#include "iwd/iwd_manager.h"
#include "e_mod_gadget.h"
#include "e_mod_popup.h"
#include "e_mod_config.h"
E_Iwd_Module *e_iwd = NULL;
EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "iwd" };
EAPI void *
e_modapi_init(E_Module *m)
{
e_iwd = E_NEW(E_Iwd_Module, 1);
e_iwd->module = m;
if (!eldbus_init())
{
E_FREE(e_iwd);
return NULL;
}
e_iwd->conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM);
if (!e_iwd->conn)
{
eldbus_shutdown();
E_FREE(e_iwd);
return NULL;
}
e_iwd_config_load();
e_iwd->manager = iwd_manager_new(e_iwd->conn);
e_iwd_popup_install_passphrase_handler();
e_iwd_gadget_init();
return m;
}
EAPI int
e_modapi_shutdown(E_Module *m EINA_UNUSED)
{
if (!e_iwd) return 1;
e_iwd_gadget_shutdown();
e_iwd_popup_shutdown();
if (e_iwd->manager) iwd_manager_free(e_iwd->manager);
e_iwd_config_save();
if (e_iwd->conn) eldbus_connection_unref(e_iwd->conn);
eldbus_shutdown();
E_FREE(e_iwd);
return 1;
}
EAPI int
e_modapi_save(E_Module *m EINA_UNUSED)
{
e_iwd_config_save();
return 1;
}