diff --git a/python/web/src/web.py b/python/web/src/web.py index a8f26bd7..aee8e4fc 100644 --- a/python/web/src/web.py +++ b/python/web/src/web.py @@ -610,11 +610,10 @@ def attach_device(): error_msg = _("Please follow the instructions at %(url)s", url=error_url) if "interface" in params.keys(): - # Note: is_bridge_configured returns False if the bridge is configured bridge_status = is_bridge_configured(params["interface"]) - if bridge_status: + if not bridge_status["status"]: return response(error=True, message=[ - (bridge_status, "error"), + (bridge_status["msg"], "error"), (error_msg, "error") ]) diff --git a/python/web/src/web_utils.py b/python/web/src/web_utils.py index 327a09b3..7d92ca7a 100644 --- a/python/web/src/web_utils.py +++ b/python/web/src/web_utils.py @@ -192,24 +192,30 @@ def auth_active(group): def is_bridge_configured(interface): """ Takes (str) interface of a network device being attached. - Returns (bool) False if the network bridge is configured. - Returns (str) with an error message if the network bridge is not configured. + Returns a (dict) with (bool) status and (str) msg """ + status = True + return_msg = "" sys_cmd = SysCmds() if interface.startswith("wlan"): if not sys_cmd.introspect_file("/etc/sysctl.conf", r"^net\.ipv4\.ip_forward=1$"): - return _("Configure IPv4 forwarding before using a wireless network device.") - if not Path("/etc/iptables/rules.v4").is_file(): - return _("Configure NAT before using a wireless network device.") + status = False + return_msg = _("Configure IPv4 forwarding before using a wireless network device.") + elif not Path("/etc/iptables/rules.v4").is_file(): + status = False + return_msg = _("Configure NAT before using a wireless network device.") else: if not sys_cmd.introspect_file( "/etc/dhcpcd.conf", r"^denyinterfaces " + interface + r"$", ): - return _("Configure the network bridge before using a wired network device.") - if not Path("/etc/network/interfaces.d/rascsi_bridge").is_file(): - return _("Configure the network bridge before using a wired network device.") - return False + status = False + return_msg = _("Configure the network bridge before using a wired network device.") + elif not Path("/etc/network/interfaces.d/rascsi_bridge").is_file(): + status = False + return_msg = _("Configure the network bridge before using a wired network device.") + + return {"status": status, "msg": return_msg + f" ({interface})"} def upload_with_dropzonejs(image_dir):