Class: OodSupport::ACLs::Nfs4Entry
- Inherits:
-
OodSupport::ACLEntry
- Object
- OodSupport::ACLEntry
- OodSupport::ACLs::Nfs4Entry
- Defined in:
- lib/ood_support/acls/nfs4.rb
Overview
Object describing single NFSv4 ACL entry
Constant Summary collapse
- VALID_TYPE =
Valid types for an ACL entry
%i[ A U D L ]
- VALID_FLAG =
Valid flags for an ACL entry
%i[ f d p i S F g ]
- VALID_PERMISSION =
Valid permissions for an ACL entry
%i[ r w a x d D t T n N c C o y ]
- REGEX_PATTERN =
Regular expression used when parsing ACL entry string
%r[^(?<type>[#{VALID_TYPE.join}]):(?<flags>[#{VALID_FLAG.join}]*):(?<principle>\w+)@(?<domain>[\w\.\-]*):(?<permissions>[#{VALID_PERMISSION.join}]+)$]
Instance Attribute Summary collapse
-
#domain ⇒ String
readonly
Domain of ACL entry.
-
#flags ⇒ Array<Symbol>
readonly
Flags set on ACL entry.
-
#permissions ⇒ Array<Symbol>
readonly
Permissions of ACL entry.
-
#type ⇒ Symbol
readonly
Type of ACL entry.
Attributes inherited from OodSupport::ACLEntry
Instance Method Summary collapse
-
#group_entry? ⇒ Boolean
Is this a group-specific ACL entry.
-
#group_owner_entry? ⇒ Boolean
Is this the owning group ACL entry.
-
#has_permission?(permission:) ⇒ Boolean
Does this entry have the requested permission.
-
#initialize(type:, flags:, domain:, permissions:, **kwargs) ⇒ Nfs4Entry
constructor
A new instance of Nfs4Entry.
-
#is_allow? ⇒ Boolean
Is this an “allow” ACL entry.
-
#is_deny? ⇒ Boolean
Is this a “deny” ACL entry.
-
#match(principle:, permission:, owner:, group:) ⇒ Boolean
Do the requested args match this ACL entry?.
-
#other_entry? ⇒ Boolean
Is this an other-specific ACL entry.
-
#to_s ⇒ String
Convert object to string.
-
#user_entry? ⇒ Boolean
Is this a user-specific ACL entry.
-
#user_owner_entry? ⇒ Boolean
Is this the owner ACL entry.
Methods inherited from OodSupport::ACLEntry
Constructor Details
#initialize(type:, flags:, domain:, permissions:, **kwargs) ⇒ Nfs4Entry
Returns a new instance of Nfs4Entry.
158 159 160 161 162 163 164 |
# 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 = .map(&:to_sym) super(**kwargs) end |
Instance Attribute Details
#domain ⇒ String (readonly)
Domain of ACL entry
147 148 149 |
# File 'lib/ood_support/acls/nfs4.rb', line 147 def domain @domain end |
#flags ⇒ Array<Symbol> (readonly)
Flags set on ACL entry
143 144 145 |
# File 'lib/ood_support/acls/nfs4.rb', line 143 def flags @flags end |
#permissions ⇒ Array<Symbol> (readonly)
Permissions of ACL entry
151 152 153 |
# File 'lib/ood_support/acls/nfs4.rb', line 151 def @permissions end |
#type ⇒ Symbol (readonly)
Type of ACL entry
139 140 141 |
# File 'lib/ood_support/acls/nfs4.rb', line 139 def type @type end |
Instance Method Details
#group_entry? ⇒ Boolean
Is this a group-specific ACL entry
211 212 213 |
# File 'lib/ood_support/acls/nfs4.rb', line 211 def group_entry? flags.include? :g end |
#group_owner_entry? ⇒ Boolean
Is this the owning group ACL entry
229 230 231 |
# File 'lib/ood_support/acls/nfs4.rb', line 229 def group_owner_entry? group_entry? && principle == "GROUP" end |
#has_permission?(permission:) ⇒ Boolean
Does this entry have the requested permission
236 237 238 |
# File 'lib/ood_support/acls/nfs4.rb', line 236 def (permission:) .include? .to_sym end |
#is_allow? ⇒ Boolean
Is this an “allow” ACL entry
168 169 170 |
# File 'lib/ood_support/acls/nfs4.rb', line 168 def is_allow? type == :A end |
#is_deny? ⇒ Boolean
Is this a “deny” ACL entry
174 175 176 |
# File 'lib/ood_support/acls/nfs4.rb', line 174 def is_deny? type == :D end |
#match(principle:, permission:, owner:, group:) ⇒ Boolean
Do the requested args match this ACL entry?
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# 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 (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 |
#other_entry? ⇒ Boolean
Is this an other-specific ACL entry
217 218 219 |
# File 'lib/ood_support/acls/nfs4.rb', line 217 def other_entry? principle == "EVERYONE" end |
#to_s ⇒ String
Convert object to string
242 243 244 |
# File 'lib/ood_support/acls/nfs4.rb', line 242 def to_s "#{type}:#{flags.join}:#{principle}@#{domain}:#{.join}" end |
#user_entry? ⇒ Boolean
Is this a user-specific ACL entry
205 206 207 |
# File 'lib/ood_support/acls/nfs4.rb', line 205 def user_entry? !group_entry? && !other_entry? end |
#user_owner_entry? ⇒ Boolean
Is this the owner ACL entry
223 224 225 |
# File 'lib/ood_support/acls/nfs4.rb', line 223 def user_owner_entry? user_entry? && principle == "OWNER" end |