• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / yast-samba-server / 10830818621

12 Sep 2024 12:29PM UTC coverage: 0.989%. First build
10830818621

push

github

lslezak
Import the changes from the OBS SLE15-SP6 project

44 of 4449 relevant lines covered (0.99%)

0.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/include/samba-server/dialogs.rb
1
# encoding: utf-8
2

3
# ------------------------------------------------------------------------------
4
# Copyright (c) 2006-2012 Novell, Inc. All Rights Reserved.
5
#
6
#
7
# This program is free software; you can redistribute it and/or modify it under
8
# the terms of version 2 of the GNU General Public License as published by the
9
# Free Software Foundation.
10
#
11
# This program is distributed in the hope that it will be useful, but WITHOUT
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License along with
16
# this program; if not, contact Novell, Inc.
17
#
18
# To contact Novell about this file by physical or electronic mail, you may find
19
# current contact information at www.novell.com.
20
# ------------------------------------------------------------------------------
21

22
# File:        include/samba-server/dialogs.ycp
23
# Package:        Configuration of samba-server
24
# Summary:        Dialogs definitions
25
# Authors:        Stanislav Visnovsky <stanislav.visnovsky@suse.cz>
26
#                Lukas Ocilka <locilka@suse.cz>
27
#
28
# $Id$
29

30
require "cwm/service_widget"
×
31

32
require "shellwords"
×
33

34
module Yast
×
35
  module SambaServerDialogsInclude
×
36

37
    def initialize_samba_server_dialogs(include_target)
×
38
      Yast.import "UI"
×
39

40
      textdomain "samba-server"
×
41

42
      Yast.import "String"
×
43
      Yast.import "Label"
×
44
      Yast.import "Wizard"
×
45
      Yast.import "Mode"
×
46
      Yast.import "Popup"
×
47
      Yast.import "ProductFeatures"
×
48
      Yast.import "FileUtils"
×
49

50
      Yast.import "SambaRole"
×
51
      Yast.import "SambaServer"
×
52
      Yast.import "SambaConfig"
×
53
      Yast.import "SambaService"
×
54
      Yast.import "SambaNetJoin"
×
55
      Yast.import "SambaTrustDom"
×
56
      Yast.import "SambaAccounts"
×
57
      Yast.import "SambaNmbLookup"
×
58
      Yast.import "Samba"
×
59
      Yast.import "SambaAD"
×
60

61
      Yast.import "CWM"
×
62
      Yast.import "CWMTab"
×
63
      Yast.import "CWMServiceStart"
×
64
      Yast.import "CWMFirewallInterfaces"
×
65
      Yast.import "OSRelease"
×
66

67
      Yast.include include_target, "samba-server/helps.rb"
×
68
      Yast.include include_target, "samba-server/dialogs-items.rb"
×
69
      Yast.include include_target, "samba-server/ldap-widget.rb"
×
70
      Yast.include include_target, "samba-client/routines.rb"
×
71
      Yast.include include_target, "samba-server/complex.rb"
×
72

73
      @return_tab = "startup"
×
74

75
      @pdc = _("&Primary Domain Controller (PDC)")
×
76
      @bdc = _("B&ackup Domain Controller (BDC)")
×
77
      @standalone = _("Not a Domain &Controller")
×
78

79
      #************************ initial wizard end *************************
80

81
      @initial_role = nil
×
82

83
      # User shares feature, bugzilla #143908
84
      @allow_share = true
×
85
      @max_shares = 0
×
86
      @shares_group = ""
×
87
      # Guest Access check-box, BNC #579993
88
      @guest_access = false
×
89

90
      @autoyast_warning_done = false
×
91

92
      @snapper_available        = nil
×
93
      @btrfs_available          = nil
×
94
    end
×
95

96
    # Widget to define status and start mode of the services
97
    #
98
    # There are two involved services, `smb` and `nmb`. See
99
    # {Yast::SambaServerComplexInclude#services}
100
    #
101
    # @return [::CWM::ServiceWidget]
102
    def service_widget
×
103
      return @service_widget if @service_widget
×
104
      @service_widget = ::CWM::ServiceWidget.new(services)
×
105
      @service_widget.default_action = :restart if need_to_restart? && !connected_users?
×
106
      @service_widget
×
107
    end
×
108

109
    # routines
110

111
    # check if snapper support is available (initial check)
112
    def snapper_available?
×
113
      if @snapper_available.nil?
×
114
        @snapper_available      =
×
115
          Package.Installed("snapper") &&
×
116
          # check for the presence of Samba's Snapper VFS module
117
          0 == SCR.Execute(path(".target.bash"), "/usr/sbin/smbd --build-options | /usr/bin/grep vfs_snapper_init")
×
118
      end
×
119
      @snapper_available
×
120
    end
×
121

122
    # check if Btrfs support is available (initial check)
123
    def btrfs_available?
×
124
      if @btrfs_available.nil?
×
125
        @btrfs_available      =
×
126
          # check for the presence of Samba's Btrfs VFS module
127
          0 == SCR.Execute(path(".target.bash"), "/usr/sbin/smbd --build-options | /usr/bin/grep vfs_btrfs_init")
×
128
      end
×
129
      @btrfs_available
×
130
    end
×
131

132
    # check if given path points to btrfs subvolume
133
    def subvolume?(path)
×
134
      return false unless path
×
135
      stat      = SCR.Read(path(".target.stat"), path)
×
136

137
      if stat["inode"] == 256
×
138
        return true
×
139
      else
×
140
        return false
×
141
      end
×
142
    end
×
143

144
    # check if given path has a corresponding snapper configuration
145
    def snapper_cfg?(path)
×
146
      return false unless path
×
147

148
      pattern = "SUBVOLUME=\"#{path}\""
×
149
      if 0 == SCR.Execute(path(".target.bash"), "/usr/bin/grep #{pattern.shellescape} /etc/snapper/configs/*")
×
150
        return true
×
151
      else
×
152
        return false
×
153
      end
×
154
    end
×
155

156
    def sharesItems(filt)
×
157
      shares = SambaConfig.GetShares
×
158
      if filt
×
159
        system = ["homes", "printers", "print$", "netlogon", "profiles"]
×
160
        shares = Builtins.filter(shares) { |s| !Builtins.contains(system, s) }
×
161
      end
×
162
      index = 0
×
163
      Builtins.maplist(shares) do |name|
×
164
        index = Ops.add(index, 1)
×
165
        pth = SambaConfig.ShareGetStr(name, "path", "")
×
166
        enabled = SambaConfig.ShareEnabled(name) ? _("Enabled") : _("Disabled")
×
167
        comment = SambaConfig.ShareGetStr(name, "comment", "")
×
168
        ro = SambaConfig.ShareGetTruth(name, "read only", true)
×
169
        ga = SambaConfig.ShareGetTruth(name, "guest ok", false)
×
170
        Item(
×
171
          Id(index),
×
172
          enabled,
×
173
          ro ? _("Yes") : _("No"),
×
174
          name,
×
175
          pth,
×
176
          ga ? _("Yes") : _("No"),
×
177
          comment
×
178
        )
×
179
      end
×
180
    end
×
181

182
    def confirmAbort
×
183
      Builtins.y2warning("confirm abort")
×
184
      return true if !SambaServer.GetModified
×
185

186
      Popup.ReallyAbort(true)
×
187
    end
×
188

189

190
    def Installation_Step1
×
191
      caption = _("Samba Installation") + ": " + _("Step 1 of 1")
×
192

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

196
      # always add the currently configured workgroup
197
      workgroup = SambaConfig.GlobalGetStr("workgroup", "")
×
198
      #    if (size(workgroup) > 0 && !contains(workgroups, workgroup)) {
199
      #        workgroups = add(workgroups, workgroup);
200
      #    }
201

