Class List Method List File List

# Module: Yast::SambaServerDialogsInclude

Defined in:
  ../../src/include/samba-server/dialogs.rb

## Instance Method Summary (collapse)

- - (Object) AddShareDialog
- - (Object) AddTrustedDomain
- - (Object) AdjustUserShareWidgets
- - (Object) AdvancedSettingsWidgetHandle(key, event)
- - (Object) AskJoinDomainDialog
- - (Object) BaseSettingsWidgetInit(key)
- - (Object) BaseSettingsWidgetStore(key, event_descr)
- - (Object) confirmAbort
- - (Object) EditShareDialog

  EditShareDialog dialog.

- - (Object) EnsureRootAccountDialog
- - (Object) getRole
- - (Object) GlobalConfigStringWidgetInit(key)
- - (Object) GlobalConfigStringWidgetStore(key, event_descr)
- - (Object) GlobalSettingsDialog
- - (Object) initialize_samba_server_dialogs(include_target)
- - (Object) InitUserShareWidgets
- - (Object) Installation_Conf_Tab
- - (Object) Installation_Step1
- - (Object) Installation_Step2
- - (Object) PassdbDialog

  Dialog to configure passdb backends.

- - (Object) RenameShare(share)

  Bugzilla #263302.

- - (Object) sharesItems(filt)
- - (Object) SharesWidgetHandle(key, event_descr)
- - (Object) SharesWidgetInit(key)
- - (Boolean) snapper_available?

  check if snapper support is available (initial check).

- - (Object) StoreUserShareWidgets(key, event_descr)
- - (Boolean) subvolume?(path)

  check if given path points to btrfs subvolume.

- - (Object) TrustedDomainsWidgetHandle(key, event_descr)
- - (Object) TrustedDomainsWidgetInit(key)
- - (Object) WinsHostResolutionWidgetInit(key)
- - (Object) WinsHostResolutionWidgetStore(key, event_descr)
- - (Object) WinsSettingsWidgetHandle(key, event_descr)
- - (Object) WinsSettingsWidgetInit(key)
- - (Object) WinsSettingsWidgetStore(key, event_descr)
- - (Object) WinsViaDHCPWidgetInit(key)
- - (Object) WinsViaDHCPWidgetStore(key, event_descr)

## Instance Method Details

### - (`Object`) AddShareDialog

    893
    894
    895
    896
    897
    898
    899
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    930
    931
    932
    933
    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    950
    951
    952
    953
    954
    955
    956
    957
    958
    959
    960
    961
    962
    963
    964
    965
    966
    967
    968
    969
    970
    971
    972
    973
    974
    975
    976
    977
    978
    979
    980
    981
    982
    983
    984
    985
    986
    987
    988
    989
    990
    991
    992
    993
    994
    995
    996
    997
    998
    999
    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    1026
    1027
    1028
    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    1040
    1041
    1042
    1043
    1044
    # File '../../src/include/samba-server/dialogs.rb', line 893

    def AddShareDialog
      default_path      = "/home"

      contents = HVSquash(HBox(
        HSpacing(1),
        VBox(Opt(:hstretch),
          VSpacing(1),
          # frame label
          Frame(_("Identification"), VBox(
            # text entry label
            InputField(Id(:name), Opt(:hstretch), _("Share &Name")),
            # text entry label
            InputField(Id(:comment), Opt(:hstretch), _("Share &Description"))
          )),
          VSpacing(1),
          # frame label
          Frame(_("Share Type"), HBox(
            HSpacing(1),
            VBox(Opt(:hstretch),
              RadioButtonGroup(VBox(
                # radio button label
                Left(RadioButton(Id(:printer), Opt(:notify), _("&Printer"))),
                # radio button label
                Left(RadioButton(Id(:directory), Opt(:notify), _("&Directory"), true))
              )),
              HBox(
                # translators: text entry label
                InputField(Id(:path), Opt(:notify), _("Share &Path"), default_path),
                VBox(
                  Label(""),
                  PushButton(Id(:browse), Label.BrowseButton)
                )
              ),
              # translators: checkbox label, setting for share
              Left(CheckBox(Id(:read_only), _("&Read-Only"), false)),
              # checkbox label
              Left(CheckBox(Id(:inherit_acls), _("&Inherit ACLs"), true)),
              # checkbox label
              Left(CheckBox(Id(:snapper_support), _("Expose Snapshots"), false))
            ),
            HSpacing(1)
          ))
        )
      ))

      Wizard.SetContentsButtons(
        # translators: dialog caption
        _("New Share"),
        contents,
        @HELPS["add_share"] || "",
        Label.BackButton,
        Label.OKButton
      )
      Wizard.HideAbortButton

      UI.SetFocus(Id(:name))
      UI.ChangeWidget(Id(:snapper_support), :Enabled, snapper_available? && subvolume?(default_path))

      ret = nil
      begin
        # enable/disable path
        on = UI.QueryWidget(Id(:directory), :Value)
        UI.ChangeWidget(Id(:path), :Enabled, on)
        UI.ChangeWidget(Id(:browse), :Enabled, on)
        UI.ChangeWidget(Id(:read_only), :Enabled, on)
        UI.ChangeWidget(Id(:inherit_acls), :Enabled, on)

        ret = UI.UserInput

        if ret == :cancel
          break if confirmAbort
          ret = nil
          next
        end

        if ret == :printer || ret == :directory
          ret = nil
          next
        end

        pathvalue = UI.QueryWidget(Id(:path), :Value)

        if ret == :path
          if snapper_available?
            UI.ChangeWidget(Id(:snapper_support), :Enabled, subvolume?(pathvalue))
          end
          ret = nil
        elsif ret == :browse
          # translators: file selection dialog title
          dir = UI.AskForExistingDirectory(pathvalue, _("Path for a Share"))
          if dir
            UI.ChangeWidget(Id(:path), :Value, dir)
            if snapper_available?
              subvolume = subvolume?(dir)
              UI.ChangeWidget(Id(:snapper_support), :Enabled, subvolume)
              UI.ChangeWidget(Id(:snapper_support), :Value, false) unless subvolume
            end
          end
          ret = nil
        elsif ret == :next
          # OK was pressed

          name          = UI.QueryWidget(Id(:name), :Value)
          comment       = UI.QueryWidget(Id(:comment), :Value)
          printable     = UI.QueryWidget(Id(:printer), :Value)

          if name.empty?
            # translators: error message
            Popup.Error(_("Share name cannot be empty."))
            ret = nil
            next
          elsif pathvalue.empty? && !printable
            # translators: error message
            Popup.Error(_("Share path cannot be empty."))
            ret = nil
            next
          elsif !printable && !SharePathWarning(pathvalue)
            ret = nil
            next
          elsif !printable && !Mode.config &&
              !FileUtils.CheckAndCreatePath(pathvalue)
            ret = nil
            next
          end

          res = { "comment" => comment }

          if printable
            res["printable"]    = "Yes"
            res["path"]         = "/var/tmp"
          else
            read_only           = UI.QueryWidget(Id(:read_only), :Value)
            inherit_acls        = UI.QueryWidget(Id(:inherit_acls), :Value)

            res["read only"]    = read_only ? "Yes" : "No"
            res["inherit acls"] = inherit_acls ? "Yes" : "No"
            res["path"]         = pathvalue
            if snapper_available? && UI.QueryWidget(Id(:snapper_support), :Value)
              res["vfs objects"]  = "snapper"
            end
          end

          if SambaConfig.ShareExists(name)
            # translators: popup error message for "add share", %1 is share name
            Popup.Error(Builtins.sformat(_("Share %1 already exists."), name))
            ret = nil
          end
          SambaConfig.ShareSetMap(name, res)
        end
      end while ret == nil
      ret
    end

