Module: Wright::Util::User Private

Defined in:
lib/wright/util/user.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Various user utility functions.

Class Method Summary collapse

Class Method Details

.group_to_gid(group) ⇒ Integer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a group’s gid.

Examples:

Wright::Util::User.group_to_gid('root')
# => 0

Wright::Util::User.group_to_gid(0)
# => 0

Parameters:

  • group (String, Integer)

    the group’s name or gid

Returns:

  • (Integer)

    the integer gid of the given group or nil if group was nil



37
38
39
# File 'lib/wright/util/user.rb', line 37

def self.group_to_gid(group)
  to_id(group, :group)
end

.next_free_gid(gid_range) ⇒ Integer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the the next free gid in a range.

Examples:

Wright::Util::User.next_free_gid(1...500)
# => 11

Parameters:

  • gid_range (Range)

    the gid range

Returns:

  • (Integer)

    the next free gid

Raises:

  • (RuntimeError)

    if there are no free gids in the range



73
74
75
# File 'lib/wright/util/user.rb', line 73

def self.next_free_gid(gid_range)
  next_free_id(gid_range, :gid)
end

.next_free_uid(uid_range) ⇒ Integer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the the next free uid in a range.

Examples:

Wright::Util::User.next_free_uid(1...500)
# => 2

Parameters:

  • uid_range (Range)

    the uid range

Returns:

  • (Integer)

    the next free uid

Raises:

  • (RuntimeError)

    if there are no free uids in the range



59
60
61
# File 'lib/wright/util/user.rb', line 59

def self.next_free_uid(uid_range)
  next_free_id(uid_range, :uid)
end

.user_to_uid(user) ⇒ Integer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a user’s uid.

Examples:

Wright::Util::User.user_to_uid('root')
# => 0

Wright::Util::User.user_to_uid(0)
# => 0

Parameters:

  • user (String, Integer)

    the user’s name or uid

Returns:

  • (Integer)

    the integer uid of the given user or nil if user was nil



20
21
22
# File 'lib/wright/util/user.rb', line 20

def self.user_to_uid(user)
  to_id(user, :user)
end