Class: Yast::SuSEFirewallProposalClass

Inherits:
Module
  • Object
show all
Includes:
Logger
Defined in:
library/network/src/modules/SuSEFirewallProposal.rb

Instance Method Summary collapse

Instance Method Details

#AddWarning(warning) ⇒ Object

Local function adds another warning string into warnings for user

Parameters:



74
75
76
77
78
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 74

def AddWarning(warning)
  @warnings_now = Builtins.add(@warnings_now, warning)

  nil
end

#ClearWarningsObject

Local function clears all warnings for user from memory



81
82
83
84
85
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 81

def ClearWarnings
  @warnings_now = []

  nil
end

#EnableFallbackPorts(fallback_ports, zones) ⇒ Object

Enables ports in zones.

Parameters:

  • fallback_ports (Array<String>)

    fallback TCP ports

  • zones (Array<String>)


232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 232

def EnableFallbackPorts(fallback_ports, zones)
  known_zones = SuSEFirewall.GetKnownFirewallZones()
  unknown_zones = zones - known_zones
  raise "Unknown firewall zones #{unknown_zones}" unless unknown_zones.empty?

  log.info "Enabling fallback ports: #{fallback_ports} in zones: #{zones}"
  zones.each do |one_zone|
    fallback_ports.each do |one_port|
      SuSEFirewall.AddService(one_port, "TCP", one_zone)
    end
  end

  nil
end

#GetChangedByUserBoolean

Local function returns if proposal was changed by user

Returns:

  • (Boolean)

    if proposal was changed by user



467
468
469
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 467

def GetChangedByUser
  @proposal_changed_by_user
end

#GetKnownInterfacesArray<String>

Local function returns list [string] of known interfaces. They must have been set using SetKnownInterfaces(list [string] interfaces) function.

Returns:

  • (Array<String>)

    of known interfaces



109
110
111
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 109

def GetKnownInterfaces
  deep_copy(@known_interfaces)
end

#GetProposalInitializedBoolean

Local function returns if proposal was initialized already

Returns:

  • (Boolean)

    if proposal was initialized



483
484
485
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 483

def GetProposalInitialized
  @proposal_initialized
end

#GetWarningsArray<String>

Function returns list of warnings for user

Returns:

  • (Array<String>)

    of warnings



90
91
92
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 90

def GetWarnings
  deep_copy(@warnings_now)
end

#IsDialUpInterface(interface) ⇒ Boolean

Function returns if interface is a dial-up type.

Returns:

  • (Boolean)

    if is dial-up interface



116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 116

def IsDialUpInterface(interface)
  all_interfaces = SuSEFirewall.GetAllKnownInterfaces

  interface_type = nil
  Builtins.foreach(all_interfaces) do |one|
    next if Ops.get(one, "id") != interface

    # this is THE interface
    interface_type = Ops.get(one, "type")
  end

  interface_type == "dialup"
end

#IsServiceOrPortsOpen(service, fallback_ports) ⇒ Object

Checks whether the given service or (TCP) ports are open at least in one FW zone.

Parameters:

  • service (String)

    e.g., "service:http-server"

  • fallback_ports (Array<String>)

    e.g., ["80"]



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 280

def IsServiceOrPortsOpen(service, fallback_ports)
  fallback_ports = deep_copy(fallback_ports)
  ret = false

  Builtins.foreach(SuSEFirewall.GetKnownFirewallZones) do |zone|
    # either service is supported
    if SuSEFirewall.IsServiceSupportedInZone(service, zone)
      ret = true
      # or check for ports
    else
      all_ports = true

      # all ports have to be open
      Builtins.foreach(fallback_ports) do |port|
        if !SuSEFirewall.HaveService(port, "TCP", zone)
          all_ports = false
          raise Break
        end
      end

      ret = true if all_ports
    end
    raise Break if ret == true
  end

  ret
end

#IsXenInstalledBoolean

Local function returns whether the Xen kernel is installed

Returns:

  • (Boolean)

    whether xen-capable kernel is installed.



347
348
349
350
351
352
353
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 347

def IsXenInstalled
  # bug #154133
  return true if Package.Installed("kernel-xen")
  return true if Package.Installed("kernel-xenpae")

  false
