Class: Yast::InetdClass

Inherits:
Module
  • Object
show all
Includes:
Logger
Defined in:
../../src/modules/Inetd.rb

Constant Summary

SERVICE_NAME =
"xinetd"

Instance Method Summary (collapse)

Instance Method Details

- (Object) Abort

Abort function

Returns:

  • If AbortFunction not defined, returnes false



172
173
174
175
# File '../../src/modules/Inetd.rb', line 172

def Abort
  return Builtins.eval(@AbortFunction) == true if @AbortFunction != nil
  false
end

- (void) addLine(new_line)

This method returns an undefined value.

add a line in DB

Parameters:

  • new_line (Hash{String => Object})

    new_line contains new entry for global netd_conf configuration



651
652
653
654
655
656
657
# File '../../src/modules/Inetd.rb', line 651

def addLine(new_line)
  new_line = deep_copy(new_line)
  # add
  new_line = Builtins.add(new_line, "changed", true)
  @netd_conf = Builtins.add(@netd_conf, new_line)
  nil
end

- (Object) adjust_xinetd_service

Starts or stops and enables or disables the xinetd service depending on the current and requested service state



315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# File '../../src/modules/Inetd.rb', line 315

def adjust_xinetd_service
  current_status = Service.active?(SERVICE_NAME)

  if @netd_status
    if current_status
      log.info "#{SERVICE_NAME} was running -> calling reload"
      Service.reload(SERVICE_NAME) unless @write_only
    else
      log.info "#{SERVICE_NAME} was stopped -> enabling and starting service"
      Service.Start(SERVICE_NAME) unless @write_only
    end
    Service.Enable(SERVICE_NAME)
  else
    if current_status
      log.info "#{SERVICE_NAME} was running -> stoping and disabling service"
      Service.Stop(SERVICE_NAME) unless @write_only
    else
      log.info "#{SERVICE_NAME} was stopped -> leaving unchanged"
    end
    Service.Disable(SERVICE_NAME)
  end
end

- (Hash) AutoPackages

Return required packages for auto-installation FIXME: Need to make this return the needed packages during installation

Returns:

  • (Hash)

    of packages to be installed and to be removed



680
681
682
# File '../../src/modules/Inetd.rb', line 680

def AutoPackages
  { "install" => [], "remove" => [] }
end

- (Object) changeLine(new_line, line_number)

Change a line in DB

Parameters:

  • new_line (Hash{String => Object})

    new_line contains changes for entry in netd_conf

  • line_number (Object)

    line_number contains iid of changed entry in netd_conf



662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
# File '../../src/modules/Inetd.rb', line 662

def changeLine(new_line, line_number)
  new_line = deep_copy(new_line)
  line_number = deep_copy(line_number)
  # entry was changed - so set "changed" flag to true
  new_line = Builtins.add(new_line, "changed", true)
  @netd_conf = Builtins.maplist(@netd_conf) do |line|
    if Ops.get_string(line, "iid", "0") == line_number
      next deep_copy(new_line)
    else
      next deep_copy(line)
    end
  end

  nil
end

- (Object) DBG(i)



684
685
686
687
688
689
# File '../../src/modules/Inetd.rb', line 684

def DBG(i)
  Builtins.y2internal("%1", i)
  Builtins.y2milestone("  netd_conf: %1", @netd_conf)

  nil
end

- (Object) deleteLine(line_number)

delete line in netd_conf

Parameters:

  • line_number (Object)

    “iid” geted from table's item ID



624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
# File '../../src/modules/Inetd.rb', line 624

def deleteLine(line_number)
  line_number = deep_copy(line_number)
  # delete
  current_line = Builtins.find(@netd_conf) do |line|
    Ops.get_string(line, "iid", "0") == line_number
  end
  if current_line == nil
    Builtins.y2internal("can't happen")
    current_line = {}
  end
  # set "deleted" flag to true
  current_line = Builtins.add(current_line, "changed", true)
  current_line = Builtins.add(current_line, "deleted", true)
  @netd_conf = Builtins.maplist(@netd_conf) do |line|
    if Ops.get_string(line, "iid", "0") == line_number
      next deep_copy(current_line)
    else
      next deep_copy(line)
    end
  end

  nil
end

- (Hash) Export

Dump the inetd settings to a single map (For use by autoinstallation.)

Returns:

  • (Hash)

    Dumped settings (later acceptable by Import ())