### - (`Object`) AddTrustedDomain

    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    # File '../../src/include/samba-server/dialogs.rb', line 735

    def AddTrustedDomain
      #rwalter I couldn't make this one show up. Please make sure my deletions didn't make it too confusing.
      contents = VBox(
        InputField(Id(:domain), Opt(:hstretch), _("Trusted &Domain")),
        Password(Id(:password), _("&Password")),
        VSpacing(1),
        HBox(
          PushButton(Id(:ok), Opt(:default), Label.OKButton),
          PushButton(Id(:cancel), Label.CancelButton)
        )
      )

      UI.OpenDialog(contents)
      UI.SetFocus(Id(:domain))

      ret = nil
      begin
        ret = Convert.to_symbol(UI.UserInput)

        if ret == :ok
          domain = Convert.to_string(UI.QueryWidget(:domain, :Value))
          passwd = Convert.to_string(UI.QueryWidget(:password, :Value))

          if Builtins.size(domain) == 0
            Yast.import "Report"
            Report.Error(_("Domain name cannot be empty."))
            ret = nil
          end
          success = SambaTrustDom.Establish(domain, passwd)
          if success != true
            Yast.import "Report"
            Report.Error(_("Cannot establish trusted domain relationship."))
            ret = nil
          end
        end
      end while ret == nil

      UI.CloseDialog

      nil
    end

### - (`Object`) AdjustUserShareWidgets

    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    # File '../../src/include/samba-server/dialogs.rb', line 488

    def AdjustUserShareWidgets
      Builtins.foreach([:group, :max_shares, :guest_ch]) do |t|
        UI.ChangeWidget(
          Id(t),
          :Enabled,
          Convert.to_boolean(UI.QueryWidget(Id(:share_ch), :Value))
        )
      end

      nil
    end

### - (`Object`) AdvancedSettingsWidgetHandle(key, event)

    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    # File '../../src/include/samba-server/dialogs.rb', line 453

    def AdvancedSettingsWidgetHandle(key, event)
      event = deep_copy(event)
      if Ops.is_symbol?(Ops.get(event, "ID")) &&
          Builtins.contains(
            [:passdb, :global_settings],
            Ops.get_symbol(event, "ID", :cancel)
          )
        @return_tab = "identity"
        return Ops.get_symbol(event, "ID", :next)
      end
      nil
    end

### - (`Object`) AskJoinDomainDialog

    1638
    1639
    1640
    1641
    1642
    1643
    1644
    1645
    1646
    1647
    1648
    1649
    1650
    1651
    1652
    1653
    1654
    1655
    1656
    1657
    1658
    1659
    1660
    1661
    1662
    1663
    1664
    1665
    1666
    1667
    1668
    1669
    1670
    1671
    1672
    1673
    1674
    1675
    1676
    1677
    1678
    1679
    1680
    1681
    1682
    1683
    1684
    1685
    1686
    1687
    1688
    1689
    1690
    1691
    1692
    1693
    1694
    1695
    1696
    1697
    1698
    1699
    1700
    1701
    1702
    1703
    1704
    1705
    1706
    1707
    1708
    1709
    1710
    1711
    1712
    1713
    1714
    1715
    1716
    1717
    1718
    1719
    1720
    1721
    1722
    1723
    1724
    1725
    1726
    # File '../../src/include/samba-server/dialogs.rb', line 1638

    def AskJoinDomainDialog
      workgroup = SambaConfig.GlobalGetStr("workgroup", "")
      role = SambaRole.GetRole

      # for autoyast, skip testing
      if Mode.config || role != "MEMBER" && role != "BDC"
        #      (!SambaNmbLookup::IsDomain(workgroup)))
        return :ok
      end

      SambaAD.ReadADS(workgroup)
      SambaAD.ReadRealm
      res = SambaNetJoin.Test(workgroup)
      return :ok if res == true

      # Xtranslators: popup question, The workgroup is a domain in fact and the machine is not a member, ask user what to do.
      # %1 is the domain name
      #    if (!Popup::YesNo(sformat(_("This host is not a member\nof the domain %1.") + "\n\n"
      #        + _("Join the domain %1?") + "\n", workgroup)))
      #    {
      #	return `ok;
      #    }

      user = "Administrator"
      passwd = ""
      UI.OpenDialog(
        VBox(
          # translators: popup to fill in the domain joining info; %1 is the domain name
          Label(
            Ops.add(
              Ops.add(
                Ops.add(
                  Builtins.sformat(
                    _(
                      "Enter the username and the password\nfor joining the domain %1."
                    ),
                    workgroup
                  ),
                  "\n\n"
                ),
                _(
                  "To join the domain anonymously, leave the\ntext entries empty."
                )
              ),
              "\n"
            )
          ),
          # text entry label
          TextEntry(Id(:user), _("&Username"), user),
          # text entry label
          Password(Id(:passwd), _("&Password")),
          HBox(
            # translators: button label to skip joining to domain
            PushButton(Id(:skip), _("Do &Not Join")),
            PushButton(Id(:cancel), Label.CancelButton),
            PushButton(Id(:ok), Opt(:default), Label.OKButton)
          )
        )
      )

      ret = UI.UserInput

      user = Convert.to_string(UI.QueryWidget(Id(:user), :Value))
      passwd = Convert.to_string(UI.QueryWidget(Id(:passwd), :Value))

      UI.CloseDialog

      return :skip if ret == :skip
      return :cancel if ret != :ok

      # try to join the domain
      error = SambaNetJoin.Join(
        workgroup,
        Builtins.tolower(role),
        user,
        passwd,
        ""
      )
      if error != nil
        Popup.Error(error)
        return :error
      end

      # Translators: Information popup, %1 is the name of the domain
      Popup.Message(
        Builtins.sformat(_("Domain %1 joined successfully."), workgroup)
      )
      :ok
    end

### - (`Object`) BaseSettingsWidgetInit(key)

    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    # File '../../src/include/samba-server/dialogs.rb', line 301

    def BaseSettingsWidgetInit(key)
      UI.ChangeWidget(
        Id("workgroup_domainname"),
        :Value,
        SambaConfig.GlobalGetStr("workgroup", "")
      )

      # initial for this dialog
      # see also BNC #553349
      @initial_role = getRole
      UI.ChangeWidget(Id("domain_controller"), :Value, @initial_role)
      Builtins.y2milestone("Initial role: %1", @initial_role)

      nil
    end

### - (`Object`) BaseSettingsWidgetStore(key, event_descr)

    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    # File '../../src/include/samba-server/dialogs.rb', line 350

    def BaseSettingsWidgetStore(key, event_descr)
      event_descr = deep_copy(event_descr)
      sel = Convert.to_string(
        UI.QueryWidget(Id("workgroup_domainname"), :Value)
      )
      Builtins.y2milestone("Setting workgroup '%1'", sel)
      SambaConfig.GlobalSetStr("workgroup", sel)

      role = Convert.to_string(UI.QueryWidget(Id("domain_controller"), :Value))
      role = "MEMBER" if role == "STANDALONE" && SambaNmbLookup.IsDomain(sel)

      # Do not set the role if it is unchanged. It would rewrite some expert settings
      # that might have been set manually (Expert Settings), bugzilla #255824
      if Builtins.toupper(role) != Builtins.toupper(@initial_role)
        Builtins.y2milestone(
          "Setting role '%1' (was '%2')",
          role,
          SambaRole.GetRole
        )
        SambaRole.SetRole(role)
      else
        Builtins.y2milestone("Role type not changed (%1)", role)
      end

      nil
    end