end

#mainObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 36

def main
  textdomain "base"

  Yast.import "SuSEFirewall"
  Yast.import "ProductFeatures"
  Yast.import "Linuxrc"
  Yast.import "Package"
  Yast.import "SuSEFirewallServices"

  # <!-- SuSEFirewall LOCAL VARIABLES //-->

  # proposal was changed by user
  @proposal_changed_by_user = false

  # proposal was initialized yet
  @proposal_initialized = false

  # known interfaces
  @known_interfaces = []

  # warnings for this "turn"
  @warnings_now = []

  @vnc_fallback_ports = ["5801", "5901"]

  # bnc #427708, yet another name of service
  @vnc_service = "service:xorg-x11-server"

  @ssh_service = "service:sshd"
end

#OpenServiceInInterfaces(service, fallback_ports, interfaces) ⇒ Object

Function opens service for network interfaces given as the third parameter. Fallback ports are used if the given service is uknown. If interfaces are not assigned to any firewall zone, all zones will be used.

Parameters:

  • service (String)

    e.g., "service:http-server"

  • fallback_ports (Array<String>)

    e.g., ["80"]

  • interfaces (Array<String>)

    e.g., ["eth3"]

See Also:



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 256

def OpenServiceInInterfaces(service, fallback_ports, interfaces)
  fallback_ports = deep_copy(fallback_ports)
  interfaces = deep_copy(interfaces)
  zones = SuSEFirewall.GetZonesOfInterfaces(interfaces)

  # Interfaces might not be assigned to any zone yet, use all zones
  zones = SuSEFirewall.GetKnownFirewallZones() if zones.empty?

  if SuSEFirewallServices.IsKnownService(service)
    log.info "Opening service #{service} on interfaces #{interfaces} (zones #{zones})"
    SuSEFirewall.SetServicesForZones([service], zones, true)
  else
    log.warn "Unknown service #{service}, enabling fallback ports"
    EnableFallbackPorts(fallback_ports, zones)
  end

  nil
end

#OpenServiceOnNonDialUpInterfaces(service, fallback_ports) ⇒ Object

Function opens up the service on all non-dial-up network interfaces. If there are no network interfaces known and the 'any' feature is supported, function opens the service for the zone supporting that feature. If there are only dial-up interfaces, function opens the service for them.

Parameters:

  • service (String)

    such as "service:koo" or "serice:boo"

  • fallback_ports (Array<String>)

    list of ports used as a fallback if the given service doesn't exist



315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 315

def OpenServiceOnNonDialUpInterfaces(service, fallback_ports)
  fallback_ports = deep_copy(fallback_ports)
  non_dial_up_interfaces = SuSEFirewall.GetAllNonDialUpInterfaces
  dial_up_interfaces = SuSEFirewall.GetAllDialUpInterfaces

  # Opening the service for non-dial-up interfaces
  if Ops.greater_than(Builtins.size(non_dial_up_interfaces), 0)
    OpenServiceInInterfaces(service, fallback_ports, non_dial_up_interfaces)
    # Only dial-up network interfaces, there mustn't be any non-dial-up one
  elsif Ops.greater_than(Builtins.size(dial_up_interfaces), 0)
    OpenServiceInInterfaces(service, fallback_ports, dial_up_interfaces)
    # No network interfaces are known
  elsif Builtins.size(@known_interfaces) == 0
    if SuSEFirewall.IsAnyNetworkInterfaceSupported == true
      Builtins.y2warning(
        "WARNING: Opening %1 for the External zone without any known interface!",
        Builtins.toupper(service)
      )
      OpenServiceInInterfaces(
        service,
        fallback_ports,
        [SuSEFirewall.special_all_interface_string]
      )
    end
  end

  nil
end

#ProposalSummaryHash{String => String}

Function returns the proposal summary

Structure:

map $[
  "output" : "HTML Proposal Summary",
  "warning" : "HTML Warning Summary",
 ]

Returns:



532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 532