572
573
574
575
576
577
578
579
# File '../../src/modules/Inetd.rb', line 572

def Export
  config = {}
  config = Builtins.add(config, "netd_conf", getChanged(@netd_conf))
  config = Builtins.add(config, "netd_status", @netd_status)
  config = Builtins.add(config, "last_created", @last_created)
  Builtins.y2milestone("%1", config)
  deep_copy(config)
end

- (Object) getChanged(config)

Get only changed entries

Parameters:

  • config (Array<Hash{String => Object>})

    complete configuration

Returns:

  • Returnse list of changes only



482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
# File '../../src/modules/Inetd.rb', line 482

def getChanged(config)
  config = deep_copy(config)
  defaults = []
  changes = []
  def_line = {}
  return deep_copy(changes) if config == nil

  defaults = deep_copy(@default_conf)

  # defaults not loaded --- get all services listed in config
  return deep_copy(config) if defaults == []

  # Deleted services: so far they are exported
  # But maybe better to allow only deleting added services (~ undo)
  # and thus not export them.
  Builtins.foreach(config) do |line|
    # only changed ones...
    if Ops.get_boolean(line, "changed", false)
      # now trim the fields that are not necessary, because
      # they are a part of the defaults

      # new or installed services (iid is `^new.*' or `^inst.*')
      # are not trimmed
      line_iid = Ops.get_string(line, "iid", "")
      if Builtins.search(line_iid, "new") == 0 ||
          Builtins.search(line_iid, "inst") == 0
        changes = Builtins.add(changes, line)
        next # skip the following code
      end

      # Find coresponding entry in `defaults'.
      # Could use iid here because we started editing
      # with the defaults list
      # but it broke the testsuite.
      def_line = Builtins.find(defaults) do |default_s|
        ServicesMatch(line, default_s)
      end

      # item not found
      # So, write this entry into `changes'
      if def_line == nil
        changes = Builtins.add(changes, line)
        next # skip the following code
      end

      # especially for inetd, server must not be tcpd, because
      # we could trow away the real server which distinguishes
      # a service among its variants
      if Ops.get_string(line, "server", "") == "/usr/sbin/tcpd"
        s = String.FirstChunk(
          Ops.get_string(line, "server_args", ""),
          " \t"
        )
        line = Builtins.add(line, "server", s)
      end

      # for each item of the map
      Builtins.foreach(line) do |name, val|
        # Remove it if its value is the default
        # and it's not a key field or "enabled" (*).
        # In particular, iid is trimmed here.
        if val == Ops.get(def_line, name) &&
            !Builtins.contains(
              ["script", "protocol", "service", "server", "enabled"],
              name
            )
          line = Builtins.remove(line, name)
        end
      end

      # "changed" is implicitly true for all Exported/Imported services
      line = Builtins.remove(line, "changed")
      # "enabled" defaults to true in _Import_, so it would
      # have been wrong above (*) to match it against the
      # _system_ default of false.
      if Ops.get_boolean(line, "enabled", false)
        line = Builtins.remove(line, "enabled")
      end

      changes = Builtins.add(changes, line)
    end
  end

  #y2milestone("%1", changes);
  deep_copy(changes)
end

- (Object) GetServicesId(mask)

LiMaL interface



693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
# File '../../src/modules/Inetd.rb', line 693

def GetServicesId(mask)
  mask = deep_copy(mask)
  ids = []
  i = 0

  while Ops.greater_than(Builtins.size(@netd_conf), i)
    fit = true
    Builtins.foreach(mask) do |key, val|
      fit = false if fit && val != Ops.get(@netd_conf, [i, key])
    end if mask != nil
    ids = Builtins.add(ids, Builtins.tostring(i)) if fit
    i = Ops.add(i, 1)
  end
  deep_copy(ids)
end

- (Boolean) Import(settings)

Get all inetd settings from the first parameter (For use by autoinstallation.)

Parameters:

  • settings (Hash)

    The YCP structure to be imported.

Returns:

  • (Boolean)

    True on success



466
467
468
469
470
471
472
473
474
475
476
477
# File '../../src/modules/Inetd.rb', line 466

def Import(settings)
  settings = deep_copy(settings)
  #y2milestone("settings = %1", settings);
  @netd_conf = mergeWithDefaults(Ops.get_list(settings, "netd_conf", []))
  # old profile can still use integer value (0 == true)
  @netd_status = [0, true].include?(settings["netd_status"])

  # common variables
  @last_created = Ops.get_integer(settings, "last_created", 0)
  #y2milestone("%1", netd_conf);
  true
