Module: Yast::SambaClientDialogsInclude

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) ExpertSettingsDialog(use_winbind)

dialog for setting expert settings, like winbind uid/gid keys (F301518)



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
215
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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
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
343
344
345
346
347
348
349
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
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
# File '../../src/include/samba-client/dialogs.rb', line 152

def ExpertSettingsDialog(use_winbind)
  winbind_uid = SambaConfig.GlobalGetStr("winbind uid", "10000-20000")
  l = Builtins.splitstring(winbind_uid, "-")
  uid_min = Builtins.tointeger(Ops.get_string(l, 0, "10000"))
  uid_min = 10000 if uid_min == nil
  uid_max = Builtins.tointeger(Ops.get_string(l, 1, "20000"))
  uid_max = 20000 if uid_max == nil

  winbind_gid = SambaConfig.GlobalGetStr("winbind gid", "10000-20000")
  l = Builtins.splitstring(winbind_gid, "-")
  gid_min = Builtins.tointeger(Ops.get_string(l, 0, "10000"))
  gid_min = 10000 if gid_min == nil
  gid_max = Builtins.tointeger(Ops.get_string(l, 1, "20000"))
  gid_max = 20000 if gid_max == nil
  dhcp_support = Samba.GetDHCP
  kerberos_method = SambaConfig.GlobalGetStr("kerberos method", "")

  # help text, do not translate 'winbind uid', 'winbind gid'
  help_text = Ops.add(
    Ops.add(
      Ops.add(
        Ops.add(
          _(
            "<p>Specify the <b>Range</b> for Samba user and group IDs (<tt>winbind uid</tt> and <tt>winbind gid</tt> values).</p>"
          ),
          HostsResolutionHelp()
        ),
        DHCPSupportHelp()
      ),
      KerberosMethodHelp()
    ),
    PAMMountHelp()
  )

  hosts_resolution = Samba.GetHostsResolution

  mount_items = []
  non_cifs_volumes = []

  # mapping of unique ID's to volume entries
  mount_map = {}
  i = 0

  Builtins.foreach(Samba.GetPAMMountVolumes) do |volume|
    if Ops.get_string(volume, "fstype", "") != "cifs"
      Builtins.y2debug("volume fstype different from cifs, skipping")
      non_cifs_volumes = Builtins.add(non_cifs_volumes, volume)
      next
    end
    Ops.set(mount_map, i, volume)
    i = Ops.add(i, 1)
  end

  build_mount_items = lambda do
    mount_items = Builtins.maplist(mount_map) do |id, volume|
      Item(
        Id(id),
        Ops.get_string(volume, "server", ""),
        Ops.get_string(volume, "path", ""),
        Ops.get_string(volume, "mountpoint", ""),
        Ops.get_string(volume, "user", ""),
        Ops.get_string(volume, "options", "")
      )
    end
    deep_copy(mount_items)
  end
  kerberos_methods = Builtins.maplist(
    [
      "secrets only",
      "system keytab",
      "dedicated keytab",
      "secrets and keytab"
    ]
  ) do |method|
    Item(Id(method), method, method == kerberos_method)
  end

  contents = HBox(
    HSpacing(3),
    VBox(
      VSpacing(0.4),
      # frame label
      Frame(
        _("&UID Range"),
        HBox(
          # int field label
          IntField(Id(:uid_min), _("&Minimum"), 0, 99999, uid_min),
          # int field label
          IntField(Id(:uid_max), _("Ma&ximum"), 0, 99999, uid_max)
        )
      ),
      VSpacing(0.5),
      # frame label
      Frame(
        _("&GID Range"),
        HBox(
          # int field label
          IntField(Id(:gid_min), _("M&inimum"), 0, 99999, gid_min),
          # int field label
          IntField(Id(:gid_max), _("M&aximum"), 0, 99999, gid_max)
        )
      ),
      VSpacing(0.2),
      # require_groups
      Frame(_("Allowed Group(s)"),
      Left(
        InputField(
          Id("require_grp"),
          Opt(:hstretch),
          _("Group Name(s) or SID(s)"),
          SambaConfig::WinbindGlobalGetStr("require_membership_of", "")
        )
      )
      ),
      VSpacing(0.2),
      # combobox label
      Left(
        ComboBox(
          Id(:kerberos_method),
          _("&Kerberos Method"),
          kerberos_methods
        )
      ),
      # frame label
      Frame(
        _("Windows Internet Name Service"),
        VBox(
          HostsResolutionTerm(hosts_resolution),
          DHCPSupportTerm(dhcp_support)
        )
      ),
      VSpacing(0.4),
      # frame label
      Frame(
        _("Mount Server Directories"),
        VBox(
          Table(
            Id(:table),
            Opt(:notify),
            Header(
              # table header
              _("Server Name"),
              # table header
              _("Remote Path"),
              # table header
              _("Local Mount Point"),
              # table header
              _("User Name"),
              # table header
              _("Options")
            ),
            build_mount_items.call
          ),
          HBox(
            PushButton(Id(:add), Label.AddButton),
            PushButton(Id(:edit), Label.EditButton),
            PushButton(Id(:delete), Label.DeleteButton),
            HStretch()
          )
        )
      )
    ),
    HSpacing(3)
  )

  Wizard.OpenOKDialog
  # dialog title
  Wizard.SetContents(_("Expert Settings"), contents, help_text, true, true)

  Builtins.foreach([:edit, :delete]) do |s|
    UI.ChangeWidget(
      Id(s),
      :Enabled,
      Ops.greater_than(Builtins.size(mount_items), 0)
    )
  end

  ret = :cancel
  selected = 0
  while true
    ret2 = UI.UserInput
    break if ret2 == :cancel
    if ret2 == :delete || ret2 == :edit || ret2 == :table
      selected = Convert.to_integer(
        UI.QueryWidget(Id(:table), :CurrentItem)
      )
      ret2 = :edit if ret2 == :table
    end
    if ret2 == :delete
      mount_map = Builtins.remove(mount_map, selected)
      UI.ChangeWidget(Id(:table), :Items, build_mount_items.call)
      Builtins.foreach([:edit, :delete]) do |s|
        UI.ChangeWidget(
          Id(s),
          :Enabled,
          Ops.greater_than(Builtins.size(mount_items), 0)
        )
      end
    end
    if ret2 == :add || ret2 == :edit
      volume = ret2 == :edit ? Ops.get(mount_map, selected, {}) : {}
      volume = MountEntryPopup(volume)
      next if volume == {}
      Ops.set(volume, "fstype", "cifs") if ret2 == :add
      id = ret2 == :edit ? selected : Builtins.size(mount_map)
      Ops.set(mount_map, id, volume)
      UI.ChangeWidget(Id(:table), :Items, build_mount_items.call)
      Builtins.foreach([:edit, :delete]) do |s|
        UI.ChangeWidget(
          Id(s),
          :Enabled,
          Ops.greater_than(Builtins.size(mount_items), 0)
        )
      end
    end
    if ret2 == :ok
      uid_min = Convert.to_integer(UI.QueryWidget(Id(:uid_min), :Value))
      uid_max = Convert.to_integer(UI.QueryWidget(Id(:uid_max), :Value))
      gid_min = Convert.to_integer(UI.QueryWidget(Id(:gid_min), :Value))
      gid_max = Convert.to_integer(UI.QueryWidget(Id(:gid_max), :Value))
      if Ops.greater_or_equal(uid_min, uid_max) ||
          Ops.greater_or_equal(gid_min, gid_max)
        # error popup: min >= max
        Popup.Error(
          _(
            "The minimum value in the range cannot be\nlarger than maximum one.\n"
          )
        )
        next
      end
      winbind_uid_new = Builtins.sformat("%1-%2", uid_min, uid_max)
      winbind_gid_new = Builtins.sformat("%1-%2", gid_min, gid_max)
      if winbind_uid_new != winbind_uid
        SambaConfig.GlobalSetStr("winbind uid", winbind_uid_new)
      end
      if winbind_gid_new != winbind_gid
        SambaConfig.GlobalSetStr("winbind gid", winbind_gid_new)
      end
      Samba.SetDHCP(Convert.to_boolean(UI.QueryWidget(Id(:dhcp), :Value)))
      Samba.SetHostsResolution(
        Convert.to_boolean(UI.QueryWidget(Id(:hosts_resolution), :Value))
      )

      kerberos_method = Convert.to_string(
        UI.QueryWidget(Id(:kerberos_method), :Value)
      )
      SambaConfig.GlobalSetStr(
        "kerberos method",
        kerberos_method == "secrets only" ? nil : kerberos_method
      )

      required_groups = Convert.to_string(
        UI.QueryWidget(Id("require_grp"), :Value)
      )
      #remove leading/trailing spaces from each comma separated entry
      required_groups = required_groups.split(',').map(&:strip).join(',')

      SambaConfig::WinbindGlobalSetStr("require_membership_of",
                                       required_groups);
      updated_volumes = deep_copy(non_cifs_volumes)
      Builtins.foreach(mount_map) do |id, volume|
        updated_volumes = Builtins.add(updated_volumes, volume)
      end
      Samba.SetPAMMountVolumes(updated_volumes)
      break
    end
  end
  UI.CloseDialog
  Convert.to_symbol(ret)
