Sha256: 224afda06030045e66f39b757205a07528c2ce8fa18757a13a431b8a47fdafd0

Contents?: true

Size: 648 Bytes

Versions: 4

Compression:

Stored size: 648 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 /bin/sh -c \"/usr/bin/test -#{access} #{file}\" #{user}"
      end

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

      def check_selinux mode
        "/usr/sbin/getenforce | grep -i -- #{escape(mode)}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
serverspec-0.4.11 lib/serverspec/commands/linux.rb
serverspec-0.4.10 lib/serverspec/commands/linux.rb
serverspec-0.4.9 lib/serverspec/commands/linux.rb
serverspec-0.4.8 lib/serverspec/commands/linux.rb