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.2.6 lib/facter/resolvers/windows/ssh.rb
facter-4.2.5 lib/facter/resolvers/windows/ssh.rb
facter-4.2.4 lib/facter/resolvers/windows/ssh.rb
facter-4.2.3 lib/facter/resolvers/windows/ssh.rb
facter-4.2.2 lib/facter/resolvers/windows/ssh.rb
facter-4.2.1 lib/facter/resolvers/windows/ssh.rb
facter-4.2.0 lib/facter/resolvers/windows/ssh.rb
facter-4.1.1 lib/facter/resolvers/windows/ssh.rb
facter-4.1.0 lib/facter/resolvers/windows/ssh.rb
facter-4.0.52 lib/facter/resolvers/windows/ssh.rb
facter-4.0.51 lib/facter/resolvers/windows/ssh.rb
facter-4.0.50 lib/facter/resolvers/windows/ssh.rb