Class | AutomateIt::AccountManager::Etc |
In: |
lib/automateit/account_manager/etc.rb
|
Parent: | ::AutomateIt::AccountManager::BaseDriver |
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.
See AccountManager#groups_for_user
# 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?
# File lib/automateit/account_manager/etc.rb, line 85 def has_group?(query) return ! groups[query].nil? end
See AccountManager#has_user?
# File lib/automateit/account_manager/etc.rb, line 51 def has_user?(query) return ! users[query].nil? end
See AccountManager#users_for_group
# 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
# 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