### - (`Object`) confirmAbort

    143
    144
    145
    146
    147
    148
    # File '../../src/include/samba-server/dialogs.rb', line 143

    def confirmAbort
      Builtins.y2warning("confirm abort")
      return true if !SambaServer.GetModified

      Popup.ReallyAbort(true)
    end

### - (`Object`) EditShareDialog

EditShareDialog dialog

Returns:

- dialog result

    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    # File '../../src/include/samba-server/dialogs.rb', line 841

    def EditShareDialog
      contents = HBox(HSpacing(1), VBox(VSpacing(1), "share_edit"), HSpacing(1))

      # dialog caption
      caption = Builtins.sformat(_("Share %1"), @shareToEdit)

      CWM.ShowAndRun(
        {
          "widget_names"       => ["share_edit"],
          "widget_descr"       => @xx_widgets,
          "contents"           => contents,
          "caption"            => caption,
          "back_button"        => Label.BackButton,
          "next_button"        => Label.OKButton,
          "abort_button"        => nil
        }
      )
    end

### - (`Object`) EnsureRootAccountDialog

    1572
    1573
    1574
    1575
    1576
    1577
    1578
    1579
    1580
    1581
    1582
    1583
    1584
    1585
    1586
    1587
    1588
    1589
    1590
    1591
    1592
    1593
    1594
    1595
    1596
    1597
    1598
    1599
    1600
    1601
    1602
    1603
    1604
    1605
    1606
    1607
    1608
    1609
    1610
    1611
    1612
    1613
    1614
    1615
    1616
    1617
    1618
    1619
    1620
    1621
    1622
    1623
    1624
    1625
    1626
    1627
    1628
    1629
    1630
    1631
    1632
    1633
    1634
    1635
    # File '../../src/include/samba-server/dialogs.rb', line 1572

    def EnsureRootAccountDialog
      if SambaRole.GetRole != "PDC" || Mode.autoinst || Mode.test ||
          SambaAccounts.UserExists("root")
        return :ok
      end

      # try to create it

      # first, ask for password
      UI.OpenDialog(
        HVSquash(
          VBox(
            Label(
              _(
                "For a proper function, Samba server needs an\n" +
                  "administrative account (root).\n" +
                  "It will be created now."
              )
            ),
            Password(Id(:passwd1), _("Samba root &Password")),
            Password(Id(:passwd2), _("&Verify Password")),
            HBox(
              PushButton(Id(:ok), Opt(:default), Label.OKButton),
              PushButton(Id(:cancel), Label.CancelButton)
            )
          )
        )
      )
      UI.SetFocus(Id(:passwd1))

      ret = nil
      passwd = nil
      begin
        ret = UI.UserInput
        if ret == :ok
          passwd1 = Convert.to_string(UI.QueryWidget(Id(:passwd1), :Value))
          passwd2 = Convert.to_string(UI.QueryWidget(Id(:passwd2), :Value))
          if passwd1 != passwd2
            # TRANSLATORS: popup error message
            Popup.Error(
              _(
                "The first and the second version\nof the password do not match."
              )
            )
            ret = nil
          else
            passwd = passwd1
          end
        end
      end while ret == nil

      UI.CloseDialog
      return :cancel if ret == :cancel

      if SambaAccounts.UserAdd("root", passwd)
        # TRANSLATORS: popup error message, %1 is a username
        Popup.Error(
          Builtins.sformat(_("Cannot create account for user %1."), "root")
        )
        return :error
      end

      :ok
    end

### - (`Object`) getRole

    295
    296
    297
    298
    299
    # File '../../src/include/samba-server/dialogs.rb', line 295

    def getRole
      role = SambaRole.GetRole
      return "STANDALONE" if role == "MEMBER"
      role
    end

### - (`Object`) GlobalConfigStringWidgetInit(key)

    344
    345
    346
    347
    348
    # File '../../src/include/samba-server/dialogs.rb', line 344

    def GlobalConfigStringWidgetInit(key)
      UI.ChangeWidget(Id(key), :Value, SambaConfig.GlobalGetStr(key, ""))

      nil
    end

### - (`Object`) GlobalConfigStringWidgetStore(key, event_descr)

    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    # File '../../src/include/samba-server/dialogs.rb', line 426

    def GlobalConfigStringWidgetStore(key, event_descr)
      event_descr = deep_copy(event_descr)
      value = Convert.to_string(UI.QueryWidget(Id(key), :Value))

      changed = SambaConfig.GlobalSetStr(key, value == "" ? nil : value)

      # warn about the netbios name change
      if key == "netbios name" && changed && !Mode.config
        Popup.Warning(Ops.get(@warnings, "netbios", ""))
      end

      nil
    end

### - (`Object`) GlobalSettingsDialog

    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    # File '../../src/include/samba-server/dialogs.rb', line 861

    def GlobalSettingsDialog
      contents = HBox(
        HSpacing(1),
        VBox(VSpacing(1), "globalsettings"),
        HSpacing(1)
      )

      # dialog caption
      caption = _("Expert Global Settings Configuration")

      res = CWM.ShowAndRun(
        {
          "widget_names"       => ["globalsettings"],
          "widget_descr"       => @xx_widgets,
          "contents"           => contents,
          "caption"            => caption,
          "back_button"        => Label.BackButton,
          "next_button"        => Label.OKButton,
          "fallback_functions" => {
            :abort => fun_ref(method(:confirmAbort), "boolean ()")
          }
        }
      )

      #    if (res == `next) {
      # update the rest of the settings using the entered ones
      #	SambaServer::role = SambaServer::DetermineRole();
      #    }

      res
    end

### - (`Object`) initialize_samba_server_dialogs(include_target)

    31
    32
    33
    34
    35
    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
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    # File '../../src/include/samba-server/dialogs.rb', line 31

    def initialize_samba_server_dialogs(include_target)
      Yast.import "UI"

      textdomain "samba-server"

      Yast.import "String"
      Yast.import "Label"
      Yast.import "Wizard"
      Yast.import "Mode"
      Yast.import "Popup"
      Yast.import "ProductFeatures"
      Yast.import "FileUtils"

      Yast.import "SambaRole"
      Yast.import "SambaServer"
      Yast.import "SambaConfig"
      Yast.import "SambaService"
      Yast.import "SambaNetJoin"
      Yast.import "SambaTrustDom"
      Yast.import "SambaAccounts"
      Yast.import "SambaNmbLookup"
      Yast.import "Samba"
      Yast.import "SambaAD"

      Yast.import "CWM"
      Yast.import "CWMTab"
      Yast.import "CWMServiceStart"
      Yast.import "CWMFirewallInterfaces"

      Yast.include include_target, "samba-server/helps.rb"
      Yast.include include_target, "samba-server/dialogs-items.rb"
      Yast.include include_target, "samba-server/ldap-widget.rb"
      Yast.include include_target, "samba-client/routines.rb"
      Yast.include include_target, "samba-server/complex.rb"

      @return_tab = "startup"

      @pdc = _("&Primary Domain Controller (PDC)")
      @bdc = _("B&ackup Domain Controller (BDC)")
      @standalone = _("Not a Domain &Controller")

      #************************ initial wizard end *************************

      @initial_role = nil

      # User shares feature, bugzilla #143908
      @allow_share = true
      @max_shares = 0
      @shares_group = ""
      # Guest Access check-box, BNC #579993
      @guest_access = false

      @autoyast_warning_done = false

      @snapper_available        = nil
    end

