※当サイトの記事には、広告・プロモーションが含まれます。

Oxidizedのmodel.rbのpostメソッドの挙動が分からな過ぎる...

gigazine.net

イギリスに拠点を構える防衛ベンチャーHelsing(ヘルシング)が2024年12月2日に、大量生産と群れ(スウォーム)での運用を想定して開発された攻撃ドローン「HX-2」を発表しました。

「ヘルシング」が初のAI攻撃ドローンを発表、データ接続なしで最大100km飛行し標的を再識別して攻撃可能 - GIGAZINE

同社は「民主主義国家の安全強化」を使命として掲げており、既にHX-2のコア技術の生産とウクライナへの配備が進んでいるとしています。

「ヘルシング」が初のAI攻撃ドローンを発表、データ接続なしで最大100km飛行し標的を再識別して攻撃可能 - GIGAZINE

⇧「民主主義」と「民主主義」が戦争を始めた場合、

同社は「民主主義国家の安全強化」を使命として掲げており

は破綻する気がするんだが...

将来は、最終的に、AIによる代理戦争に向かっていくことになるんかね?

Oxidizedのmodel.rbのpostメソッドの挙動が分からな過ぎる...

何度か、このブログで話題にしてきた、

github.com

Oxidized is a network device configuration backup tool. It's a RANCID replacement!

It is light and extensible and supports over 130 operating system types.

https://github.com/ytti/oxidized

⇧「Ruby」製のライブラリがあるのだが、

github.com

https://github.com/ytti/oxidized/blob/master/lib/oxidized/model/model.rb

require 'strscan'
require_relative 'outputs'

module Oxidized
  class Model
    using Refinements

    include Oxidized::Config::Vars

    class << self
      def inherited(klass)
        super
        if klass.superclass == Oxidized::Model
          klass.instance_variable_set '@cmd',     (Hash.new { |h, k| h[k] = [] })
          klass.instance_variable_set '@cfg',     (Hash.new { |h, k| h[k] = [] })
          klass.instance_variable_set '@procs',   (Hash.new { |h, k| h[k] = [] })
          klass.instance_variable_set '@expect',  []
          klass.instance_variable_set '@comment', nil
          klass.instance_variable_set '@prompt',  nil
        else # we're subclassing some existing model, take its variables
          instance_variables.each do |var|
            iv = instance_variable_get(var)
            klass.instance_variable_set var, iv.dup
            @cmd[:cmd] = iv[:cmd].dup if var.to_s == "@cmd"
          end
        end
      end

      def comment(str = "# ")
        @comment = if block_given?
                     yield
                   elsif not @comment
                     str
                   else
                     @comment
                   end
      end

      def prompt(regex = nil)
        @prompt = regex || @prompt
      end

      def cfg(*methods, **args, &block)
        [methods].flatten.each do |method|
          process_args_block(@cfg[method.to_s], args, block)
        end
      end

      def cfgs
        @cfg
      end

      def cmd(cmd_arg = nil, **args, &block)
        if cmd_arg.instance_of?(Symbol)
          process_args_block(@cmd[cmd_arg], args, block)
        else
          process_args_block(@cmd[:cmd], args, [cmd_arg, block])
        end
        Oxidized.logger.debug "lib/oxidized/model/model.rb Added #{cmd_arg} to the commands list"
      end

      def cmds
        @cmd
      end

      def expect(regex, **args, &block)
        process_args_block(@expect, args, [regex, block])
      end

      def expects
        @expect
      end

      # calls the block at the end of the model, prepending the output of the
      # block to the output string
      #
      # @author Saku Ytti <saku@ytti.fi>
      # @since 0.0.39
      # @yield expects block which should return [String]
      # @return [void]
      def pre(**args, &block)
        process_args_block(@procs[:pre], args, block)
      end

      # calls the block at the end of the model, adding the output of the block
      # to the output string
      #
      # @author Saku Ytti <saku@ytti.fi>
      # @since 0.0.39
      # @yield expects block which should return [String]
      # @return [void]
      def post(**args, &block)
        process_args_block(@procs[:post], args, block)
      end

      # @author Saku Ytti <saku@ytti.fi>
      # @since 0.0.39
      # @return [Hash] hash proc procs :pre+:post to be prepended/postfixed to output
      attr_reader :procs

      private

      def process_args_block(target, args, block)
        if args[:clear]
          if block.instance_of?(Array)
            target.reject! { |k, _| k == block[0] }
            target.push(block)
          else
            target.replace([block])
          end
        else
          method = args[:prepend] ? :unshift : :push
          target.send(method, block)
        end
      end
    end

    attr_accessor :input, :node

    def cmd(string, &block)
      Oxidized.logger.debug "lib/oxidized/model/model.rb Executing #{string}"
      out = @input.cmd(string)
      return false unless out

      out = out.b unless Oxidized.config.input.utf8_encoded?
      self.class.cmds[:all].each do |all_block|
        out = instance_exec out, string, &all_block
      end
      if vars :remove_secret
        self.class.cmds[:secret].each do |all_block|
          out = instance_exec out, string, &all_block
        end
      end
      out = instance_exec out, &block if block
      process_cmd_output out, string
    end

    def output
      @input.output
    end

    def send(data)
      @input.send data
    end

    def expect(...)
      self.class.expect(...)
    end

    def cfg
      self.class.cfgs
    end

    def prompt
      self.class.prompt
    end

    def expects(data)
      self.class.expects.each do |re, cb|
        if data.match re
          data = cb.arity == 2 ? instance_exec([data, re], &cb) : instance_exec(data, &cb)
        end
      end
      data
    end

    def get
      Oxidized.logger.debug 'lib/oxidized/model/model.rb Collecting commands\' outputs'
      outputs = Outputs.new
      procs = self.class.procs
      self.class.cmds[:cmd].each do |command, block|
        out = cmd command, &block
        return false unless out

        outputs << out
      end
      procs[:pre].each do |pre_proc|
        outputs.unshift process_cmd_output(instance_eval(&pre_proc), '')
      end
      procs[:post].each do |post_proc|
        outputs << process_cmd_output(instance_eval(&post_proc), '')
      end
      outputs
    end

    def comment(str)
      data = ''
      str.each_line do |line|
        data << self.class.comment << line
      end
      data
    end

    def xmlcomment(str)
      # XML Comments start with <!-- and end with -->
      #
      # Because it's illegal for the first or last characters of a comment
      # to be a -, i.e. <!--- or ---> are illegal, and also to improve
      # readability, we add extra spaces after and before the beginning
      # and end of comment markers.
      #
      # Also, XML Comments must not contain --. So we put a space between
      # any double hyphens, by replacing any - that is followed by another -
      # with '- '
      data = ''
      str.each_line do |_line|
        data << '<!-- ' << str.gsub(/-(?=-)/, '- ').chomp << " -->\n"
      end
      data
    end

    def screenscrape
      @input.class.to_s.match(/Telnet/) || vars(:ssh_no_exec)
    end

    private

    def process_cmd_output(output, name)
      output = String.new('') unless output.instance_of?(String)
      output.process_cmd(name)
      output
    end
  end
