Sha256: ea2872f61fa09dc621907482fbc0410c2c7c22022373ffb0ae6af887d81029fa

Contents?: true

Size: 717 Bytes

Versions: 4

Compression:

Stored size: 717 Bytes

Contents

require 'shellwords'

module Serverspec
  module Commands
    class Linux < Base
      def check_access_by_user(file, user, access)
        "su -s sh -c \"test -#{access} #{file}\" #{user}"
      end

      def check_iptables_rule(rule, table=nil, chain=nil)
        cmd = "iptables"
        cmd += " -t #{escape(table)}" if table
        cmd += " -S"
        cmd += " #{escape(chain)}" if chain
        cmd += " | grep -- #{escape(rule)}"
        cmd
      end

      def check_selinux(mode)
        "getenforce | grep -i -- #{escape(mode)} && grep -i -- ^SELINUX=#{escape(mode)}$ /etc/selinux/config"
      end

      def check_kernel_module_loaded(name)
        "lsmod | grep ^#{name}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
serverspec-0.6.10 lib/serverspec/commands/linux.rb
serverspec-0.6.9 lib/serverspec/commands/linux.rb
serverspec-0.6.8 lib/serverspec/commands/linux.rb
serverspec-0.6.7 lib/serverspec/commands/linux.rb