### - (`Object`) InitUserShareWidgets

    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    # File '../../src/include/samba-server/dialogs.rb', line 466

    def InitUserShareWidgets
      @max_shares = Samba.GetMaxShares

      if @max_shares == 0
        @max_shares = 100
        @allow_share = false
      else
        @allow_share = true
      end

      @guest_access = @allow_share && Samba.GetGuessAccess

      @shares_group = Samba.shares_group

      UI.ChangeWidget(Id(:group), :Value, @shares_group)
      UI.ChangeWidget(Id(:max_shares), :Value, @max_shares)
      UI.ChangeWidget(Id(:share_ch), :Value, @allow_share)
      UI.ChangeWidget(Id(:guest_ch), :Value, @guest_access)

      nil
    end

### - (`Object`) Installation_Conf_Tab

    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    1061
    1062
    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    1080
    1081
    1082
    1083
    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    1097
    1098
    1099
    1100
    1101
    1102
    1103
    1104
    1105
    1106
    1107
    1108
    1109
    1110
    1111
    1112
    1113
    1114
    1115
    1116
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    1124
    1125
    1126
    1127
    1128
    1129
    1130
    1131
    1132
    1133
    1134
    1135
    1136
    1137
    1138
    1139
    1140
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    1150
    1151
    1152
    1153
    1154
    1155
    1156
    1157
    1158
    1159
    1160
    1161
    1162
    1163
    1164
    1165
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    1176
    1177
    1178
    1179
    1180
    1181
    1182
    1183
    1184
    1185
    1186
    1187
    1188
    1189
    1190
    1191
    1192
    1193
    1194
    1195
    1196
    1197
    1198
    1199
    1200
    1201
    1202
    1203
    1204
    1205
    1206
    1207
    1208
    1209
    1210
    1211
    1212
    1213
    1214
    1215
    1216
    1217
    1218
    1219
    1220
    1221
    1222
    1223
    1224
    1225
    1226
    1227
    1228
    1229
    1230
    1231
    1232
    1233
    1234
    1235
    1236
    1237
    1238
    1239
    1240
    1241
    1242
    1243
    1244
    1245
    1246
    1247
    1248
    1249
    1250
    1251
    1252
    1253
    1254
    1255
    1256
    1257
    1258
    1259
    1260
    1261
    1262
    1263
    1264
    1265
    1266
    1267
    1268
    1269
    1270
    1271
    1272
    1273
    1274
    1275
    1276
    1277
    1278
    1279
    1280
    1281
    1282
    1283
    1284
    1285
    1286
    1287
    1288
    1289
    1290
    1291
    1292
    1293
    1294
    1295
    1296
    1297
    1298
    1299
    1300
    1301
    1302
    1303
    1304
    1305
    1306
    1307
    1308
    1309
    1310
    1311
    1312
    1313
    1314
    1315
    1316
    1317
    1318
    1319
    1320
    1321
    1322
    1323
    1324
    1325
    1326
    1327
    1328
    1329
    1330
    1331
    1332
    1333
    1334
    1335
    1336
    1337
    1338
    1339
    1340
    1341
    1342
    1343
    1344
    1345
    1346
    1347
    1348
    1349
    1350
    1351
    1352
    1353
    1354
    1355
    1356
    1357
    1358
    1359
    1360
    1361
    1362
    1363
    1364
    1365
    1366
    1367
    1368
    1369
    1370
    1371
    1372
    1373
    1374
    1375
    1376
    1377
    1378
    1379
    1380
    1381
    1382
    1383
    1384
    1385
    1386
    1387
    1388
    1389
    1390
    1391
    1392
    1393
    1394
    1395
    1396
    1397
    1398
    1399
    1400
    1401
    1402
    1403
    1404
    1405
    1406
    1407
    1408
    1409
    1410
    1411
    1412
    1413
    1414
    1415
    1416
    1417
    1418
    1419
    1420
    1421
    1422
    1423
    1424
    1425
    1426
    1427
    1428
    1429
    1430
    1431
    1432
    1433
    1434
    1435
    1436
    1437
    1438
    1439
    1440
    1441
    1442
    1443
    1444
    1445
    1446
    1447
    1448
    1449
    1450
    1451
    1452
    1453
    1454
    1455
    1456
    1457
    1458
    1459
    1460
    1461
    1462
    1463
    1464
    1465
    1466
    1467
    1468
    1469
    1470
    1471
    1472
    1473
    1474
    1475
    1476
    1477
    1478
    1479
    1480
    1481
    1482
    1483
    1484
    1485
    1486
    1487
    1488
    1489
    1490
    1491
    1492
    1493
    1494
    1495
    1496
    1497
    1498
    1499
    1500
    1501
    1502
    1503
    1504
    1505
    1506
    1507
    1508
    1509
    1510
    1511
    1512
    1513
    1514
    1515
    1516
    1517
    1518
    1519
    1520
    1521
    1522
    1523
    1524
    # File '../../src/include/samba-server/dialogs.rb', line 1048

    def Installation_Conf_Tab
      shares_widget = HBox(
        HWeight(1, Empty()),
        HWeight(
          100,
          VBox(
            HBox(
              Left(Label(_("Available Shares"))),
              HStretch(),
              Right(
                MenuButton(
                  _("&Filter"),
                  [
                    Item(Id(:filter_all), _("Show &All Shares")),
                    Item(
                      Id(:filter_non_system),
                      _("Do Not Show &System Shares")
                    )
                  ]
                )
              )
            ),
            # translators: table header texts
            Table(
              Id(:table),
              Opt(:hvstretch,:notify),
              Header(
                _("Status"),
                _("Read-Only"),
                _("Name"),
                _("Path"),
                _("Guest Access"),
                _("Comment")
              ),
              []
            ),
            HBox(
              PushButton(Id(:add), Ops.add(Label.AddButton, "...")),
              PushButton(Id(:edit), Ops.add(Label.EditButton, "...")),
              PushButton(Id(:delete), Label.DeleteButton),
              HStretch(),
              PushButton(Id(:rename), _("&Rename...")),
              PushButton(Id(:guest), _("Guest Access")),
              PushButton(Id(:toggle), _("&Toggle Status"))
            )
          )
        ),
        HWeight(1, Empty())
      )

      wins_widget = HBox(
        HSpacing(1),
        VBox(
          VSpacing(0.5),
          RadioButtonGroup(
            Id("wins_support"),
            VBox(
              Left(
                RadioButton(
                  Id("wins_server_support"),
                  Opt(:notify),
                  _("WINS Server Support")
                )
              ),
              Left(
                RadioButton(
                  Id("remote_wins_server"),
                  Opt(:notify),
                  _("Remote WINS Server")
                )
              )
            )
          ),
          HBox(HSpacing(3), TextEntry(Id("wins_server_name"), _("Na&me"))),
          VSpacing(1)
        ),
        HSpacing(1)
      )

      wins_via_dhcp = DHCPSupportTerm(Samba.GetDHCP)

      # TRANSLATORS: check box
      wins_host_resolution = Left(
        CheckBox(Id(:wins_dns), _("Use WINS for Hostname Resolution"))
      )

      roles = [
        # translators: combobox item
        Item(Id("STANDALONE"), _("Not a DC")),
        # translators: combobox item
        Item(Id("PDC"), _("Primary (PDC)"))
      ]

      # translators: combobox item
      roles = Builtins.add(roles, Item(Id("BDC"), _("Backup (BDC)")))

      basesettings_widget = Frame(
        _("Base Settings"),
        HBox(
          HSpacing(1),
          VBox(
            # `ComboBox(`id("workgroup_domainname"), `opt(`editable, `hstretch), _("&Workgroup or Domain Name"),
            #	SambaNmbLookup::GetAvailableNeighbours(nil)),
            InputField(
              Id("workgroup_domainname"),
              Opt(:hstretch),
              _("&Workgroup or Domain Name")
            ),
            # translators: combobox label
            ComboBox(
              Id("domain_controller"),
              Opt(:hstretch),
              _("Domain &Controller"),
              roles
            ),
            VStretch()
          ),
          HSpacing(1)
        )
      )

      advanced_settings_widget = MenuButton(
        _("Advanced Settings..."),
        [
          Item(Id(:global_settings), _("&Expert Global Settings")),
          Item(Id(:passdb), _("&User Authentication Sources"))
        ]
      )

      trusted_domains_widget = HBox(
        HWeight(1, Empty()),
        HWeight(
          100,
          VBox(
            VWeight(
              7,
              ReplacePoint(
                Id(:domains_tr),
                SelectionBox(Id("trusted_domains"), _("&Trusted Domains"), [])
              )
            ),
            VWeight(
              1,
              HBox(
                PushButton(Id(:add_domain), Ops.add(Label.AddButton, "...")),
                PushButton(Id(:delete_domain), Label.DeleteButton),
                HStretch()
              )
            ),
            VStretch()
          )
        ),
        HWeight(1, Empty())
      )

      caption = _("Samba Configuration")

      tabs_descr = {
        "startup"  => {
          #tab label
          "header"       => _("Start-&Up"),
          "contents"     => HBox(
            HWeight(2, Empty()),
            HWeight(
              100,
              VBox(
                VSpacing(1),
                "SERVICE START",
                VSpacing(1),
                Frame(_("Firewall Settings"), "FIREWALL"),
                VStretch()
              )
            ),
            HWeight(2, Empty())
          ),
          "widget_names" => ["SERVICE START", "FIREWALL"]
        },
        "shares"   => {
          "header"       => _("&Shares"),
          "contents"     => VBox(
            VBox("SHARES"),
            HBox(
              HSpacing(1),
              # Bugzilla #143908
              # Bugzilla #144787, comment #43
              SharesTerm(
                {
                  "allow_share"  => @allow_share,
                  "group"        => @shares_group,
                  "max_shares"   => @max_shares,
                  # BNC #579993, Allow guest access
                  "guest_access" => @guest_access
                }
              ),
              HSpacing(1)
            ),
            VSpacing(1)
          ),
          "widget_names" => ["SHARES"]
        },
        "identity" => {
          "header"       => _("I&dentity"),
          "contents"     => HBox(
            "IDENTITY COMMON HELP",
            HWeight(1, Empty()),
            HWeight(
              100,
              VBox(
                VSpacing(0.5),
                VBox(
                  HBox(
                    HWeight(1, VBox("BASE SETTINGS")),
                    HSpacing(0.5),
                    HWeight(
                      1,
                      Frame(
                        _("WINS"),
                        VBox(
                          "WINS SETTINGS",
                          HBox(HSpacing(1), "WINS via DHCP"),
                          HBox(HSpacing(1), "WINS Host Resolution"),
                          VStretch()
                        )
                      )
                    )
                  ),
                  VSpacing(0.5),
                  HBox(
                    HWeight(1, VBox("netbios name", "ADVANCED SETTINGS")),
                    HSpacing(0.5),
                    HWeight(1, Empty())
                  )
                ),
                VStretch()
              )
            ),
            HWeight(1, Empty())
          ),
          "widget_names" => [
            "IDENTITY COMMON HELP",
            "BASE SETTINGS",
            "WINS SETTINGS",
            "WINS via DHCP",
            "WINS Host Resolution",
            "netbios name",
            "ADVANCED SETTINGS"
          ]
        }
      }

      tabs_descr = Builtins.union(
        tabs_descr,
        {
          "trusted_domains_tab" => {
            "header"       => _("&Trusted Domains"),
            "contents"     => VBox("TRUSTED DOMAINS"),
            "widget_names" => ["TRUSTED DOMAINS"]
          },
          "ldap_settings_tab"   => {
            "header"       => _("&LDAP Settings"),
            "contents"     => VBox("LDAP ESSENTIAL"),
            "widget_names" => ["LDAP ESSENTIAL"]
          }
        }
      )

      tabs_widget_descr = {
        "SERVICE START"        => CWMServiceStart.CreateAutoStartWidget(
          {
            "get_service_auto_start" => fun_ref(
              SambaService.method(:GetServiceAutoStart),
              "boolean ()"
            ),
            "set_service_auto_start" => fun_ref(
              SambaService.method(:SetServiceAutoStart),
              "void (boolean)"
            )
          }
        ),
        # BNC #247344, BNC #541958 (comment #18)
        "FIREWALL"             => CWMFirewallInterfaces.CreateOpenFirewallWidget(
          {
            "services"        => [
              "service:samba-server",
              "service:netbios-server",
              "service:samba-client"
            ],
            "display_details" => true
          }
        ),
        "SHARES"               => {
          "widget"        => :custom,
          "custom_widget" => shares_widget,
          "init"          => fun_ref(method(:SharesWidgetInit), "void (string)"),
          "handle"        => fun_ref(
            method(:SharesWidgetHandle),
            "symbol (string, map)"
          ),
          "store"         => fun_ref(
            method(:StoreUserShareWidgets),
            "void (string, map)"
          ),
          "help"          => Ops.add(
            Ops.get_string(@HELPS, "smb_conf_tab_shares", ""),
            SharesHelp()
          )
        },
        "IDENTITY COMMON HELP" => {
          "widget"        => :custom,
          "custom_widget" => Empty(),
          "help"          => Ops.get_string(@HELPS, "smb_conf_tab_identity", "")
        },
        "BASE SETTINGS"        => {
          "widget"        => :custom,
          "custom_widget" => basesettings_widget,
          "help"          => Ops.get_string(
            @HELPS,
            "smb_conf_tab_base_settings",
            ""
          ),
          "init"          => fun_ref(
            method(:BaseSettingsWidgetInit),
            "void (string)"
          ),
          "store"         => fun_ref(
            method(:BaseSettingsWidgetStore),
            "void (string, map)"
          )
        },
        "WINS SETTINGS"        => {
          "widget"        => :custom,
          "custom_widget" => wins_widget,
          "help"          => HostsResolutionHelp(),
          "init"          => fun_ref(
            method(:WinsSettingsWidgetInit),
            "void (string)"
          ),
          "store"         => fun_ref(
            method(:WinsSettingsWidgetStore),
            "void (string, map)"
          ),
          "handle"        => fun_ref(
            method(:WinsSettingsWidgetHandle),
            "symbol (string, map)"
          )
        },
        "WINS via DHCP"        => {
          "widget"        => :custom,
          "custom_widget" => wins_via_dhcp,
          "help"          => Ops.get_string(
            @HELPS,
            "smb_conf_tab_wins_via_dhcp",
            ""
          ),
          "init"          => fun_ref(
            method(:WinsViaDHCPWidgetInit),
            "void (string)"
          ),
          "store"         => fun_ref(
            method(:WinsViaDHCPWidgetStore),
            "void (string, map)"
          )
        },
        "WINS Host Resolution" => {
          "widget"        => :custom,
          "custom_widget" => wins_host_resolution,
          "help"          => Ops.get_string(
            @HELPS,
            "smb_conf_tab_wins_host_resolution",
            ""
          ),
          "init"          => fun_ref(
            method(:WinsHostResolutionWidgetInit),
            "void (string)"
          ),
          "store"         => fun_ref(
            method(:WinsHostResolutionWidgetStore),
            "void (string, map)"
          )
        },
        "netbios name"         => {
          "widget" => :textentry,
          "label"  => _("NetBIOS &Hostname"),
          "help"   => Ops.get_string(@HELPS, "smb_conf_tab_netbios_name", ""),
          "init"   => fun_ref(
            method(:GlobalConfigStringWidgetInit),
            "void (string)"
          ),
          "store"  => fun_ref(
            method(:GlobalConfigStringWidgetStore),
            "void (string, map)"
          )
        },
        "ADVANCED SETTINGS"    => {
          "widget"        => :custom,
          "custom_widget" => advanced_settings_widget,
          "help"          => Ops.get_string(
            @HELPS,
            "smb_conf_tab_advanced_settings",
            ""
          ),
          "handle"        => fun_ref(
            method(:AdvancedSettingsWidgetHandle),
            "symbol (string, map)"
          )
        },
        "TRUSTED DOMAINS"      => {
          "widget"        => :custom,
          "custom_widget" => trusted_domains_widget,
          "init"          => fun_ref(
            method(:TrustedDomainsWidgetInit),
            "void (string)"
          ),
          "handle"        => fun_ref(
            method(:TrustedDomainsWidgetHandle),
            "symbol (string, map)"
          ),
          "help"          => Ops.get_string(
            @HELPS,
            "smb_conf_tab_trusted_domains",
            ""
          )
        },
        "LDAP ESSENTIAL"       => CreateSambaLDAPSettingsEssentialWidget()
      }

      widget_descr = {
        "tab" => CWMTab.CreateWidget(
          {
            "tab_order"    => [
              "startup",
              "shares",
              "identity",
              "trusted_domains_tab",
              "ldap_settings_tab"
            ],
            "tabs"         => tabs_descr,
            "widget_descr" => tabs_widget_descr,
            "initial_tab"  => @return_tab,
            "tab_help"     => ""
          }
        )
      }

      contents = VBox("tab", VStretch())

      w = CWM.CreateWidgets(
        ["tab"],
        Convert.convert(
          widget_descr,
          :from => "map",
          :to   => "map <string, map <string, any>>"
        )
      )
      help = CWM.MergeHelps(w)
      contents = CWM.PrepareDialog(contents, w)

      Wizard.SetContentsButtons(
        caption,
        contents,
        help,
        Label.BackButton,
        Label.OKButton
      )

      # BNC #440538
      # Adjusted according to the YaST Style Guide
      Wizard.SetAbortButton(:abort, Label.CancelButton)
      Wizard.HideBackButton

      ret = CWM.Run(
        w,
        { :abort => fun_ref(method(:confirmAbort), "boolean ()") }
      )

      deep_copy(ret)
    end