def ProposalSummary
  # output: $[ "output" : "HTML Proposal", "warning" : "HTML Warning" ];
  output = ""
  warning = ""

  # SuSEfirewall2 package needn't be installed
  if !SuSEFirewall.SuSEFirewallIsInstalled
    # TRANSLATORS: Proposal informative text
    output = "<ul>" +
      _(
        "The SuSEfirewall2 package is not installed. The firewall will be disabled."
      ) + "</ul>"

    return { "output" => output, "warning" => warning }
  end

  # SuSEfirewall2 is installed...

  firewall_is_enabled = SuSEFirewall.GetEnableService == true

  output = Ops.add(output, "<ul>\n")
  output = Ops.add(
    Ops.add(
      Ops.add(output, "<li>"),
      if firewall_is_enabled
        # TRANSLATORS: Proposal informative text "Firewall is enabled (disable)" with link around
        # IMPORTANT: Please, do not change the HTML link <a href="...">...</a>, only visible text
        _(
          "Firewall is enabled (<a href=\"firewall--disable_firewall_in_proposal\">disable</a>)"
        )
      else
        # TRANSLATORS: Proposal informative text "Firewall is disabled (enable)" with link around
        # IMPORTANT: Please, do not change the HTML link <a href="...">...</a>, only visible text
        _(
          "Firewall is disabled (<a href=\"firewall--enable_firewall_in_proposal\">enable</a>)"
        )
      end
    ),
    "</li>\n"
  )

  if firewall_is_enabled
    # Any enabled SSH means SSH-is-enabled
    is_ssh_enabled = false

    # Any known interfaces
    if Ops.greater_than(Builtins.size(@known_interfaces), 0)
      Builtins.y2milestone("Interfaces: %1", @known_interfaces)

      # all known interfaces for testing
      used_zones = SuSEFirewall.GetZonesOfInterfacesWithAnyFeatureSupported(
        @known_interfaces
      )
      Builtins.y2milestone("Zones used by firewall: %1", used_zones)

      Builtins.foreach(used_zones) do |zone|
        if SuSEFirewall.IsServiceSupportedInZone(@ssh_service, zone) ||
            SuSEFirewall.HaveService("ssh", "TCP", zone)
          is_ssh_enabled = true
        end
      end

      output = Ops.add(
        Ops.add(
          Ops.add(output, "<li>"),
          if is_ssh_enabled
            # TRANSLATORS: Network proposal informative text with link around
            # IMPORTANT: Please, do not change the HTML link <a href="...">...</a>, only visible text
            _(
              "SSH port is open (<a href=\"firewall--disable_ssh_in_proposal\">close</a>)"
            )
          else
            # TRANSLATORS: Network proposal informative text with link around
            # IMPORTANT: Please, do not change the HTML link <a href="...">...</a>, only visible text
            _(
              "SSH port is blocked (<a href=\"firewall--enable_ssh_in_proposal\">open</a>)"
            )
          end
        ),
        "</li>\n"
      )

      # No known interfaces, but 'any' is supported
      # and ssh is enabled there
    elsif SuSEFirewall.IsAnyNetworkInterfaceSupported &&
        SuSEFirewall.IsServiceSupportedInZone(
          @ssh_service,
          SuSEFirewall.special_all_interface_zone
        )
      is_ssh_enabled = true
      # TRANSLATORS: Network proposal informative text with link around
      # IMPORTANT: Please, do not change the HTML link <a href="...">...</a>, only visible text
      output = Ops.add(
        Ops.add(
          Ops.add(output, "<li>"),
          _(
            "SSH port is open (<a href=\"firewall--disable_ssh_in_proposal\">close</a>), but\nthere are no network interfaces configured"
          )
        ),
        "</li>"
      )
    end
    Builtins.y2milestone(
      "SSH is " + (is_ssh_enabled ? "" : "not ") + "enabled"
    )

    if Linuxrc.usessh && !is_ssh_enabled
      # TRANSLATORS: This is a warning message. Installation over SSH without SSH allowed on firewall
      AddWarning(
        _(
          "You are installing a system over SSH, but you have not opened the SSH port on the firewall."
        )
      )
    end

    # when the firewall is enabled and we are installing the system over VNC
    if Linuxrc.vnc
      # Any enabled VNC means VNC-is-enabled
      is_vnc_enabled = false
      if Ops.greater_than(Builtins.size(@known_interfaces), 0)
        Builtins.foreach(
          SuSEFirewall.GetZonesOfInterfacesWithAnyFeatureSupported(
            @known_interfaces
          )
        ) do |zone|
          if SuSEFirewall.IsServiceSupportedInZone(@vnc_service, zone) == true
            is_vnc_enabled = true
            # checking also fallback ports
          else
            set_vnc_enabled_to = true
            Builtins.foreach(@vnc_fallback_ports) do |one_port|
              if SuSEFirewall.HaveService(one_port, "TCP", zone) != true
                set_vnc_enabled_to = false
                raise Break
              end
              is_vnc_enabled = true if set_vnc_enabled_to == true
            end
          end
        end
      end
      Builtins.y2milestone(
        "VNC port is " + (is_vnc_enabled ? "open" : "blocked") + " in the firewall"
      )

      output = Ops.add(
        Ops.add(
          Ops.add(output, "<li>"),
          if is_vnc_enabled
            # TRANSLATORS: Network proposal informative text "Remote Administration (VNC) is enabled" with link around
            # IMPORTANT: Please, do not change the HTML link <a href="...">...</a>, only visible text
            _(
              "Remote Administration (VNC) ports are open (<a href=\"firewall--disable_vnc_in_proposal\">close</a>)"
            )
          else
            # TRANSLATORS: Network proposal informative text "Remote Administration (VNC) is disabled" with link around
            # IMPORTANT: Please, do not change the HTML link <a href="...">...</a>, only visible text
            _(
              "Remote Administration (VNC) ports are blocked (<a href=\"firewall--enable_vnc_in_proposal\">open</a>)"
            )
          end
        ),
        "</li>\n"
      )

      if !is_vnc_enabled
        # TRANSLATORS: This is a warning message. Installation over VNC without VNC allowed on firewall
        AddWarning(
          _(
            "You are installing a system using remote administration (VNC), but you have not opened the VNC ports on the firewall."
          )
        )
      end
    end

    if Linuxrc.useiscsi
      is_iscsi_enabled = IsServiceOrPortsOpen(
        @iscsi_target_service,
        @iscsi_target_fallback_ports
      )

      output = Ops.add(
        Ops.add(
          Ops.add(output, "<li>"),
          if is_iscsi_enabled
            # TRANSLATORS: Network proposal informative text
            _("iSCSI Target ports are open")
          else
            # TRANSLATORS: Network proposal informative text
            _("iSCSI Target ports are blocked")
          end
        ),
        "</li>\n"
      )

      if !is_iscsi_enabled
        # TRANSLATORS: This is a warning message. Installation to iSCSI without iSCSI allowed on firewall
        AddWarning(
          _(
            "You are installing a system using iSCSI Target, but you have not opened the needed ports on the firewall."
          )
        )
      end
    end

    warnings_strings = GetWarnings()
    if Ops.greater_than(Builtins.size(warnings_strings), 0)
      ClearWarnings()
      Builtins.foreach(warnings_strings) do |single_warning|
        warning = Ops.add(
          Ops.add(Ops.add(warning, "<li>"), single_warning),
          "</li>\n"
        )
      end
      warning = Ops.add(Ops.add("<ul>\n", warning), "</ul>\n")
    end
  end

  output = Ops.add(output, "</ul>\n")

  { "output" => output, "warning" => warning }
