|
|
@@ -62,8 +62,11 @@ find_pid_user_of(){
|
|
|
}
|
|
|
|
|
|
find_systemctl_pids(){
|
|
|
+ local shell_pid
|
|
|
+ local systemctl_pid
|
|
|
ps -elf | grep 'systemctl' | grep -v grep | awk '{print $13}' | sort -u | while read term
|
|
|
do
|
|
|
+ echo ${shell_pid} ${systemctl_pid} >&2
|
|
|
if [ -z "${shell_pid:-}" ]
|
|
|
then
|
|
|
shell_pid=$(find_pid_user_of /dev/$term '.*sh$')
|
|
|
@@ -75,24 +78,24 @@ find_systemctl_pids(){
|
|
|
echo ${shell_pid} ${systemctl_pid}
|
|
|
done
|
|
|
}
|
|
|
-
|
|
|
process_and_parent=`find_systemctl_pids`
|
|
|
|
|
|
-if has_parent_process ${process_and_parent}
|
|
|
+if [ -n "${process_and_parent}" ]
|
|
|
then
|
|
|
- shell_process=$(echo ${process_and_parent} | awk '{print $1}')
|
|
|
- parent_term=`readlink /proc/${shell_process}/fd/2`
|
|
|
+ if has_parent_process ${process_and_parent}
|
|
|
+ then
|
|
|
+ shell_process=`echo ${process_and_parent} | awk '{print $1}'`
|
|
|
+ parent_term=`readlink /proc/${shell_process}/fd/2`
|
|
|
+ fi
|
|
|
fi
|
|
|
-echo "$$" > $parent_term
|
|
|
-ps -elf | grep 'systemctl' | grep -v grep > $parent_term
|
|
|
|
|
|
-set -eu #o pipefail
|
|
|
+set -eu
|
|
|
|
|
|
help_message_lfirewall(){
|
|
|
cat <<-EOF
|
|
|
Light Firewall configuration script.
|
|
|
|
|
|
- $(basename ${0}) [OPTIONS...] COMMAND
|
|
|
+ `basename ${0}` [OPTIONS...] COMMAND
|
|
|
|
|
|
COMMANDS
|
|
|
|
|
|
@@ -114,7 +117,7 @@ cat <<-EOF
|
|
|
1. Before setting any rule: clear the firewall
|
|
|
2. Setup your rules
|
|
|
3. run:
|
|
|
- $(basename ${0}) saveuser
|
|
|
+ `basename ${0}` saveuser
|
|
|
|
|
|
AUTHOR
|
|
|
Author: Laurent Hubert
|