HEX

Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit - prohibited by configuration in /home/u547966/brikov.ru/www/wp-content/plugins/admin-menu-editor/menu-editor.php on line 745
Server: Apache
System: Linux 4.19.0-0.bpo.9-amd64 x86_64 at red40
User: u547966 (5490)
PHP: 5.3.29-mh2
Disabled: syslog, dl, popen, proc_open, proc_nice, proc_get_status, proc_close, proc_terminate, posix_mkfifo, chown, chgrp, accelerator_reset, opcache_reset, accelerator_get_status, opcache_get_status, pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait, pcntl_wifexited, pcntl_wifstopped, pcntl_wifsignaled, pcntl_wifcontinued, pcntl_wexitstatus, pcntl_wtermsig, pcntl_wstopsig, pcntl_signal, pcntl_signal_dispatch, pcntl_get_last_error, pcntl_strerror, pcntl_sigprocmask, pcntl_sigwaitinfo, pcntl_sigtimedwait, pcntl_exec, pcntl_getpriority, pcntl_setpriority
Upload Files
File: //var/cache/puppet/lib/facter/openvpn.rb
require 'facter'

module Openvpn
  def self.etc_path
    case Facter.value(:osfamily)
    when 'FreeBSD'
      '/usr/local/etc/openvpn'
    when 'RedHat'
      '/etc/openvpn'
    when 'Debian'
      '/etc/openvpn'
    when 'Archlinux'
      '/etc/openvpn'
    when 'Linux'
      '/etc/openvpn'
    else
      ''
    end
  end

  def self.client_certs
    path = etc_path
    clients = {}
    if File.directory?(path)
      Dir.entries(path).each do |server|
        next unless File.directory?("#{path}/#{server}/download-configs")
        clients[server.to_s] = {}

        Dir.entries("#{path}/#{server}/download-configs").each do |client|
          next unless File.directory?("#{path}/#{server}/download-configs/#{client}") && client !~ %r{^\.\.?$} && client !~ %r{\.tblk$}

          clients[server.to_s][client.to_s] = {}
          clients[server.to_s][client.to_s]['conf'] = File.open("#{path}/#{server}/download-configs/#{client}/#{client}.conf", 'r').read
          clients[server.to_s][client.to_s]['ca'] = File.open("#{path}/#{server}/download-configs/#{client}/keys/#{client}/ca.crt", 'r').read
          clients[server.to_s][client.to_s]['crt'] = File.open("#{path}/#{server}/download-configs/#{client}/keys/#{client}/#{client}.crt", 'r').read
          clients[server.to_s][client.to_s]['key'] = File.open("#{path}/#{server}/download-configs/#{client}/keys/#{client}/#{client}.key", 'r').read
          if File.exist?("#{path}/#{server}/download-configs/#{client}/keys/#{client}/ta.key")
            clients[server.to_s][client.to_s]['ta'] = File.open("#{path}/#{server}/download-configs/#{client}/keys/#{client}/ta.key", 'r').read
          end
        end
      end
    end
    clients
  end

  # Method to call the Facter DSL and dynamically add facts at runtime.
  #
  # This method is necessary to add reasonable RSpec coverage for the custom
  # fact
  #
  # @return [NilClass]
  def self.add_facts
    certs = client_certs
    Facter.add('openvpn') do
      setcode do
        certs
      end
    end
  end
end

Openvpn.add_facts