### - (`Object`) Installation_Step1

    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
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    # File '../../src/include/samba-server/dialogs.rb', line 151

    def Installation_Step1
      caption = _("Samba Installation") + ": " + _("Step 1 of 2")

      # feature dropped
      # list <string> workgroups = SambaNmbLookup::GetAvailableNeighbours(nil);

      # always add the currently configured workgroup
      workgroup = SambaConfig.GlobalGetStr("workgroup", "")
      #    if (size(workgroup) > 0 && !contains(workgroups, workgroup)) {
      #	workgroups = add(workgroups, workgroup);
      #    }

      contents = VBox(
        VSquash(
          Left(
            # `ComboBox ( `id( "workgroups" ), `opt( `editable ), _("&Workgroup or Domain Name"), workgroups )

            # TRANSLATORS: text entry
            InputField(
              Id("workgroups"),
              Opt(:hstretch),
              _("&Workgroup or Domain Name"),
              workgroup
            )
          )
        ),
        VStretch()
      )

      Wizard.SetContents(
        caption,
        contents,
        Ops.get_string(@HELPS, "inst_step1", ""),
        false,
        true
      )

      Wizard.DisableBackButton

      if Ops.greater_than(Builtins.size(workgroup), 0)
        UI.ChangeWidget(Id("workgroups"), :Value, workgroup)
      end

      ret = nil
      while true
        ret = UI.UserInput
        if ret == :next || ret == :cancel || ret == :abort
          break
        else
          Builtins.y2error("unexpected retcode: %1", ret)
          next
        end
      end

      if ret == :next
        sel = Convert.to_string(UI.QueryWidget(Id("workgroups"), :Value))
        Builtins.y2milestone("Setting workgroup '%1'", sel)
        SambaConfig.GlobalSetStr("workgroup", sel)
      end

      Wizard.RestoreBackButton

      deep_copy(ret)
    end

