Sha256: 6c1559699a3dd7f2895a0797016b2945f421fcac30c05793623cc3f496cc29fe

Contents?: true

Size: 874 Bytes

Versions: 26

Compression:

Stored size: 874 Bytes

Contents

require 'shellwords'

module Serverspec
  module Commands
    class Darwin < Base
      def check_file_md5checksum(file, expected)
        "openssl md5 #{escape(file)} | cut -d'=' -f2 | cut -c 2- | grep -E ^#{escape(expected)}$"
      end

      def check_mode(file, mode)
        regexp = "^#{mode}$"
        "stat -f%Lp #{escape(file)} | grep -- #{escape(regexp)}"
      end

      def check_owner(file, owner)
        regexp = "^#{owner}$"
        "stat -f %Su #{escape(file)} | grep -- #{escape(regexp)}"
      end

      def check_grouped(file, group)
        regexp = "^#{group}$"
        "stat -f %Sg #{escape(file)} | grep -- #{escape(regexp)}"
      end

      def get_mode(file)
        "stat -f%Lp #{escape(file)}"
      end

      def check_access_by_user(file, user, access)
        "sudo -u #{user} -s /bin/test -#{access} #{file}"
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
serverspec-0.7.2 lib/serverspec/commands/darwin.rb
serverspec-0.7.1 lib/serverspec/commands/darwin.rb
serverspec-0.7.0 lib/serverspec/commands/darwin.rb
serverspec-0.6.30 lib/serverspec/commands/darwin.rb
serverspec-0.6.29 lib/serverspec/commands/darwin.rb
serverspec-0.6.28 lib/serverspec/commands/darwin.rb
serverspec-0.6.27 lib/serverspec/commands/darwin.rb
serverspec-0.6.26 lib/serverspec/commands/darwin.rb
serverspec-0.6.25 lib/serverspec/commands/darwin.rb
serverspec-0.6.24 lib/serverspec/commands/darwin.rb
serverspec-0.6.23 lib/serverspec/commands/darwin.rb
serverspec-0.6.22 lib/serverspec/commands/darwin.rb
serverspec-0.6.21 lib/serverspec/commands/darwin.rb
serverspec-0.6.20 lib/serverspec/commands/darwin.rb
serverspec-0.6.19 lib/serverspec/commands/darwin.rb
serverspec-0.6.18 lib/serverspec/commands/darwin.rb
serverspec-0.6.17 lib/serverspec/commands/darwin.rb
serverspec-0.6.16 lib/serverspec/commands/darwin.rb
serverspec-0.6.15 lib/serverspec/commands/darwin.rb
serverspec-0.6.13 lib/serverspec/commands/darwin.rb