Browse Source

Check root user before executing

Vova Tkach 6 years ago
parent
commit
d3b46ab626
5 changed files with 35 additions and 0 deletions
  1. 7 0
      iptables-http-clear
  2. 7 0
      iptables-http-cloudflare
  3. 7 0
      iptables-write
  4. 7 0
      ping-disable
  5. 7 0
      ping-enable

+ 7 - 0
iptables-http-clear

@@ -1,5 +1,12 @@
 #!/bin/bash
 
+# Check for root user
+CURR_USER=`/usr/bin/whoami`
+if [ "$CURR_USER" != "root" ]; then
+	echo "I need root rights... Please login from root"
+	exit
+fi
+
 # Clear all rules for port 80
 while :
 do

+ 7 - 0
iptables-http-cloudflare

@@ -1,5 +1,12 @@
 #!/bin/bash
 
+# Check for root user
+CURR_USER=`/usr/bin/whoami`
+if [ "$CURR_USER" != "root" ]; then
+	echo "I need root rights... Please login from root"
+	exit
+fi
+
 # Clear rules
 /usr/local/bin/iptables-http-clear
 

+ 7 - 0
iptables-write

@@ -1,5 +1,12 @@
 #!/bin/sh
 
+# Check for root user
+CURR_USER=`/usr/bin/whoami`
+if [ "$CURR_USER" != "root" ]; then
+	echo "I need root rights... Please login from root"
+	exit
+fi
+
 # Save current rules to file
 iptables-save > /etc/iptables.up.rules
 cat /etc/iptables.up.rules

+ 7 - 0
ping-disable

@@ -1,5 +1,12 @@
 #!/bin/sh
 
+# Check for root user
+CURR_USER=`/usr/bin/whoami`
+if [ "$CURR_USER" != "root" ]; then
+	echo "I need root rights... Please login from root"
+	exit
+fi
+
 # Disable ping reply Permanently
 # You can permanently disable the ping reply using the following method.
 # Step 1: Edit the sysctl.conf file and add the following line.

+ 7 - 0
ping-enable

@@ -1,3 +1,10 @@
 #!/bin/sh
 
+# Check for root user
+CURR_USER=`/usr/bin/whoami`
+if [ "$CURR_USER" != "root" ]; then
+	echo "I need root rights... Please login from root"
+	exit
+fi
+
 echo "0" >  /proc/sys/net/ipv4/icmp_echo_ignore_all