Class AutomateIt::AccountManager::Etc
In: lib/automateit/account_manager/etc.rb
Parent: ::AutomateIt::AccountManager::BaseDriver

AccountManager::Etc

An AccountManager driver for Unix-like OSes that have the Ruby Etc module. It is only suitable for doing queries and lacks methods that perform modifications, such as add_user. Platform-specific drivers inherit from this class and provide methods that perform modifications.

Methods

Classes and Modules

Class AutomateIt::AccountManager::Etc::GroupQuery
Class AutomateIt::AccountManager::Etc::UserQuery

Public Instance methods

See AccountManager#groups

[Source]

# File lib/automateit/account_manager/etc.rb, line 80
  def groups
    return GroupQuery.new
  end

See AccountManager#groups_for_user

[Source]

# File lib/automateit/account_manager/etc.rb, line 90
  def groups_for_user(query)
    pwent = users[query]
    return [] if preview? and not pwent
    username = pwent.name
    result = Set.new
    result << groups[pwent.gid].name if groups[pwent.gid]
    ::Etc.group do |grent|
      result << grent.name if grent.mem.include?(username)
    end
    return result.to_a
  end

See AccountManager#has_group?

[Source]

# File lib/automateit/account_manager/etc.rb, line 85
  def has_group?(query)
    return ! groups[query].nil?
  end

See AccountManager#has_user?

[Source]

# File lib/automateit/account_manager/etc.rb, line 51
  def has_user?(query)
    return ! users[query].nil?
  end

See AccountManager#users

[Source]

# File lib/automateit/account_manager/etc.rb, line 46
  def users
    return UserQuery.new
  end

See AccountManager#users_for_group

[Source]

# File lib/automateit/account_manager/etc.rb, line 103
  def users_for_group(query)
    grent = groups[query]
    return (preview? || ! grent) ? [] : grent.mem
  end

See AccountManager#users_to_groups

[Source]

# File lib/automateit/account_manager/etc.rb, line 109
  def users_to_groups
    result = {}
    ::Etc.group do |grent|
      grent.mem.each do |username|
        result[username] ||= Set.new
        result[username] << grent.name
      end
    end
    ::Etc.passwd do |pwent|
      grent = groups[pwent.gid]
      unless grent
        log.fatal(PNOTE+"WARNING: User's default group doesn't exist: user %s, gid %s" % [pwent.name, pwent.gid])
        next
      end
      result[pwent.name] ||= Set.new
      result[pwent.name] << grent.name
    end
    return result
  end

[Validate]