end

- (Object) main



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
# File '../../src/modules/Inetd.rb', line 42

def main
  Yast.import "UI"
  textdomain "inetd"

  #
  # **Structure:**
  #
  #     service
  #      <pre>
  #      A service map looks like this:
  #      $[
  #* as seen on TV^H^H (x)inetd.conf:
  #        "service": string      // * different from equally named field above
  #        "rpc_version": string
  #        "socket_type": string
  #        "protocol": string
  #        "wait": boolean
  #        "max": integer         // inetd only
  #        "user": string         // *
  #        "group": string
  #        "server": string
  #        "server_args": string
  #        "comment": string      // possibly multiline, without #
  #        "enabled": boolean     // service is active
  #* bookkeeping fields:
  #        "iid": string          // internal id, use as table `id
  #                               //   Iid is necessary because there may be multiple variants
  #                               //   of the same service. See next for iid handling.
  #        "changed": boolean     // when writing, unchanged services are ignored
  #                               //   new services (created) must be set as changed
  #                               //   see changeLine() and see addLine() for more details
  #        "deleted": boolean     // when deleting, this is set to TRUE and changed
  #                               // must be set too (see deleteLine())
  #        "script": string	// which configuration file this comes from
  #        "package": string	// which rpm it is in
  #* other fields:
  #      When handling existing maps, take care to preserve any other fields
  #      that may be present!
  #
  #  "unparsed": string	// what the agent could not parse
  # ]
  #
  # path netd = .whatever.inetd or .whatever.xinetd;
  #
  # SCR::Read (.etc.inetd_conf.services) -> list of inetd configuration
  # SCR::Read (.etc.xinetd_conf.services) -> list of xinetd configuration
  # SCR::Write (.etc.inetd_conf.services, list) -> boolean
  # SCR::Write (.etc.xinetd_conf.services, list) -> boolean
  #
  # "iid" handling:
  # The agent (ag_netd) uses it to locate the service in the config
  # files.  Its value should be considered opaque, except that
  # ag_netd will check whether it contains a colon (:) and if not,
  # consider it a new service.
  # Thus new services get "new"+number.
  # Non-installed services:
  #   in normal ui they appear only in the table and get "NI"+number
  #   in autoyast ui they get "inst"+number
  # Where number is last_created
  # </pre>
  # @see <a href="../autoyast_proto.xhtml">autoyast docs</a>.

  Yast.import "Service"
  Yast.import "Progress"
  Yast.import "Report"
  Yast.import "Summary"
  Yast.import "Directory"
  Yast.import "String"
  Yast.import "XVersion"

  Yast.include self, "inetd/default_conf_xinetd.rb"

  # Abort function
  # return boolean return true if abort
  @AbortFunction = nil

  Yast.include self, "inetd/routines.rb"

  # Configuration was changed
  @modified = false

  # used in unused module inetd_proposal.ycp. This will be removed
  @proposal_valid = false

  # For autoinstallation Write() process.
  # Write_only means that the service will not be actually started,
  # because it is done by init later.
  # But also that the service data are only a patch to be applied to the system.
  @write_only = false

  # If autoinstallation mode (true), we do not want to install RPMs during configuration.
  # Otherwise (false) we allow all.
  @auto_mode = false

  # Autoyast now does not initially call Import $[] anymore. But our
  # design is so broken that we need it and will work hard to achieve it.
  @autoyast_initialized = false

  # <pre>
  # These variable holds inetd configuration.
  # This is list of maps. Each map has the following structure:
  #   $[
  #     "comment": String,
  #     "comment_inside": String, // this is agent internal
  #     "enabled": boolean,
  #     "group": String,
  #     "user": String,
  #     "iid": String,
  #     "protocol": String,
  #     "rpc_version": String,
  #     "server": String,
  #     "server_args": String,
  #     "service": String,
  #     "socket_type": String,
  #     "unparsed": String,       // agent internal
  #     "wait": boolean
  #  ]
  # </pre>
  @netd_conf = []

  # Is xinetd running?
  # These variables contains return values from Service::Status() calls.
  @netd_status = false

  # This variable is used for new iid "generator"
  @last_created = 0
end

- (Array) mergeAfterInstall(system_c, user_c)

Merges autoinstall profile into the system configuration.

