lib/facter/security_baseline/common/check_service_enabled.rb
def check_xinetd_service(service, type = 'std')
  ret = false
  if type == 'ubuntu'
    ret = check_xinetd_service_ubuntu(service)
  else
    srv = Facter::Core::Execution.exec("chkconfig --list 2>/dev/null | grep #{service}:")
    if srv.nil? || srv.empty?
      ret = false
    else
      srvs = srv.split("\n")
      srvs.each do |line|
        data = line.split(%r{:})
        data[1].strip!
        if data[1].casecmp('off') != 0
          ret = true
        end
      end
    end
  end

  ret
end
# check if an xinetd servicve is enabled
check if an xinetd servicve is enabled
check if an xinetd servicve is enabled
def check_xinetd_service(service, type = 'std')
  ret = false
  if type == 'ubuntu'
    ret = check_xinetd_service_ubuntu(service)
  else
    srv = Facter::Core::Execution.exec("chkconfig --list 2>/dev/null | grep #{service}:")
    if srv.nil? || srv.empty?
      ret = false
    else
      srvs = srv.split("\n")
      srvs.each do |line|
        data = line.split(%r{:})
        data[1].strip!
        if data[1].casecmp('off') != 0
          ret = true
        end
      end
    end
  end
  ret
end
def check_xinetd_service ( service , type = 'std' ) ret = false if type == 'ubuntu' ret = check_xinetd_service_ubuntu ( service ) else srv = Facter :: Core :: Execution . exec ( "chkconfig --list 2>/dev/null | grep #{service}:" ) if srv . nil? || srv . empty? ret = false else srvs = srv . split ( "\n" ) srvs . each do | line | data = line . split ( %r{ : } ) data [ 1 ] . strip! if data [ 1 ] . casecmp ( 'off' ) != 0 ret = true end end end end ret end
check if an xinetd servicve is enabled
check if an xinetd servicve is enabled
service
type