end

⇧ model.rbファイルを継承したmodelクラスが、「OS(Operation System)」毎に用意されていますと。

全ては「model.rb」を継承しているのだが、

  1. preメソッド
  2. その他のメソッド
  3. postメソッド

という順番で処理されるのだと思うのだが、今いち、Rubyの親クラスの変数へのアクセスが分からんのだが、

https://github.com/ytti/oxidized/blob/master/lib/oxidized/model/linuxgeneric.rb

class LinuxGeneric < Oxidized::Model
  using Refinements

  prompt /^(\w.*|\W.*)[:#$] /
  comment '# '

  # add a comment in the final conf
  def add_comment(comment)
    "\n###### #{comment} ######\n"
  end

  cmd :all do |cfg|
    cfg.gsub! /^(default (\S+).* (expires) ).*/, '\\1 <redacted>'
    cfg.cut_both
  end

  # show the persistent configuration
  pre do
    cfg = add_comment 'THE HOSTNAME'
    cfg += cmd 'cat /etc/hostname'

    cfg += add_comment 'THE HOSTS'
    cfg += cmd 'cat /etc/hosts'

    cfg += add_comment 'THE INTERFACES'
    cfg += cmd 'ip link'

    cfg += add_comment 'RESOLV.CONF'
    cfg += cmd 'cat /etc/resolv.conf'

    cfg += add_comment 'IP Routes'
    cfg += cmd 'ip route'

    cfg += add_comment 'IPv6 Routes'
    cfg += cmd 'ip -6 route'

    cfg += add_comment 'MOTD'
    cfg += cmd 'cat /etc/motd'

    cfg += add_comment 'PASSWD'
    cfg += cmd 'cat /etc/passwd'

    cfg += add_comment 'GROUP'
    cfg += cmd 'cat /etc/group'

    cfg += add_comment 'nsswitch.conf'
    cfg += cmd 'cat /etc/nsswitch.conf'

    cfg += add_comment 'VERSION'
    cfg += cmd 'cat /etc/issue'

    cfg
  end

  cfg :telnet do
    username /^Username:/
    password /^Password:/
  end

  cfg :telnet, :ssh do
    post_login do
      if vars(:enable) == true
        cmd "sudo su -", /^\[sudo\] password/
        cmd @node.auth[:password]
      elsif vars(:enable)
        cmd "su -", /^Password:/
        cmd vars(:enable)
      end
    end

    pre_logout do
      cmd "exit" if vars(:enable)
    end
    pre_logout 'exit'
  end
end    

⇧ 上記のクラスを継承した、

■/opt/app/oxidized/.config/oxidized/model/linuxgenericextra.rb

require 'oxidized/model/linuxgeneric.rb'

class LinuxGenericExtra < LinuxGeneric
  using Refinements

  post do
    comments = []

    # 'ip a' コマンドの結果を取得し、コメントを追加
    result = cmd('ip a') do |cfg|
      title = add_comment('HOST IP ADDRESS')
      title += "\n" + cfg
      title  # 修正: 結果を返す
    end
    comments << result

    # 'uname -a' コマンドの結果を取得し、コメントを追加
    result = cmd('uname -a') do |cfg|
      title = add_comment('HOST NAME')
      title += "\n" + cfg
      title  # 修正: 結果を返す
    end
    comments << result

    # 'date' コマンドの結果を取得し、コメントを追加
    result = cmd('date "+%Y/%m/%d %H:%M:%S"') do |cfg|
      title = add_comment('CURRENT DATETIME')
      title += "\n" + cfg
      title  # 修正: 結果を返す
    end
    comments << result

    # すべてのコメントを結合して出力
    comment comments.join("\n")
  end
end    

⇧ 上記のクラスでOxidizedの処理をさせたところ、親クラスの変数を更新できた。

■Oxidizedの実行結果

# [root@Toshinobu-PC .git]# gils-tree --full-tree -r HEAD
100644 blob 809515124ae9ae09cf1f559b2586f330bc123c98    .github/workflows/github-actions.yml
100644 blob 49e240a9368c0f0dc3adeff2cd2ae7ae2c66c4f5    README.md
100644 blob 4a992c079b395ab5b25befe393f4cdcad7f9a2be    commit_history.txt
100644 blob d173621f8214c2839bf310c732d60e42ad8bb129    localhost
100644 blob a28b6748e651a5a88868b191ef483b5f2f803f31    new_file.txt
[root@Toshinobu-PC .git]# git --git-dir=/opt/app/oxidized/.config/oxidized/.git cat-file blob d173621f8214c2839bf310c732d60e42ad8bb129

###### THE HOSTNAME ######
redhat7.9

###### THE HOSTS ######
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

###### THE INTERFACES ######
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:b2:6e:a8 brd ff:ff:ff:ff:ff:ff
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:4c:f9:e2 brd ff:ff:ff:ff:ff:ff

###### RESOLV.CONF ######
# Generated by NetworkManager
search 9
nameserver 192.168.1.1

###### IP Routes ######
default via 10.0.2.1 dev enp0s3 proto dhcp src 10.0.2.4 metric 100
default via 192.168.234.1 dev enp0s8 proto static metric 101
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.4 metric 100
192.168.234.0/24 dev enp0s8 proto kernel scope link src 192.168.234.4 metric 101

###### IPv6 Routes ######
::1 dev lo proto kernel metric 256 pref medium
fe80::/64 dev enp0s3 proto kernel metric 1024 pref medium
fe80::/64 dev enp0s8 proto kernel metric 1024 pref medium

###### MOTD ######

###### PASSWD ######
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
chrony:x:998:996::/var/lib/chrony:/sbin/nologin
ts0818:x:1000:1000:ts0818:/home/ts0818:/bin/bash
tss:x:59:59:Account used for TPM access:/:/sbin/nologin
systemd-coredump:x:997:993:systemd Core Dumper:/:/sbin/nologin
systemd-resolve:x:193:193:systemd Resolver:/:/sbin/nologin
unbound:x:996:992:Unbound DNS resolver:/etc/unbound:/sbin/nologin

###### GROUP ######
root:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
disk:x:6:
lp:x:7:
mem:x:8:
kmem:x:9:
wheel:x:10:ts0818
cdrom:x:11:
mail:x:12:postfix
man:x:15:
dialout:x:18:
floppy:x:19:
games:x:20:
tape:x:33:
video:x:39:
ftp:x:50:
lock:x:54:
audio:x:63:
nobody:x:99:
users:x:100:
utmp:x:22:
utempter:x:35:
input:x:999:
systemd-journal:x:190:
systemd-network:x:192:
dbus:x:81:
polkitd:x:998:
ssh_keys:x:997:
sshd:x:74:
postdrop:x:90:
postfix:x:89:
chrony:x:996:
ts0818:x:1000:ts0818
cgred:x:995:
tss:x:59:
kvm:x:36:
render:x:994:
systemd-coredump:x:993:
systemd-resolve:x:193:
unbound:x:992:
sgx:x:991:

###### nsswitch.conf ######
#
# /etc/nsswitch.conf
#
# An example Name Service Switch config file. This file should be
# sorted with the most-used services at the beginning.
#
# The entry '[NOTFOUND=return]' means that the search for an
# entry should stop if the search in the previous entry turned
# up nothing. Note that if the search failed due to some other reason
# (like no NIS server responding) then the search continues with the
# next entry.
#
# Valid entries include:
#
#       nisplus                 Use NIS+ (NIS version 3)
#       nis                     Use NIS (NIS version 2), also called YP
#       dns                     Use DNS (Domain Name Service)
#       files                   Use the local files
#       db                      Use the local database (.db) files
#       compat                  Use NIS on compat mode
#       hesiod                  Use Hesiod for user lookups
#       sss                     Use sssd (System Security Services Daemon)
#       [NOTFOUND=return]       Stop searching if not found so far
#
# WARNING: Running nscd with a secondary caching service like sssd may lead to
#          unexpected behaviour, especially with how long entries are cached.

# To use db, put the "db" in front of "files" for entries you want to be
# looked up first in the databases
#
# Example:
#passwd:    db files nisplus nis
#shadow:    db files nisplus nis
#group:     db files nisplus nis

passwd:     files sss
shadow:     files sss
group:      files sss
#initgroups: files sss

#hosts:     db files nisplus nis dns
hosts:      files dns myhostname

# Example - obey only what nisplus tells us...
#services:   nisplus [NOTFOUND=return] files
#networks:   nisplus [NOTFOUND=return] files
#protocols:  nisplus [NOTFOUND=return] files
#rpc:        nisplus [NOTFOUND=return] files
#ethers:     nisplus [NOTFOUND=return] files
#netmasks:   nisplus [NOTFOUND=return] files

bootparams: nisplus [NOTFOUND=return] files

ethers:     files
netmasks:   files
networks:   files
protocols:  files
rpc:        files
services:   files sss

netgroup:   nisplus sss

publickey:  nisplus

automount:  files nisplus sss
aliases:    files nisplus


###### VERSION ######
\S
Kernel \r on an \m

#
# ###### HOST IP ADDRESS ######
#
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
#     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
#     inet 127.0.0.1/8 scope host lo
#        valid_lft forever preferred_lft forever
#     inet6 ::1/128 scope host
#        valid_lft forever preferred_lft forever
# 2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
#     link/ether 08:00:27:b2:6e:a8 brd ff:ff:ff:ff:ff:ff
#     inet 10.0.2.4/24 brd 10.0.2.255 scope global dynamic noprefixroute enp0s3
#        valid_lft 388sec preferred_lft 388sec
#     inet6 fe80::8ca:adcf:52c4:9fe3/64 scope link noprefixroute
#        valid_lft forever preferred_lft forever
# 3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
#     link/ether 08:00:27:4c:f9:e2 brd ff:ff:ff:ff:ff:ff
#     inet 192.168.234.4/24 brd 192.168.234.255 scope global noprefixroute enp0s8
#        valid_lft forever preferred_lft forever
#     inet6 fe80::1dce:618f:d8a1:aeec/64 scope link noprefixroute
#        valid_lft forever preferred_lft forever
#
#
# ###### HOST NAME ######
#
Linux redhat7.9 5.14.0-427.35.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Aug 30 15:47:10 EDT 2024 x86_64 x86_64 x86_64 GNU/Linux
#
#
# ###### CURRENT DATETIME ######
#
2024/12/04 22:09:33

⇧ とりあえず、postメソッド以外も挙動が分からな過ぎるんだが、何か直接、クラス変数を更新できてしまうのは違和感があり過ぎるんよね...

JavaだとSetterとかLombokで設定する感じになるので、

comment comments.join("\n")

⇧ のような更新の仕方に違和感を感じてしまう...

何やら、

■/opt/app/oxidized/.config/oxidized/model/linuxgenericextra.rb

require 'oxidized/model/linuxgeneric.rb'

class LinuxGenericExtra < LinuxGeneric
  using Refinements

  post do
    comments = []

    # 'ip a' コマンドの結果を取得し、コメントを追加
    result = cmd('ip a') do |cfg|
      title = add_comment('HOST IP ADDRESS')
      title += "\n" + cfg
      # 結果を返す
      title
    end
    comments << result

    # 'uname -a' コマンドの結果を取得し、コメントを追加
    result = cmd('uname -a') do |cfg|
      title = add_comment('HOST NAME')
      title += "\n" + cfg
      # 結果を返す
      title
    end
    comments << result

    # 'date' コマンドの結果を取得し、コメントを追加
    result = cmd('date "+%Y/%m/%d %H:%M:%S"') do |cfg|
      title = add_comment('CURRENT DATETIME')
      title += "\n" + cfg
      # 結果を返す
      title
    end
    comments << result

    # すべてのコメントを結合して出力
    comments.join("\n")
  end
end    

親クラスの変数を経由しなくても、

■Oxidizedの実行結果

[root@Toshinobu-PC .git]# git ls-tree --full-tree -r HEAD
100644 blob 809515124ae9ae09cf1f559b2586f330bc123c98    .github/workflows/github-actions.yml
100644 blob 49e240a9368c0f0dc3adeff2cd2ae7ae2c66c4f5    README.md
100644 blob 4a992c079b395ab5b25befe393f4cdcad7f9a2be    commit_history.txt
100644 blob 6d8beee9306d0b487c20b5aa0d28eb6af747d1ed    localhost
100644 blob a28b6748e651a5a88868b191ef483b5f2f803f31    new_file.txt
[root@Toshinobu-PC .git]# git --git-dir=/opt/app/oxidized/.config/oxidized/.git cat-file blob 6d8beee9306d0b487c20b5aa0d28eb6af747d1ed

###### THE HOSTNAME ######
redhat7.9

###### THE HOSTS ######
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

###### THE INTERFACES ######
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:b2:6e:a8 brd ff:ff:ff:ff:ff:ff
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:4c:f9:e2 brd ff:ff:ff:ff:ff:ff

###### RESOLV.CONF ######
# Generated by NetworkManager
search 9
nameserver 192.168.1.1

###### IP Routes ######
default via 10.0.2.1 dev enp0s3 proto dhcp src 10.0.2.4 metric 100
default via 192.168.234.1 dev enp0s8 proto static metric 101
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.4 metric 100
192.168.234.0/24 dev enp0s8 proto kernel scope link src 192.168.234.4 metric 101

###### IPv6 Routes ######
::1 dev lo proto kernel metric 256 pref medium
fe80::/64 dev enp0s3 proto kernel metric 1024 pref medium
fe80::/64 dev enp0s8 proto kernel metric 1024 pref medium

###### MOTD ######

###### PASSWD ######
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
chrony:x:998:996::/var/lib/chrony:/sbin/nologin
ts0818:x:1000:1000:ts0818:/home/ts0818:/bin/bash
tss:x:59:59:Account used for TPM access:/:/sbin/nologin
systemd-coredump:x:997:993:systemd Core Dumper:/:/sbin/nologin
systemd-resolve:x:193:193:systemd Resolver:/:/sbin/nologin
unbound:x:996:992:Unbound DNS resolver:/etc/unbound:/sbin/nologin

###### GROUP ######
root:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
disk:x:6:
lp:x:7:
mem:x:8:
kmem:x:9:
wheel:x:10:ts0818
cdrom:x:11:
mail:x:12:postfix
man:x:15:
dialout:x:18:
floppy:x:19:
games:x:20:
tape:x:33:
video:x:39:
ftp:x:50:
lock:x:54:
audio:x:63:
nobody:x:99:
users:x:100:
utmp:x:22:
utempter:x:35:
input:x:999:
systemd-journal:x:190:
systemd-network:x:192:
dbus:x:81:
polkitd:x:998:
ssh_keys:x:997:
sshd:x:74:
postdrop:x:90:
postfix:x:89:
chrony:x:996:
ts0818:x:1000:ts0818
cgred:x:995:
tss:x:59:
kvm:x:36:
render:x:994:
systemd-coredump:x:993:
systemd-resolve:x:193:
unbound:x:992:
sgx:x:991:

###### nsswitch.conf ######
#
# /etc/nsswitch.conf
#
# An example Name Service Switch config file. This file should be
# sorted with the most-used services at the beginning.
#
# The entry '[NOTFOUND=return]' means that the search for an
# entry should stop if the search in the previous entry turned
# up nothing. Note that if the search failed due to some other reason
# (like no NIS server responding) then the search continues with the
# next entry.
#
# Valid entries include:
#
#       nisplus                 Use NIS+ (NIS version 3)
#       nis                     Use NIS (NIS version 2), also called YP
#       dns                     Use DNS (Domain Name Service)
#       files                   Use the local files
#       db                      Use the local database (.db) files
#       compat                  Use NIS on compat mode
#       hesiod                  Use Hesiod for user lookups
#       sss                     Use sssd (System Security Services Daemon)
#       [NOTFOUND=return]       Stop searching if not found so far
#
# WARNING: Running nscd with a secondary caching service like sssd may lead to
#          unexpected behaviour, especially with how long entries are cached.

# To use db, put the "db" in front of "files" for entries you want to be
# looked up first in the databases
#
# Example:
#passwd:    db files nisplus nis
#shadow:    db files nisplus nis
#group:     db files nisplus nis

passwd:     files sss
shadow:     files sss
group:      files sss
#initgroups: files sss

#hosts:     db files nisplus nis dns
hosts:      files dns myhostname

# Example - obey only what nisplus tells us...
#services:   nisplus [NOTFOUND=return] files
#networks:   nisplus [NOTFOUND=return] files
#protocols:  nisplus [NOTFOUND=return] files
#rpc:        nisplus [NOTFOUND=return] files
#ethers:     nisplus [NOTFOUND=return] files
#netmasks:   nisplus [NOTFOUND=return] files

bootparams: nisplus [NOTFOUND=return] files

ethers:     files
netmasks:   files
networks:   files
protocols:  files
rpc:        files
services:   files sss

netgroup:   nisplus sss

publickey:  nisplus

automount:  files nisplus sss
aliases:    files nisplus


###### VERSION ######
\S
Kernel \r on an \m


###### HOST IP ADDRESS ######

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:b2:6e:a8 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.4/24 brd 10.0.2.255 scope global dynamic noprefixroute enp0s3
       valid_lft 417sec preferred_lft 417sec
    inet6 fe80::8ca:adcf:52c4:9fe3/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:4c:f9:e2 brd ff:ff:ff:ff:ff:ff
    inet 192.168.234.4/24 brd 192.168.234.255 scope global noprefixroute enp0s8
       valid_lft forever preferred_lft forever
    inet6 fe80::1dce:618f:d8a1:aeec/64 scope link noprefixroute
       valid_lft forever preferred_lft forever


###### HOST NAME ######

Linux redhat7.9 5.14.0-427.35.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Aug 30 15:47:10 EDT 2024 x86_64 x86_64 x86_64 GNU/Linux


###### CURRENT DATETIME ######

2024/12/04 22:59:00

⇧ 追記されたのだが、postメソッドの仕組みが謎過ぎる...

型が分からないのも辛いのだが、トリッキーなコーディングを何とかして欲しい気分...

とりあえず、他のmodelクラスを継承した場合でも同様に動作して欲しいものだが...

ios.rbを拡張したmodelクラスで実現しないといけないので...

ios.rbは、postメソッドを使っているから、linuxgeneric.rbを継承した時と挙動が変わりそうなのよね...

「Oxidized」はブラックボックス過ぎるのと、情報が少ないのとで利用したくないんよね...

ちなみに、

⇧ ChatGPTさんにも匙を投げられた感じです...

ChatGPTの提案されたコードは全く機能しませんでした...

ちなみに、

github.com

⇧「Ruby」の特徴なのか分からんのだが、ブロック内の処理をメソッド化していないせいで、親クラスのブロック内の処理をコピペせざる得ないという...

親クラスの方で、メソッド化しておいてくれれば再利用できたのだが、「Oxidized」の思想なのか、「Ruby」の思想なのか、誠に残念過ぎる...

Ruby」何も分からん...

毎度モヤモヤ感が半端ない…

今回はこのへんで。