Sha256: 6aa0aed55be4fc25f51cf5a1ed589d78f3cbbeaf79a51babb73bcbea58e3917c

Contents?: true

Size: 748 Bytes

Versions: 3

Compression:

Stored size: 748 Bytes

Contents

require 'etc'

module Dockerun
  module Cli

    module UserInfo
      include TR::CondUtils

      def self.user_info(login = nil)
        login = Etc.getlogin if is_empty?(login)
        res = { login: login }
        begin
          res[:uid] = Etc.getpwnam(login).uid
        rescue Exception => ex
          res[:uid] = nil
        end
        res
      end

      def self.group_info(login = nil)
        login = Etc.getlogin if is_empty?(login)
        res = {  }
        begin
          gnm = Etc.getgrnam(login)
          res[:group_name] = gnm.name
          res[:gid] = gnm.gid
        rescue Exception => ex
          p ex
          res[:group_name] = ""
          res[:gid] = nil
        end
        res
      end

    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dockerun-0.4.2 lib/dockerun/cli/user_info.rb
dockerun-0.4.1 lib/dockerun/cli/user_info.rb
dockerun-0.4.0 lib/dockerun/cli/user_info.rb