Guest User

Untitled

a guest
Aug 2nd, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 1.60 KB | None | 0 0
  1.     /*Check if ufw is enabled*/
  2.     ufw_status = Process.spawn_sync(null, {"ufw_status", ""}, null);
  3.     if ufw_status[1].find("Status: active") != -1:
  4.             return "enable"
  5.     else:
  6.             return "disable"
  7.  
  8.  
  9.     /*Check if policy is incoming or outgoing*/
  10.         if policy == "incoming":
  11.             Process.spawn_sync(null, {"grep DEFAULT_INPUT_POLICY /etc/default/ufw", null}, out ufw_default_incoming);
  12.             if ufw_default_incoming[1].find("ACCEPT") != -1:
  13.                 return "allow"
  14.             elif ufw_default_incoming[1].find("DROP") != -1:
  15.                 return "deny"
  16.             elif ufw_default_incoming[1].find("REJECT") != -1:
  17.                 return "reject"
  18.        
  19.         elif policy == "outgoing":
  20.             Process.spawn_sync(null, {"grep DEFAULT_OUTPUT_POLICY /etc/default/ufw", null}, out ufw_default_outgoing);
  21.             if ufw_default_outgoing[1].find("ACCEPT") != -1:
  22.                 return "allow"
  23.             elif ufw_default_outgoing[1].find("DROP") != -1:
  24.                 return "deny"
  25.             elif ufw_default_outgoing[1].find("REJECT") != -1:
  26.                 return "reject"
  27.  
  28.  
  29.      /*Look for log level*/
  30.         Process.spawn_sync(null, {"cat /etc/ufw/ufw.conf", null}, out ufw_cmd);
  31.         if ufw_cmd[1].find("LOGLEVEL=full") != -1:
  32.             return "full"
  33.         elif ufw_cmd[1].find("LOGLEVEL=high") != -1:
  34.             return "high"
  35.         elif ufw_cmd[1].find("LOGLEVEL=medium") != -1:
  36.             return "medium"
  37.         elif ufw_cmd[1].find("LOGLEVEL=low") != -1:
  38.             return "low"
  39.         else:
  40.             return "off"
Add Comment
Please, Sign In to add comment