end

- (Object) initialize_samba_client_dialogs(include_target)



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File '../../src/include/samba-client/dialogs.rb', line 30

def initialize_samba_client_dialogs(include_target)
  Yast.import "UI"

  textdomain "samba-client"

  Yast.import "Autologin"
  Yast.import "CWMFirewallInterfaces"
  Yast.import "Directory"
  Yast.import "Label"
  Yast.import "Message"
  Yast.import "Mode"
  Yast.import "Package"
  Yast.import "Popup"
  Yast.import "Samba"
  Yast.import "SambaConfig"
  Yast.import "Stage"
  Yast.import "Wizard"

  Yast.include include_target, "samba-client/helps.rb"
  Yast.include include_target, "samba-client/routines.rb"
end

- (Object) MembershipDialog

Samba memberhip dialog

Returns:

  • dialog result



425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
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
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
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
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
812
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
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
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
892
893
894
895
896
897
898
899
900
901
902
903
904
# File '../../src/include/samba-client/dialogs.rb', line 425

def MembershipDialog
  # Samba-client workgroup dialog caption
  caption = _("Windows Domain Membership")
  mkhomedir = Samba.mkhomedir
  allow_share = true
  max_shares = Samba.GetMaxShares
  if max_shares == 0
    max_shares = 100
    allow_share = false
  end
  shares_group = Samba.shares_group
  guest = allow_share && Samba.GetGuessAccess
  status_term = VBox(ReplacePoint(Id(:rpstatus), Empty()))
  pw_data = deep_copy(Samba.password_data)
  left_domain = ""

  # internal function: update the status line
  check_domain_membership = lambda do |domain|
    Samba.SetWorkgroup(domain)

    return if Mode.config

    # busy popup text
    Popup.ShowFeedback("", _("Verifying AD domain membership..."))
    SambaAD.ReadADS(domain)
    if SambaAD.ADS != ""
      domain = SambaAD.GetWorkgroup(domain)
      Samba.SetWorkgroup(domain)
      SambaAD.ReadRealm
    end
    Popup.ClearFeedback

    leave_button = SambaAD.ADS == "" ?
      Empty() :
      # push button label
      PushButton(Id(:leave), _("&Leave"))
    UI.ReplaceWidget(
      Id(:rpstatus),
      Stage.cont || CheckWorkgroup(domain) != :joined_domain ?
        Empty() :
        HBox(
          # status label
          Left(Label(_("Currently a member of this domain"))),
          HStretch(),
          leave_button
        )
    )

    nil
  end

  # winbind enabled on start
  was_winbind = Samba.GetWinbind

  winbind_term = Stage.cont ?
    Empty() :
    VBox(
      VSpacing(0.4),
      Left(
        CheckBox(
          Id(:winbind),
          Opt(:notify),
          # translators: checkbox label to enable winbind
          _("&Use SMB Information for Linux Authentication"),
          Samba.GetWinbind
        )
      )
    )

  mkhomedir_term = VBox(
    Left(
      CheckBox(
        Id(:mkhomedir),
        # checkbox label
        _("&Create Home Directory on Login"),
        mkhomedir
      )
    )
  )

  autoyast_term = Mode.config ?
    VBox(
      VSpacing(),
      # frame label
      Frame(
        _("Join Settings"),
        HBox(
          # text entry label
          InputField(
            Id("user"),
            Opt(:hstretch),
            _("&Username"),
            Ops.get_string(pw_data, "user", "") != nil ?
              Ops.get_string(pw_data, "user", "") :
              ""
          ),
          # text entry label
          Password(
            Id("password"),
            Opt(:hstretch),
            _("&Password"),
            Ops.get_string(pw_data, "password", "")
          ),
          # text entry label
          InputField(
            Id("machine"),
            Opt(:hstretch),
            _("Mac&hine Account OU"),
            Ops.get_string(pw_data, "machine", "") != nil ?
              Ops.get_string(pw_data, "machine", "") :
              ""
          )
        )
      ),
      VSpacing(),
      # text entry label
      InputField(Id(:ads), Opt(:hstretch), _("Active Directory Server"))
    ) :
    Empty()

  ntp_term = Mode.config ?
    Empty() :
    VBox(
      VSpacing(0.4),
      # button label (run YaST client for NTP)
      Right(PushButton(Id(:ntp), _("N&TP Configuration...")))
    )

  # checkbox label
  text_nscd = _("Disable Name Service Cache")
  # checkbox label
  text_fam = _("Start File Alteration Monitor")

  firewall_widget = CWMFirewallInterfaces.CreateOpenFirewallWidget(
    { "services" => ["samba-server"], "display_details" => true }
  )
  firewall_layout = Ops.get_term(firewall_widget, "custom_widget", VBox())

  #    Wizard::SetContentsButtons( caption, `HVSquash( `VBox(
  Wizard.SetContentsButtons(
    caption,
    HBox(
      HSpacing(3),
      VBox(
        # translators: frame label
        Frame(
          _("Membership"),
          VBox(
            HBox(
              HSpacing(0.2),
              InputField(
                Id(:workgroup),
                Opt(:hstretch),
                Stage.cont ?
                  _("&Domain") :
                  # translators: text entry label
                  _("&Domain or Workgroup"),
                Samba.GetWorkgroupOrRealm
              )
            ),
            status_term,
            winbind_term,
            HBox(
              Stage.cont ? Empty() : HSpacing(2),
              VBox(
                mkhomedir_term,
                Left(
                  # checkbox label
                  CheckBox(
                    Id(:caching),
                    _("Off&line Authentication"),
                    Samba.GetWinbindCaching
                  )
                ),
                Left(
                  # checkbox label
                  CheckBox(
                    Id(:ssh),
                    Opt(:notify),
                    _("&Single Sign-on for SSH"),
                    Samba.GetSSHSupport
                  )
                ),
                VSpacing(0.2)
              )
            ),
            Left(
              SambaAD.ADS != "" && !SambaAD.IsDHCPClient(false) ?
                # checkbox label
                CheckBox(Id(:adapt_dns), _("Change primary DNS suffix")) :
                VBox()
            )
          )
        ),
        VSpacing(0.4),
        # button label
        Right(PushButton(Id(:expert), _("&Expert Settings..."))),
        SharesTerm(
          {
            "allow_share"  => allow_share,
            "group"        => shares_group,
            "max_shares"   => max_shares,
            "guest_access" => guest
          }
        ),
        autoyast_term,
        ntp_term
      ),
      HSpacing(3)
    ),
    Ops.add(
      Ops.add(
        Ops.add(
          Stage.cont ?
            Ops.get_string(@HELPS, "MembershipDialog_cont", "") :
            Ops.get_string(@HELPS, "MembershipDialog_nocont", ""),
          Ops.get_string(@HELPS, "MembershipDialog_common", "")
        ),
        SharesHelp()
      ),
      Mode.config ?
        Ops.get_string(@HELPS, "MembershipDialog_config", "") :
        Ops.get_string(@HELPS, "MembershipDialog_NTP", "")
    ),
    Stage.cont ? Label.BackButton : Label.CancelButton,
    Stage.cont ? Label.NextButton : Label.OKButton
  )
  #    CWMFirewallInterfaces::OpenFirewallInit (firewall_widget, "");
  Builtins.foreach([:mkhomedir, :caching, :ssh]) do |t|
    UI.ChangeWidget(Id(t), :Enabled, Samba.GetWinbind || Stage.cont)
  end
  Builtins.foreach([:group, :max_shares, :guest_ch]) do |t|
    UI.ChangeWidget(Id(t), :Enabled, allow_share)
  end

  if !Stage.cont
    Wizard.HideAbortButton
    check_domain_membership.call(Samba.GetWorkgroupOrRealm)
  end

  ret = nil
  while true
    event = UI.WaitForEvent
    ret = Ops.get_symbol(event, "ID")
    #	CWMFirewallInterfaces::OpenFirewallHandle(firewall_widget,"",event);
    use_winbind = Stage.cont ?
      true :
      Convert.to_boolean(UI.QueryWidget(Id(:winbind), :Value))

    if ret == :abort || ret == :cancel || ret == :back && !Stage.cont
      if ReallyAbort()
        break
      else
        next
      end
    elsif ret == :leave
      workgroup = Convert.to_string(UI.QueryWidget(Id(:workgroup), :Value))
      if LeaveDomain(workgroup) == :ok
        left_domain = workgroup
        check_domain_membership.call(workgroup)
        UI.ChangeWidget(Id(:winbind), :Value, false)
        SambaAD.SetADS("")
      end
    elsif ret == :winbind
      UI.ChangeWidget(Id(:mkhomedir), :Enabled, use_winbind)
      UI.ChangeWidget(Id(:caching), :Enabled, use_winbind)
      UI.ChangeWidget(Id(:ssh), :Enabled, use_winbind)
    elsif ret == :share_ch
      Builtins.foreach([:group, :max_shares, :guest_ch]) do |t|
        UI.ChangeWidget(
          Id(t),
          :Enabled,
          Convert.to_boolean(UI.QueryWidget(Id(:share_ch), :Value))
        )
      end
    elsif ret == :expert
      ExpertSettingsDialog(use_winbind)
    elsif ret == :ntp
      if Package.InstallAll(["yast2-ntp-client"])
        workgroup = Convert.to_string(
          UI.QueryWidget(Id(:workgroup), :Value)
        )
        ads = SambaAD.ReadADS(workgroup)
        tmpfile = Ops.add(Directory.vardir, "/ad_ntp_data.ycp")
        ad_data = { "ads" => ads }
        SCR.Write(path(".target.ycp"), tmpfile, ad_data)
        WFM.CallFunction("ntp-client", [])
      end
    elsif ret == :next
      workgroup = Convert.to_string(UI.QueryWidget(Id(:workgroup), :Value))
      if workgroup != Samba.GetWorkgroup &&
          (left_domain == "" || workgroup != left_domain)
        check_domain_membership.call(workgroup)
        workgroup = Samba.GetWorkgroup
      end

      Samba.SetWinbind(use_winbind)

      if use_winbind
        packages = ["samba-winbind"]
        if SambaAD.ADS != ""
          packages = Convert.convert(
            Builtins.merge(packages, ["krb5", "krb5-client"]),
            :from => "list",
            :to   => "list <string>"
          )
        end
        if Samba.PAMMountModified &&
            Ops.greater_than(Builtins.size(Samba.GetPAMMountVolumes), 0)
          packages = Builtins.add(packages, "pam_mount")
        end
        if !Package.InstallAll(packages)
          Popup.Error(Message.FailedToInstallPackages)
          ret = :not_next
          UI.ChangeWidget(Id(:winbind), :Value, false)
          next
        end
      end

      # for domain ask to join
      workgroup_type = CheckWorkgroup(workgroup)

      # need to set this before the join
      Samba.SetSSHSupport(
        use_winbind && Convert.to_boolean(UI.QueryWidget(Id(:ssh), :Value))
      )

      if UI.WidgetExists(:adapt_dns)
        SambaNetJoin.SetAdaptDNS(
          Convert.to_boolean(UI.QueryWidget(Id(:adapt_dns), :Value))
        )
      end

      if Mode.config
        Builtins.foreach(["user", "password", "machine"]) do |key|
          val = Convert.to_string(UI.QueryWidget(Id(key), :Value))
          Ops.set(Samba.password_data, key, val) if val != nil && val != ""
        end
        if Convert.to_string(UI.QueryWidget(Id(:ads), :Value)) != ""
          SambaAD.SetADS(
            Convert.to_string(UI.QueryWidget(Id(:ads), :Value))
          )
        end
      else
        if Samba.GetWinbind && workgroup_type == :workgroup
          Popup.Error(
            Ops.add(
              Ops.add(
                # 1st part of an error message:
                # winbind cannot provide user information taken from
                # a workgroup, must be a domain; %1 is the workgroup name
                Builtins.sformat(
                  _(
                    "Cannot use the workgroup\n'%1' for Linux authentication."
                  ),
                  workgroup
                ),
                "\n\n"
              ),
              Stage.cont ?
                # translators: 2nd part of an error message
                _("Enter a valid domain.") :
                # translators: 2nd part of an error message
                _(
                  "Enter a domain or disable\nusing SMB for Linux authentication."
                )
            )
          )
          next
        end

        in_domain = nil
        if Stage.cont && workgroup_type != :joined_domain
          # return `ok or `fail
          in_domain = JoinDomain(workgroup)
          Samba.in_domain = in_domain
          next if in_domain == :fail
        end

        if false # we might use it to warn user (#155716)
          # continue/cancel popup
          Popup.ContinueCancel(
            Builtins.sformat(
              _(
                "Configuring this system as a client for Active Directory resets the following\n" +
                  "settings in smb.conf to the default values:\n" +
                  "%1"
              ),
              Builtins.mergestring(["domain master", "domain logons"], "\n")
            )
          )
        end
        if !Stage.cont &&
            (left_domain == "" || use_winbind || left_domain != workgroup)
          # return `ok, `fail or `nojoin
          in_domain = AskJoinDomain(workgroup, workgroup_type)
          next if in_domain == :fail
          if in_domain != :ok && Samba.GetWinbind
            # 1st part of an error message:
            # winbind cannot provide user information if the host
            # is not in a domain
            Popup.Error(
              _(
                "The host must be a member of a domain\nfor Linux authentication using SMB."
              ) + "\n\n" +
                # translators: 2nd part of an error message
                _(
                  "Join a domain or disable use of SMB\nfor Linux authentication."
                )
            )
            next
          end
        end
        if Samba.GetWinbind
          # used outside this module for autologin function. must be complete sentence.
          Autologin.AskForDisabling(_("Samba is now enabled."))
        end
      end
      if Mode.config ||
          Stage.cont && Samba.in_domain == :ok &&
            Ops.get_string(
              Samba.network_setup,
              ["dhcp", "DHCLIENT_SET_HOSTNAME"],
              "yes"
            ) == "yes"
        # yes/no popup text
        Samba.disable_dhcp_hostname = Popup.YesNo(
          _(
            "In a Microsoft environment,\n" +
              "hostname changes with DHCP are problematic.\n" +
              "Disable hostname changes with DHCP?"
          )
        )
      end


      Samba.SetMkHomeDir(
        use_winbind &&
          Convert.to_boolean(UI.QueryWidget(Id(:mkhomedir), :Value))
      )
      Samba.SetWinbindCaching(
        use_winbind &&
          Convert.to_boolean(UI.QueryWidget(Id(:caching), :Value))
      )

      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))
      max = 0 if !new_share
      Samba.SetShares(
        max,
        Convert.to_string(UI.QueryWidget(Id(:group), :Value))
      )
      Samba.SetGuessAccess(
        new_share &&
          Convert.to_boolean(UI.QueryWidget(Id(:guest_ch), :Value))
      )
      if !Stage.cont && !Mode.config && use_winbind && !was_winbind
        # message popup, part 1/2
        Popup.Message(
          _(
            "This change only affects newly created processes and not already\n" +
              "running services. Restart your services manually or reboot \n" +
              "the machine to enable it for all services.\n"
          )
        )
      end
      #	    CWMFirewallInterfaces::OpenFirewallStore (firewall_widget,"",event);
      break
    elsif ret == :back
      break
    end
  end

  Wizard.RestoreNextButton
  Wizard.RestoreBackButton
  Convert.to_symbol(ret)