end

#Proposevoid

This method returns an undefined value.

Function proposes the SuSEfirewall2 configuration



500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 500

def Propose
  # No proposal when SuSEfirewall2 is not installed
  if !SuSEFirewall.SuSEFirewallIsInstalled
    SuSEFirewall.SetEnableService(false)
    SuSEFirewall.SetStartService(false)
    return nil
  end

  # Not changed by user - Propose from scratch
  if GetChangedByUser()
    Builtins.y2milestone("Calling firewall configuration update proposal")
    UpdateProposal()
  else
    Builtins.y2milestone("Calling firewall configuration proposal")
    Reset()
    ProposeFunctions()
    # Changed - don't break user's configuration
  end

  nil
end

#propose_iscsiObject

Proposes firewall settings for iSCSI



755
756
757
758
759
760
761
762
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 755

def propose_iscsi
  log.info "iSCSI has been used during installation, proposing FW full_init_on_boot"

  # bsc#916376: ports need to be open already during boot
  SuSEFirewall.full_init_on_boot(true)

  nil
end

#ProposeFunctionsObject

Local function for proposing firewall configuration.



356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 356

def ProposeFunctions
  known_interfaces = SuSEFirewall.GetAllKnownInterfaces

  dial_up_interfaces = []
  non_dup_interfaces = []
  Builtins.foreach(known_interfaces) do |interface|
    if Ops.get(interface, "type") == "dial_up"
      dial_up_interfaces = Builtins.add(
        dial_up_interfaces,
        Ops.get(interface, "id", "")
      )
    else
      non_dup_interfaces = Builtins.add(
        non_dup_interfaces,
        Ops.get(interface, "id", "")
      )
    end
  end

  Builtins.y2milestone(
    "Proposal based on configuration: Dial-up interfaces: %1, Other: %2",
    dial_up_interfaces,
    non_dup_interfaces
  )

  # has any network interface
  if Builtins.size(non_dup_interfaces) == 0 ||
      Builtins.size(dial_up_interfaces) == 0
    SuSEFirewall.SetEnableService(
      ProductFeatures.GetBooleanFeature("globals", "enable_firewall")
    )
    SuSEFirewall.SetStartService(
      ProductFeatures.GetBooleanFeature("globals", "enable_firewall")
    )
  end

  # has non-dial-up and also dial-up interfaces
  if Ops.greater_than(Builtins.size(non_dup_interfaces), 0) &&
      Ops.greater_than(Builtins.size(dial_up_interfaces), 0)
    SetInterfacesToZone(non_dup_interfaces, "INT")
    SetInterfacesToZone(dial_up_interfaces, "EXT")
    SuSEFirewall.SetServicesForZones([@ssh_service], ["INT", "EXT"], true) if ProductFeatures.GetBooleanFeature("globals", "firewall_enable_ssh")

    # has non-dial-up and doesn't have dial-up interfaces
  elsif Ops.greater_than(Builtins.size(non_dup_interfaces), 0) &&
      Builtins.size(dial_up_interfaces) == 0
    SetInterfacesToZone(non_dup_interfaces, "EXT")
    SuSEFirewall.SetServicesForZones([@ssh_service], ["EXT"], true) if ProductFeatures.GetBooleanFeature("globals", "firewall_enable_ssh")

    # doesn't have non-dial-up and has dial-up interfaces
  elsif Builtins.size(non_dup_interfaces) == 0 &&
      Ops.greater_than(Builtins.size(dial_up_interfaces), 0)
    SetInterfacesToZone(dial_up_interfaces, "EXT")
    SuSEFirewall.SetServicesForZones([@ssh_service], ["EXT"], true) if ProductFeatures.GetBooleanFeature("globals", "firewall_enable_ssh")
  end

  # Dial-up interfaces are considered to be internal,
  # Non-dial-up are considered to be external.
  # If there are only Non-dial-up interfaces, they are all considered as external.
  #
  # VNC Installation proposes to open VNC Access up on the Non-dial-up interfaces only.
  # SSH Installation is the same case...
  if Linuxrc.vnc
    Builtins.y2milestone(
      "This is an installation over VNC, opening VNC on all non-dial-up interfaces..."
    )
    # Try the service first, then ports
    # bnc #398855
    OpenServiceOnNonDialUpInterfaces(@vnc_service, @vnc_fallback_ports)
  end
  if Linuxrc.usessh
    Builtins.y2milestone(
      "This is an installation over SSH, opening SSH on all non-dial-up interfaces..."
    )
    # Try the service first, then ports
    # bnc #398855
    OpenServiceOnNonDialUpInterfaces(@ssh_service, ["ssh"])
  end

  # Firewall support for XEN domain0
  if IsXenInstalled()
    Builtins.y2milestone(
      "Adding Xen support into the firewall configuration"
    )
    SuSEFirewall.AddXenSupport
  end

  propose_iscsi if Linuxrc.useiscsi

  SetKnownInterfaces(SuSEFirewall.GetListOfKnownInterfaces)

  nil
