File tree Expand file tree Collapse file tree 1 file changed +10
-14
lines changed
modules/post/windows/manage Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -112,21 +112,17 @@ def check_ipv6
112
112
113
113
def fw_enable_ports
114
114
print_status ( "Setting port #{ datastore [ 'LOCAL_PORT' ] } in Windows Firewall ..." )
115
- begin
116
- if sysinfo [ "OS" ] =~ /Windows 7|Vista|2008|2012/
117
- cmd_exec ( "netsh" , "advfirewall firewall add rule name=\" Windows Service\" dir=in protocol=TCP action=allow localport=\" #{ datastore [ 'LOCAL_PORT' ] } \" " )
118
- else
119
- cmd_exec ( "netsh" , "firewall set portopening protocol=TCP port=\" #{ datastore [ 'LOCAL_PORT' ] } \" " )
120
- end
121
- output = cmd_exec ( "netsh" , "firewall show state" )
115
+ if sysinfo [ "OS" ] =~ /Windows 7|Vista|2008|2012/
116
+ cmd_exec ( "netsh" , "advfirewall firewall add rule name=\" Windows Service\" dir=in protocol=TCP action=allow localport=\" #{ datastore [ 'LOCAL_PORT' ] } \" " )
117
+ else
118
+ cmd_exec ( "netsh" , "firewall set portopening protocol=TCP port=\" #{ datastore [ 'LOCAL_PORT' ] } \" " )
119
+ end
120
+ output = cmd_exec ( "netsh" , "firewall show state" )
122
121
123
- if output =~ /^#{ datastore [ 'LOCAL_PORT' ] } /
124
- print_good ( "Port opened in Windows Firewall." )
125
- else
126
- print_error ( "There was an error enabling the port." )
127
- end
128
- rescue ::Exception => e
129
- print_status ( "The following Error was encountered: #{ e . class } #{ e } " )
122
+ if output =~ /^#{ datastore [ 'LOCAL_PORT' ] } /
123
+ print_good ( "Port opened in Windows Firewall." )
124
+ else
125
+ print_error ( "There was an error enabling the port." )
130
126
end
131
127
end
132
128
end
You can’t perform that action at this time.
0 commit comments