Class: Firewalld::FirewalldBashAPI

Inherits:
Object
  • Object
show all
Includes:
Yast::Logger
Defined in:
library/network/src/lib/network/firewalld.rb

Overview

The firewalld bash API

Instance Method Summary collapse

Instance Method Details

#add_interface(zone, interface) ⇒ Boolean



187
188
189
# File 'library/network/src/lib/network/firewalld.rb', line 187

def add_interface(zone, interface)
  fwd_quiet_result("--permanent --zone=#{zone} --add-interface=#{interface}")
end

#add_masquerade(zone) ⇒ Boolean



319
320
321
322
# File 'library/network/src/lib/network/firewalld.rb', line 319

def add_masquerade(zone)
  return true if masquerade_enabled?(zone)
  fwd_quiet_result("--permanent --zone=#{zone} --add-masquerade")
end

#add_port(zone, port) ⇒ Boolean



279
280
281
# File 'library/network/src/lib/network/firewalld.rb', line 279

def add_port(zone, port)
  fwd_quiet_result("--permanent --zone=#{zone} --add-port=#{port}")
end

#add_protocol(zone, protocol) ⇒ Boolean



286
287
288
# File 'library/network/src/lib/network/firewalld.rb', line 286

def add_protocol(zone, protocol)
  fwd_quiet_result("--permanent --zone=#{zone} --add-protocol=#{protocol}")
end

#add_service(zone, service) ⇒ Boolean



272
273
274
# File 'library/network/src/lib/network/firewalld.rb', line 272

def add_service(zone, service)
  fwd_quiet_result("--permanent --zone=#{zone} --add-service=#{service}")
end

#complete_reloadBoolean



124
125
126
# File 'library/network/src/lib/network/firewalld.rb', line 124

def complete_reload
  fwd_quiet_result("--complete-reload")
end

#info_service(service) ⇒ Array<String>



207
208
209
# File 'library/network/src/lib/network/firewalld.rb', line 207

def info_service(service)
  fwd_result("--permanent --info-service #{service}").split("\n")
end

#interface_enabled?(zone, interface) ⇒ Boolean



180
181
182
# File 'library/network/src/lib/network/firewalld.rb', line 180

def interface_enabled?(zone, interface)
  fwd_quiet_result("--permanent --zone=#{zone} --query-interface=#{interface}")
end

#list_all(zone) ⇒ Array<String>



166
167
168
# File 'library/network/src/lib/network/firewalld.rb', line 166

def list_all(zone)
  fwd_result("--permanent --zone=#{zone} --list-all").split(" ")
end

#list_all_zonesArray<String>



171
172
173
# File 'library/network/src/lib/network/firewalld.rb', line 171

def list_all_zones
  fwd_result("--permanent --list-all-zones").split("\n")
end

#list_interfaces(zone) ⇒ Array<String>



142
143
144
# File 'library/network/src/lib/network/firewalld.rb', line 142

def list_interfaces(zone)
  fwd_result("--permanent --zone=#{zone} --list-interfaces").split(" ")
end

#list_ports(zone) ⇒ Array<String>



154
155
156
# File 'library/network/src/lib/network/firewalld.rb', line 154

def list_ports(zone)
  fwd_result("--permanent --zone=#{zone} --list-ports").split(" ")
end

#list_protocols(zone) ⇒ Array<String>



160
161
162
# File 'library/network/src/lib/network/firewalld.rb', line 160

def list_protocols(zone)
  fwd_result("--permanent --zone=#{zone} --list-protocols").split(" ")
end

#list_services(zone) ⇒ Arrray<String>



148
149
150
# File 'library/network/src/lib/network/firewalld.rb', line 148

def list_services(zone)
  fwd_result("--permanent --zone=#{zone} --list-services").split(" ")
end

#log_denied_packetsString



349
350
351
# File 'library/network/src/lib/network/firewalld.rb', line 349

def log_denied_packets
  fwd_result("--get-log-denied").strip
end

#log_denied_packets=(kind) ⇒ Boolean

all, unicast, broadcast, multicast and off when denied



344
345
346
# File 'library/network/src/lib/network/firewalld.rb', line 344

def log_denied_packets=(kind)
  fwd_quiet_result("--set-log-denied=#{kind}")
end

#log_denied_packets?(kind) ⇒ Boolean

all, unicast, broadcast, multicast and off



336
337
338
# File 'library/network/src/lib/network/firewalld.rb', line 336

def log_denied_packets?(kind)
  fwd_result("--get-log-denied").strip == kind ? true : false
end

#make_permanentBoolean



129
130
131
# File 'library/network/src/lib/network/firewalld.rb', line 129