end

#Resetvoid

This method returns an undefined value.

Function fills up default configuration into internal values



490
491
492
493
494
495
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 490

def Reset
  SuSEFirewall.ResetReadFlag
  SuSEFirewall.Read

  nil
end

#ServiceEnabled(service, zones) ⇒ Boolean

Returns whether service is enabled in zones.

Parameters:

Returns:

  • (Boolean)

    if enabled



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 198

def ServiceEnabled(service, zones)
  zones = deep_copy(zones)
  if service.nil? || service == ""
    Builtins.y2error("Ups, service: %1?", service)
    return false
  end

  if zones.nil? || zones == []
    Builtins.y2error("Ups, zones: %1?", zones)
    return false
  end

  serenabled = true

  serstat = SuSEFirewall.GetServices([service])
  Builtins.foreach(zones) do |one_zone|
    if Ops.get(serstat, [service, one_zone]) == false
      Builtins.y2milestone(
        "Service %1 is not enabled in %2",
        service,
        one_zone
      )
      serenabled = false
      raise Break
    end
  end

  serenabled
end

#SetChangedByUser(changed) ⇒ Object

Function sets that proposal was changed by user

Parameters:

  • changed (true, false)

    if changed by user



457
458
459
460
461
462
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 457

def SetChangedByUser(changed)
  Builtins.y2milestone("Proposal was changed by user")
  @proposal_changed_by_user = changed

  nil
