Class List Method List File List

# Module: Yast::SudoDialogsInclude

Defined in:
  ../../src/include/sudo/dialogs.rb

## Instance Method Summary (collapse)

- - (Object) CreateItems(aliases)
- - (Object) HandleCmndAliases(key, event)
- - (Object) HandleHostAliases(key, event)
- - (Object) HandleRunAsAliases(key, event)
- - (Object) HandleUserAliases(key, event)
- - (Object) HandleUserSpecs(key, event)
- - (Object) InitCmndAliases(key)
- - (Object) InitHostAliases(key)
- - (Object) initialize_sudo_dialogs(include_target)
- - (Object) InitRunAsAliases(key)
- - (Object) InitUserAliases(key)
- - (Object) InitUserSpecs(key)
- - (Object) RunSudoDialogs
- - (Object) SwapItems(idx1, idx2)
- - (Object) SwapUIItems(idx1, idx2)

## Instance Method Details

### - (`Object`) CreateItems(aliases)

    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    # File '../../src/include/sudo/dialogs.rb', line 292

    def CreateItems(aliases)
      aliases = deep_copy(aliases)
      items = []
      i = 0

      Builtins.foreach(aliases) do |ent|
        items = Builtins.add(
          items,
          Item(
            Id(i),
            Ops.get_string(ent, "name", ""),
            Builtins.mergestring(Ops.get_list(ent, "mem", []), ",")
          )
        )
        i = Ops.add(i, 1)
      end

      deep_copy(items)
    end

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

    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
    # File '../../src/include/sudo/dialogs.rb', line 644

    def HandleCmndAliases(key, event)
      event = deep_copy(event)
      ret = Ops.get(event, "ID")

      if ret == "add_command_alias"
        # No alias name set so far
        Sudo.SetItem(Builtins.size(Sudo.GetCmndAliases2))
        return :add_c_alias
      elsif ret == "edit_command_alias"
        Sudo.SetItem(
          Convert.to_integer(
            UI.QueryWidget(Id("table_command_aliases"), :CurrentItem)
          )
        )
        return :edit_c_alias
      elsif ret == "delete_command_alias"
        idx = Convert.to_integer(
          UI.QueryWidget(Id("table_command_aliases"), :CurrentItem)
        )
        items = Convert.convert(
          UI.QueryWidget(Id("table_command_aliases"), :Items),
          :from => "any",
          :to   => "list <term>"
        )
        name = Ops.get_string(Sudo.GetCmndAliases2, [idx, "name"], "")
        confirm_delete = true

        if Sudo.SearchRules("commands", name)
          if !Popup.ContinueCancel(
              Builtins.sformat(
                _(
                  "Command alias %1 is being used in one of the sudo rules.\nDeleting it may result in an inconsistent sudo configuration file. Really delete it?\n"
                ),
                name
              )
            )
            confirm_delete = false
          end
        end

        if confirm_delete
          Sudo.RemoveCmndAlias2(idx)
          items = CreateItems(Sudo.GetCmndAliases2)
          UI.ChangeWidget(Id("table_command_aliases"), :Items, items)
          Sudo.SetModified
        end
        EnableDisableButtons(
          "edit_command_alias",
          "delete_command_alias",
          items
        )
      end

      nil
    end

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

    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
    # File '../../src/include/sudo/dialogs.rb', line 455

    def HandleHostAliases(key, event)
      event = deep_copy(event)
      ret = Ops.get(event, "ID")

      if ret == "add_host_alias"
        Sudo.SetItem(Builtins.size(Sudo.GetHostAliases2))
        #current_alias_name = "";
        return :add_h_alias
      elsif ret == "edit_host_alias"
        Sudo.SetItem(
          Convert.to_integer(
            UI.QueryWidget(Id("table_host_aliases"), :CurrentItem)
          )
        )
        return :edit_h_alias
      elsif ret == "delete_host_alias"
        idx = Convert.to_integer(
          UI.QueryWidget(Id("table_host_aliases"), :CurrentItem)
        )
        items = Convert.convert(
          UI.QueryWidget(Id("table_host_aliases"), :Items),
          :from => "any",
          :to   => "list <term>"
        )
        name = Ops.get_string(Sudo.GetHostAliases2, [idx, "name"], "")

        confirm_delete = true

        if Sudo.SearchRules("host", name)
          if !Popup.ContinueCancel(
              Builtins.sformat(
                _(
                  "Host alias %1 is being used in one of the sudo rules.\nDeleting it may result in an inconsistent sudo configuration file. Really delete it?\n"
                ),
                name
              )
            )
            confirm_delete = false
          end
        end

        if confirm_delete
          Sudo.RemoveHostAlias2(idx)
          items = CreateItems(Sudo.GetHostAliases2)
          UI.ChangeWidget(Id("table_host_aliases"), :Items, items)
          Sudo.SetModified
        end
        EnableDisableButtons("edit_host_alias", "delete_host_alias", items)
      end

      nil
    end

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

    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
    # File '../../src/include/sudo/dialogs.rb', line 581

    def HandleRunAsAliases(key, event)
      event = deep_copy(event)
      ret = Ops.get(event, "ID")

      if ret == "add_runas_alias"
        # No alias name set so far
        Sudo.SetItem(Builtins.size(Sudo.GetRunAsAliases2))
        return :add_r_alias
      elsif ret == "edit_runas_alias"
        Sudo.SetItem(
          Convert.to_integer(
            UI.QueryWidget(Id("table_runas_aliases"), :CurrentItem)
          )
        )
        return :edit_r_alias
      elsif ret == "delete_runas_alias"
        idx = Convert.to_integer(
          UI.QueryWidget(Id("table_runas_aliases"), :CurrentItem)
        )
        items = Convert.convert(
          UI.QueryWidget(Id("table_runas_aliases"), :Items),
          :from => "any",
          :to   => "list <term>"
        )
        name = Ops.get_string(Sudo.GetRunAsAliases2, [idx, "name"], "")

        confirm_delete = true

        if Sudo.SearchRules("run_as", Ops.add(Ops.add("(", name), ")"))
          if !Popup.ContinueCancel(
              Builtins.sformat(
                _(
                  "RunAs alias %1 is being used in one of the sudo rules.\nDeleting it may result in an inconsistent sudo configuration file. Really delete it?\n"
                ),
                name
              )
            )
            confirm_delete = false
          end
        end

        if confirm_delete
          Sudo.RemoveRunAsAlias2(idx)
          items = CreateItems(Sudo.GetRunAsAliases2)
          UI.ChangeWidget(Id("table_runas_aliases"), :Items, items)
          Sudo.SetModified
        end
        EnableDisableButtons("edit_runas_alias", "delete_runas_alias", items)
      end

      nil
    end

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

    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
    # File '../../src/include/sudo/dialogs.rb', line 518

    def HandleUserAliases(key, event)
      event = deep_copy(event)
      ret = Ops.get(event, "ID")

      if ret == "add_user_alias"
        # No alias name set so far
        Sudo.SetItem(Builtins.size(Sudo.GetUserAliases2))
        return :add_u_alias
      elsif ret == "edit_user_alias"
        Sudo.SetItem(
          Convert.to_integer(
            UI.QueryWidget(Id("table_user_aliases"), :CurrentItem)
          )
        )
        return :edit_u_alias
      elsif ret == "delete_user_alias"
        idx = Convert.to_integer(
          UI.QueryWidget(Id("table_user_aliases"), :CurrentItem)
        )
        items = Convert.convert(
          UI.QueryWidget(Id("table_user_aliases"), :Items),
          :from => "any",
          :to   => "list <term>"
        )
        name = Ops.get_string(Sudo.GetUserAliases2, [idx, "name"], "")

        confirm_delete = true

        if Sudo.SearchRules("user", name)
          if !Popup.ContinueCancel(
              Builtins.sformat(
                _(
                  "User alias %1 is being used in one of the sudo rules.\nDeleting it may result in an inconsistent sudo configuration file. Really delete it?\n"
                ),
                name
              )
            )
            confirm_delete = false
          end
        end

        if confirm_delete
          Sudo.RemoveUserAlias2(idx)
          items = CreateItems(Sudo.GetUserAliases2)
          UI.ChangeWidget(Id("table_user_aliases"), :Items, items)
          Sudo.SetModified
        end
        EnableDisableButtons("edit_user_alias", "delete_user_alias", items)
      end

      nil
    end

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

    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/sudo/dialogs.rb', line 353

    def HandleUserSpecs(key, event)
      event = deep_copy(event)
      ret = Ops.get(event, "ID")

      if ret == "add_spec"
        Sudo.SetItem(Builtins.size(Sudo.GetRules))
        return :add_spec
      elsif ret == "edit_spec"
        idx = Convert.to_integer(
          UI.QueryWidget(Id("table_user_spec"), :CurrentItem)
        )
        Sudo.SetItem(idx)
        return :edit_spec if Sudo.SystemRulePopup(Sudo.GetRule(idx), false)
      elsif ret == "delete_spec"
        idx = Convert.to_integer(
          UI.QueryWidget(Id("table_user_spec"), :CurrentItem)
        )
        items = Convert.convert(
          UI.QueryWidget(Id("table_user_spec"), :Items),
          :from => "any",
          :to   => "list <term>"
        )

        if Sudo.SystemRulePopup(Sudo.GetRule(idx), true)
          Sudo.RemoveRule(idx)
          items = Builtins.remove(items, idx)

          i = 0
          items = Builtins.maplist(items) do |tmp|
            args = Builtins.argsof(tmp)
            t = Builtins.toterm(
              :item,
              Builtins.merge([Id(i)], Builtins.sublist(args, 1))
            )
            i = Ops.add(i, 1)
            deep_copy(t)
          end
          UI.ChangeWidget(Id("table_user_spec"), :Items, items)
          Sudo.SetModified
        end
        EnableDisableButtons("edit_spec", "delete_spec", items)
      elsif ret == "up"
        idx = Convert.to_integer(
          UI.QueryWidget(Id("table_user_spec"), :CurrentItem)
        )
        if idx != 0
          SwapItems(idx, Ops.subtract(idx, 1))
          SwapUIItems(idx, Ops.subtract(idx, 1))
          UI.ChangeWidget(
            Id("table_user_spec"),
            :CurrentItem,
            Ops.subtract(idx, 1)
          )
          Sudo.SetModified
        end
      elsif ret == "down"
        idx = Convert.to_integer(
          UI.QueryWidget(Id("table_user_spec"), :CurrentItem)
        )
        if idx != Ops.subtract(Builtins.size(Sudo.GetRules), 1)
          SwapItems(idx, Ops.add(idx, 1))
          SwapUIItems(idx, Ops.add(idx, 1))
          UI.ChangeWidget(Id("table_user_spec"), :CurrentItem, Ops.add(idx, 1))
          Sudo.SetModified
        end
      end

      nil
    end