Parameters:

  • system_c (Array<Hash{String => Object>})

    holds new configuration (on the system)

  • user_c (Array<Hash{String => Object>})

    holds old configuration (auto: profile + defaults)

Returns:

  • (Array)

    Returnes new solved xinetd configuration (ready for Write()).

See Also:



350
351
352
353
354
# File '../../src/modules/Inetd.rb', line 350

def mergeAfterInstall(system_c, user_c)
  system_c = deep_copy(system_c)
  user_c = deep_copy(user_c)
  MergeAyProfile(system_c, user_c)
end

- (Object) MergeAyProfile(target, changes)

Merges AY profile items into a target list (defaults or system).

Parameters:

  • target (Array<Hash{String => Object>})

    base list of services

  • changes (Array<Hash{String => Object>})

    imported changes

Returns:

  • merged list of services

See Also:

  • href="../autoyast_proto.xhtml">autoyast docs.


404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
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
454
455
456
457
458
459
460
# File '../../src/modules/Inetd.rb', line 404

def MergeAyProfile(target, changes)
  target = deep_copy(target)
  changes = deep_copy(changes)
  # for each change in the patch list:
  Builtins.foreach(changes) do |change_s|
    matches = 0
    # For compatibility and as a hook for workarounds
    # if the matching turns out to be too clever:
    # skip matching
    change_iid = Ops.get_string(change_s, "iid", "")
    if Builtins.search(change_iid, "new") != 0 # do nothing if matches is 0 and we add the service
      # || find (change_iid, "inst") == 0
      # apply the change to the target list:
      target = Builtins.maplist(target) do |target_s|
        new_entry = deep_copy(target_s)
        if ServicesMatch(change_s, target_s)
          # yippee, it matches
          matches = Ops.add(matches, 1)

          # Cannot do a simple union, because we don't
          # want to merge the "server" key field:
          # The "basename (package)" content generated by the
          # AY UI must be avoided.
          # And while merging, iid must be also preserved
          to_merge = SafeRemove(change_s, ["server", "iid"])
          new_entry = Convert.convert(
            Builtins.union(new_entry, to_merge),
            :from => "map",
            :to   => "map <string, any>"
          )
          new_entry = Builtins.add(new_entry, "changed", true)
          # "enabled" is true - if not present
          new_entry = Builtins.add(
            new_entry,
            "enabled",
            Ops.get_boolean(change_s, "enabled", true)
          )
        end
        deep_copy(new_entry)
      end
    end
    # Not found in target? Three states happened:
    #  - Service is new (user wants forEx. telnet on port #53;-)
    #  - Service is from non-SuSE package
    #  - Service name or description is invalid
    if matches == 0
      target = Builtins.add(target, change_s)
    elsif Ops.greater_than(matches, 1)
      Builtins.y2warning("Ambiguous match (%1): %2", matches, change_s)
    end
  end

  #y2milestone("%1", changes);
  #y2milestone("%1", target);

  deep_copy(target)
end

- (Array) MergeEditedWithSystem(system_conf, edited_conf)

This function solves differences between new (after installing requested packages) xinetd configuration and the configuration edited by the user. <pre> In normal mode: take the system services if it matches a service in the ui (ServicesMatch) use the ui data (not-installed ones are not a part of netd_conf, they only enter the table in mergexinetdconfs) Deleted services: OK. Added services: a separate pass needed </pre> TODO reduce the quadratic complexity.

Parameters:

  • system_conf (Array<Hash{String => Object>})

    holds new configuration (on the system)

  • edited_conf (Array<Hash{String => Object>})

    holds old configuration (UI)

Returns:

  • (Array)

    Returnes new solved xinetd configuration (ready for Write()).



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
# File '../../src/modules/Inetd.rb', line 239

def MergeEditedWithSystem(system_conf, edited_conf)
  system_conf = deep_copy(system_conf)
  edited_conf = deep_copy(edited_conf)
  new_entry = nil

  # Take system services as the basis
  # (they include the newly installed ones)
  # and replace most of them with their edited counterparts
  # that also takes care of deleted services
  # but not of added ones
  system_conf = Builtins.maplist(system_conf) do |system_s|
    new_entry = deep_copy(system_s)
    Builtins.foreach(edited_conf) do |edited_s|
      new_entry = deep_copy(edited_s) if ServicesMatch(system_s, edited_s)
    end
    deep_copy(new_entry)
  end

  Builtins.y2milestone("CONF: %1", edited_conf)
  # now the added services
  added = Builtins.filter(edited_conf) do |edited_s|
    Builtins.search(Ops.get_string(edited_s, "iid", ""), "new") == 0
  end
  Builtins.flatten([system_conf, added])
