Sha256: 18971f4b6d452eaa968f735ac2fe0a54737ad6bc48aa679824fdc25589e670ee

Contents?: true

Size: 892 Bytes

Versions: 1

Compression:

Stored size: 892 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),
    :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

1 entries across 1 versions & 1 rubygems

Version Path
automateit-0.71103 lib/automateit/account_manager/nscd.rb