class OodSupport::ACLs::Nfs4Entry
Object describing single NFSv4 ACL
entry
Constants
Attributes
Domain of ACL
entry @return [String] domain of acl entry
Flags set on ACL
entry @return [Array<Symbol>] flags on acl entry
Permissions of ACL
entry @return [Array<Symbol>] permissions of acl entry
Type of ACL
entry @return [Symbol] type of acl entry
Public Class Methods
@param type [#to_sym] type of acl entry @param flags [Array<#to_sym>] list of flags for entry @param domain [#to_s] domain of principle @param permissions [Array<#to_sym>] list of permissions for entry @see ACLEntry#initialize
OodSupport::ACLEntry::new
# File lib/ood_support/acls/nfs4.rb, line 158 def initialize(type:, flags:, domain:, permissions:, **kwargs) @type = type.to_sym @flags = flags.map(&:to_sym) @domain = domain.to_s @permissions = permissions.map(&:to_sym) super(kwargs) end
Private Class Methods
Parse an entry string into input parameters
# File lib/ood_support/acls/nfs4.rb, line 248 def self.parse_entry(entry) e = REGEX_PATTERN.match(entry.to_s.strip) do |m| { type: m[:type], flags: m[:flags].chars, principle: m[:principle], domain: m[:domain], permissions: m[:permissions].chars } end e ? e : raise(InvalidACLEntry, "invalid entry: #{entry}") end
Public Instance Methods
Is this a group-specific ACL
entry @return [Boolean] is this a group entry
# File lib/ood_support/acls/nfs4.rb, line 211 def group_entry? flags.include? :g end
Is this the owning group ACL
entry @return [Boolean] is this the owning group entry
# File lib/ood_support/acls/nfs4.rb, line 229 def group_owner_entry? group_entry? && principle == "GROUP" end
Does this entry have the requested permission @param permission [#to_sym] the requested permission @return [Boolean] found this permission
# File lib/ood_support/acls/nfs4.rb, line 236 def has_permission?(permission:) permissions.include? permission.to_sym end
Is this an “allow” ACL
entry @return [Boolean] is this an allow entry
# File lib/ood_support/acls/nfs4.rb, line 168 def is_allow? type == :A end
Is this a “deny” ACL
entry @return [Boolean] is this a deny entry
# File lib/ood_support/acls/nfs4.rb, line 174 def is_deny? type == :D end
Do the requested args match this ACL
entry? @param principle [User, Group
, to_s
] requested principle @param permission [#to_sym] requested permission @param owner [String] owner of corresponding ACL
@param group [String] owning group of corresponding ACL
@raise [ArgumentError] principle isn't {User} or {Group} object @return [Boolean] does this match this entry
# File lib/ood_support/acls/nfs4.rb, line 185 def match(principle:, permission:, owner:, group:) principle = User.new(principle) if (!principle.is_a?(User) && !principle.is_a?(Group)) return false unless has_permission?(permission: permission) # Ignore domain, I don't want or care to check for domain matches p = self.principle p = owner if user_owner_entry? p = group if group_owner_entry? if (principle.is_a?(User) && group_entry?) principle.groups.include?(p) elsif (principle.is_a?(User) && user_entry?) || (principle.is_a?(Group) && group_entry?) principle == p elsif other_entry? true else false end end
Is this an other-specific ACL
entry @return [Boolean] is this an other entry
# File lib/ood_support/acls/nfs4.rb, line 217 def other_entry? principle == "EVERYONE" end
Convert object to string @return [String] the string describing this object
# File lib/ood_support/acls/nfs4.rb, line 242 def to_s "#{type}:#{flags.join}:#{principle}@#{domain}:#{permissions.join}" end
Is this a user-specific ACL
entry @return [Boolean] is this a user entry
# File lib/ood_support/acls/nfs4.rb, line 205 def user_entry? !group_entry? && !other_entry? end
Is this the owner ACL
entry @return [Boolean] is this the owner entry
# File lib/ood_support/acls/nfs4.rb, line 223 def user_owner_entry? user_entry? && principle == "OWNER" end