202
      contents = VBox(
×
203
        VSquash(
×
204
          Left(
×
205
            # `ComboBox ( `id( "workgroups" ), `opt( `editable ), _("&Workgroup or Domain Name"), workgroups )
206

207
            # TRANSLATORS: text entry
208
            InputField(
×
209
              Id("workgroups"),
×
210
              Opt(:hstretch),
×
211
              _("&Workgroup or Domain Name"),
×
212
              workgroup
×
213
            )
×
214
          )
×
215
        ),
×
216
        VStretch()
×
217
      )
×
218

219
      Wizard.SetContents(
×
220
        caption,
×
221
        contents,
×
222
        Ops.get_string(@HELPS, "inst_step1", ""),
×
223
        false,
×
224
        true
×
225
      )
×
226

227
      Wizard.DisableBackButton
×
228

229
      if Ops.greater_than(Builtins.size(workgroup), 0)
×
230
        UI.ChangeWidget(Id("workgroups"), :Value, workgroup)
×
231
      end
×
232

233
      ret = nil
×
234
      while true
×
235
        ret = UI.UserInput
×
236
        if ret == :next || ret == :cancel || ret == :abort
×
237
          break
×
238
        else
×
239
          Builtins.y2error("unexpected retcode: %1", ret)
×
240
          next
×
241
        end
×
242
      end
×
243

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

250
      Wizard.RestoreBackButton
×
251

252
      deep_copy(ret)
×
253
    end
×
254

255
    def getRole
×
256
      role = SambaRole.GetRole
×
257
      return "STANDALONE" if role == "MEMBER"
×
258
      role
×
259
    end
×
260

261
    def BaseSettingsWidgetInit(key)
×
262
      UI.ChangeWidget(
×
263
        Id("workgroup_domainname"),
×
264
        :Value,
×
265
        SambaConfig.GlobalGetStr("workgroup", "")
×
266
      )
×
267

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

274
      nil
×
275
    end
×
276

277
    def WinsSettingsWidgetInit(key)
×
278
      wins = SambaConfig.GlobalGetTruth("wins support", false)
×
279

280
      UI.ChangeWidget(Id("wins_server_support"), :Value, wins)
×
281
      UI.ChangeWidget(Id("remote_wins_server"), :Value, !wins)
×
282
      UI.ChangeWidget(Id("wins_server_name"), :Enabled, !wins)
×
283
      UI.ChangeWidget(
×
284
        Id("wins_server_name"),
×
285
        :Value,
×
286
        SambaConfig.GlobalGetStr("wins server", "")
×
287
      )
×
288

289
      nil
×
290
    end
×
291

292
    def WinsViaDHCPWidgetInit(key)
×
293
      UI.ChangeWidget(Id(:dhcp), :Value, Samba.GetDHCP)
×
294

295
      nil
×
296
    end
×
297

298
    def WinsHostResolutionWidgetInit(key)
×
299
      UI.ChangeWidget(Id(:wins_dns), :Value, Samba.GetHostsResolution)
×
300

301
      nil
×
302
    end
×
303

304
    def GlobalConfigStringWidgetInit(key)
×
305
      UI.ChangeWidget(Id(key), :Value, SambaConfig.GlobalGetStr(key, ""))
×
306

307
      nil
×
308
    end
×
309

310
    def BaseSettingsWidgetStore(key, event_descr)
×
311
      event_descr = deep_copy(event_descr)
×
312
      sel = Convert.to_string(
×
313
        UI.QueryWidget(Id("workgroup_domainname"), :Value)
×
314
      )
×
315
      Builtins.y2milestone("Setting workgroup '%1'", sel)
×
316
      SambaConfig.GlobalSetStr("workgroup", sel)
×
317

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

321
      # Do not set the role if it is unchanged. It would rewrite some expert settings
322
      # that might have been set manually (Expert Settings), bugzilla #255824
323
      if Builtins.toupper(role) != Builtins.toupper(@initial_role)
×
324
        Builtins.y2milestone(
×
325
          "Setting role '%1' (was '%2')",
×
326
          role,
×
327
          SambaRole.GetRole
×
328
        )
×
329
        SambaRole.SetRole(role)
×
330
      else
×
331
        Builtins.y2milestone("Role type not changed (%1)", role)
×
332
      end
×
333

334
      nil
×
335
    end
×
336

337
    def WinsSettingsWidgetStore(key, event_descr)
×
338
      event_descr = deep_copy(event_descr)
×
339
      if Convert.to_boolean(UI.QueryWidget(Id("wins_server_support"), :Value))
×
340
        Builtins.y2milestone("Enabling wins support")
×
341
        SambaConfig.GlobalSetTruth("wins support", true)
×
342
        SambaConfig.GlobalSetStr("wins server", nil)
×
343
      else
×
344
        SambaConfig.GlobalSetTruth("wins support", false)
×
345
        SambaConfig.GlobalSetStr(
×
346
          "wins server",
×
347
          Convert.to_string(UI.QueryWidget(Id("wins_server_name"), :Value))
×
348
        )
×
349
        Builtins.y2milestone(
×
350
          "Disabling wins support, using server '%1'",
×
351
          SambaConfig.GlobalGetStr("wins server", "<none>")
×
352
        )
×
353
      end
×
354

355
      nil
×
356
    end
×
357

358
    def WinsViaDHCPWidgetStore(key, event_descr)
×
359
      event_descr = deep_copy(event_descr)
×
360
      new_value = Convert.to_boolean(UI.QueryWidget(Id(:dhcp), :Value))
×
361
      if new_value != nil
×
362
        Builtins.y2milestone(
×
363
          "Setting WINS via DHCP to '%1' returned '%2'",
×
364
          new_value,
×
365
          Samba.SetDHCP(new_value)
×
366
        )
×
367
      end
×
368

369
      nil
×
370
    end
×
371

372
    def WinsHostResolutionWidgetStore(key, event_descr)
×
373
      event_descr = deep_copy(event_descr)
×
374
      new_value = Convert.to_boolean(UI.QueryWidget(Id(:wins_dns), :Value))
×
375
      if new_value != nil
×
376
        Builtins.y2milestone(
×
377
          "Setting WINS Host Resolution '%1' returned '%2'",
×
378
          new_value,
×
379
          Samba.SetHostsResolution(new_value)
×
380
        )
×
381
      end
×
382

383
      nil
×
384
    end
×
385

386
    def GlobalConfigStringWidgetStore(key, event_descr)
×
387
      event_descr = deep_copy(event_descr)
×
388
      value = Convert.to_string(UI.QueryWidget(Id(key), :Value))
×
389

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

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

397
      nil
×
398
    end
×
399

400
    def WinsSettingsWidgetHandle(key, event_descr)
×
401
      event_descr = deep_copy(event_descr)
×
402
      event = Ops.get(event_descr, "ID")
×
403
      if event == "wins_server_support" || event == "remote_wins_server"
×
404
        UI.ChangeWidget(
×
405
          Id("wins_server_name"),
×
406
          :Enabled,
×
407
          event == "remote_wins_server"
×
408
        )
×
409
      end
×
410
      nil
×
411
    end
×
412

413
    def AdvancedSettingsWidgetHandle(key, event)
×
414
      event = deep_copy(event)
×
415
      if Ops.is_symbol?(Ops.get(event, "ID")) &&
×
416
          Builtins.contains(
×
417
            [:passdb, :global_settings],
×
418
            Ops.get_symbol(event, "ID", :cancel)
×
419
          )
×
420
        @return_tab = "identity"
×
421
        return Ops.get_symbol(event, "ID", :next)
×
422
      end
×
423
      nil
×
424
    end
×
425

426
    def InitUserShareWidgets
×
427
      @max_shares = Samba.GetMaxShares
×
428

429
      if @max_shares == 0
×
430
        @max_shares = 100
