2 Commits 6dcdab2514 ... 6b885e4d66

Autore SHA1 Messaggio Data
  Laurent HUBERT 6b885e4d66 Corrected bugs: search of parent process + network interface not present 9 mesi fa
  Laurent HUBERT 3b8c706fed Changed: check of network interface presence 9 mesi fa
1 ha cambiato i file con 19 aggiunte e 12 eliminazioni
  1. 19 12
      scripts/lfirewall

+ 19 - 12
scripts/lfirewall

@@ -37,18 +37,24 @@ has_parent_process(){
 	then
 		echo ${parent_to_search}
 		return 0
-	else if [ $pid > 1 ]
+	else if [ $pid -gt 1 ]
 		then
-			ppid=$(ps --pid ${pid} -o ppid= | xargs)
-			if [ $ppid = $pid ]
+			ppid=$(ps --pid ${pid} -o ppid= | xargs) || echo "OUT OF RANGE PID=${pid}" >&2
+			if [ -n "$ppid" ]
 			then
-				echo "ERROR: pid=$pid is the same as ppid=$ppid" >&2
-				echo -1
+				if [ $ppid = $pid ]
+				then
+					#echo "ERROR: pid=$pid is the same as ppid=$ppid" >&2
+					echo -1
+				else
+					has_parent_process ${parent_to_search} ${ppid}
+				fi
 			else
-				has_parent_process ${parent_to_search} ${ppid}
+				#echo "ERROR: pid='$pid' has ppid='$ppid'" >&2
+				echo -2
 			fi
 		else
-			echo "NOT FOUND: ${parent_to_search}" >&2
+			#echo "NOT FOUND: ${parent_to_search}" >&2
 			echo 1
 		fi
 	fi
@@ -66,7 +72,7 @@ find_systemctl_pids(){
 	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
+		#echo ${shell_pid} ${systemctl_pid} >&2
 		if [ -z "${shell_pid:-}" ]
 		then
 			shell_pid=$(find_pid_user_of /dev/$term '.*sh$')
@@ -239,10 +245,11 @@ if [ -f $CONFIGURATION_LOCAL_FILE ] ; then
 	set -u
 fi
 
-
-if ! /usr/sbin/ifup --no-act $NETWORK_IF > /dev/null 2>&1
+# Should I disable this ?
+# I think I should... but will the 
+if ! /usr/bin/ip link show $NETWORK_IF > /dev/null 2>&1
 then
-	echo "Network interface '$NETWORK_IF' is not present or configured" >&2
+	echo "Network interface '$NETWORK_IF' is not present" >&2
 	exit 2
 fi
 
@@ -743,7 +750,7 @@ case "$1" in
 		echo "Droping all connections !!!"
 		fw_dropall
 		echo "done."
-		if [ -c "${parent_term}" ]
+		if [ -c "${parent_term:-}" ]
 		then
 			exec 2>${parent_term}
 		fi