Forráskód Böngészése

bash check

Bash check improved
Cristhian Martínez Ochoa 3 éve
szülő
commit
f94c60c51f
3 módosított fájl, 20 hozzáadás és 15 törlés
  1. 6 4
      lib/general
  2. 7 5
      lib/verify
  3. 7 6
      weby

+ 6 - 4
lib/general

@@ -24,11 +24,13 @@ readonly dim=`tput dim`
 
 
 
 
 # Check for BASH Shell
 # Check for BASH Shell
-if [[ -f /proc/$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0" | grep -v "grep" | tail -n 1 | awk '{print $2}')/cmdline ]]; then
+if [[ -f /proc/$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0[ ]+S[s]?[ ]+" | grep -v "grep" | tail -n 1 | awk '{print $2}')/cmdline ]]; then
 	# This is a very "shity" method, but checking if file exists is very reliable
 	# This is a very "shity" method, but checking if file exists is very reliable
-	shell_current=$(tr -d '\000' < /proc/$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0" | grep -v "grep" | tail -n 1 | awk '{print $2}')/cmdline)
-elif [[ -f /proc/$(ps -aux | grep -E "$USER.*pts/0[ ]+S[ ]+" | tail -n 1 | awk '{print $2}')/cmdline ]]; then
-	shell_current=$(tr -d '\000' < /proc/$(ps -aux | grep -E "$USER.*pts/0[ ]+S[ ]+" | tail -n 1 | awk '{print $2}')/cmdline)
+	# If modified: this same script is in installer, general lib and verify
+	shell_current=$(tr -d '\000' < /proc/$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0[ ]+S[s]?[ ]+" | grep -v "grep" | tail -n 1 | awk '{print $2}')/cmdline)
+elif [[ -f /proc/$(ps -aux | grep -E "$USER.*pts/0[ ]+S[s]?[ ]+" | tail -n 1 | awk '{print $2}')/cmdline ]]; then
+	# This second check is useful when logedin as root
+	shell_current=$(tr -d '\000' < /proc/$(ps -aux | grep -E "$USER.*pts/0[ ]+S[s]?[ ]+" | tail -n 1 | awk '{print $2}')/cmdline)
 fi
 fi
 if [[ -n $shell_current && $shell_current != *"bash"* ]]; then
 if [[ -n $shell_current && $shell_current != *"bash"* ]]; then
 	echo "${red}BASH Shell is required! ${dim}(${shell_current}) ${end}"
 	echo "${red}BASH Shell is required! ${dim}(${shell_current}) ${end}"

+ 7 - 5
lib/verify

@@ -751,17 +751,19 @@ fi
 
 
 if [[ -z $critical_mode ]]; then
 if [[ -z $critical_mode ]]; then
 	# Check for BASH Shell
 	# Check for BASH Shell
-	if [[ -f /proc/$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0" | grep -v "grep" | tail -n 1 | awk '{print $2}')/cmdline ]]; then
+	if [[ -f /proc/$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0[ ]+S[s]?[ ]+" | grep -v "grep" | tail -n 1 | awk '{print $2}')/cmdline ]]; then
 		# This is a very "shity" method, but checking if file exists is very reliable
 		# This is a very "shity" method, but checking if file exists is very reliable
-		local ver_shell_current=$(tr -d '\000' < /proc/$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0" | grep -v "grep" | tail -n 1 | awk '{print $2}')/cmdline)
-	elif [[ -f /proc/$(ps -aux | grep -E "$USER.*pts/0[ ]+S[ ]+" | tail -n 1 | awk '{print $2}')/cmdline ]]; then
-		local ver_shell_current=$(tr -d '\000' < /proc/$(ps -aux | grep -E "$USER.*pts/0[ ]+S[ ]+" | tail -n 1 | awk '{print $2}')/cmdline)
+		# If modified: this same script is in installer, general lib and verify
+		local ver_shell_current=$(tr -d '\000' < /proc/$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0[ ]+S[s]?[ ]+" | grep -v "grep" | tail -n 1 | awk '{print $2}')/cmdline)
+	elif [[ -f /proc/$(ps -aux | grep -E "$USER.*pts/0[ ]+S[s]?[ ]+" | tail -n 1 | awk '{print $2}')/cmdline ]]; then
+		# This second check is useful when logedin as root
+		local ver_shell_current=$(tr -d '\000' < /proc/$(ps -aux | grep -E "$USER.*pts/0[ ]+S[s]?[ ]+" | tail -n 1 | awk '{print $2}')/cmdline)
 	else
 	else
 		echo "${blu}${dim}- [INFO] Shell check fails to retrieve data! ${end}${red}"
 		echo "${blu}${dim}- [INFO] Shell check fails to retrieve data! ${end}${red}"
 	fi
 	fi
 	if [[ -n $ver_shell_current && $ver_shell_current != *"bash"* ]]; then
 	if [[ -n $ver_shell_current && $ver_shell_current != *"bash"* ]]; then
 		# Should never be displayed because is blocked in general lib, but who knows!
 		# Should never be displayed because is blocked in general lib, but who knows!
-		echo "${red}- [WARNING] BASH Shell is required! ${dim}(${shell_current}) ${end}"
+		echo "${dim}- [WARNING] BASH Shell is required! ${dim}(${ver_shell_current}) ${end}${red}"
 		local ver_six_war="1"
 		local ver_six_war="1"
 	fi
 	fi
 	
 	

+ 7 - 6
weby

@@ -14,15 +14,16 @@ if ! [[ $distr == "Ubuntu" && $osver =~ ^(bionic|focal)$ ]]; then
 fi
 fi
 
 
 # Check for BASH Shell
 # Check for BASH Shell
-if [[ -f /proc/$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0" | grep -v "grep" | tail -n 1 | awk '{print $2}')/cmdline ]]; then
+if [[ -f /proc/$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0[ ]+S[s]?[ ]+" | grep -v "grep" | tail -n 1 | awk '{print $2}')/cmdline ]]; then
 	# This is a very "shity" method, but checking if file exists is very reliable
 	# This is a very "shity" method, but checking if file exists is very reliable
-	shell_current=$(tr -d '\000' < /proc/$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0" | grep -v "grep" | tail -n 1 | awk '{print $2}')/cmdline)
-elif [[ -f /proc/$(ps -aux | grep -E "$USER.*pts/0[ ]+S[ ]+" | tail -n 1 | awk '{print $2}')/cmdline ]]; then
+	# If modified: this same script is in installer, general lib and verify
+	ins_shell_current=$(tr -d '\000' < /proc/$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0[ ]+S[s]?[ ]+" | grep -v "grep" | tail -n 1 | awk '{print $2}')/cmdline)
+elif [[ -f /proc/$(ps -aux | grep -E "$USER.*pts/0[ ]+S[s]?[ ]+" | tail -n 1 | awk '{print $2}')/cmdline ]]; then
 	# This second check is useful when logedin as root
 	# This second check is useful when logedin as root
-	shell_current=$(tr -d '\000' < /proc/$(ps -aux | grep -E "$USER.*pts/0[ ]+S[ ]+" | tail -n 1 | awk '{print $2}')/cmdline)
+	ins_shell_current=$(tr -d '\000' < /proc/$(ps -aux | grep -E "$USER.*pts/0[ ]+S[s]?[ ]+" | tail -n 1 | awk '{print $2}')/cmdline)
 fi
 fi
-if [[ -n $shell_current && $shell_current != *"bash"* ]]; then
-	echo "$(tput setaf 1)BASH Shell is required! $(tput dim)(${shell_current}) $(tput sgr0)"
+if [[ -n $ins_shell_current && $ins_shell_current != *"bash"* ]]; then
+	echo "$(tput setaf 1)BASH Shell is required! $(tput dim)(${ins_shell_current}) $(tput sgr0)"
 	sudo rm weby
 	sudo rm weby
 	exit 1
 	exit 1
 fi
 fi