Sha256: 493ddee1794693fee626a9aa8fc3f5d4d437f61ef438fdf492c4716825c8246f

Contents?: true

Size: 1.3 KB

Versions: 32

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    module Windows
      class Ssh < BaseResolver
        @log = Facter::Log.new(self)

        init_resolver

        FILE_NAMES = %w[ssh_host_rsa_key.pub ssh_host_dsa_key.pub
                        ssh_host_ecdsa_key.pub ssh_host_ed25519_key.pub].freeze
        class << self
          private

          def post_resolve(fact_name, _options)
            @fact_list.fetch(fact_name) { retrieve_info(fact_name) }
          end

          def retrieve_info(fact_name)
            ssh_dir = determine_ssh_dir
            return unless ssh_dir && File.directory?(ssh_dir)

            ssh_list = []

            FILE_NAMES.each do |file_name|
              output = Facter::Util::FileHelper.safe_read(File.join(ssh_dir, file_name))
              next if output.empty?

              key_type, key = output.split(' ')
              ssh_list << Facter::Util::Resolvers::SshHelper.create_ssh(key_type, key)
            end
            @fact_list[:ssh] = ssh_list.empty? ? nil : ssh_list
            @fact_list[fact_name]
          end

          def determine_ssh_dir
            progdata_dir = ENV['programdata']

            return if !progdata_dir || progdata_dir.empty?

            File.join(progdata_dir, 'ssh')
          end
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
facter-4.7.0 lib/facter/resolvers/windows/ssh.rb
facter-4.6.1 lib/facter/resolvers/windows/ssh.rb
facter-4.6.0 lib/facter/resolvers/windows/ssh.rb
facter-4.5.2 lib/facter/resolvers/windows/ssh.rb
facter-4.5.1 lib/facter/resolvers/windows/ssh.rb
facter-4.5.0 lib/facter/resolvers/windows/ssh.rb
facter-4.4.3 lib/facter/resolvers/windows/ssh.rb
facter-4.4.2 lib/facter/resolvers/windows/ssh.rb
facter-4.4.1 lib/facter/resolvers/windows/ssh.rb
facter-4.4.0 lib/facter/resolvers/windows/ssh.rb
facter-4.3.1 lib/facter/resolvers/windows/ssh.rb
facter-4.3.0 lib/facter/resolvers/windows/ssh.rb
facter-4.2.14 lib/facter/resolvers/windows/ssh.rb
facter-4.2.13 lib/facter/resolvers/windows/ssh.rb
facter-4.2.12 lib/facter/resolvers/windows/ssh.rb
facter-4.2.11 lib/facter/resolvers/windows/ssh.rb
facter-4.2.10 lib/facter/resolvers/windows/ssh.rb
facter-4.2.9 lib/facter/resolvers/windows/ssh.rb
facter-4.2.8 lib/facter/resolvers/windows/ssh.rb
facter-4.2.7 lib/facter/resolvers/windows/ssh.rb