| From d1c19eccd0e147ac26818a7320a22c2cd1c73c5a Mon Sep 17 00:00:00 2001 | |
| From: Ginko <[email protected]> | |
| Date: Sat, 16 Aug 2025 20:19:43 -0400 | |
| Subject: [PATCH 1/2] op-mode: T7677: fix BrokenPipeError when user quits | |
| output of show firewall | |
| --- | |
| src/op_mode/firewall.py | 12 ++++++++++++ | |
| 1 file changed, 12 insertions(+) | |
| diff --git a/src/op_mode/firewall.py b/src/op_mode/firewall.py | |
| index 15fbb65a2..ba65058da 100755 | |
| --- a/src/op_mode/firewall.py | |
| +++ b/src/op_mode/firewall.py | |
| @@ -17,7 +17,9 @@ | |
| import argparse | |
| import ipaddress | |
| import json | |
| +import os | |
| import re | |
| +import sys | |
| import tabulate | |
| import textwrap | |
| @@ -25,6 +27,15 @@ | |
| from vyos.utils.process import cmd | |
| from vyos.utils.dict import dict_search_args | |
| +def catch_broken_pipe(func): | |
| + def wrapped(*args, **kwargs): | |
| + try: | |
| + func(*args, **kwargs) | |
| + except (BrokenPipeError, KeyboardInterrupt): | |
| + # Flush standard streams; redirect remaining output to devnull | |
| + os.dup2(os.open(os.devnull, os.O_WRONLY), sys.stdout.fileno()) # pylint: disable = no-member | |
| + return wrapped | |
| + | |
| def get_config_node(conf, node=None, family=None, hook=None, priority=None): | |
| if node == 'nat': | |
| if family == 'ipv6': | |
| @@ -339,6 +350,7 @@ def show_firewall_rule(family, hook, priority, rule_id): | |
| if firewall: | |
| output_firewall_name(family, hook, priority, firewall, rule_id) | |
| +@catch_broken_pipe | |
| def show_firewall_group(name=None): | |
| conf = Config() | |
| firewall = get_config_node(conf, node='firewall') | |
| -- | |
| 2.39.5 (Apple Git-154) | |
File Metadata
File Metadata
- Mime Type
- text/x-diff
- Storage Engine
- blob
- Storage Format
- Raw Data
- Storage Handle
- 2701914
- Default Alt Text
- 0001-op-mode-T7677-fix-BrokenPipeError-when-user-quits-show-firewall-summary.patch (1 KB)