|
@@ -64,11 +64,6 @@ find_pid_user_of(){
|
|
|
find_systemctl_pids(){
|
|
find_systemctl_pids(){
|
|
|
ps -elf | grep 'systemctl' | grep -v grep | awk '{print $13}' | sort -u | while read term
|
|
ps -elf | grep 'systemctl' | grep -v grep | awk '{print $13}' | sort -u | while read term
|
|
|
do
|
|
do
|
|
|
- #echo "$term ---"
|
|
|
|
|
- #lsof /dev/$term
|
|
|
|
|
- #lsof -F 'cp' /dev/$term
|
|
|
|
|
- #echo "$term >>>"
|
|
|
|
|
- #lsof /dev/$term | awk 'NR>1 && $1 ~ /.*sh$/ && !($2 in a){a[$2]++; print $2}'
|
|
|
|
|
if [ -z "${shell_pid:-}" ]
|
|
if [ -z "${shell_pid:-}" ]
|
|
|
then
|
|
then
|
|
|
shell_pid=$(find_pid_user_of /dev/$term '.*sh$')
|
|
shell_pid=$(find_pid_user_of /dev/$term '.*sh$')
|
|
@@ -77,17 +72,10 @@ find_systemctl_pids(){
|
|
|
then
|
|
then
|
|
|
systemctl_pid=$(find_pid_user_of /dev/$term 'systemctl')
|
|
systemctl_pid=$(find_pid_user_of /dev/$term 'systemctl')
|
|
|
fi
|
|
fi
|
|
|
- #echo "shell_pid=$shell_pid" >&2
|
|
|
|
|
- #echo "systemctl_pid=$systemctl_pid" >&2
|
|
|
|
|
echo ${shell_pid} ${systemctl_pid}
|
|
echo ${shell_pid} ${systemctl_pid}
|
|
|
- #echo "TEST:$term" > /dev/$term
|
|
|
|
|
done
|
|
done
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
|
|
|
|
|
-#declare -g shell_pid=""
|
|
|
|
|
-#declare -g systemctl_pid=""
|
|
|
|
|
-#ps -elf | grep 'systemctl' | grep -v grep | awk '{print $13}' | sort -u | while read term ; do echo "$term"; lsof /dev/$term ; echo "TEST:$term" > /dev/$term ; done
|
|
|
|
|
process_and_parent=`find_systemctl_pids`
|
|
process_and_parent=`find_systemctl_pids`
|
|
|
|
|
|
|
|
if has_parent_process ${process_and_parent}
|
|
if has_parent_process ${process_and_parent}
|
|
@@ -95,10 +83,8 @@ then
|
|
|
shell_process=$(echo ${process_and_parent} | awk '{print $1}')
|
|
shell_process=$(echo ${process_and_parent} | awk '{print $1}')
|
|
|
parent_term=`readlink /proc/${shell_process}/fd/2`
|
|
parent_term=`readlink /proc/${shell_process}/fd/2`
|
|
|
fi
|
|
fi
|
|
|
-
|
|
|
|
|
-#echo "Parent terminal: ${parent_term}"
|
|
|
|
|
-#echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
|
|
|
|
|
-
|
|
|
|
|
|
|
+echo "$$" > $parent_term
|
|
|
|
|
+ps -elf | grep 'systemctl' | grep -v grep > $parent_term
|
|
|
|
|
|
|
|
set -eu #o pipefail
|
|
set -eu #o pipefail
|
|
|
|
|
|
|
@@ -659,7 +645,7 @@ case "$1" in
|
|
|
echo "Droping all connections !!!"
|
|
echo "Droping all connections !!!"
|
|
|
fw_dropall
|
|
fw_dropall
|
|
|
echo "done."
|
|
echo "done."
|
|
|
- if [ -n "${parent_term}" ]
|
|
|
|
|
|
|
+ if [ -c "${parent_term}" ]
|
|
|
then
|
|
then
|
|
|
exec 2>${parent_term}
|
|
exec 2>${parent_term}
|
|
|
fi
|
|
fi
|