### - (`Object`) InitCmndAliases(key)

    700
    701
    702
    703
    704
    705
    706
    707
    708
    # File '../../src/include/sudo/dialogs.rb', line 700

    def InitCmndAliases(key)
      aliases = Sudo.GetCmndAliases2
      items = CreateItems(aliases)

      UI.ChangeWidget(Id("table_command_aliases"), :Items, items)
      EnableDisableButtons("edit_command_alias", "delete_command_alias", items)

      nil
    end

### - (`Object`) InitHostAliases(key)

    508
    509
    510
    511
    512
    513
    514
    515
    516
    # File '../../src/include/sudo/dialogs.rb', line 508

    def InitHostAliases(key)
      aliases = Sudo.GetHostAliases2
      items = CreateItems(aliases)

      UI.ChangeWidget(Id("table_host_aliases"), :Items, items)
      EnableDisableButtons("edit_host_alias", "delete_host_alias", items)

      nil
    end

### - (`Object`) initialize_sudo_dialogs(include_target)

    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    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
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    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
    # File '../../src/include/sudo/dialogs.rb', line 30

    def initialize_sudo_dialogs(include_target)
      Yast.import "UI"

      textdomain "sudo"

      Yast.import "Label"
      Yast.import "Wizard"
      Yast.import "Sudo"
      Yast.import "DialogTree"

      Yast.include include_target, "sudo/helps.rb"
      Yast.include include_target, "sudo/complex.rb"

      @sudo_caption = _("Sudo Configuration")

      @widgets_handling = {
        "UserSpecifications" => {
          "widget"        => :custom,
          "custom_widget" => VBox(),
          "init"          => fun_ref(method(:InitUserSpecs), "void (string)"),
          "handle"        => fun_ref(
            method(:HandleUserSpecs),
            "symbol (string, map)"
          ),
          "help"          => Ops.get_string(@HELPS, "spec", "")
        },
        "UserAliases"        => {
          "widget"        => :custom,
          "custom_widget" => VBox(),
          "init"          => fun_ref(method(:InitUserAliases), "void (string)"),
          "handle"        => fun_ref(
            method(:HandleUserAliases),
            "symbol (string, map)"
          ),
          "help"          => Ops.get_string(@HELPS, "user_aliases", "")
        },
        "RunAsAliases"       => {
          "widget"        => :custom,
          "custom_widget" => VBox(),
          "init"          => fun_ref(method(:InitRunAsAliases), "void (string)"),
          "handle"        => fun_ref(
            method(:HandleRunAsAliases),
            "symbol (string, map)"
          ),
          "help"          => Ops.get_string(@HELPS, "runas_aliases", "")
        },
        "HostAliases"        => {
          "widget"        => :custom,
          "custom_widget" => VBox(),
          "init"          => fun_ref(method(:InitHostAliases), "void (string)"),
          "handle"        => fun_ref(
            method(:HandleHostAliases),
            "symbol (string, map)"
          ),
          "help"          => Ops.get_string(@HELPS, "host_aliases", "")
        },
        "CommandAliases"     => {
          "widget"        => :custom,
          "custom_widget" => VBox(),
          "init"          => fun_ref(method(:InitCmndAliases), "void (string)"),
          "handle"        => fun_ref(
            method(:HandleCmndAliases),
            "symbol (string, map)"
          ),
          "help"          => Ops.get_string(@HELPS, "command_aliases", "")
        }
      }

      @functions = { :abort => fun_ref(Sudo.method(:Abort), "boolean ()") }

      @tabs = {
        "user_specs"    => {
          "contents"        => VBox(
            HBox(
              Table(
                Id("table_user_spec"),
                Opt(:keepSorting),
                Header(
                  _("Users"),
                  _("Hosts"),
                  _("RunAs"),
                  _("NOPASSWD"),
                  _("Commands")
                ),
                []
              ),
              VBox(
                PushButton(Id("up"), _("Up")),
                PushButton(Id("down"), _("Down"))
              )
            ),
            Left(
              HBox(
                PushButton(
                  Id("add_spec"),
                  Opt(:key_F3),
                  Ops.add(Ops.add(" ", Label.AddButton), " ")
                ),
                PushButton(
                  Id("edit_spec"),
                  Opt(:key_F4),
                  Ops.add(Ops.add(" ", Label.EditButton), " ")
                ),
                PushButton(
                  Id("delete_spec"),
                  Opt(:key_F5),
                  Ops.add(Ops.add(" ", Label.DeleteButton), " ")
                )
              )
            )
          ),
          "caption"         => Ops.add(
            Ops.add(@sudo_caption, ": "),
            _("Rules for sudo")
          ),
          "tree_item_label" => _("Rules for sudo "),
          "widget_names"    => ["UserSpecifications"]
        },
        "user_aliases"  => {
          "contents"        => VBox(
            Table(
              Id("table_user_aliases"),
              Opt(:keepSorting),
              Header(_("Alias Name"), _("Members")),
              []
            ),
            Left(
              HBox(
                PushButton(
                  Id("add_user_alias"),
                  Opt(:key_F3),
                  Ops.add(Ops.add(" ", Label.AddButton), " ")
                ),
                PushButton(
                  Id("edit_user_alias"),
                  Opt(:key_F4),
                  Ops.add(Ops.add(" ", Label.EditButton), " ")
                ),
                PushButton(
                  Id("delete_user_alias"),
                  Opt(:key_F5),
                  Ops.add(Ops.add(" ", Label.DeleteButton), " ")
                )
              )
            )
          ),
          "caption"         => Ops.add(
            Ops.add(@sudo_caption, ": "),
            _("User Aliases")
          ),
          "tree_item_label" => _("User Aliases"),
          "widget_names"    => ["UserAliases"]
        },
        "runas_aliases" => {
          "contents"        => VBox(
            Table(
              Id("table_runas_aliases"),
              Opt(:keepSorting),
              Header(_("Alias Name"), _("Members")),
              []
            ),
            Left(
              HBox(
                PushButton(
                  Id("add_runas_alias"),
                  Opt(:key_F3),
                  Ops.add(Ops.add(" ", Label.AddButton), " ")
                ),
                PushButton(
                  Id("edit_runas_alias"),
                  Opt(:key_F4),
                  Ops.add(Ops.add(" ", Label.EditButton), " ")
                ),
                PushButton(
                  Id("delete_runas_alias"),
                  Opt(:key_F5),
                  Ops.add(Ops.add(" ", Label.DeleteButton), " ")
                )
              )
            )
          ),
          "caption"         => Ops.add(
            Ops.add(@sudo_caption, ": "),
            _("RunAs Aliases")
          ),
          "tree_item_label" => _("RunAs Aliases"),
          "widget_names"    => ["RunAsAliases"]
        },
        "host_aliases"  => {
          "contents"        => VBox(
            Table(
              Id("table_host_aliases"),
              Opt(:keepSorting),
              Header(_("Alias Name"), _("Hosts")),
              []
            ),
            Left(
              HBox(
                PushButton(
                  Id("add_host_alias"),
                  Opt(:key_F3),
                  Ops.add(Ops.add(" ", Label.AddButton), " ")
                ),
                PushButton(
                  Id("edit_host_alias"),
                  Opt(:key_F4),
                  Ops.add(Ops.add(" ", Label.EditButton), " ")
                ),
                PushButton(
                  Id("delete_host_alias"),
                  Opt(:key_F5),
                  Ops.add(Ops.add(" ", Label.DeleteButton), " ")
                )
              )
            )
          ),
          "caption"         => Ops.add(
            Ops.add(@sudo_caption, ": "),
            _("Host Aliases")
          ),
          "tree_item_label" => _("Host Aliases"),
          "widget_names"    => ["HostAliases"]
        },
        "cmnd_aliases"  => {
          "contents"        => VBox(
            Table(
              Id("table_command_aliases"),
              Opt(:keepSorting),
              Header(_("Alias Name"), _("Commands")),
              []
            ),
            Left(
              HBox(
                PushButton(
                  Id("add_command_alias"),
                  Opt(:key_F3),
                  Ops.add(Ops.add(" ", Label.AddButton), " ")
                ),
                PushButton(
                  Id("edit_command_alias"),
                  Opt(:key_F4),
                  Ops.add(Ops.add(" ", Label.EditButton), " ")
                ),
                PushButton(
                  Id("delete_command_alias"),
                  Opt(:key_F5),
                  Ops.add(Ops.add(" ", Label.DeleteButton), " ")
                )
              )
            )
          ),
          "caption"         => Ops.add(
            Ops.add(@sudo_caption, ": "),
            _("Command Aliases")
          ),
          "tree_item_label" => _("Command Aliases"),
          "widget_names"    => ["CommandAliases"]
        }
      }
    end

