[bgp]: Add sudo check for TSA/B/C command execution (#15288)
TSA/B/C scripts invoke commands that require root permissions. If the user does not have sudo permissions, the scripts today execute until the command and throw a backtrace with error at the specific command. Added a check to ensure the operations check for root permissions upfront.
This commit is contained in:
parent
6a8f1bad63
commit
8058550c09
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user