Sha256: 82725132895367e2824ef0f6c4756b104415e6a23ebbcc9a67a684ed96af82c2

Contents?: true

Size: 807 Bytes

Versions: 32

Compression:

Stored size: 807 Bytes

Contents

provides 'etc', 'current_user'

require 'etc'

def fix_encoding(str)
  str.force_encoding(Encoding.default_external) if str.respond_to?(:force_encoding)
  str
end

unless etc
  etc Mash.new

  etc[:passwd] = Mash.new
  etc[:group] = Mash.new

  Etc.passwd do |entry|
    user_passwd_entry = Mash.new(:dir => entry.dir, :gid => entry.gid, :uid => entry.uid, :shell => entry.shell, :gecos => entry.gecos)
    user_passwd_entry.each_value {|v| fix_encoding(v)}
    etc[:passwd][fix_encoding(entry.name)] = user_passwd_entry
  end

  Etc.group do |entry|
    group_entry = Mash.new(:gid => entry.gid,
                           :members => entry.mem.map {|u| fix_encoding(u)})

    etc[:group][fix_encoding(entry.name)] = group_entry
  end
end

unless current_user
  current_user fix_encoding(Etc.getlogin)
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
ohai-6.24.2 lib/ohai/plugins/passwd.rb
ohai-6.24.0 lib/ohai/plugins/passwd.rb
ohai-6.24.0.rc.0 lib/ohai/plugins/passwd.rb
ohai-6.22.0 lib/ohai/plugins/passwd.rb
ohai-6.22.0.rc.0 lib/ohai/plugins/passwd.rb
ohai-6.20.0 lib/ohai/plugins/passwd.rb
ohai-6.20.0.rc.1 lib/ohai/plugins/passwd.rb
ohai-6.18.0 lib/ohai/plugins/passwd.rb
ohai-6.18.0.rc.4 lib/ohai/plugins/passwd.rb
ohai-6.18.0.rc.3 lib/ohai/plugins/passwd.rb
ohai-6.18.0.rc.1 lib/ohai/plugins/passwd.rb
ohai-6.18.0.rc.0 lib/ohai/plugins/passwd.rb
ohai-6.16.0 lib/ohai/plugins/passwd.rb
ohai-6.16.0.beta.2 lib/ohai/plugins/passwd.rb
ohai-6.16.0.beta.1 lib/ohai/plugins/passwd.rb
ohai-6.14.0 lib/ohai/plugins/passwd.rb
ohai-6.14.0.rc.1 lib/ohai/plugins/passwd.rb
ohai-0.6.14.rc.1 lib/ohai/plugins/passwd.rb
ohai-0.6.12 lib/ohai/plugins/passwd.rb
ohai-0.6.12.rc.5 lib/ohai/plugins/passwd.rb