### - (`Object`) InitRunAsAliases(key)

    634
    635
    636
    637
    638
    639
    640
    641
    642
    # File '../../src/include/sudo/dialogs.rb', line 634

    def InitRunAsAliases(key)
      aliases = Sudo.GetRunAsAliases2
      items = CreateItems(aliases)

      UI.ChangeWidget(Id("table_runas_aliases"), :Items, items)
      EnableDisableButtons("edit_runas_alias", "delete_runas_alias", items)

      nil
    end

### - (`Object`) InitUserAliases(key)

    571
    572
    573
    574
    575
    576
    577
    578
    579
    # File '../../src/include/sudo/dialogs.rb', line 571

    def InitUserAliases(key)
      aliases = Sudo.GetUserAliases2
      items = CreateItems(aliases)

      UI.ChangeWidget(Id("table_user_aliases"), :Items, items)
      EnableDisableButtons("edit_user_alias", "delete_user_alias", items)

      nil
    end

### - (`Object`) InitUserSpecs(key)

    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    # File '../../src/include/sudo/dialogs.rb', line 423

    def InitUserSpecs(key)
      items = []
      rules = Sudo.GetRules
      idx = 0

      Builtins.foreach(rules) do |ent|
        cmds = ""
        if Ops.greater_than(Builtins.size(Ops.get_list(ent, "commands", [])), 1)
          cmds = Builtins.mergestring(Ops.get_list(ent, "commands", []), ",")
        else
          cmds = Ops.get(Ops.get_list(ent, "commands", []), 0, "")
        end
        items = Builtins.add(
          items,
          Item(
            Id(idx),
            Ops.get_string(ent, "user", ""),
            Ops.get_string(ent, "host", ""),
            Ops.get_string(ent, "run_as", ""),
            Ops.get_string(ent, "tag", "") == "NOPASSWD:" ? _("Yes") : _("No"),
            cmds
          )
        )
        idx = Ops.add(idx, 1)
      end

      UI.ChangeWidget(Id("table_user_spec"), :Items, items)
      EnableDisableButtons("edit_spec", "delete_spec", items)

      nil
    end

