Skip to content

Commit

Permalink
T6291: Removed sudo from subprocess calls
Browse files Browse the repository at this point in the history
Removed sudo from subprocess calls. The sudo elevation will be handled in the op-mode-definition XML.
  • Loading branch information
l0crian1 authored May 4, 2024
1 parent 7e920b7 commit 1a2ad8f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/op_mode/bonding.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def list_to_dict(data, headers, basekey):

def show_lacp_neighbors(raw: bool, interface: typing.Optional[str]):
headers = ["Interface", "Member", "Local ID", "Remote ID"]
data = subprocess.run(f"sudo cat /proc/net/bonding/{interface}", stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, shell=True, text=False).stdout.decode('utf-8')
data = subprocess.run(f"cat /proc/net/bonding/{interface}", stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, shell=True, text=False).stdout.decode('utf-8')
if 'Bonding Mode: IEEE 802.3ad Dynamic link aggregation' not in data:
raise vyos.opmode.DataUnavailable(f"{interface} is not present or not configured with mode 802.3ad")

Expand Down Expand Up @@ -73,7 +73,7 @@ def show_lacp_detail(raw: bool, interface: typing.Optional[str]):
bondList = []

for interface in intList:
data = subprocess.run(f"sudo cat /proc/net/bonding/{interface}", stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, shell=True, text=False).stdout.decode('utf-8')
data = subprocess.run(f"cat /proc/net/bonding/{interface}", stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, shell=True, text=False).stdout.decode('utf-8')
if 'Bonding Mode: IEEE 802.3ad Dynamic link aggregation' not in data:
continue

Expand Down

0 comments on commit 1a2ad8f

Please sign in to comment.