def make_permanent
  fwd_quiet_result("--runtime-to-permanent")
end

#masquerade_enabled?(zone) ⇒ Boolean



313
314
315
# File 'library/network/src/lib/network/firewalld.rb', line 313

def masquerade_enabled?(zone)
  fwd_quiet_result("--permanent --zone=#{zone} --query-masquerade")
end

#port_enabled?(zone, port) ⇒ Boolean



258
259
260
# File 'library/network/src/lib/network/firewalld.rb', line 258

def port_enabled?(zone, port)
  fwd_quiet_result("--permanent --zone=#{zone} --query-port=#{port}")
end

#protocol_enabled?(zone, protocol) ⇒ Boolean



265
266
267
# File 'library/network/src/lib/network/firewalld.rb', line 265

def protocol_enabled?(zone, protocol)
  fwd_quiet_result("--permanent --zone=#{zone} --query-protocol=#{protocol}")
end

#reloadBoolean



119
120
121
# File 'library/network/src/lib/network/firewalld.rb', line 119

def reload
  fwd_quiet_result("--reload")
end

#remove_interface(zone, interface) ⇒ Boolean



194
195
196
# File 'library/network/src/lib/network/firewalld.rb', line 194

def remove_interface(zone, interface)
  fwd_quiet_result("--permanent --zone=#{zone} --remove-interface=#{interface}")
end

#remove_masquerade(zone) ⇒ Boolean



326
327
328
329
# File 'library/network/src/lib/network/firewalld.rb', line 326

def remove_masquerade(zone)
  return true if !masquerade_enabled?(zone)
  fwd_quiet_result("--permanent --zone=#{zone} --remove-masquerade")
end

#remove_port(zone, port) ⇒ Boolean



300
301
302
# File 'library/network/src/lib/network/firewalld.rb', line 300

def remove_port(zone, port)
  fwd_quiet_result("--permanent --zone=#{zone} --remove-port=#{port}")
end

#remove_protocol(zone, protocol) ⇒ Boolean



307
308
309
# File 'library/network/src/lib/network/firewalld.rb', line 307

def remove_protocol(zone, protocol)
  fwd_quiet_result("--permanent --zone=#{zone} --remove-protocol=#{protocol}")
end

#remove_service(zone, service) ⇒ Boolean



293
294
295
# File 'library/network/src/lib/network/firewalld.rb', line 293

def remove_service(zone, service)
  fwd_quiet_result("--permanent --zone=#{zone} --remove-service=#{service}")
end

#running?Boolean



114
115
116
# File 'library/network/src/lib/network/firewalld.rb', line 114

def running?
  fwd_quiet_result("--state")
end

#service_description(service) ⇒ String



220
221
222
# File 'library/network/src/lib/network/firewalld.rb', line 220

def service_description(service)
  fwd_result("--permanent --service=#{service} --get-description").rstrip
end

#service_enabled?(zone, service) ⇒ Boolean



233
234
235
# File 'library/network/src/lib/network/firewalld.rb', line 233

def service_enabled?(zone, service)
  fwd_quiet_result("--permanent --zone=#{zone} --query-service=#{service}")
end

#service_modules(service) ⇒ Array<String>



251
252
253
# File 'library/network/src/lib/network/firewalld.rb', line 251

def service_modules(service)
  fwd_result("--permanent --service=#{service} --get-modules").strip
end

#service_ports(service) ⇒ Array<String>



239
240
241
# File 'library/network/src/lib/network/firewalld.rb', line 239

def service_ports(service)
  fwd_result("--permanent --service=#{service} --get-ports").strip
end

#service_protocols(service) ⇒ Array<String>



245
246
247
# File 'library/network/src/lib/network/firewalld.rb', line 245

def service_protocols(service)
  fwd_result("--permanent --service=#{service} --get-protocols").strip
end

#service_short(service) ⇒ String



213
214
215
216
# File 'library/network/src/lib/network/firewalld.rb', line 213

def service_short(service)
  # these may not exist on early firewalld releases
  fwd_result("--permanent --service=#{service} --get-short").rstrip
end

#service_supported?(service) ⇒ Boolean



226
227
228
# File 'library/network/src/lib/network/firewalld.rb', line 226

def service_supported?(service)
  services.include?(service)
end

#servicesArray<String>



201
202
203
# File 'library/network/src/lib/network/firewalld.rb', line 201

def services
  fwd_result("--permanent --get-services").split(" ")
end

#zonesArray<String>



136
137
138
# File 'library/network/src/lib/network/firewalld.rb', line 136

def zones
  fwd_result("--permanent --get-zones").split(" ")
end