end

- (Object) mergeWithDefaults(changes)

merges imported changes with services defaults

Parameters:

  • changes (Array<Hash{String => Object>})

    imported changes

Returns:

  • complete configuration with user changes

See Also:



360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File '../../src/modules/Inetd.rb', line 360

def mergeWithDefaults(changes)
  changes = deep_copy(changes)
  repaired_default_conf = []

  # replacing all './etc/xinetd.d/...' paths with '/etc/xinetd.d/...'
  # path must be absolute
  Builtins.foreach(@default_conf) do |service|
    iid = Ops.get_string(service, "iid", "")
    if Builtins.regexpmatch(iid, "^(.*):./etc/xinetd.d/(.*)$")
      Ops.set(
        service,
        "iid",
        Builtins.regexpsub(
          iid,
          "^(.*):\\./etc/xinetd.d/(.*)$",
          "\\1:/etc/xinetd.d/\\2"
        )
      )
    end
    repaired_default_conf = Builtins.add(repaired_default_conf, service)
  end

  MergeAyProfile(repaired_default_conf, changes)
end

- (String) mkeServiceSummary

Create unsorted list of enabled services

Returns:

  • (String)

    Returnes string with RichText-formated list



583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
# File '../../src/modules/Inetd.rb', line 583

def mkeServiceSummary
  _S = ""
  Builtins.foreach(@netd_conf) do |line|
    #"enabled" defaults to true
    if Ops.get_boolean(line, "enabled", true) &&
        !Ops.get_boolean(line, "deleted", false)
      _S = Builtins.sformat(
        "%1<li>%2 <i>(%3)</i>",
        _S,
        Ops.get_string(line, "service", ""),
        Ops.get_string(line, "protocol", "")
      )
    end
  end
  if _S == ""
    _S = _("<p><ul><i>All services are marked as stopped.</i></ul></p>")
  end
  _S
end

- (Object) Modified

Data was modified? This function returnes modified variable.

Returns:

  • true if modified



179
180
181
182
# File '../../src/modules/Inetd.rb', line 179

def Modified
  #y2debug("modified=%1",modified);
  @modified
end

- (Object) Read

Read all inetd settings

Returns:

  • true on success



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
# File '../../src/modules/Inetd.rb', line 186

def Read
  # Inetd read dialog caption
  caption = _("Initializing inetd Configuration")

  steps = 1

  Progress.New(
    caption,
    " ",
    steps,
    [_("Read the Configuration")],
    [_("Reading the configuration..."), _("Finished")],
    ""
  )

  read_status = 0
  # read database
  return false if Abort()

  @netd_conf = Convert.convert(
    SCR.Read(path(".etc.xinetd_conf.services")),
    :from => "any",
    :to   => "list <map <string, any>>"
  )

  @netd_status = Service.active?(SERVICE_NAME)

  return false if Abort()
  ProgressNextStage(_("Finished"))

  return false if Abort()
  @modified = false
  Progress.Finish
  true
end

- (Object) SafeRemove(m, keys)

Removes keys from a map. Unlike the remove builtin, does not mind if the keys are already removed.

Parameters:

  • m (Hash)

    a map

  • keys (Array)

    list of keys to remove

Returns:

  • the map without the specified keys



390
391
392
393
394
395
396
397
# File '../../src/modules/Inetd.rb', line 390

def SafeRemove(m, keys)
  m = deep_copy(m)
  keys = deep_copy(keys)
  Builtins.foreach(keys) do |key|
    m = Builtins.remove(m, key) if Builtins.haskey(m, key)
  end
  deep_copy(m)
end

- (Object) ServiceAdd(service)



756
757
758
759
760
# File '../../src/modules/Inetd.rb', line 756

def ServiceAdd(service)
  service = deep_copy(service)
  addLine(service)
  true
end

- (Object) ServiceAttributes(id)



709
710
711
712
713
# File '../../src/modules/Inetd.rb', line 709

def ServiceAttributes(id)
  Builtins.maplist(Ops.get(@netd_conf, Builtins.tointeger(id), {})) do |attribute, val|
    attribute
  end
end

- (Object) ServiceChange(id, service)