### - (`Object`) Installation_Step2

    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    # File '../../src/include/samba-server/dialogs.rb', line 216

    def Installation_Step2
      caption = _("Samba Installation") + ": " + _("Step 2 of 2")

      workgroup = SambaConfig.GlobalGetStr("workgroup", "")
      has_pdc = SambaNmbLookup.HasPDC(workgroup)
      has_bdc = SambaNmbLookup.HasBDC(workgroup)

      contents = VBox(
        #header of status-like information. followed by domain name
        VSquash(
          Left(Label(Ops.add(_("Current Domain Name:") + " ", workgroup)))
        ),
        VSpacing(1),
        VSquash(
          Frame(
            _("Samba Server Type"),
            VBox(
              RadioButtonGroup(
                Id("samba_server_type"),
                VBox(
                  VSpacing(1),
                  Left(RadioButton(Id("PDC"), @pdc, !has_pdc)),
                  HBox(
                    HSpacing(4),
                    # appears on new line after Primary Domain Controller radio button
                    Left(
                      Label(
                        has_pdc ?
                          _("Not available because a PDC is present.") :
                          ""
                      )
                    )
                  ),
                  VBox(
                    Left(RadioButton(Id("BDC"), @bdc, false)),
                    HBox(HSpacing(4), Left(Label("")))
                  ),
                  Left(RadioButton(Id("Standalone"), @standalone, has_pdc)),
                  VSpacing(1)
                )
              )
            )
          )
        ),
        VStretch()
      )

      help = Ops.get_string(@HELPS, "inst_step2", "")

      Wizard.SetContents(caption, contents, help, true, true)

      UI.ChangeWidget(Id("PDC"), :Enabled, !has_pdc)

      ret = nil
      while true
        ret = UI.UserInput
        if ret == :abort || ret == :cancel
          break if confirmAbort
          next
        end
        if ret == :back || ret == :next || ret == :abort || ret == :cancel
          if ret == :next
            # store the value
            SambaRole.SetRole(
              Convert.to_string(
                UI.QueryWidget(Id("samba_server_type"), :CurrentButton)
              )
            )
          end
          break
        else
          Builtins.y2error("unexpected retcode: %1", ret)
          next
        end
      end

      deep_copy(ret)
    end

### - (`Object`) PassdbDialog

Dialog to configure passdb backends.

Returns:

- dialog result

    1529
    1530
    1531
    1532
    1533
    1534
    1535
    1536
    1537
    1538
    1539
    1540
    1541
    1542
    1543
    1544
    1545
    1546
    1547
    1548
    1549
    1550
    1551
    1552
    1553
    1554
    1555
    1556
    1557
    1558
    1559
    1560
    1561
    1562
    1563
    1564
    1565
    1566
    1567
    1568
    1569
    # File '../../src/include/samba-server/dialogs.rb', line 1529

    def PassdbDialog
      # dialog caption
      caption = _("User Information Sources")

      w = CWM.CreateWidgets(
        ["passdb_edit"],
        Convert.convert(
          @xx_widgets,
          :from => "map",
          :to   => "map <string, map <string, any>>"
        )
      )

      contents = HBox(
        HSpacing(1),
        VBox(VSpacing(1), Ops.get_term(w, [0, "widget"]) { VSpacing(0) }),
        HSpacing(1)
      )

      help = CWM.MergeHelps(w)

      Wizard.SetContentsButtons(
        caption,
        contents,
        help,
        Label.BackButton,
        Label.OKButton
      )

      #     UI::ReplaceWidget( `id(`_tp_table_repl),
      #         // TRANSLATORS: menu button label for accessing the LDAP-related settings and actions
      #         `MenuButton( "LDAP",
      # 	    // translators: menu item to show a LDAP-related settings
      # 	    [ `item( `id(`ldap), _("Global LDAP Settings") ),
      # 	      // translators: menu item to test the currently selected LDAP url
      # 	      `item( `id(`ldap_test), _("Test LDAP Connection") ),
      # 	    ]
      # 	)
      #     );
      CWM.Run(w, { :abort => fun_ref(method(:confirmAbort), "boolean ()") })
    end

