Skip to content

Commit

Permalink
Merge pull request sonic-net#62 from gechiang/ghc-202205
Browse files Browse the repository at this point in the history
[bgp]: Add sudo check for TSA/B/C command execution (sonic-net#15288)
  • Loading branch information
gechiang committed Jul 13, 2023
2 parents afa2423 + 5a1abf2 commit 0c4ed8f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
8 changes: 7 additions & 1 deletion dockers/docker-fpm-frr/base_image_files/TSA
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#!/bin/bash

# Restrict command to sudo users
if [ "$EUID" -ne 0 ] ; then
echo "Root priveleges are needed for this operation"
exit 1
fi

if [ -f /etc/sonic/chassisdb.conf ]; then
rexec all -c "TSA chassis"
rexec all -c "sudo TSA chassis"
echo "Please execute \"rexec all -c 'sudo config save -y'\" to preserve System mode in Maintenance after reboot\
or config reload on all linecards"
exit 0
Expand Down
8 changes: 7 additions & 1 deletion dockers/docker-fpm-frr/base_image_files/TSB
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#!/bin/bash

# Restrict command to sudo users
if [ "$EUID" -ne 0 ] ; then
echo "Root priveleges are needed for this operation"
exit 1
fi

# If run on supervisor of chassis, trigger remote execution of TSB on all linecards
if [ -f /etc/sonic/chassisdb.conf ]; then
rexec all -c "TSB chassis"
rexec all -c "sudo TSB chassis"
echo "Please execute \"rexec all -c 'sudo config save -y'\" to preserve System mode in Normal state after reboot\
or config reload on all linecards"
exit 0
Expand Down
10 changes: 8 additions & 2 deletions dockers/docker-fpm-frr/base_image_files/TSC
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
#!/bin/bash

# Restrict command to sudo users
if [ "$EUID" -ne 0 ] ; then
echo "Root priveleges are needed for this operation"
exit 1
fi

if [ -f /etc/sonic/chassisdb.conf ]; then
if [[ $1 == "no-stats" ]]; then
rexec all -c "TSC no-stats"
rexec all -c "sudo TSC no-stats"
else
rexec all -c "TSC"
rexec all -c "sudo TSC"
fi
exit 0
fi
Expand Down

0 comments on commit 0c4ed8f

Please sign in to comment.