Class: Serverspec::Commands::Darwin

Inherits:
Base
  • Object
show all
Defined in:
lib/serverspec/commands/darwin.rb

Instance Method Summary collapse

Methods inherited from Base

#check_authorized_key, #check_belonging_group, #check_cron_entry, #check_directory, #check_enabled, #check_file, #check_file_contain, #check_file_contain_with_fixed_strings, #check_file_contain_with_regexp, #check_file_contain_within, #check_gid, #check_group, #check_home_directory, #check_installed, #check_installed_by_gem, #check_installed_by_npm, #check_installed_by_pecl, #check_installed_by_pip, #check_ipfilter_rule, #check_ipnat_rule, #check_iptables_rule, #check_ipv4_address, #check_kernel_module_loaded, #check_listening, #check_listening_with_protocol, #check_login_shell, #check_mail_alias, #check_monitored_by_god, #check_monitored_by_monit, #check_mounted, #check_process, #check_reachable, #check_resolvable, #check_routing_table, #check_running, #check_running_under_supervisor, #check_running_under_upstart, #check_selinux, #check_socket, #check_svcprop, #check_svcprops, #check_uid, #check_user, #check_yumrepo, #check_yumrepo_enabled, #check_zfs, #escape

Instance Method Details

#check_access_by_user(file, user, access) ⇒ Object



37
38
39
# File 'lib/serverspec/commands/darwin.rb', line 37

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

#check_file_md5checksum(file, expected) ⇒ Object



6
7
8
# File 'lib/serverspec/commands/darwin.rb', line 6

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

#check_file_sha256checksum(file, expected) ⇒ Object



10
11
12
# File 'lib/serverspec/commands/darwin.rb', line 10

def check_file_sha256checksum(file, expected)
  "openssl sha256 #{escape(file)} | cut -d'=' -f2 | cut -c 2- | grep -E ^#{escape(expected)}$"
end

#check_grouped(file, group) ⇒ Object



28
29
30
31
# File 'lib/serverspec/commands/darwin.rb', line 28

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


14
15
16
# File 'lib/serverspec/commands/darwin.rb', line 14

def check_link(link, target)
  "stat -f %Y #{escape(link)} | grep -- #{escape(target)}"
end

#check_mode(file, mode) ⇒ Object



18
19
20
21
# File 'lib/serverspec/commands/darwin.rb', line 18

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

#check_owner(file, owner) ⇒ Object



23
24
25
26
# File 'lib/serverspec/commands/darwin.rb', line 23

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

#get_mode(file) ⇒ Object



33
34
35
# File 'lib/serverspec/commands/darwin.rb', line 33

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