end

- (Object) MountEntryPopup(volume)

Popup for editing the mount entry data



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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
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
142
143
144
145
146
147
148
149
# File '../../src/include/samba-client/dialogs.rb', line 53

def MountEntryPopup(volume)
  volume = deep_copy(volume)
  # labels of keys which are shown only if they are already present in the
  # volume entry (manualy added to congig file)
  key2label =
    # we do not show "fstype" key, this is limited to cifs...
    {
      # text entry label
      "uid"  => _("U&ID"),
      # text entry label
      "pgrp" => _("&Primary Group Name"),
      # text entry label
      "sgrp" => _("&Secondary Group Name"),
      # text entry label
      "gid"  => _("&GID")
    }

  input_fields = VBox(
    # text entry label
    InputField(Id("server"), Opt(:hstretch), _("&Server Name")),
    # text entry label
    InputField(Id("path"), Opt(:hstretch), _("Remote &Path")),
    # text entry label
    InputField(Id("mountpoint"), Opt(:hstretch), _("&Mount Point")),
    # text entry label
    InputField(Id("options"), Opt(:hstretch), _("O&ptions")),
    # text entry label
    InputField(Id("user"), Opt(:hstretch), _("&User Name"))
  )
  # default keys
  widgets = ["server", "path", "mountpoint", "options", "user"]

  Builtins.foreach(key2label) do |key, label|
    if Builtins.haskey(volume, key)
      input_fields = Builtins.add(
        input_fields,
        InputField(Id(key), Opt(:hstretch), label)
      )
      widgets = Builtins.add(widgets, key)
    end
  end

  UI.OpenDialog(
    Opt(:decorated),
    HBox(
      HSpacing(0.2),
      VBox(
        HSpacing(50),
        VSpacing(0.2),
        input_fields,
        VSpacing(0.2),
        ButtonBox(
          PushButton(Id(:ok), Label.OKButton),
          PushButton(Id(:cancel), Label.CancelButton)
        ),
        VSpacing(0.2)
      ),
      HSpacing(0.2)
    )
  )

  if volume == {}
    # offer this as a default option for new volumes (bnc#433845)
    Ops.set(volume, "options", "user=%(DOMAIN_USER)")
  end
  Builtins.foreach(widgets) do |key|
    UI.ChangeWidget(Id(key), :Value, Ops.get_string(volume, key, ""))
  end

  ret = UI.UserInput
  if ret == :ok
    # saving value to the same map we got as argument =>
    # keys that were not shown (e.g. fstype) are preserved)
    Builtins.foreach(widgets) do |key|
      Ops.set(volume, key, UI.QueryWidget(Id(key), :Value))
    end
  end
  UI.CloseDialog

  # filter out default keys without value (but leave the rest, so they
  # may appear on next editing)
  volume = Builtins.filter(
    Convert.convert(volume, :from => "map", :to => "map <string, string>")
  ) do |k, v|
    v != "" ||
      !Builtins.contains(
        ["server", "path", "mountpoint", "options", "user"],
        k
      )
  end
  # nothing was added, remove the proposal
  if Builtins.size(volume) == 1 &&
      Ops.get_string(volume, "options", "") == "user=%(DOMAIN_USER)"
    volume = {}
  end
  deep_copy(volume)
end