762
763
764
765
766
767
768
769
# File '../../src/modules/Inetd.rb', line 762

def ServiceChange(id, service)
  service = deep_copy(service)
  changeLine(
    service,
    Ops.get_string(@netd_conf, [Builtins.tointeger(id), "iid"], "")
  )
  true
end

- (Object) ServiceDelete(id)



749
750
751
752
753
754
# File '../../src/modules/Inetd.rb', line 749

def ServiceDelete(id)
  deleteLine(
    Ops.get_string(@netd_conf, [Builtins.tointeger(id), "iid"], "")
  )
  true
end

- (Object) ServiceEnabled(id)



745
746
747
# File '../../src/modules/Inetd.rb', line 745

def ServiceEnabled(id)
  ServiceGetTruth(id, "enabled", true)
end

- (Object) ServiceGetInt(id, attribute, dflt)



725
726
727
728
729
730
731
732
733
# File '../../src/modules/Inetd.rb', line 725

def ServiceGetInt(id, attribute, dflt)
  if Builtins.haskey(
      Ops.get(@netd_conf, Builtins.tointeger(id), {}),
      attribute
    )
    return Ops.get_integer(@netd_conf, [Builtins.tointeger(id), attribute])
  end
  dflt
end

- (Object) ServiceGetStr(id, attribute, dflt)



715
716
717
718
719
720
721
722
723
# File '../../src/modules/Inetd.rb', line 715

def ServiceGetStr(id, attribute, dflt)
  if Builtins.haskey(
      Ops.get(@netd_conf, Builtins.tointeger(id), {}),
      attribute
    )
    return Ops.get_string(@netd_conf, [Builtins.tointeger(id), attribute])
  end
  dflt
end

- (Object) ServiceGetTruth(id, attribute, dflt)



735
736
737
738
739
740
741
742
743
# File '../../src/modules/Inetd.rb', line 735

def ServiceGetTruth(id, attribute, dflt)
  if Builtins.haskey(
      Ops.get(@netd_conf, Builtins.tointeger(id), {}),
      attribute
    )
    return Ops.get_boolean(@netd_conf, [Builtins.tointeger(id), attribute])
  end
  dflt
end

- (Object) Summary

Create a textual summary and a list of unconfigured cards

Returns:

  • summary of the current configuration



605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
# File '../../src/modules/Inetd.rb', line 605

def Summary
  _S = ""
  if @netd_conf == []
    # Translators: Summary head, if nothing configured
    _S = Summary.AddHeader(_S, _("Network services"))
    _S = Summary.AddLine(_S, Summary.NotConfigured)
  else
    # Translators: Summary head, if something configured
    head = Builtins.sformat(_("Network services are managed via %1"), SERVICE_NAME)

    _S = Summary.AddHeader(_S, head)
    _S = Summary.AddHeader(_S, _("These services will be enabled"))
    _S = Builtins.sformat("%1<ul>%2</ul></p>", _S, mkeServiceSummary)
  end
  _S
end

- (Object) Write

Write all inetd settings

Returns:

  • true on success



267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# File '../../src/modules/Inetd.rb', line 267

def Write
  # Inetd read dialog caption
  caption = _("Saving inetd Configuration")

  steps = 1

  Progress.New(
    caption,
    " ",
    steps,
    [_("Write the settings")],
    [_("Writing the settings..."), _("Finished")],
    ""
  )

  Builtins.y2milestone("Calling write:\n")
  # write settings
  return false if Abort()

  if @write_only
    # YUCK, looks like autoinst part, should be done in inetd_auto.ycp
    new_conf = []
    new_conf = Convert.convert(
      SCR.Read(path(".etc.xinetd_conf.services")),
      :from => "any",
      :to   => "list <map <string, any>>"
    )
    @netd_conf = mergeAfterInstall(new_conf, @netd_conf)
  end

  SCR.Write(path(".etc.xinetd_conf.services"), @netd_conf)
  adjust_xinetd_service

  Builtins.y2milestone("Writing done\n")

  # in future: catch errors
  Report.Error(_("Cannot write settings!")) if false

  return false if Abort()
  ProgressNextStage(_("Finished"))

  return false if Abort()
  Progress.Finish
  true
end

- (Boolean) WriteOnly

Only Write settings

Returns:

  • (Boolean)

    True on success



340
341
342
343
# File '../../src/modules/Inetd.rb', line 340

def WriteOnly
  @write_only = true
  Write()
end