×
431
        @allow_share = false
×
432
      else
×
433
        @allow_share = true
×
434
      end
×
435

436
      @guest_access = @allow_share && Samba.GetGuessAccess
×
437

438
      @shares_group = Samba.shares_group
×
439

440
      UI.ChangeWidget(Id(:group), :Value, @shares_group)
×
441
      UI.ChangeWidget(Id(:max_shares), :Value, @max_shares)
×
442
      UI.ChangeWidget(Id(:share_ch), :Value, @allow_share)
×
443
      UI.ChangeWidget(Id(:guest_ch), :Value, @guest_access)
×
444

445
      nil
×
446
    end
×
447

448
    def AdjustUserShareWidgets
×
449
      Builtins.foreach([:group, :max_shares, :guest_ch]) do |t|
×
450
        UI.ChangeWidget(
×
451
          Id(t),
×
452
          :Enabled,
×
453
          Convert.to_boolean(UI.QueryWidget(Id(:share_ch), :Value))
×
454
        )
×
455
      end
×
456

457
      nil
×
458
    end
×
459

460
    def StoreUserShareWidgets(key, event_descr)
×
461
      event_descr = deep_copy(event_descr)
×
462
      new_share = Convert.to_boolean(UI.QueryWidget(Id(:share_ch), :Value))
×
463
      if new_share && !@allow_share && SharesExist(Samba.shares_dir)
×
464
        Samba.remove_shares = AskForSharesRemoval()
×
465
      end
×
466
      max = Convert.to_integer(UI.QueryWidget(Id(:max_shares), :Value))
×
467
      if !new_share
×
468
        max = 0
×
469
        # Samba::stop_services = AskToStopServices();
470
        Samba.stop_services = false
×
471
      end
×
472
      Samba.SetShares(
×
473
        max,
×
474
        Convert.to_string(UI.QueryWidget(Id(:group), :Value))
×
475
      )
×
476
      Samba.SetGuessAccess(
×
477
        new_share && Convert.to_boolean(UI.QueryWidget(Id(:guest_ch), :Value))
×
478
      )
×
479

480
      SambaServer.SetModified
×
481

482
      nil
×
483
    end
×
484

485
    def SharesWidgetInit(key)
×
486
      items = sharesItems(false)
×
487

488
      UI.ChangeWidget(Id(:table), :Items, items)
×
489
      UI.ChangeWidget(
×
490
        Id(:edit),
×
491
        :Enabled,
×
492
        Ops.greater_than(Builtins.size(items), 0)
×
493
      )
×
494
      UI.ChangeWidget(
×
495
        Id(:delete),
×
496
        :Enabled,
×
497
        Ops.greater_than(Builtins.size(items), 0)
×
498
      )
×
499
      UI.ChangeWidget(
×
500
        Id(:toggle),
×
501
        :Enabled,
×
502
        Ops.greater_than(Builtins.size(items), 0)
×
503
      )
×
504
      UI.ChangeWidget(
×
505
        Id(:guest),
×
506
        :Enabled,
×
507
        Ops.greater_than(Builtins.size(items), 0)
×
508
      )
×
509

510
      InitUserShareWidgets()
×
511
      AdjustUserShareWidgets()
×
512

513
      nil
×
514
    end
×
515

516
    # Bugzilla #263302
517
    def RenameShare(share)
×
518
      if !SambaConfig.ShareExists(share)
×
519
        Builtins.y2error("Share %1 doesn't exist", share)
×
520
        return false
×
521
      end
×
522

523
      content = VBox(
×
524
        # TRANSLATORS: dialog caption
525
        Heading(_("Rename Share")),
×
526
        HSquash(
×
527
          MinWidth(
×
528
            35,
×
529
            VBox(
×
530
              # TRANSLATORS: text entry
531
              InputField(
×
532
                Id("share_name"),
×
533
                Opt(:hstretch),
×
534
                _("New Share &Name"),
×
535
                share
×
536
              )
×
537
            )
×
538
          )
×
539
        ),
×
540
        VSpacing(1),
×
541
        ButtonBox(
×
542
          PushButton(Id(:ok), Opt(:okButton), Label.OKButton),
×
543
          PushButton(Id(:cancel), Opt(:cancelButton), Label.CancelButton)
×
544
        )
×
545
      )
×
546

547
      UI.OpenDialog(content)
×
548
      UI.SetFocus(Id("share_name"))
×
549

550
      fc_ret = false
×
551

552
      ret = nil
×
553
      while true
×
554
        ret = UI.UserInput
×
555

556
        if ret == :ok
×
557
          new_share_name = Convert.to_string(
×
558
            UI.QueryWidget(Id("share_name"), :Value)
×
559
          )
×
560

561
          if new_share_name == ""
×
562
            # TRANSLATORS: popup error message
563
            Report.Error(_("Enter a new share name."))
×
564
            next
×
565
          elsif share == new_share_name
×
566
            Builtins.y2milestone("Old and new share names are the same")
×
567
            break
×
568
          elsif SambaConfig.ShareExists(new_share_name)
×
569
            # TRANSLATORS: popup error message, %1 is a variable share name
570
            Report.Error(
×
571
              Builtins.sformat(
×
572
                _("Share '%1' already exists.\nChoose another share name.\n"),
×
573
                new_share_name
×
574
              )
×
575
            )
×
576
            next
×
577
          end
×
578

579
          # Renaming share
580
          old_share_settings = SambaConfig.ShareGetMap(share)
×
581
          old_share_enabled = SambaConfig.ShareEnabled(share)
×
582

583
          Builtins.y2milestone(
×
584
            "Creating new share '%1' %2 -> %3",
×
585
            new_share_name,
×
586
            old_share_settings,
×
587
            SambaConfig.ShareSetMap(new_share_name, old_share_settings)
×
588
          )
×
589
          Builtins.y2milestone(
×
590
            "Removing share '%1' -> %2",
×
591
            share,
×
592
            SambaConfig.ShareRemove(share)
×
593
          )
×
594

595
          # enable or disable new share according the old one
596
          if SambaConfig.ShareEnabled(new_share_name) != old_share_enabled
×
597
            SambaConfig.ShareAdjust(
×
598
              new_share_name,
×
599
              !SambaConfig.ShareEnabled(new_share_name)
×
600
            )
×
601
          end
×
602

603
          fc_ret = true
×
604
          break 
×
605
          # cancel
606
        else
×
607
          break
×
608
        end
×
609
      end
×
610

611
      UI.CloseDialog
×
612

613
      fc_ret
×
614
    end
×
615

616
    def SharesWidgetHandle(key, event_descr)
×
617
      event_descr = deep_copy(event_descr)
×
618
      return nil if !Ops.is_symbol?(Ops.get(event_descr, "ID"))
×
619
      ret = Ops.get_symbol(event_descr, "ID")
×
620
      @return_tab = "shares"
×
621

622
      if ret == :share_ch
×
623
        AdjustUserShareWidgets()
×
624
        return nil
×
625
      end
×
626
      return ret if ret == :add
×
627
      if ret == :filter_all || ret == :filter_non_system
×
628
        items = sharesItems(ret == :filter_non_system)
×
629
        UI.ChangeWidget(Id(:table), :Items, items)
×
630
        return nil
×
631
      end
×
632

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

636
      share = Ops.get_string(
×
637
        Builtins.argsof(
×
638
          Convert.to_term(UI.QueryWidget(Id(:table), term(:Item, id)))
×
639
        ),
×
640
        3
×
641
      )
×
642
      return nil if share == nil
×
643

644
      if ret == :edit || ret == :table
×
645
        @shareToEdit = share
×
646
        return :edit
×
647
      end
×
648
      if ret == :toggle
×
649
        SambaConfig.ShareAdjust(share, !SambaConfig.ShareEnabled(share))
×
650
        UI.ChangeWidget(Id(:table), :Items, sharesItems(false))
×
651
        UI.ChangeWidget(Id(:table), :CurrentItem, id)
×
652
        return nil
×
653
      end
×
654
      if ret == :guest
×
655
        SambaConfig.ShareSetTruth(
×
656
          share,
×
657
          "guest ok",
×
658
          !SambaConfig.ShareGetTruth(share, "guest ok", false)
×
659
        )
×
660
        UI.ChangeWidget(Id(:table), :Items, sharesItems(false))
×
661
        UI.ChangeWidget(Id(:table), :CurrentItem, id)
×
662
        return nil
×
663
      end
×
664
      if ret == :delete
×
665
        # confirmation dialog before deleting a share
666
        if Popup.YesNo(
×
667
            Builtins.sformat(
×
668
              _(
×
669
                "If you delete share %1,\n" +
×
670
                  "all its settings will be lost.\n" +
×
671
                  "Really delete it?"
×
672
              ),
×
673
              share
×
674
            )
×
675
          )
×
676
          Builtins.y2milestone(
×
677
            "Removing share '%1' -> %2",
×
678
            share,
×
679
            SambaConfig.ShareRemove(share)
×
680
          )
×
681
          UI.ChangeWidget(Id(:table), :Items, sharesItems(false))
×
682
        end
×
683
      end
×
684
      if ret == :rename
×
685
        if RenameShare(share)
×
686
          UI.ChangeWidget(Id(:table), :Items, sharesItems(false))
×
687
        end
×
688
        return nil
×
689
      end
×
690

691
      nil
×
692
    end
×
693

694

695
    def AddTrustedDomain
×
696
      #rwalter I couldn't make this one show up. Please make sure my deletions didn't make it too confusing.
697
      contents = VBox(
×
698
        InputField(Id(:domain), Opt(:hstretch), _("Trusted &Domain")),
×
699
        Password(Id(:password), _("&Password")),
×
700
        VSpacing(1),
×
701
        HBox(
×
702
          PushButton(Id(:ok), Opt(:default), Label.OKButton),
×
703
          PushButton(Id(:cancel), Label.CancelButton)
×
704
        )
×
705
      )
×
706

707
      UI.OpenDialog(contents)
×
708
      UI.SetFocus(Id(:domain))
×
709

710
      ret = nil
×
711
      begin
×
712
        ret = Convert.to_symbol(UI.UserInput)
×
713

714
        if ret == :ok
×
715
          domain = Convert.to_string(UI.QueryWidget(:domain, :Value))
×
716
          passwd = Convert.to_string(UI.QueryWidget(:password, :Value))
×
717

718
          if Builtins.size(domain) == 0
×
719
            Yast.import "Report"
×
720
            Report.Error(_("Domain name cannot be empty."))
×
721
            ret = nil
×
722
          end
×
723
          success = SambaTrustDom.Establish(domain, passwd)
×
724
          if success != true
×
725
            Yast.import "Report"
×
726
            Report.Error(_("Cannot establish trusted domain relationship."))
×
727
            ret = nil
×
728
          end
×
729
        end
×
730
      end while ret == nil
×
731

732

733
      UI.CloseDialog
×
734

735
      nil
×
736
    end
×
737

738
    def TrustedDomainsWidgetInit(key)
×
739
      if Mode.config && !@autoyast_warning_done
×
740
        # issue a warning, if not already done so
741
        Popup.Warning(
×
742
          _(
×
743
            "The password for trusted domains\n" +
×
744
              "is stored in the autoinstallation control file. The password\n" +
×
745
              "is stored as plain text. This can be considered\n" +
×
746
              "a security threat."
×
747
          )
×
748
        )
×
749
        @autoyast_warning_done = true
×
750
      end
×
751

752
      domains = []
×
753

754
      # SambaTrustDom::List() might return 'nil'
755
      samba_trust_domain_list = SambaTrustDom.List
×
756
      if samba_trust_domain_list != nil || samba_trust_domain_list != []
×
757
        Builtins.foreach(samba_trust_domain_list) do |key2|
×
758
          domains = Builtins.add(domains, Item(Id(key2), key2))
×
759
        end
×
760
      end
×
761

762
      UI.ReplaceWidget(
×
763
        Id(:domains_tr),
×
764
        SelectionBox(Id("trusted_domains"), _("&Trusted Domains"), domains)
×
765
      )
×
766

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

770
      nil
×
771
    end
×
772

773
    def TrustedDomainsWidgetHandle(key, event_descr)
×
774
      event_descr = deep_copy(event_descr)
×
775
      if Ops.get(event_descr, "ID") == :add_domain
×
776
        AddTrustedDomain()
×
777
      elsif Ops.get(event_descr, "ID") == :delete_domain
×
778
        to_delete = Convert.to_string(
×
779
          UI.QueryWidget(Id("trusted_domains"), :CurrentItem)
×
780
        )
×
781

782
        # confirmation
783
        if Popup.ContinueCancel(
×
784
            Builtins.sformat(
×
785
              _("Really abandon trust relationship\nto trusted domain %1?"),
×
786
              to_delete
×
787
            )
×
788
          )
×
789
          SambaTrustDom.Revoke(to_delete)
×
790
        end
×
791
      end
×
792

793
      # reinitialize contents
794
      TrustedDomainsWidgetInit(key)
×
795

796
      nil
×
797
    end
×
798

799
    # EditShareDialog dialog
800
    # @return dialog result
801
    def EditShareDialog
×
802
      contents = HBox(HSpacing(1), VBox(VSpacing(1), "share_edit"), HSpacing(1))
×
803

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

807

808
      CWM.ShowAndRun(
×
809
        {
×
810
          "widget_names"       => ["share_edit"],
×
811
          "widget_descr"       => @xx_widgets,
×
812
          "contents"           => contents,
×
813
          "caption"            => caption,
×
814
          "back_button"        => Label.BackButton,
×
815
          "next_button"        => Label.OKButton,
×
816
          "abort_button"        => nil
×
817
        }
×
818
      )
×
819
    end
×
820

821
    def GlobalSettingsDialog
×
822
      contents = HBox(
×
823
        HSpacing(1),
×
824
        VBox(VSpacing(1), "globalsettings"),
×
825
        HSpacing(1)
×
826
      )
×
827

828
      # dialog caption
829
      caption = _("Expert Global Settings Configuration")
×
830

831
      res = CWM.ShowAndRun(
×
832
        {
×
833
          "widget_names"       => ["globalsettings"],
×
834
          "widget_descr"       => @xx_widgets,
×
835
          "contents"           => contents,
×
836
          "caption"            => caption,
×
837
          "back_button"        => Label.BackButton,
×
838
          "next_button"        => Label.OKButton,
×
839
          "fallback_functions" => {
×
840
            :abort => fun_ref(method(:confirmAbort), "boolean ()")
×
841
          }
×
842
        }
×
843
      )
×
844

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

850
      res
×
851
    end
×
852

853
    def AddShareDialog
×
854
      default_path      = "/home"
×
855

856
      contents = HVSquash(HBox(
×
857
        HSpacing(1),
×
858
        VBox(Opt(:hstretch),
×
859
          VSpacing(1),
×
860
          # frame label
861
          Frame(_("Identification"), VBox(
×
862
            # text entry label
863
            InputField(Id(:name), Opt(:hstretch), _("Share &Name")),
×
864
            # text entry label
865
            InputField(Id(:comment), Opt(:hstretch), _("Share &Description"))
×
866
          )),
×
867
          VSpacing(1),
×
868
          # frame label
869
          Frame(_("Share Type"), HBox(
×
870
            HSpacing(1),
×
871
            VBox(Opt(:hstretch),
×
872
              RadioButtonGroup(VBox(
×
873
                # radio button label
874
                Left(RadioButton(Id(:printer), Opt(:notify), _("&Printer"))),
×
875
                # radio button label
876
                Left(RadioButton(Id(:directory), Opt(:notify), _("&Directory"), true))
×
877
              )),
×
878
              HBox(
×
879
                # translators: text entry label
880
                InputField(Id(:path), Opt(:notify), _("Share &Path"), default_path),
×
881
                VBox(
×
882
                  Label(""),
×
883
                  PushButton(Id(:browse), Label.BrowseButton)
×
884
                )
×
885
              ),
×
886
              # translators: checkbox label, setting for share
887
              Left(CheckBox(Id(:read_only), _("&Read-Only"), false)),
×
888
              # checkbox label
889
              Left(CheckBox(Id(:inherit_acls), _("&Inherit ACLs"), true)),
×
890
              # checkbox label
891
              Left(CheckBox(Id(:snapper_support), _("Expose Snapshots"), false)),
×
892
              # checkbox label
893
              Left(CheckBox(Id(:btrfs_support), _("Utilize Btrfs Features"), false))
×
894
            ),
×
895
            HSpacing(1)
×
896
          ))
×
897
        )
×
898
      ))
×
899

900
      Wizard.SetContentsButtons(
×
901
        # translators: dialog caption
902
        _("New Share"),
×
903
        contents,
×
904
        @HELPS["add_share"] || "",
×
905
        Label.BackButton,
×
906
        Label.OKButton
×
907
      )
×
908
      Wizard.HideAbortButton
×
909

910
      UI.SetFocus(Id(:name))
×
911
      UI.ChangeWidget(Id(:snapper_support), :Enabled, snapper_available? && subvolume?(default_path) && snapper_cfg?(default_path))
×
912
      UI.ChangeWidget(Id(:btrfs_support), :Enabled, btrfs_available? && subvolume?(default_path))
×
913

914
      ret = nil
×
915
      begin
×
916
        # enable/disable path
917
        on = UI.QueryWidget(Id(:directory), :Value)
×
918
        UI.ChangeWidget(Id(:path), :Enabled, on)
×
919
        UI.ChangeWidget(Id(:browse), :Enabled, on)
×
920
        UI.ChangeWidget(Id(:read_only), :Enabled, on)
×
921
        UI.ChangeWidget(Id(:inherit_acls), :Enabled, on)
×
922

923
        ret = UI.UserInput
×
924

925
        if ret == :cancel
×
926
          break if confirmAbort
×
927
          ret = nil
×
928
          next
×
929
        end
×
930

931
        if ret == :printer || ret == :directory
×
932
          ret = nil
×
933
          next
×
934
        end
×
935

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

938
        if ret == :path
×
939
          if snapper_available?
×
940
            UI.ChangeWidget(Id(:snapper_support), :Enabled, subvolume?(pathvalue) && snapper_cfg?(pathvalue))
×
941
          end
×
942
          if btrfs_available?
×
943
            UI.ChangeWidget(Id(:btrfs_support), :Enabled, subvolume?(pathvalue))
×
944
          end
×
945
          ret = nil
×
946
        elsif ret == :browse
×
947
          # translators: file selection dialog title
948
          dir = UI.AskForExistingDirectory(pathvalue, _("Path for a Share"))
×
949
          if dir
×
950
            UI.ChangeWidget(Id(:path), :Value, dir)
×
951
            if snapper_available?
×
952
              subvolume_cfg = subvolume?(dir) && snapper_cfg?(dir)
×
953
              UI.ChangeWidget(Id(:snapper_support), :Enabled, subvolume_cfg)
×
954
              UI.ChangeWidget(Id(:snapper_support), :Value, false) unless subvolume_cfg
×
955
            end
×
956
            if btrfs_available?
×
957
              subvolume = subvolume?(dir)
×
958
              UI.ChangeWidget(Id(:btrfs_support), :Enabled, subvolume)
×
959
              UI.ChangeWidget(Id(:btrfs_support), :Value, false) unless subvolume
×
960
            end
×
961
          end
×
962
          ret = nil
×
963
        elsif ret == :next
×
964
          # OK was pressed
965

966
          name          = UI.QueryWidget(Id(:name), :Value)
×
967
          comment       = UI.QueryWidget(Id(:comment), :Value)
×
968
          printable     = UI.QueryWidget(Id(:printer), :Value)
×
969

970
          if name.empty?
×
971
            # translators: error message
972
            Popup.Error(_("Share name cannot be empty."))
×
973
            ret = nil
×
974
            next
×
975
          elsif pathvalue.empty? && !printable
×
976
            # translators: error message
977
            Popup.Error(_("Share path cannot be empty."))
×
978
            ret = nil
×
979
            next
×
980
          elsif !printable && !SharePathWarning(pathvalue)
×
981
            ret = nil
×
982
            next
×
983
          elsif !printable && !Mode.config &&
×
984
              !FileUtils.CheckAndCreatePath(pathvalue)
×
985
            ret = nil
×
986
            next
×
987
          end
×
988

989
          res = { "comment" => comment }
×
990

991
          if printable
×
992
            res["printable"]    = "Yes"
×
993
            res["path"]         = "/var/tmp"
×
994
          else
×
995
            read_only           = UI.QueryWidget(Id(:read_only), :Value)
×
996
            inherit_acls        = UI.QueryWidget(Id(:inherit_acls), :Value)
×
997

998
            res["read only"]    = read_only ? "Yes" : "No"
×
999
            res["inherit acls"] = inherit_acls ? "Yes" : "No"
×
1000
            res["path"]         = pathvalue
×
1001
            res["vfs objects"]  = ""
×
1002
            if snapper_available? && UI.QueryWidget(Id(:snapper_support), :Value)
×
1003
              res["vfs objects"] << "snapper "
×
1004
            end
×
1005
            if btrfs_available? && UI.QueryWidget(Id(:btrfs_support), :Value)
×
1006
              res["vfs objects"] << "btrfs "
×
1007
            end
×
1008
          end
×
1009

1010
          if SambaConfig.ShareExists(name)
×
1011
            # translators: popup error message for "add share", %1 is share name
1012
            Popup.Error(Builtins.sformat(_("Share %1 already exists."), name))
×
1013
            ret = nil
×
1014
          end
×
1015
          SambaConfig.ShareSetMap(name, res)
×
1016
        end
×
1017
      end while ret == nil
×
1018
      ret
×
1019
    end
×
1020

1021

1022

1023
    def Installation_Conf_Tab
×
1024
      shares_widget = HBox(
×
1025
        HWeight(1, Empty()),
×
1026
        HWeight(
×
1027
          100,
×
1028
          VBox(
×
1029
            HBox(
×
1030
              Left(Label(_("Available Shares"))),
×
1031
              HStretch(),
×
1032
              Right(
×
1033
                MenuButton(
×
1034
                  _("&Filter"),
×
1035
                  [
×
1036
                    Item(Id(:filter_all), _("Show &All Shares")),
×
1037
                    Item(
×
1038
                      Id(:filter_non_system),
×
1039
                      _("Do Not Show &System Shares")
×
1040
                    )
×
1041
                  ]
×
1042
                )
×
1043
              )
×
1044
            ),
×
1045
            # translators: table header texts
1046
            Table(
×
1047
              Id(:table),
×
1048
              Opt(:hvstretch,:notify),
×
1049
              Header(
×
1050
                _("Status"),
×
1051
                _("Read-Only"),
×
1052
                _("Name"),
×
1053
                _("Path"),
×
1054
                _("Guest Access"),
×
1055
                _("Comment")
×
1056
              ),
×
1057
              []
×
1058
            ),
×
1059
            HBox(
×
1060
              PushButton(Id(:add), Ops.add(Label.AddButton, "...")),
×
1061
              PushButton(Id(:edit), Ops.add(Label.EditButton, "...")),
×
1062
              PushButton(Id(:delete), Label.DeleteButton),
×
1063
              HStretch(),
×
1064
              PushButton(Id(:rename), _("&Rename...")),
×
1065
              PushButton(Id(:guest), _("Guest Access")),
×
1066
              PushButton(Id(:toggle), _("&Toggle Status"))
×
1067
            )
×
1068
          )
×
1069
        ),
×
1070
        HWeight(1, Empty())
×
1071
      )
×
1072

1073
      wins_widget = HBox(
×
1074
        HSpacing(1),
×
1075
        VBox(
×
1076
          VSpacing(0.5),
×
1077
          RadioButtonGroup(
×
1078
            Id("wins_support"),
×
1079
            VBox(
×
1080
              Left(
×
1081
                RadioButton(
×
1082
                  Id("wins_server_support"),
×
1083
                  Opt(:notify),
×
1084
                  _("WINS Server Support")
×
1085
                )
×
1086
              ),
×
1087
              Left(
×
1088
                RadioButton(
×
1089
                  Id("remote_wins_server"),
×
1090
                  Opt(:notify),
×
1091
                  _("Remote WINS Server")
×
1092
                )
×
1093
              )
×
1094
            )
×
1095
          ),
×
1096
          HBox(HSpacing(3), TextEntry(Id("wins_server_name"), _("Na&me"))),
×
1097
          VSpacing(1)
×
1098
        ),
×
1099
        HSpacing(1)
×
1100
      )
×
1101

1102
      wins_via_dhcp = DHCPSupportTerm(Samba.GetDHCP)
×
1103

1104
      # TRANSLATORS: check box
1105
      wins_host_resolution = Left(
×
1106
        CheckBox(Id(:wins_dns), _("Use WINS for Hostname Resolution"))
×
1107
      )
×
1108

1109
      roles = [
×
1110
        # translators: combobox item
1111
        Item(Id("STANDALONE"), _("Not a DC")),
×
1112
        # translators: combobox item
1113
        Item(Id("PDC"), _("Primary (PDC)"))
×
1114
      ]
×
1115

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

1119
      basesettings_widget = Frame(
×
1120
        _("Base Settings"),
×
1121
        HBox(
×
1122
          HSpacing(1),
×
1123
          VBox(
×
1124
            # `ComboBox(`id("workgroup_domainname"), `opt(`editable, `hstretch), _("&Workgroup or Domain Name"),
1125
            #        SambaNmbLookup::GetAvailableNeighbours(nil)),
1126
            InputField(
×
1127
              Id("workgroup_domainname"),
×
1128
              Opt(:hstretch),
×
1129
              _("&Workgroup or Domain Name")
×
1130
            ),
×
1131
            # translators: combobox label
1132
            ComboBox(
×
1133
              Id("domain_controller"),
×
1134
              Opt(:hstretch),
×
1135
              _("Domain &Controller"),
×
1136
              roles
×
1137
            ),
×
1138
            VStretch()
×
1139
          ),
×
1140
          HSpacing(1)
×
1141
        )
×
1142
      )
×
1143

1144
      advanced_settings_widget = MenuButton(
×
1145
        _("Advanced Settings..."),
×
1146
        [
×
1147
          Item(Id(:global_settings), _("&Expert Global Settings")),
×
1148
          Item(Id(:passdb), _("&User Authentication Sources"))
×
1149
        ]
×
1150
      )
×
1151

1152
      trusted_domains_widget = HBox(
×
1153
        HWeight(1, Empty()),
×
1154
        HWeight(
×
1155
          100,
×
1156
          VBox(
×
1157
            VWeight(
×
1158
              7,
×
1159
              ReplacePoint(
×
1160
                Id(:domains_tr),
×
1161
                SelectionBox(Id("trusted_domains"), _("&Trusted Domains"), [])
×
1162
              )
×
1163
            ),
×
1164
            VWeight(
×
1165
              1,
×
1166
              HBox(
×
1167
                PushButton(Id(:add_domain), Ops.add(Label.AddButton, "...")),
×
1168
                PushButton(Id(:delete_domain), Label.DeleteButton),
×
1169
                HStretch()
×
1170
              )
×
1171
            ),
×
1172
            VStretch()
×
1173
          )
×
1174
        ),
×
1175
        HWeight(1, Empty())
×
1176
      )
×
1177

1178
      caption = _("Samba Configuration")
×
1179

1180
      tabs_descr = {
×
1181
        "startup"  => {
×
1182
          #tab label
1183
          "header"       => _("Start-&Up"),
×
1184
          "contents"     => HBox(
×
1185
            HWeight(2, Empty()),
×
1186
            HWeight(
×
1187
              100,
×
1188
              VBox(
×
1189
                VSpacing(1),
×
1190
                "service_widget",
×
1191
                VSpacing(1),
×
1192
                "FIREWALL",
×
1193
                VStretch()
×
1194
              )
×
1195
            ),
×
1196
            HWeight(2, Empty())
×
1197
          ),
×
1198
          "widget_names" => ["service_widget", "FIREWALL"]
×
1199
        },
×
1200
        "shares"   => {
×
1201
          "header"       => _("&Shares"),
×
1202
          "contents"     => VBox(
×
1203
            VBox("SHARES"),
×
1204
            HBox(
×
1205
              HSpacing(1),
×
1206
              # Bugzilla #143908
1207
              # Bugzilla #144787, comment #43
1208
              SharesTerm(
×
1209
                {
×
1210
                  "allow_share"  => @allow_share,
×
1211
                  "group"        => @shares_group,
×
1212
                  "max_shares"   => @max_shares,
×
1213
                  # BNC #579993, Allow guest access
1214
                  "guest_access" => @guest_access
×
1215
                }
×
1216
              ),
×
1217
              HSpacing(1)
×
1218
            ),
×
1219
            VSpacing(1)
×
1220
          ),
×
1221
          "widget_names" => ["SHARES"]
×
1222
        },
×
1223
        "identity" => {
×
1224
          "header"       => _("I&dentity"),
×
1225
          "contents"     => HBox(
×
1226
            "IDENTITY COMMON HELP",
×
1227
            HWeight(1, Empty()),
×
1228
            HWeight(
×
1229
              100,
×
1230
              VBox(
×
1231
                VSpacing(0.5),
×
1232
                VBox(
×
1233
                  HBox(
×
1234
                    HWeight(1, VBox("BASE SETTINGS")),
×
1235
                    HSpacing(0.5),
×
1236
                    HWeight(
×
1237
                      1,
×
1238
                      Frame(
×
1239
                        _("WINS"),
×
1240
                        VBox(
×
1241
                          "WINS SETTINGS",
×
1242
                          HBox(HSpacing(1), "WINS via DHCP"),
×
1243
                          HBox(HSpacing(1), "WINS Host Resolution"),
×
1244
                          VStretch()
×
1245
                        )
×
1246
                      )
×
1247
                    )
×
1248
                  ),
×
1249
                  VSpacing(0.5),
×
1250
                  HBox(
×
1251
                    HWeight(1, VBox("netbios name", "ADVANCED SETTINGS")),
×
1252
                    HSpacing(0.5),
×
1253
                    HWeight(1, Empty())
×
1254
                  )
×
1255
                ),
×
1256
                VStretch()
×
1257
              )
×
1258
            ),
×
1259
            HWeight(1, Empty())
×
1260
          ),
×
1261
          "widget_names" => [
×
1262
            "IDENTITY COMMON HELP",
×
1263
            "BASE SETTINGS",
×
1264
            "WINS SETTINGS",
×
1265
            "WINS via DHCP",
×
1266
            "WINS Host Resolution",
×
1267
            "netbios name",
×
1268
            "ADVANCED SETTINGS"
×
1269
          ]
×
1270
        }
×
1271
      }
