wpasupplicant: Disable D-Bus auto-activation on all calls
Every method call and property access to fi.w1.wpa_supplicant1 used flag 0, leaving D-Bus service activation enabled. Any stray request — a startup race before `service wpa_supplicant start` takes effect, or a leaked call while the Ethernet uplink is the chosen path — would make the bus daemon spawn `wpa_supplicant -u` from its .service file, bypassing repeater's own launch of the daemon. Route every interaction through callNoAutoStart/getPropNoAutoStart/ setPropNoAutoStart, which set dbus.FlagNoAutoStart. A leaked call now fails cleanly with ServiceUnknown instead of resurrecting the daemon, leaving repeater as the sole launcher. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
15d17ed35e
commit
11ae69de56
5 changed files with 85 additions and 25 deletions
|
|
@ -28,7 +28,7 @@ func (i *WPAInterface) Scan(scanType string) error {
|
|||
"Type": scanType, // "active" or "passive"
|
||||
}
|
||||
|
||||
err := i.obj.Call(InterfaceInterface+".Scan", 0, args).Err
|
||||
err := callNoAutoStart(i.obj, InterfaceInterface+".Scan", args).Err
|
||||
if err != nil {
|
||||
return fmt.Errorf("scan failed: %v", err)
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ func (i *WPAInterface) Scan(scanType string) error {
|
|||
|
||||
// GetBSSs returns a list of BSS (Basic Service Set) object paths
|
||||
func (i *WPAInterface) GetBSSs() ([]dbus.ObjectPath, error) {
|
||||
prop, err := i.obj.GetProperty(InterfaceInterface + ".BSSs")
|
||||
prop, err := getPropNoAutoStart(i.obj, InterfaceInterface+".BSSs")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get BSSs property: %v", err)
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ func (i *WPAInterface) GetBSSs() ([]dbus.ObjectPath, error) {
|
|||
|
||||
// GetState returns the current connection state
|
||||
func (i *WPAInterface) GetState() (WPAState, error) {
|
||||
prop, err := i.obj.GetProperty(InterfaceInterface + ".State")
|
||||
prop, err := getPropNoAutoStart(i.obj, InterfaceInterface+".State")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get State property: %v", err)
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ func (i *WPAInterface) GetState() (WPAState, error) {
|
|||
|
||||
// GetCurrentBSS returns the currently connected BSS object path
|
||||
func (i *WPAInterface) GetCurrentBSS() (dbus.ObjectPath, error) {
|
||||
prop, err := i.obj.GetProperty(InterfaceInterface + ".CurrentBSS")
|
||||
prop, err := getPropNoAutoStart(i.obj, InterfaceInterface+".CurrentBSS")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get CurrentBSS property: %v", err)
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ func (i *WPAInterface) AddNetwork(config map[string]interface{}) (dbus.ObjectPat
|
|||
dbusConfig[key] = dbus.MakeVariant(value)
|
||||
}
|
||||
|
||||
err := i.obj.Call(InterfaceInterface+".AddNetwork", 0, dbusConfig).Store(&networkPath)
|
||||
err := callNoAutoStart(i.obj, InterfaceInterface+".AddNetwork", dbusConfig).Store(&networkPath)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to add network: %v", err)
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ func (i *WPAInterface) AddNetwork(config map[string]interface{}) (dbus.ObjectPat
|
|||
|
||||
// SelectNetwork connects to a network
|
||||
func (i *WPAInterface) SelectNetwork(networkPath dbus.ObjectPath) error {
|
||||
err := i.obj.Call(InterfaceInterface+".SelectNetwork", 0, networkPath).Err
|
||||
err := callNoAutoStart(i.obj, InterfaceInterface+".SelectNetwork", networkPath).Err
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to select network: %v", err)
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ func (i *WPAInterface) SelectNetwork(networkPath dbus.ObjectPath) error {
|
|||
// EnableNetwork marks a network configuration as enabled (eligible for auto-connect)
|
||||
func (i *WPAInterface) EnableNetwork(networkPath dbus.ObjectPath) error {
|
||||
netObj := i.conn.Object(Service, networkPath)
|
||||
err := netObj.SetProperty(NetworkInterface+".Enabled", dbus.MakeVariant(true))
|
||||
err := setPropNoAutoStart(netObj, NetworkInterface+".Enabled", dbus.MakeVariant(true))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to enable network: %v", err)
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ func (i *WPAInterface) EnableNetwork(networkPath dbus.ObjectPath) error {
|
|||
|
||||
// RemoveNetwork removes a network configuration
|
||||
func (i *WPAInterface) RemoveNetwork(networkPath dbus.ObjectPath) error {
|
||||
err := i.obj.Call(InterfaceInterface+".RemoveNetwork", 0, networkPath).Err
|
||||
err := callNoAutoStart(i.obj, InterfaceInterface+".RemoveNetwork", networkPath).Err
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to remove network: %v", err)
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ func (i *WPAInterface) RemoveNetwork(networkPath dbus.ObjectPath) error {
|
|||
|
||||
// GetNetworks returns the object paths of all configured networks
|
||||
func (i *WPAInterface) GetNetworks() ([]dbus.ObjectPath, error) {
|
||||
prop, err := i.obj.GetProperty(InterfaceInterface + ".Networks")
|
||||
prop, err := getPropNoAutoStart(i.obj, InterfaceInterface+".Networks")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get Networks property: %v", err)
|
||||
}
|
||||
|
|
@ -143,7 +143,7 @@ func (i *WPAInterface) GetNetworks() ([]dbus.ObjectPath, error) {
|
|||
|
||||
// Disconnect disconnects from the current network
|
||||
func (i *WPAInterface) Disconnect() error {
|
||||
err := i.obj.Call(InterfaceInterface+".Disconnect", 0).Err
|
||||
err := callNoAutoStart(i.obj, InterfaceInterface+".Disconnect").Err
|
||||
if err != nil {
|
||||
return fmt.Errorf("disconnect failed: %v", err)
|
||||
}
|
||||
|
|
@ -152,7 +152,7 @@ func (i *WPAInterface) Disconnect() error {
|
|||
|
||||
// SaveConfig saves the current configuration to the wpa_supplicant config file
|
||||
func (i *WPAInterface) SaveConfig() error {
|
||||
err := i.obj.Call(InterfaceInterface+".SaveConfig", 0).Err
|
||||
err := callNoAutoStart(i.obj, InterfaceInterface+".SaveConfig").Err
|
||||
if err != nil {
|
||||
return fmt.Errorf("save config failed: %v", err)
|
||||
}
|
||||
|
|
@ -166,7 +166,7 @@ func (i *WPAInterface) GetPath() dbus.ObjectPath {
|
|||
|
||||
// GetScanning returns whether a scan is currently in progress
|
||||
func (i *WPAInterface) GetScanning() (bool, error) {
|
||||
prop, err := i.obj.GetProperty(InterfaceInterface + ".Scanning")
|
||||
prop, err := getPropNoAutoStart(i.obj, InterfaceInterface+".Scanning")
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to get Scanning property: %v", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue