Module: Sprinkle::Verifiers::Permission

Defined in:
lib/sprinkle/verifiers/permission.rb

Overview

Permission and ownership Verifier

Contains a verifier to check the permissions and ownership of a file or directory.

Example Usage

verify { has_permission '/etc/apache2/apache2.conf', 0644 }

verify { belongs_to_user '/etc/apache2/apache2.conf', 'noop' }

verify { belongs_to_user '/etc/apache2/apache2.conf', 1000 }

Instance Method Summary collapse

Instance Method Details

#belongs_to_group(path, group) ⇒ Object


27
28
29
30
# File 'lib/sprinkle/verifiers/permission.rb', line 27

def belongs_to_group(path, group)
  arg = group.is_a?(Integer) ? "-gid" : "-group"
  @commands << "find #{path} -maxdepth 0 #{arg} #{group} | egrep '.*'"
end

#belongs_to_user(path, user) ⇒ Object


22
23
24
25
# File 'lib/sprinkle/verifiers/permission.rb', line 22

def belongs_to_user(path, user)
  arg = user.is_a?(Integer) ? "-uid" : "-user"
  @commands << "find #{path} -maxdepth 0 #{arg} #{user} | egrep '.*'"
end

#has_permission(path, permission) ⇒ Object


18
19
20
# File 'lib/sprinkle/verifiers/permission.rb', line 18

def has_permission(path, permission)
  @commands << "find #{path} -maxdepth 0 -perm #{permission} | egrep '.*'"
end