Sha256: 0016d6a7014dbb88b14e21638e21477a52924907ecef4b41f45b4ee42af035a9

Contents?: true

Size: 981 Bytes

Versions: 10

Compression:

Stored size: 981 Bytes

Contents

# == AccountManager::NSCD
#
# AccountManager driver for invalidating records stored in the NSCD, Name
# Service Cache Daemon, found on Unix-like systems.
class ::AutomateIt::AccountManager::NSCD < ::AutomateIt::AccountManager::BaseDriver
  depends_on :programs => %w(nscd ps),
    # FIXME AccountManager.nscd - "ps -ef" isn't portable, may need to be "ps aux" or such
    :callbacks => lambda{`ps -ef`.match(%r{/usr/sbin/nscd$})}

  def suitability(method, *args) # :nodoc:
    # Level must be higher than Portable
    return available? ? 5 : 0
  end

  # Returns the NSCD database for the specified shorthand +query+.
  def database_for(query)
    case query.to_sym
    when :user, :users, :passwd, :password
      :passwd
    when :group, :groups
      :group
    else
      raise ArgumentError.new("Unknown cache database: #{query}")
    end
  end

  def invalidate(database)
    return false unless available?

    interpreter.sh("nscd -i #{database_for(database)}")
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
automateit-0.71104 lib/automateit/account_manager/nscd.rb
automateit-0.71112 lib/automateit/account_manager/nscd.rb
automateit-0.71219 lib/automateit/account_manager/nscd.rb
automateit-0.71221 lib/automateit/account_manager/nscd.rb
automateit-0.71111 lib/automateit/account_manager/nscd.rb
automateit-0.71220 lib/automateit/account_manager/nscd.rb
automateit-0.71226.1 lib/automateit/account_manager/nscd.rb
automateit-0.71230 lib/automateit/account_manager/nscd.rb
automateit-0.80116 lib/automateit/account_manager/nscd.rb
automateit-0.71226 lib/automateit/account_manager/nscd.rb