Class ACL
In: drb/acl.rb
Parent: Object

Methods

Classes and Modules

Class ACL::ACLEntry
Class ACL::ACLList

Constants

VERSION = ["2.0.0"]
DENY_ALLOW = 0
ALLOW_DENY = 1

Public Class methods

[Source]

# File drb/acl.rb, line 82
  def initialize(list=nil, order = DENY_ALLOW)
    @order = order
    @deny = ACLList.new
    @allow = ACLList.new
    install_list(list) if list
  end

Public Instance methods

[Source]

# File drb/acl.rb, line 95
  def allow_addr?(addr)
    case @order
    when DENY_ALLOW
      return true if @allow.match(addr)
      return false if @deny.match(addr)
      return true
    when ALLOW_DENY
      return false if @deny.match(addr)
      return true if @allow.match(addr)
      return false
    else
      false
    end
  end

[Source]

# File drb/acl.rb, line 90
  def allow_socket?(soc)
    allow_addr?(soc.peeraddr)
  end

[Source]

# File drb/acl.rb, line 111
  def install_list(list)
    i = 0
    while i < list.size
      permission, domain = list.slice(i,2)
      case permission.downcase
      when 'allow'
        @allow.add(domain)
      when 'deny'
        @deny.add(domain)
      else
        raise "Invalid ACL entry #{list.to_s}"
      end
      i += 2
    end
  end

[Validate]