Sha256: 431a0a1ecdabddd0a3e4881846ff62578b0ebce0a0fd815af5baa005c723aecc

Contents?: true

Size: 763 Bytes

Versions: 6

Compression:

Stored size: 763 Bytes

Contents

require 'shellwords'

module Serverspec
  module Commands
    class Linux < Base
      class NotImplementedError < Exception; end

      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

6 entries across 6 versions & 1 rubygems

Version Path
serverspec-0.6.6 lib/serverspec/commands/linux.rb
serverspec-0.6.5 lib/serverspec/commands/linux.rb
serverspec-0.6.4 lib/serverspec/commands/linux.rb
serverspec-0.6.3 lib/serverspec/commands/linux.rb
serverspec-0.6.2 lib/serverspec/commands/linux.rb
serverspec-0.6.1 lib/serverspec/commands/linux.rb