• 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-items.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:        modules/dialogs-items.ycp
23
# Package:        Configuration of samba-server
24
# Summary:        Widgets used by SAMBA server configuration
25
# Authors:        Jiri Srain <jsrain@suse.cz>
26
#                Stanislav Visnovsky <visnov@suse.cz>
27
#                Martin Lazar <mlazar@suse.cz>
28
#
29
# $Id$
30
module Yast
×
31
  module SambaServerDialogsItemsInclude
×
32
    def initialize_samba_server_dialogs_items(include_target)
×
33
      Yast.import "UI"
×
34

35
      textdomain "samba-server"
×
36

37
      Yast.import "Label"
×
38
      Yast.import "Popup"
×
39
      Yast.import "LogView"
×
40
      Yast.import "TablePopup"
×
41
      Yast.import "FileUtils"
×
42
      Yast.import "Report"
×
43

44
      Yast.import "SambaServer"
×
45
      Yast.import "SambaConfig"
×
46
      Yast.import "SambaBackend"
×
47

48
      Yast.include include_target, "samba-server/helps.rb"
×
49
      Yast.include include_target, "samba-server/complex.rb"
×
50

51
      Yast.include include_target, "samba-server/samba-options-local.rb"
×
52
      Yast.include include_target, "samba-server/samba-options-global.rb"
×
53

54
      #//////////////////////////////////
55
      @shareswidget = TablePopup.CreateTableDescr(
×
56
        {
×
57
          "add_delete_buttons" => true,
×
58
          "up_down_buttons"    => false,
×
59
          "unique_keys"        => true
×
60
        },
×
61
        {
×
62
          "init"          => fun_ref(method(:ShareInitFun), "void (string)"),
×
63
          "handle"        => fun_ref(
×
64
            method(:ShareHandleFun),
×
65
            "symbol (string, map)"
×
66
          ),
×
67
          "options"       => @local_option_widgets,
×
68
          "ids"           => fun_ref(method(:ShareEditContents), "list (map)"),
×
69
          "fallback"      => {
×
70
            "init"    => fun_ref(
×
71
              method(:ShareEditPopupInit),
×
72
              "void (any, string)"
×
73
            ),
×
74
            "store"   => fun_ref(
×
75
              method(:ShareEditPopupStore),
×
76
              "void (any, string)"
×
77
            ),
×
78
            "summary" => fun_ref(
×
79
              method(:ShareEditSummary),
×
80
              "string (any, string)"
×
81
            )
×
82
          },
×
83
          "option_delete" => fun_ref(
×
84
            method(:ShareEditEntryDelete),
×
85
            "boolean (any, string)"
×
86
          ),
×
87
          "add_items"     => Builtins.maplist(@local_option_widgets) do |key, values|
×
88
            key
×
89
          end,
×
90
          "help"          => Ops.get_string(@HELPS, "share_edit", "")
×
91
        }
×
92
      )
×
93

94
      @globalsettingswidget = TablePopup.CreateTableDescr(
×
95
        {
×
96
          "add_delete_buttons" => true,
×
97
          "up_down_buttons"    => false,
×
98
          "unique_keys"        => true
×
99
        },
×
100
        {
×
101
          "options"       => @global_option_widgets,
×
102
          "ids"           => fun_ref(
×
103
            method(:GlobalSettingsContents),
×
104
            "list (map)"
×
105
          ),
×
106
          "fallback"      => {
×
107
            "init"    => fun_ref(
×
108
              method(:GlobalSettingsPopupInit),
×
109
              "void (any, string)"
×
110
            ),
×
111
            "store"   => fun_ref(
×
112
              method(:GlobalSettingsPopupStore),
×
113
              "void (any, string)"
×
114
            ),
×
115
            "summary" => fun_ref(
×
116
              method(:GlobalSettingsSummary),
×
117
              "string (any, string)"
×
118
            )
×
119
          },
×
120
          "option_delete" => fun_ref(
×
121
            method(:GlobalSettingsEntryDelete),
×
122
            "boolean (any, string)"
×
123
          ),
×
124
          "add_items"     => Builtins.maplist(@global_option_widgets) do |key, values|
×
125
            key
×
126
          end,
×
127
          "help"          => Ops.get_string(@HELPS, "global_settings", "")
×
128
        }
×
129
      )
×
130

131
      @passdboptions =
×
132
        # MySQL will not be offered, unknown backend
133
        #    "mysql" : $[
134
        #        "table" : $[
135
        #            // table entry description for MySQL-based SAM
136
        #           "label" : _("MySQL database"),
137
        #        ],
138
        #        "popup" : $[
139
        #         "widget" : `textentry,
140
        #        ],
141
        #    ],
142
        {
×
143
          "smbpasswd" => {
×
144
            "table" => {
×
145
              # table entry description for smbpasswd-based SAM
146
              "label" => _(
×
147
                "smbpasswd file"
×
148
              )
×
149
            },
×
150
            "popup" => { "widget" => :textentry }
×
151
          },
×
152
          "ldapsam"   => {
×
153
            "table" => {
×
154
              # table entry description for LDAP-based SAM
155
              "label" => _("LDAP")
×
156
            },
×
157
            "popup" => {
×
158
              "widget"            => :textentry,
×
159
              "validate_type"     => :function,
×
160
              "validate_function" => fun_ref(
×
161
                method(:ValidateLDAPURL),
×
162
                "boolean (any, string, map)"
×
163
              )
×
164
            }
×
165
          },
×
166
          "tdbsam"    => {
×
167
            "table" => {
×
168
              # table entry description for TDB-based SAM
169
              "label" => _(
×
170
                "TDB database"
×
171
              )
×
172
            },
×
173
            "popup" => { "widget" => :textentry }
×
174
          }
×
175
        }
×
176

177
      @passdbwidget = TablePopup.CreateTableDescr(
×
178
        {
×
179
          "add_delete_buttons" => true,
×
180
          "up_down_buttons"    => false,
×
181
          "unique_keys"        => false
×
182
        },
×
183
        {
×
184
          "init"              => fun_ref(method(:initPassdb), "void (string)"),
×
185
          "handle"            => fun_ref(
×
186
            method(:handlePassdb),
×
187
            "symbol (string, map)"
×
188
          ),
×
189
          "store"             => fun_ref(
×
190
            method(:storePassdb),
×
191
            "void (string, map)"
×
192
          ),
×
193
          "ids"               => fun_ref(
×
194
            method(:PassdbEditContents),
×
195
            "list (map)"
×
196
          ),
×
197
          "help"              => Ops.get_string(@HELPS, "passdb_edit", ""),
×
198
          "options"           => @passdboptions,
×
199
          "add_items"         => ["smbpasswd", "ldapsam", "tdbsam"],
×
200
          "add_unlisted"      => false,
×
201
          "id2key"            => fun_ref(
×
202
            method(:PassdbId2Key),
×
203
            "string (map, any)"
×
204
          ),
×
205
          "option_delete"     => fun_ref(
×
206
            method(:PassdbEntryDelete),
×
207
            "boolean (any, string)"
×
208
          ),
×
209
          "validate_type"     => :function,
×
210
          "validate_function" => fun_ref(
×
211
            method(:PassdbEditOptionValidate),
×
212
            "boolean (string, map)"
×
213
          ),
×
214
          # only one passdb backend is possible
215
          # "option_move" : PassdbOptionMove,
216
          "fallback"          => {
×
217
            "init"    => fun_ref(
×
218
              method(:PassdbEditOptionInit),
×
219
              "void (any, string)"
×
220
            ),
×
221
            "store"   => fun_ref(
×
222
              method(:PassdbEditOptionStore),
×
223
              "void (any, string)"
×
224
            ),
×
225
            "summary" => fun_ref(
×
226
              method(:PassdbEditOptionSummary),
×
227
              "string (any, string)"
×
228
            )
×
229
          }
×
230
        }
×
231
      )
×
232

233

234
      # Map of widgets for CWM
235
      @xx_widgets = {
×
236
        "share_edit"     => @shareswidget,
×
237
        "passdb_edit"    => @passdbwidget,
×
238
        "globalsettings" => @globalsettingswidget
×
239
      }
×
240

241

242
      # A share name do be editted in the Edit share dialog
243
      @shareToEdit = nil
×
244

245
      #************************************ passdb list table ***********************************
246

247
      @max_id = 0
×
248
      @passdb_backends = nil
×
249
      @passdb_order = []
×
250
    end
×
251

252
    def ValidateLDAPURL(opt_id, opt_key, event_descr)
×
253
      opt_id = deep_copy(opt_id)
×
254
      event_descr = deep_copy(event_descr)
×
255
      Yast.import "URL"
×
256

257
      url = Convert.to_string(UI.QueryWidget(Id(opt_key), :Value))
×
258

259
      if Builtins.regexpmatch(url, "^[ \t]+")
×
260
        # TRANSLATORS: popup error
261
        Report.Error(_("Optional value must not begin with a space character."))
×
262
        return false
×
263
      end
×
264

265
      quotes_used = false
×
266

267
      # ldapsam:"ldap://ldap1.example.com ldap://ldap2.example.com"
268
      if Builtins.regexpmatch(url, "^\".*\"[ \t]*$")
×
269
        quotes_used = true
×
270
        url = Builtins.regexpsub(url, "^\"(.*)\"[ \t]*$", "\\1")
×
271
      end
×
272

273
      urls = Builtins.splitstring(url, " \t")
×
274
      urls = Builtins.filter(urls) { |url2| url2 != "" }
×
275

276
      if Ops.greater_than(Builtins.size(urls), 1) && !quotes_used
×
277
        # TRANSLATORS: popup error
278
        Report.Error(
×
279
          _("Multiple optional values for one backend must be quoted.")
×
280
        )
×
281
        return false
×
282
      end
×
283

284
      ret = true
×
285
      Builtins.foreach(urls) do |url2|
×
286
        next if ret != true
×
287
        if !URL.Check(url2)
×
288
          Builtins.y2error("Invalid url '%1'", url2)
×
289
          # TRANSLATORS: popup error, %1 is replaced with some URL
290
          Popup.Error(
×
291
            Builtins.sformat(_("The entered URL '%1' is invalid"), url2)
×
292
          )
×
293
          ret = false
×
294
        end
×
295
        u = URL.Parse(url2)
×
296
        if Ops.get(u, "scheme") != "ldap" && Ops.get(u, "scheme") != "ldaps"
×
297
          Builtins.y2error("Invalid url '%1'", url2)
×
298
          # TRANSLATORS: popup error, %1 is replaced with some URL
299
          Popup.Error(
×
300
            Builtins.sformat(_("The entered URL '%1' is invalid"), url2)
×
301
          )
×
302
          ret = false
×
303
        end
×
304
      end
×
305

306
      ret
×
307
    end
×
308

309
    def SharePathWarning(p)
×
310
      text = nil
×
311

312
      if p == "/"
×
313
        text = @root_warning
×
314
      else
×
315
        text = Ops.get(@warnings, p) if Ops.get(@warnings, p) != nil
×
316
      end
×
317

318
      return Popup.ContinueCancel(text) if text != nil
×
319

320
      true
×
321
    end
×
322
    def ValidateSharePath(opt_id, opt_key, event_descr)
×
323
      opt_id = deep_copy(opt_id)
×
324
      event_descr = deep_copy(event_descr)
×
325
      p = Convert.to_string(UI.QueryWidget(Id(opt_key), :Value))
×
326

327
      return false if !SharePathWarning(p)
×
328
      return false if !FileUtils.CheckAndCreatePath(p)
×
329

330
      true
×
331
    end
×
332
    def ShareInitFun(key)
×
333
      TablePopup.TableInit(Ops.get_map(@xx_widgets, "share_edit", {}), key)
×
334

335
      nil
×
336
    end
×
337
    def ShareHandleFun(key, event_descr)
×
338
      event_descr = deep_copy(event_descr)
×
339
      TablePopup.TableHandle(
×
340
        Ops.get_map(@xx_widgets, "share_edit", {}),
×
341
        key,
×
342
        event_descr
×
343
      )
×
344
    end
×
345
    def ShareEditContents(descr)
×
346
      descr = deep_copy(descr)
×
347
      SambaConfig.ShareKeys(@shareToEdit)
×
348
    end
×
349
    def ShareEditEntryDelete(opt_id, opt_key)
×
350
      opt_id = deep_copy(opt_id)
×
351
      # message popup
352
      return false if !Popup.YesNo(_("Delete the selected entry?"))
×
353
      SambaConfig.ShareSetStr(@shareToEdit, opt_key, nil)
×
354
      true
×
355
    end
×
356
    def ShareEditPopupInit(opt_id, opt_key)
×
357
      opt_id = deep_copy(opt_id)
×
358
      if opt_id != nil
×
359
        # not adding a new option
360
        val = UI.QueryWidget(Id(opt_key), :Value)
×
361
        if Ops.is_boolean?(val)
×
362
          UI.ChangeWidget(
×
363
            Id(opt_key),
×
364
            :Value,
×
365
            SambaConfig.ShareGetTruth(@shareToEdit, opt_key, nil)
×
366
          )
×
367
        else
×
368
          UI.ChangeWidget(
×
369
            Id(opt_key),
×
370
            :Value,
×
371
            SambaConfig.ShareGetStr(@shareToEdit, opt_key, nil)
×
372
          )
×
373
        end
×
374
      end
×
375
      UI.SetFocus(Id(opt_key))
×
376

377
      nil
×
378
    end
×
379
    def ShareEditPopupStore(opt_id, opt_key)
×
380
      opt_id = deep_copy(opt_id)
×
381
      val = UI.QueryWidget(Id(opt_key), :Value)
×
382
      if Ops.is_boolean?(val)
×
383
        SambaConfig.ShareSetTruth(
×
384
          @shareToEdit,
×
385
          opt_key,
×
386
          Convert.to_boolean(val)
×
387
        )
×
388
      else
×
389
        SambaConfig.ShareSetStr(@shareToEdit, opt_key, Convert.to_string(val))
×
390
      end
×
391

392
      nil
×
393
    end
×
394
    def ShareEditSummary(opt_id, opt_key)
×
395
      opt_id = deep_copy(opt_id)
×
396
      SambaConfig.ShareGetStr(@shareToEdit, opt_key, "")
×
397
    end
×
398
    def GlobalSettingsContents(descr)
×
399
      descr = deep_copy(descr)
×
400
      SambaConfig.GlobalKeys
×
401
    end
×
402
    def GlobalSettingsEntryDelete(opt_id, opt_key)
×
403
      opt_id = deep_copy(opt_id)
×
404
      # message popup
405
      return false if !Popup.YesNo(_("Delete the selected entry?"))
×
406
      SambaConfig.GlobalSetStr(opt_key, nil)
×
407
      true
×
408
    end
×
409
    def GlobalSettingsPopupInit(opt_id, opt_key)
×
410
      opt_id = deep_copy(opt_id)
×
411
      if opt_id != nil
×
412
        val = UI.QueryWidget(Id(opt_key), :Value)
×
413
        if Ops.is_boolean?(val)
×
414
          UI.ChangeWidget(
×
415
            Id(opt_key),
×
416
            :Value,
×
417
            SambaConfig.GlobalGetTruth(opt_key, nil)
×
418
          )
×
419
        else
×
420
          UI.ChangeWidget(
×
421
            Id(opt_key),
×
422
            :Value,
×
423
            SambaConfig.GlobalGetStr(opt_key, nil)
×
424
          )
×
425
        end
×
426
      end
×
427
      UI.SetFocus(Id(opt_key))
×
428

429
      nil
×
430
    end
×
431
    def GlobalSettingsPopupStore(opt_id, opt_key)
×
432
      opt_id = deep_copy(opt_id)
×
433
      val = UI.QueryWidget(Id(opt_key), :Value)
×
434
      if Ops.is_boolean?(val)
×
435
        SambaConfig.GlobalSetTruth(opt_key, Convert.to_boolean(val))
×
436
      else
×
437
        SambaConfig.GlobalSetStr(opt_key, Convert.to_string(val))
×
438
      end
×
439

440
      nil
×
441
    end
×
442
    def GlobalSettingsSummary(opt_id, opt_key)
×
443
      opt_id = deep_copy(opt_id)
×
444
      SambaConfig.GlobalGetStr(opt_key, "")
×
445
    end
×
446

447
    def SomeBackendsAreInUse
×
448
      Ops.greater_than(Builtins.size(@passdb_backends), 0)
×
449
    end
×
450

451
    def RedrawPassdbEditButtons
×
452
      if UI.WidgetExists(Id(:_tp_add))
×
453
        UI.ChangeWidget(Id(:_tp_add), :Enabled, !SomeBackendsAreInUse())
×
454
      end
×
455

456
      nil
×
457
    end
×
458
    def PassdbEditContents(descr)
×
459
      descr = deep_copy(descr)
×
460
      if @passdb_backends != nil
×
461
        # we are already initialized
462
        return deep_copy(@passdb_order)
×
463
      else
×
464
        l = SambaBackend.GetPassdbBackends
×
465
        ids = []
×
466
        @max_id = -1
×
467
        @passdb_backends = Builtins.listmap(l) do |backend|
×
468
          @max_id = Ops.add(@max_id, 1)
×
469
          s = Builtins.sformat("%1", @max_id)
×
470
          ids = Builtins.add(ids, s)
×
471
          { s => backend }
×
472
        end
×
473
        @max_id = Ops.add(@max_id, 1)
×
474
        @passdb_order = deep_copy(ids)
×
475
        return deep_copy(ids)
×
476
      end
×
477
    end
×
478
    def PassdbEditOptionValidate(key, event_descr)
×
479
      event_descr = deep_copy(event_descr)
×
480
      if !SomeBackendsAreInUse()
×
481
        Report.Error(_("At least one backend must be specified."))
×
482

483
        return false
×
484
      end
×
485

486
      true
×
487
    end
×
488
    def PassdbEditOptionInit(opt_id, opt_key)
×
489
      opt_id = deep_copy(opt_id)
×
490
      if opt_id != nil
×
491
        # not adding a new option
492
        UI.ChangeWidget(
×
493
          Id(opt_key),
×
494
          :Value,
×
495
          SambaBackend.GetLocation(
×
496
            Ops.get(@passdb_backends, Convert.to_string(opt_id), "")
×
497
          )
×
498
        )
×
499
      end
×
500
      UI.SetFocus(Id(opt_key))
×
501

502
      RedrawPassdbEditButtons()
×
503

504
      nil
×
505
    end
×
506
    def PassdbEditOptionStore(opt_id, opt_key)
×
507
      opt_id = deep_copy(opt_id)
×
508
      details = Convert.to_string(UI.QueryWidget(Id(opt_key), :Value))
×
509
      # TODO: handle empty details
510

511
      if Builtins.size(details) != 0
×
512
        details = Ops.add(":", details)
×
513
      else
×
514
        details = ""
×
515
      end
×
516

517
      if opt_id != nil
×
518
        # update
519
        # take the SAM type from the old data and append the new details
520
        Ops.set(
×
521
          @passdb_backends,
×
522
          Convert.to_string(opt_id),
×
523
          Ops.add(
×
524
            SambaBackend.GetName(
×
525
              Ops.get(@passdb_backends, Convert.to_string(opt_id))
×
526
            ),
×
527
            details
×
528
          )
×
529
        )
×
530
      else
×
531
        # insert new
532
        id = Builtins.sformat("%1", @max_id)
×
533
        @max_id = Ops.add(@max_id, 1)
×
534
        @passdb_backends = Builtins.add(
×
535
          @passdb_backends,
×
536
          id,
×
537
          Ops.add(opt_key, details)
×
538
        )
×
539
        @passdb_order = Builtins.add(@passdb_order, id)
×
540
      end
×
541

542
      nil
×
543
    end
×
544
    def PassdbEditOptionSummary(opt_id, opt_key)
×
545
      opt_id = deep_copy(opt_id)
×
546
      option = Ops.get(@passdb_backends, Convert.to_string(opt_id), "")
×
547
      SambaBackend.GetLocation(option)
×
548
    end
×
549
    def PassdbId2Key(desc, id)
×
550
      desc = deep_copy(desc)
×
551
      id = deep_copy(id)
×
552
      s_id = Ops.get(@passdb_backends, Convert.to_string(id), "")
×
553
      SambaBackend.GetName(s_id)
×
554
    end
×
555
    def PassdbEntryDelete(opt_id, opt_key)
×
556
      opt_id = deep_copy(opt_id)
×
557
      #        if (size (passdb_backends) == 1)
558
      #        {
559
      #            // error message if user tries to delete the last passdb backend
560
      #            Report::Error (_("At least one back-end must be specified.
561
      #
562
      #The back-end cannot be deleted.
563
      #"));
564
      #            return false;
565
      #        }
566

567
      # message popup
568
      return false if !Popup.YesNo(_("Delete the selected back-end?"))
×
569

570
      id = Convert.to_string(opt_id)
×
571
      @passdb_backends = Builtins.filter(@passdb_backends) { |k, v| k != id }
×
572
      @passdb_order = Builtins.filter(@passdb_order) { |k| k != id }
×
573

574
      RedrawPassdbEditButtons()
×
575

576
      true
×
577
    end
×
578
    def AddPassdbBackend
×
579
      UI.OpenDialog(
×
580
        VBox(
×
581
          # translators: frame text when adding a passdb backend
582
          Frame(
×
583
            _("Back-End Type"),
×
584
            RadioButtonGroup(
×
585
              Id(:types),
×
586
              VBox(
×
587
                # translators: passdb backend radio button
588
                Left(
×
589
                  RadioButton(
×
590
                    Id("smbpasswd"),
×
591
                    Opt(:notify),
×
592
                    _("smbpasswd File")
×
593
                  )
×
594
                ), # Unknown passdb backend
×
595
                #                    // translators: passdb backend radio button
596
                #                    `Left (`RadioButton ( `id("mysql"), `opt (`notify),_("MySQL Database") ) )
597
                # translators: passdb backend radio button
598
                Left(RadioButton(Id("ldapsam"), Opt(:notify), _("LDAP"))),
×
599
                # translators: passdb backend radio button
600
                Left(RadioButton(Id("tdbsam"), Opt(:notify), _("TDB Database")))
×
601
              )
×
602
            )
×
603
          ),
×
604
          # translators: textentry label to enter details for the selected passdb backend
605
          TextEntry(Id("details"), _("&Details")),
×
606
          HBox(
×
607
            PushButton(Id("add"), Opt(:default), Label.AddButton),
×
608
            PushButton(Id("cancel"), Label.CancelButton)
×
609
          )
×
610
        )
×
611
      )
×
612
      begin
×
613
        ret = UI.UserInput
×
614
        if Builtins.contains(["smbpasswd", "ldapsam", "tdbsam", "mysql"], ret)
×
615
          # prefill a hint, if details empty
616
          details = Convert.to_string(UI.QueryWidget(Id("details"), :Value))
×
617
          if Builtins.size(details) == 0
×
618
            if ret == "ldapsam"
×
619
              Yast.import "Ldap"
×
620
              # ask LDAP client for the value
621
              server = Ldap.server
×
622

623
              # ensure to take only the first one
624
              servers = Builtins.splitstring(server, " ")
×
625
              UI.ChangeWidget(
×
626
                Id("details"),
×
627
                :Value,
×
628
                Ops.add("ldap://", Ops.get(servers, 0, "localhost"))
×
629
              )
×
630
            end
×
631
          end
×
632

633
          next
×
634
        elsif ret == "add"
×
635
          # check: all types except smbpasswd must get detailed info
636
          type = Convert.to_string(UI.QueryWidget(Id(:types), :CurrentButton))
×
637
          details = Convert.to_string(UI.QueryWidget(Id("details"), :Value))
×
638
          if Builtins.size(details) != 0
×
639
            details = Ops.add(":", details)
×
640
          else
×
641
            details = ""
×
642
          end
×
643

644
          if type == "mysql" && Builtins.size(details) == 0
×
645
            # translators: error message, if the MySQL backend
646
            # is selected, but no details are entered
647
            Popup.Error(
×
648
              _(
×
649
                "An identifier must be provided\n" +
×
650
                  "in details \n" +
×
651
                  "for the MySQL passdb back-end.\n" +
×
652
                  "\n" +
×
653
                  "Consult the Samba HOWTO collection for\n" +
×
654
                  "further information.\n"
×
655
              )
×
656
            )
×
657
            next
×
658
          # validate LDAP
659
          elsif type == "ldapsam" && Ops.greater_than(Builtins.size(details), 0)
×
660
            # fill in empty params to keep interpreter happy
661
            next if !ValidateLDAPURL(nil, "details", nil)
×
662
          end
×
663

664
          # add the value
665
          id = Builtins.sformat("%1", @max_id)
×
666
          @max_id = Ops.add(@max_id, 1)
×
667
          @passdb_backends = Builtins.add(
×
668
            @passdb_backends,
×
669
            id,
×
670
            Ops.add(type, details)
×
671
          )
×
672
          @passdb_order = Builtins.add(@passdb_order, id)
×
673
        end
×
674
        break
×
675
      end while true
×
676

677
      UI.CloseDialog
×
678

679
      nil
×
680
    end
×
681
    def PassdbOptionMove(opt_id, opt_key, direction)
×
682
      opt_id = deep_copy(opt_id)
×
683
      id = Convert.to_string(opt_id)
×
684

685
      @passdb_order = Builtins.sort(@passdb_order) do |left, right|
×
686
        res = direction == :down ?
×
687
          left == id ? false : true :
×
688
          right == id ? false : true
×
689
        res
×
690
      end
×
691
      initPassdb(opt_key)
×
692
      deep_copy(opt_id)
×
693
    end
×
694
    def initPassdb(key)
×
695
      TablePopup.TableInit(Ops.get_map(@xx_widgets, "passdb_edit", {}), key)
×
696
      RedrawPassdbEditButtons()
×
697

698
      nil
×
699
    end
×
700
    def handlePassdb(key, event_descr)
×
701
      event_descr = deep_copy(event_descr)
×
702
      if Ops.get(event_descr, "ID") == :_tp_add
×
703
        AddPassdbBackend()
×
704
        TablePopup.TableInit(Ops.get_map(@xx_widgets, "passdb_edit", {}), key)
×
705
        RedrawPassdbEditButtons()
×
706
        # continue
707
        return nil
×
708
      end
×
709

710
      if Ops.get(event_descr, "ID") == :back
×
711
        @passdb_backends = nil
×
712
        return nil
×
713
      end
×
714

715
      ret = TablePopup.TableHandle(
×
716
        Ops.get_map(@xx_widgets, "passdb_edit", {}),
×
717
        key,
×
718
        event_descr
×
719
      )
×
720
      RedrawPassdbEditButtons()
×
721
      ret
×
722
    end
×
723
    def storePassdb(key, event)
×
724
      event = deep_copy(event)
×
725
      res = Builtins.maplist(@passdb_order) do |id|
×
726
        Ops.get(@passdb_backends, id, "")
×
727
      end
×
728
      SambaBackend.SetPassdbBackends(res)
×
729
      @passdb_backends = nil # require a new initialization
×
730

731
      nil
×
732
    end
×
733
  end
×
734
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