class OodSupport::ACLs::Nfs4ACL
Object describing an NFSv4 ACL
Constants
Attributes
Name of owning group for this ACL
@return [String] group name
Name of owner for this ACL
@return [String] owner name
Public Class Methods
Add ACL
to file path @param path [String] path to file or directory @param entry [Nfs4Entry] entry to add to file @raise [InvalidPath] file path doesn't exist @raise [BadExitCode] the command line called exited with non-zero status @return [Nfs4ACL] new acl of path
# File lib/ood_support/acls/nfs4.rb, line 41 def self.add_facl(path:, entry:) path = Pathname.new path raise InvalidPath, "invalid path: #{path}" unless path.exist? _, err, s = Open3.capture3(SET_FACL_BIN, '-a', entry.to_s, path.to_s) raise BadExitCode, err unless s.success? get_facl(path: path) end
Get ACL
from file path @param path [String] path to file or directory @raise [InvalidPath] file path doesn't exist @raise [BadExitCode] the command line called exited with non-zero status @return [Nfs4ACL] acl generated from path
# File lib/ood_support/acls/nfs4.rb, line 26 def self.get_facl(path:) path = Pathname.new path raise InvalidPath, "invalid path: #{path}" unless path.exist? stat = path.stat acl, err, s = Open3.capture3(GET_FACL_BIN, path.to_s) raise BadExitCode, err unless s.success? parse(acl, owner: User.new(stat.uid), group: Group.new(stat.gid)) end
Modify in-place an entry for file path @param path [String] path to file or directory @param old_entry [Nfs4Entry] old entry to modify in-place in file @param new_entry [Nfs4Entry] new entry to be replaced with @raise [InvalidPath] file path doesn't exist @raise [BadExitCode] the command line called exited with non-zero status @return [Nfs4ACL] new acl of path
# File lib/ood_support/acls/nfs4.rb, line 70 def self.mod_facl(path:, old_entry:, new_entry:) path = Pathname.new path raise InvalidPath, "invalid path: #{path}" unless path.exist? _, err, s = Open3.capture3(SET_FACL_BIN, '-m', old_entry.to_s, new_entry.to_s, path.to_s) raise BadExitCode, err unless s.success? get_facl(path: path) end
@param owner [#to_s] name of owner @param group [#to_s] name of group @see ACL#initialize
OodSupport::ACL::new
# File lib/ood_support/acls/nfs4.rb, line 95 def initialize(owner:, group:, **kwargs) super(kwargs.merge(default: false)) @owner = owner.to_s @group = group.to_s end
Remove ACL
from file path @param path [String] path to file or directory @param entry [Nfs4Entry] entry to remove from file @raise [InvalidPath] file path doesn't exist @raise [BadExitCode] the command line called exited with non-zero status @return [Nfs4ACL] new acl of path
# File lib/ood_support/acls/nfs4.rb, line 55 def self.rem_facl(path:, entry:) path = Pathname.new path raise InvalidPath, "invalid path: #{path}" unless path.exist? _, err, s = Open3.capture3(SET_FACL_BIN, '-x', entry.to_s, path.to_s) raise BadExitCode, err unless s.success? get_facl(path: path) end
Set ACL
(overwrites original) for file path @param path [String] path to file or directory @param acl [Nfs4ACL] ACL
to overwrite original with @raise [InvalidPath] file path doesn't exist @raise [BadExitCode] the command line called exited with non-zero status @return [Nfs4ACL] new acl of path
# File lib/ood_support/acls/nfs4.rb, line 84 def self.set_facl(path:, acl:) path = Pathname.new path raise InvalidPath, "invalid path: #{path}" unless path.exist? _, err, s = Open3.capture3(SET_FACL_BIN, '-s', acl.to_s, path.to_s) raise BadExitCode, err unless s.success? get_facl(path: path) end
Private Class Methods
Use Nfs4Entry
for entry objects
# File lib/ood_support/acls/nfs4.rb, line 118 def self.entry_class Nfs4Entry end
Public Instance Methods
Check if queried principle has access to resource @param principle [User, Group] principle to check against @param permission [Symbol] permission to check against @return [Boolean] does principle have access?
# File lib/ood_support/acls/nfs4.rb, line 105 def allow?(principle:, permission:) # Check in array order ordered_check(principle: principle, permission: permission, owner: owner, group: group) end
Convert object to hash @return [Hash] the hash describing this object
OodSupport::ACL#to_h
# File lib/ood_support/acls/nfs4.rb, line 112 def to_h super.merge owner: owner, group: group end