### - (`Object`) RunSudoDialogs

    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    # File '../../src/include/sudo/dialogs.rb', line 710

    def RunSudoDialogs
      tree_dialogs = [
        "user_specs",
        "user_aliases",
        "runas_aliases",
        "host_aliases",
        "cmnd_aliases"
      ]

      DialogTree.ShowAndRun(
        {
          "ids_order"      => tree_dialogs,
          "initial_screen" => @initial_screen,
          "screens"        => @tabs,
          "widget_descr"   => @widgets_handling,
          "back_button"    => nil, #Label::BackButton(),
          "abort_button"   => Label.CancelButton,
          "next_button"    => Label.OKButton,
          "functions"      => @functions
        }
      )
    end

### - (`Object`) SwapItems(idx1, idx2)

    343
    344
    345
    346
    347
    348
    349
    350
    351
    # File '../../src/include/sudo/dialogs.rb', line 343

    def SwapItems(idx1, idx2)
      item1 = Sudo.GetRule(idx1)
      item2 = Sudo.GetRule(idx2)

      Sudo.SetRule(idx2, item1)
      Sudo.SetRule(idx1, item2)

      nil
    end

### - (`Object`) SwapUIItems(idx1, idx2)

    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
    # File '../../src/include/sudo/dialogs.rb', line 312

    def SwapUIItems(idx1, idx2)
      items = Convert.convert(
        UI.QueryWidget(Id("table_user_spec"), :Items),
        :from => "any",
        :to   => "list <term>"
      )
      args1 = Builtins.argsof(Ops.get(items, idx1, term(:none)))
      args2 = Builtins.argsof(Ops.get(items, idx2, term(:none)))

      Ops.set(
        items,
        idx1,
        Builtins.toterm(
          :item,
          Builtins.merge([Id(idx1)], Builtins.sublist(args2, 1))
        )
      )
      Ops.set(
        items,
        idx2,
        Builtins.toterm(
          :item,
          Builtins.merge([Id(idx2)], Builtins.sublist(args1, 1))
        )
      )

      UI.ChangeWidget(Id("table_user_spec"), :Items, items)

      nil
    end