×
1272

1273
      tabs_descr = Builtins.union(
×
1274
        tabs_descr,
×
1275
        {
×
1276
          "trusted_domains_tab" => {
×
1277
            "header"       => _("&Trusted Domains"),
×
1278
            "contents"     => VBox("TRUSTED DOMAINS"),
×
1279
            "widget_names" => ["TRUSTED DOMAINS"]
×
1280
          },
×
1281
          "ldap_settings_tab"   => {
×
1282
            "header"       => _("&LDAP Settings"),
×
1283
            "contents"     => VBox("LDAP ESSENTIAL"),
×
1284
            "widget_names" => ["LDAP ESSENTIAL"]
×
1285
          }
×
1286
        }
×
1287
      )
×
1288

1289
      tabs_widget_descr = {
×
1290
        "service_widget"       => service_widget.cwm_definition,
×
1291
        # BNC #247344, BNC #541958 (comment #18)
1292
        "FIREWALL"             => CWMFirewallInterfaces.CreateOpenFirewallWidget(
×
1293
          {
×
1294
            # Firewalld default service definition
1295
            "services"        => ["samba"],
×
1296
            "display_details" => true
×
1297
          }
×
1298
        ),
×
1299
        "SHARES"               => {
×
1300
          "widget"        => :custom,
×
1301
          "custom_widget" => shares_widget,
×
1302
          "init"          => fun_ref(method(:SharesWidgetInit), "void (string)"),
×
1303
          "handle"        => fun_ref(
×
1304
            method(:SharesWidgetHandle),
×
1305
            "symbol (string, map)"
×
1306
          ),
×
1307
          "store"         => fun_ref(
×
1308
            method(:StoreUserShareWidgets),
×
1309
            "void (string, map)"
×
1310
          ),
×
1311
          "help"          => Ops.add(
×
1312
            Ops.get_string(@HELPS, "smb_conf_tab_shares", ""),
×
1313
            SharesHelp()
×
1314
          )
×
1315
        },
×
1316
        "IDENTITY COMMON HELP" => {
×
1317
          "widget"        => :custom,
×
1318
          "custom_widget" => Empty(),
×
1319
          "help"          => Ops.get_string(@HELPS, "smb_conf_tab_identity", "")
×
1320
        },
×
1321
        "BASE SETTINGS"        => {
×
1322
          "widget"        => :custom,
×
1323
          "custom_widget" => basesettings_widget,
×
1324
          "help"          => Ops.get_string(
×
1325
            @HELPS,
×
1326
            "smb_conf_tab_base_settings",
×
1327
            ""
×
1328
          ),
×
1329
          "init"          => fun_ref(
×
1330
            method(:BaseSettingsWidgetInit),
×
1331
            "void (string)"
×
1332
          ),
×
1333
          "store"         => fun_ref(
×
1334
            method(:BaseSettingsWidgetStore),
×
1335
            "void (string, map)"
×
1336
          )
×
1337
        },
×
1338
        "WINS SETTINGS"        => {
×
1339
          "widget"        => :custom,
×
1340
          "custom_widget" => wins_widget,
×
1341
          "help"          => HostsResolutionHelp(),
×
1342
          "init"          => fun_ref(
×
1343
            method(:WinsSettingsWidgetInit),
×
1344
            "void (string)"
×
1345
          ),
×
1346
          "store"         => fun_ref(
×
1347
            method(:WinsSettingsWidgetStore),
×
1348
            "void (string, map)"
×
1349
          ),
×
1350
          "handle"        => fun_ref(
×
1351
            method(:WinsSettingsWidgetHandle),
×
1352
            "symbol (string, map)"
×
1353
          )
×
1354
        },
×
1355
        "WINS via DHCP"        => {
×
1356
          "widget"        => :custom,
×
1357
          "custom_widget" => wins_via_dhcp,
×
1358
          "help"          => Ops.get_string(
×
1359
            @HELPS,
×
1360
            "smb_conf_tab_wins_via_dhcp",
×
1361
            ""
×
1362
          ),
×
1363
          "init"          => fun_ref(
×
1364
            method(:WinsViaDHCPWidgetInit),
×
1365
            "void (string)"
×
1366
          ),
×
1367
          "store"         => fun_ref(
×
1368
            method(:WinsViaDHCPWidgetStore),
×
1369
            "void (string, map)"
×
1370
          )
×
1371
        },
×
1372
        "WINS Host Resolution" => {
×
1373
          "widget"        => :custom,
×
1374
          "custom_widget" => wins_host_resolution,
×
1375
          "help"          => Ops.get_string(
×
1376
            @HELPS,
×
1377
            "smb_conf_tab_wins_host_resolution",
×
1378
            ""
×
1379
          ),
×
1380
          "init"          => fun_ref(
×
1381
            method(:WinsHostResolutionWidgetInit),
×
1382
            "void (string)"
×
1383
          ),
×
1384
          "store"         => fun_ref(
×
1385
            method(:WinsHostResolutionWidgetStore),
×
1386
            "void (string, map)"
×
1387
          )
×
1388
        },
×
1389
        "netbios name"         => {
×
1390
          "widget" => :textentry,
×
1391
          "label"  => _("NetBIOS &Hostname"),
×
1392
          "help"   => Ops.get_string(@HELPS, "smb_conf_tab_netbios_name", ""),
×
1393
          "init"   => fun_ref(
×
1394
            method(:GlobalConfigStringWidgetInit),
×
1395
            "void (string)"
×
1396
          ),
×
1397
          "store"  => fun_ref(
×
1398
            method(:GlobalConfigStringWidgetStore),
×
1399
            "void (string, map)"
×
1400
          )
×
1401
        },
×
1402
        "ADVANCED SETTINGS"    => {
×
1403
          "widget"        => :custom,
×
1404
          "custom_widget" => advanced_settings_widget,
×
1405
          "help"          => Ops.get_string(
×
1406
            @HELPS,
×
1407
            "smb_conf_tab_advanced_settings",
×
1408
            ""
×
1409
          ),
×
1410
          "handle"        => fun_ref(
×
1411
            method(:AdvancedSettingsWidgetHandle),
×
1412
            "symbol (string, map)"
×
1413
          )
×
1414
        },
×
1415
        "TRUSTED DOMAINS"      => {
×
1416
          "widget"        => :custom,
×
1417
          "custom_widget" => trusted_domains_widget,
×
1418
          "init"          => fun_ref(
×
1419
            method(:TrustedDomainsWidgetInit),
×
1420
            "void (string)"
×
1421
          ),
×
1422
          "handle"        => fun_ref(
×
1423
            method(:TrustedDomainsWidgetHandle),
×
1424
            "symbol (string, map)"
×
1425
          ),
×
1426
          "help"          => Ops.get_string(
×
1427
            @HELPS,
×
1428
            "smb_conf_tab_trusted_domains",
×
1429
            ""
×
1430
          )
×
1431
        },
×
1432
        "LDAP ESSENTIAL"       => CreateSambaLDAPSettingsEssentialWidget()
×
1433
      }
×
1434

1435
      widget_descr = {
×
1436
        "tab" => CWMTab.CreateWidget(
×
1437
          {
×
1438
            "tab_order"    => [
×
1439
              "startup",
×
1440
              "shares",
×
1441
              "identity",
×
1442
              "trusted_domains_tab",
×
1443
              "ldap_settings_tab"
×
1444
            ],
×
1445
            "tabs"         => tabs_descr,
×
1446
            "widget_descr" => tabs_widget_descr,
×
1447
            "initial_tab"  => @return_tab,
×
1448
            "tab_help"     => ""
×
1449
          }
×
1450
        )
×
1451
      }
×
1452

1453
      contents = VBox("tab", VStretch())
×
1454

