Class: Specinfra::Command::Linux::Base::File

Inherits:
Base::File show all
Defined in:
lib/specinfra/command/linux/base/file.rb

Direct Known Subclasses

Arch::Base::File, Redhat::Base::File

Class Method Summary collapse

Methods inherited from Base::File

change_group, change_mode, change_owner, check_contains, check_contains_lines, check_contains_with_fixed_strings, check_contains_with_regexp, check_contains_within, check_exists, check_has_mode, check_is_block_device, check_is_character_device, check_is_directory, check_is_file, check_is_grouped, check_is_link, check_is_linked_to, check_is_mounted, check_is_owned_by, check_is_pipe, check_is_socket, check_is_symlink, copy, create_as_directory, download, get_content, get_link_target, get_md5sum, get_mode, get_mtime, get_owner_group, get_owner_user, get_sha256sum, get_size, link_to, move, remove

Methods inherited from Base

create, escape

Class Method Details

.check_attribute(file, attribute) ⇒ Object



11
12
13
14
# File 'lib/specinfra/command/linux/base/file.rb', line 11

def check_attribute(file, attribute)
  "lsattr -d #{escape(file)} 2>&1 | " + 
  "awk '$1~/^[A-Za-z-]+$/ && $1~/#{escape(attribute)}/ {exit 0} {exit 1}'"
end

.check_is_accessible_by_user(file, user, access) ⇒ Object



3
4
5
# File 'lib/specinfra/command/linux/base/file.rb', line 3

def check_is_accessible_by_user(file, user, access)
  "su -s /bin/sh -c \"test -#{access} #{file}\" #{user}"
end

.check_is_immutable(file) ⇒ Object



7
8
9
# File 'lib/specinfra/command/linux/base/file.rb', line 7

def check_is_immutable(file)
  check_attribute(file, 'i')
end

.get_selinuxlabel(file) ⇒ Object



16
17
18
# File 'lib/specinfra/command/linux/base/file.rb', line 16

def get_selinuxlabel(file)
  "stat -c %C #{escape(file)}"
end