### - (`Object`) RenameShare(share)

Bugzilla #263302

    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
    # File '../../src/include/samba-server/dialogs.rb', line 557

    def RenameShare(share)
      if !SambaConfig.ShareExists(share)
        Builtins.y2error("Share %1 doesn't exist", share)
        return false
      end

      content = VBox(
        # TRANSLATORS: dialog caption
        Heading(_("Rename Share")),
        HSquash(
          MinWidth(
            35,
            VBox(
              # TRANSLATORS: text entry
              InputField(
                Id("share_name"),
                Opt(:hstretch),
                _("New Share &Name"),
                share
              )
            )
          )
        ),
        VSpacing(1),
        ButtonBox(
          PushButton(Id(:ok), Opt(:okButton), Label.OKButton),
          PushButton(Id(:cancel), Opt(:cancelButton), Label.CancelButton)
        )
      )

      UI.OpenDialog(content)
      UI.SetFocus(Id("share_name"))

      fc_ret = false

      ret = nil
      while true
        ret = UI.UserInput

        if ret == :ok
          new_share_name = Convert.to_string(
            UI.QueryWidget(Id("share_name"), :Value)
          )

          if new_share_name == ""
            # TRANSLATORS: popup error message
            Report.Error(_("Enter a new share name."))
            next
          elsif share == new_share_name
            Builtins.y2milestone("Old and new share names are the same")
            break
          elsif SambaConfig.ShareExists(new_share_name)
            # TRANSLATORS: popup error message, %1 is a variable share name
            Report.Error(
              Builtins.sformat(
                _("Share '%1' already exists.\nChoose another share name.\n"),
                new_share_name
              )
            )
            next
          end

          # Renaming share
          old_share_settings = SambaConfig.ShareGetMap(share)
          old_share_enabled = SambaConfig.ShareEnabled(share)

          Builtins.y2milestone(
            "Creating new share '%1' %2 -> %3",
            new_share_name,
            old_share_settings,
            SambaConfig.ShareSetMap(new_share_name, old_share_settings)
          )
          Builtins.y2milestone(
            "Removing share '%1' -> %2",
            share,
            SambaConfig.ShareRemove(share)
          )

          # enable or disable new share according the old one
          if SambaConfig.ShareEnabled(new_share_name) != old_share_enabled
            SambaConfig.ShareAdjust(
              new_share_name,
              !SambaConfig.ShareEnabled(new_share_name)
            )
          end

          fc_ret = true
          break
          # cancel
        else
          break
        end
      end

      UI.CloseDialog

      fc_ret
    end

### - (`Object`) sharesItems(filt)

    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    # File '../../src/include/samba-server/dialogs.rb', line 117

    def sharesItems(filt)
      shares = SambaConfig.GetShares
      if filt
        system = ["homes", "printers", "print$", "netlogon", "profiles"]
        shares = Builtins.filter(shares) { |s| !Builtins.contains(system, s) }
      end
      index = 0
      Builtins.maplist(shares) do |name|
        index = Ops.add(index, 1)
        pth = SambaConfig.ShareGetStr(name, "path", "")
        enabled = SambaConfig.ShareEnabled(name) ? _("Enabled") : _("Disabled")
        comment = SambaConfig.ShareGetStr(name, "comment", "")
        ro = SambaConfig.ShareGetTruth(name, "read only", true)
        ga = SambaConfig.ShareGetTruth(name, "guest ok", false)
        Item(
          Id(index),
          enabled,
          ro ? _("Yes") : _("No"),
          name,
          pth,
          ga ? _("Yes") : _("No"),
          comment
        )
      end
    end

### - (`Object`) SharesWidgetHandle(key, event_descr)

    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
    # File '../../src/include/samba-server/dialogs.rb', line 656

    def SharesWidgetHandle(key, event_descr)
      event_descr = deep_copy(event_descr)
      return nil if !Ops.is_symbol?(Ops.get(event_descr, "ID"))
      ret = Ops.get_symbol(event_descr, "ID")
      @return_tab = "shares"

      if ret == :share_ch
        AdjustUserShareWidgets()
        return nil
      end
      return ret if ret == :add
      if ret == :filter_all || ret == :filter_non_system
        items = sharesItems(ret == :filter_non_system)
        UI.ChangeWidget(Id(:table), :Items, items)
        return nil
      end

      id = Convert.to_integer(UI.QueryWidget(Id(:table), :CurrentItem))
      return nil if id == nil

      share = Ops.get_string(
        Builtins.argsof(
          Convert.to_term(UI.QueryWidget(Id(:table), term(:Item, id)))
        ),
        3
      )
      return nil if share == nil

      if ret == :edit || ret == :table
        @shareToEdit = share
        return :edit
      end
      if ret == :toggle
        SambaConfig.ShareAdjust(share, !SambaConfig.ShareEnabled(share))
        UI.ChangeWidget(Id(:table), :Items, sharesItems(false))
        UI.ChangeWidget(Id(:table), :CurrentItem, id)
        return nil
      end
      if ret == :guest
        SambaConfig.ShareSetTruth(
          share,
          "guest ok",
          !SambaConfig.ShareGetTruth(share, "guest ok", false)
        )
        UI.ChangeWidget(Id(:table), :Items, sharesItems(false))
        UI.ChangeWidget(Id(:table), :CurrentItem, id)
        return nil
      end
      if ret == :delete
        # confirmation dialog before deleting a share
        if Popup.YesNo(
            Builtins.sformat(
              _(
                "If you delete share %1,\n" +
                  "all its settings will be lost.\n" +
                  "Really delete it?"
              ),
              share
            )
          )
          Builtins.y2milestone(
            "Removing share '%1' -> %2",
            share,
            SambaConfig.ShareRemove(share)
          )
          UI.ChangeWidget(Id(:table), :Items, sharesItems(false))
        end
      end
      if ret == :rename
        if RenameShare(share)
          UI.ChangeWidget(Id(:table), :Items, sharesItems(false))
        end
        return nil
      end

      nil
    end

### - (`Object`) SharesWidgetInit(key)

    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    # File '../../src/include/samba-server/dialogs.rb', line 525

    def SharesWidgetInit(key)
      items = sharesItems(false)

      UI.ChangeWidget(Id(:table), :Items, items)
      UI.ChangeWidget(
        Id(:edit),
        :Enabled,
        Ops.greater_than(Builtins.size(items), 0)
      )
      UI.ChangeWidget(
        Id(:delete),
        :Enabled,
        Ops.greater_than(Builtins.size(items), 0)
      )
      UI.ChangeWidget(
        Id(:toggle),
        :Enabled,
        Ops.greater_than(Builtins.size(items), 0)
      )
      UI.ChangeWidget(
        Id(:guest),
        :Enabled,
        Ops.greater_than(Builtins.size(items), 0)
      )

      InitUserShareWidgets()
      AdjustUserShareWidgets()

      nil
    end

### - (`Boolean`) snapper_available?

check if snapper support is available (initial check)

Returns:

- (`Boolean`)

    91
    92
    93
    94
    95
    96
    97
    98
    99
    # File '../../src/include/samba-server/dialogs.rb', line 91

    def snapper_available?
      if @snapper_available.nil?
        @snapper_available      =
          Package.Installed("snapper") &&
          # check for the presence of Samba's Snapper VFS module
          0 == SCR.Execute(path(".target.bash"), "smbd --build-options | grep vfs_snapper_init")
      end
      @snapper_available
    end