end

#SetInterfacesToZone(interfaces, zone) ⇒ Object

Local function adds list of interfaces into zone.

Parameters:



134
135
136
137
138
139
140
141
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 134

def SetInterfacesToZone(interfaces, zone)
  interfaces = deep_copy(interfaces)
  Builtins.foreach(interfaces) do |interface|
    SuSEFirewall.AddInterfaceIntoZone(interface, zone)
  end

  nil
end

#SetKnownInterfaces(interfaces) ⇒ Object

Local function sets currently known interfaces.

Parameters:

  • interfaces (Array<String>)

    list of known interfaces



97
98
99
100
101
102
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 97

def SetKnownInterfaces(interfaces)
  interfaces = deep_copy(interfaces)
  @known_interfaces = deep_copy(interfaces)

  nil
end

#SetProposalInitialized(initialized) ⇒ Object

Function sets that proposal was initialized

Parameters:

  • initialized (true, false)

    if initialized



474
475
476
477
478
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 474

def SetProposalInitialized(initialized)
  @proposal_initialized = initialized

  nil
end

#UpdateProposalObject

Local function for updating user-changed proposal.



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'library/network/src/modules/SuSEFirewallProposal.rb', line 144

def UpdateProposal
  last_known_interfaces = GetKnownInterfaces()
  currently_known_interfaces = SuSEFirewall.GetListOfKnownInterfaces

  had_dialup_interfaces = false
  Builtins.foreach(last_known_interfaces) do |this_interface|
    if IsDialUpInterface(this_interface)
      had_dialup_interfaces = true
      raise Break
    end
  end

  Builtins.foreach(currently_known_interfaces) do |interface|
    # already known but not assigned
    next if Builtins.contains(last_known_interfaces, interface)
    # already configured in some zone
    next if !SuSEFirewall.GetZoneOfInterface(interface).nil?

    # any dial-up interfaces presented and the new one isn't dial-up
    if had_dialup_interfaces && !IsDialUpInterface(interface)
      AddWarning(
        Builtins.sformat(
          # TRANSLATORS: Warning in installation proposal, %1 is a device name (eth0, sl0, ...)
          _(
            "New network device '%1' found; added as an internal firewall interface"
          ),
          interface
        )
      )
      SetInterfacesToZone([interface], "INT")
    else
      AddWarning(
        Builtins.sformat(
          # TRANSLATORS: Warning in installation proposal, %1 is a device name (eth0, sl0, ...)
          _(
            "New network device '%1' found; added as an external firewall interface"
          ),
          interface
        )
      )
      SetInterfacesToZone([interface], "EXT")
    end
  end

  SetKnownInterfaces(currently_known_interfaces)

  nil
end