1455
      w = CWM.CreateWidgets(
×
1456
        ["tab"],
×
1457
        Convert.convert(
×
1458
          widget_descr,
×
1459
          :from => "map",
×
1460
          :to   => "map <string, map <string, any>>"
×
1461
        )
×
1462
      )
×
1463
      help = CWM.MergeHelps(w)
×
1464
      contents = CWM.PrepareDialog(contents, w)
×
1465

1466
      Wizard.SetContentsButtons(
×
1467
        caption,
×
1468
        contents,
×
1469
        help,
×
1470
        Label.BackButton,
×
1471
        Label.OKButton
×
1472
      )
×
1473

1474
      # BNC #440538
1475
      # Adjusted according to the YaST Style Guide
1476
      Wizard.SetAbortButton(:abort, Label.CancelButton)
×
1477
      Wizard.HideBackButton
×
1478

1479
      ret = CWM.Run(
×
1480
        w,
×
1481
        { :abort => fun_ref(method(:confirmAbort), "boolean ()") }
×
1482
      )
×
1483

1484
      deep_copy(ret)
×
1485
    end
×
1486

1487

1488
    # Dialog to configure passdb backends.
1489
    # @return dialog result
1490
    def PassdbDialog
×
1491
      # dialog caption
1492
      caption = _("User Information Sources")
×
1493

1494
      w = CWM.CreateWidgets(
×
1495
        ["passdb_edit"],
×
1496
        Convert.convert(
×
1497
          @xx_widgets,
×
1498
          :from => "map",
×
1499
          :to   => "map <string, map <string, any>>"
×
1500
        )
×
1501
      )
×
1502

1503
      contents = HBox(
×
1504
        HSpacing(1),
×
1505
        VBox(VSpacing(1), Ops.get_term(w, [0, "widget"]) { VSpacing(0) }),
×
1506
        HSpacing(1)
×
1507
      )
×
1508

1509
      help = CWM.MergeHelps(w)
×
1510

1511
      Wizard.SetContentsButtons(
×
1512
        caption,
×
1513
        contents,
×
1514
        help,
×
1515
        Label.BackButton,
×
1516
        Label.OKButton
×
1517
      )
×
1518

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

1532

1533
    def EnsureRootAccountDialog
×
1534
      if SambaRole.GetRole != "PDC" || Mode.autoinst || Mode.test ||
×
1535
          SambaAccounts.UserExists("root")
×
1536
        return :ok
×
1537
      end
×
1538

1539
      # try to create it
1540

1541
      # first, ask for password
1542
      UI.OpenDialog(
×
1543
        HVSquash(
×
1544
          VBox(
×
1545
            Label(
×
1546
              _(
×
1547
                "For a proper function, Samba server needs an\n" +
×
1548
                  "administrative account (root).\n" +
×
1549
                  "It will be created now."
×
1550
              )
×
1551
            ),
×
1552
            Password(Id(:passwd1), _("Samba root &Password")),
×
1553
            Password(Id(:passwd2), _("&Verify Password")),
×
1554
            HBox(
×
1555
              PushButton(Id(:ok), Opt(:default), Label.OKButton),
×
1556
              PushButton(Id(:cancel), Label.CancelButton)
×
1557
            )
×
1558
          )
×
1559
        )
×
1560
      )
×
1561
      UI.SetFocus(Id(:passwd1))
×
1562

1563
      ret = nil
×
1564
      passwd = nil
×
1565
      begin
×
1566
        ret = UI.UserInput
×
1567
        if ret == :ok
×
1568
          passwd1 = Convert.to_string(UI.QueryWidget(Id(:passwd1), :Value))
×
1569
          passwd2 = Convert.to_string(UI.QueryWidget(Id(:passwd2), :Value))
×
1570
          if passwd1 != passwd2
×
1571
            # TRANSLATORS: popup error message
1572
            Popup.Error(
×
1573
              _(
×
1574
                "The first and the second version\nof the password do not match."
×
1575
              )
×
1576
            )
×
1577
            ret = nil
×
1578
          else
×
1579
            passwd = passwd1
×
1580
          end
×
1581
        end
×
1582
      end while ret == nil
×
1583

1584
      UI.CloseDialog
×
1585
      return :cancel if ret == :cancel
×
1586

1587
      if SambaAccounts.UserAdd("root", passwd)
×
1588
        # TRANSLATORS: popup error message, %1 is a username
1589
        Popup.Error(
×
1590
          Builtins.sformat(_("Cannot create account for user %1."), "root")
×
1591
        )
×
1592
        return :error
×
1593
      end
×
1594

1595
      :ok
×
1596
    end
×
1597

1598

1599
    def AskJoinDomainDialog
×
1600
      workgroup = SambaConfig.GlobalGetStr("workgroup", "")
×
1601
      role = SambaRole.GetRole
×
1602

1603
      # for autoyast, skip testing
1604
      if Mode.config || role != "MEMBER" && role != "BDC"
×
1605
        #      (!SambaNmbLookup::IsDomain(workgroup)))
1606
        return :ok
×
1607
      end
×
1608

1609
      SambaAD.ReadADS(workgroup)
×
1610
      SambaAD.ReadRealm
×
1611
      res = SambaNetJoin.Test(workgroup)
×
1612
      return :ok if res == true
×
1613

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

1622
      user = "Administrator"
×
1623
      passwd = ""
×
1624
      UI.OpenDialog(
×
1625
        VBox(
×
1626
          # translators: popup to fill in the domain joining info; %1 is the domain name
1627
          Label(
×
1628
            Ops.add(
×
1629
              Ops.add(
×
1630
                Ops.add(
×
1631
                  Builtins.sformat(
×
1632
                    _(
×
1633
                      "Enter the username and the password\nfor joining the domain %1."
×
1634
                    ),
×
1635
                    workgroup
×
1636
                  ),
×
1637
                  "\n\n"
×
1638
                ),
×
1639
                _(
×
1640
                  "To join the domain anonymously, leave the\ntext entries empty."
×
1641
                )
×
1642
              ),
×
1643
              "\n"
×
1644
            )
×
1645
          ),
×
1646
          # text entry label
1647
          TextEntry(Id(:user), _("&Username"), user),
×
1648
          # text entry label
1649
          Password(Id(:passwd), _("&Password")),
×
1650
          HBox(
×
1651
            # translators: button label to skip joining to domain
1652
            PushButton(Id(:skip), _("Do &Not Join")),
×
1653
            PushButton(Id(:cancel), Label.CancelButton),
×
1654
            PushButton(Id(:ok), Opt(:default), Label.OKButton)
×
1655
          )
×
1656
        )
×
1657
      )
×
1658

1659
      ret = UI.UserInput
×
1660

1661
      user = Convert.to_string(UI.QueryWidget(Id(:user), :Value))
×
1662
      passwd = Convert.to_string(UI.QueryWidget(Id(:passwd), :Value))
×
1663

1664
      UI.CloseDialog
×
1665

1666
      return :skip if ret == :skip
×
1667
      return :cancel if ret != :ok
×
1668

1669
      relname = OSRelease.ReleaseName
×
1670
      relver = OSRelease.ReleaseVersion
×
1671
      # try to join the domain
1672
      error = SambaNetJoin.Join(
×
1673
        workgroup,
×
1674
        Builtins.tolower(role),
×
1675
        user,
×
1676
        passwd,
×
1677
        "",
×
1678
        relname,
×
1679
        relver
×
1680
      )
×
1681
      if error != nil
×
1682
        Popup.Error(error)
×
1683
        return :error
×
1684
      end
×
1685

1686
      # Translators: Information popup, %1 is the name of the domain
1687
      Popup.Message(
×
1688
        Builtins.sformat(_("Domain %1 joined successfully."), workgroup)
×
1689
      )
×
1690
      :ok
×
1691
    end
×
1692
  end
×
1693
end
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc