Sha256: f869e3fd4609786a14e26f84c582811fa42d4d656b81a7f0216f195415b621c8

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

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

  # Invalidates the NSCD database, thus forcing a cache reload.
  def invalidate(database)
    return false unless available?

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

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
automate-it-0.9.2 lib/automateit/account_manager/nscd.rb
automate-it-0.9.1 lib/automateit/account_manager/nscd.rb
automate-it-0.9.0 lib/automateit/account_manager/nscd.rb
automateit-0.80624 lib/automateit/account_manager/nscd.rb