### - (`Object`) StoreUserShareWidgets(key, event_descr)

    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    # File '../../src/include/samba-server/dialogs.rb', line 500

    def StoreUserShareWidgets(key, event_descr)
      event_descr = deep_copy(event_descr)
      new_share = Convert.to_boolean(UI.QueryWidget(Id(:share_ch), :Value))
      if new_share && !@allow_share && SharesExist(Samba.shares_dir)
        Samba.remove_shares = AskForSharesRemoval()
      end
      max = Convert.to_integer(UI.QueryWidget(Id(:max_shares), :Value))
      if !new_share
        max = 0
        # Samba::stop_services = AskToStopServices();
        Samba.stop_services = false
      end
      Samba.SetShares(
        max,
        Convert.to_string(UI.QueryWidget(Id(:group), :Value))
      )
      Samba.SetGuessAccess(
        new_share && Convert.to_boolean(UI.QueryWidget(Id(:guest_ch), :Value))
      )

      SambaServer.SetModified

      nil
    end

### - (`Boolean`) subvolume?(path)

check if given path points to btrfs subvolume

Returns:

- (`Boolean`)

    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    # File '../../src/include/samba-server/dialogs.rb', line 102

    def subvolume?(path)
      return false unless path
      stat      = SCR.Read(path(".target.stat"), path)

      # 1. is btrfs subvolume
      if stat["inode"] == 256 &&
        # 2. has snapper config
        0 == SCR.Execute(path(".target.bash"), "grep 'SUBVOLUME=\"#{path}\"' /etc/snapper/configs/*")
        return true
      else
        return false
      end
    end

### - (`Object`) TrustedDomainsWidgetHandle(key, event_descr)

    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    # File '../../src/include/samba-server/dialogs.rb', line 813

    def TrustedDomainsWidgetHandle(key, event_descr)
      event_descr = deep_copy(event_descr)
      if Ops.get(event_descr, "ID") == :add_domain
        AddTrustedDomain()
      elsif Ops.get(event_descr, "ID") == :delete_domain
        to_delete = Convert.to_string(
          UI.QueryWidget(Id("trusted_domains"), :CurrentItem)
        )

        # confirmation
        if Popup.ContinueCancel(
            Builtins.sformat(
              _("Really abandon trust relationship\nto trusted domain %1?"),
              to_delete
            )
          )
          SambaTrustDom.Revoke(to_delete)
        end
      end

      # reinitialize contents
      TrustedDomainsWidgetInit(key)

      nil
    end

### - (`Object`) TrustedDomainsWidgetInit(key)

    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    # File '../../src/include/samba-server/dialogs.rb', line 778

    def TrustedDomainsWidgetInit(key)
      if Mode.config && !@autoyast_warning_done
        # issue a warning, if not already done so
        Popup.Warning(
          _(
            "The password for trusted domains\n" +
              "is stored in the autoinstallation control file. The password\n" +
              "is stored as plain text. This can be considered\n" +
              "a security threat."
          )
        )
        @autoyast_warning_done = true
      end

      domains = []

      # SambaTrustDom::List() might return 'nil'
      samba_trust_domain_list = SambaTrustDom.List
      if samba_trust_domain_list != nil || samba_trust_domain_list != []
        Builtins.foreach(samba_trust_domain_list) do |key2|
          domains = Builtins.add(domains, Item(Id(key2), key2))
        end
      end

      UI.ReplaceWidget(
        Id(:domains_tr),
        SelectionBox(Id("trusted_domains"), _("&Trusted Domains"), domains)
      )

      # disable delete button if needed
      UI.ChangeWidget(Id(:delete_domain), :Enabled, Builtins.size(domains) != 0)

      nil
    end

### - (`Object`) WinsHostResolutionWidgetInit(key)

    338
    339
    340
    341
    342
    # File '../../src/include/samba-server/dialogs.rb', line 338

    def WinsHostResolutionWidgetInit(key)
      UI.ChangeWidget(Id(:wins_dns), :Value, Samba.GetHostsResolution)

      nil
    end

### - (`Object`) WinsHostResolutionWidgetStore(key, event_descr)

    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    # File '../../src/include/samba-server/dialogs.rb', line 412

    def WinsHostResolutionWidgetStore(key, event_descr)
      event_descr = deep_copy(event_descr)
      new_value = Convert.to_boolean(UI.QueryWidget(Id(:wins_dns), :Value))
      if new_value != nil
        Builtins.y2milestone(
          "Setting WINS Host Resolution '%1' returned '%2'",
          new_value,
          Samba.SetHostsResolution(new_value)
        )
      end

      nil
    end

### - (`Object`) WinsSettingsWidgetHandle(key, event_descr)

    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    # File '../../src/include/samba-server/dialogs.rb', line 440

    def WinsSettingsWidgetHandle(key, event_descr)
      event_descr = deep_copy(event_descr)
      event = Ops.get(event_descr, "ID")
      if event == "wins_server_support" || event == "remote_wins_server"
        UI.ChangeWidget(
          Id("wins_server_name"),
          :Enabled,
          event == "remote_wins_server"
        )
      end
      nil
    end

### - (`Object`) WinsSettingsWidgetInit(key)

    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    # File '../../src/include/samba-server/dialogs.rb', line 317

    def WinsSettingsWidgetInit(key)
      wins = SambaConfig.GlobalGetTruth("wins support", false)

      UI.ChangeWidget(Id("wins_server_support"), :Value, wins)
      UI.ChangeWidget(Id("remote_wins_server"), :Value, !wins)
      UI.ChangeWidget(Id("wins_server_name"), :Enabled, !wins)
      UI.ChangeWidget(
        Id("wins_server_name"),
        :Value,
        SambaConfig.GlobalGetStr("wins server", "")
      )

      nil
    end

### - (`Object`) WinsSettingsWidgetStore(key, event_descr)

    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    # File '../../src/include/samba-server/dialogs.rb', line 377

    def WinsSettingsWidgetStore(key, event_descr)
      event_descr = deep_copy(event_descr)
      if Convert.to_boolean(UI.QueryWidget(Id("wins_server_support"), :Value))
        Builtins.y2milestone("Enabling wins support")
        SambaConfig.GlobalSetTruth("wins support", true)
        SambaConfig.GlobalSetStr("wins server", nil)
      else
        SambaConfig.GlobalSetTruth("wins support", false)
        SambaConfig.GlobalSetStr(
          "wins server",
          Convert.to_string(UI.QueryWidget(Id("wins_server_name"), :Value))
        )
        Builtins.y2milestone(
          "Disabling wins support, using server '%1'",
          SambaConfig.GlobalGetStr("wins server", "<none>")
        )
      end

      nil
    end

### - (`Object`) WinsViaDHCPWidgetInit(key)

    332
    333
    334
    335
    336
    # File '../../src/include/samba-server/dialogs.rb', line 332

    def WinsViaDHCPWidgetInit(key)
      UI.ChangeWidget(Id(:dhcp), :Value, Samba.GetDHCP)

      nil
    end

### - (`Object`) WinsViaDHCPWidgetStore(key, event_descr)

    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    # File '../../src/include/samba-server/dialogs.rb', line 398

    def WinsViaDHCPWidgetStore(key, event_descr)
      event_descr = deep_copy(event_descr)
      new_value = Convert.to_boolean(UI.QueryWidget(Id(:dhcp), :Value))
      if new_value != nil
        Builtins.y2milestone(
          "Setting WINS via DHCP to '%1' returned '%2'",
          new_value,
          Samba.SetDHCP(new_value)
        )
      end

      nil
    end