Module: Utils::UID Private

Defined in:
utils/uid.rb

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Class Method Summary collapse

Class Method Details

.drop_euid(&_block) ⇒ T.type_parameter(:U)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • _block (T.proc.returns(T.type_parameter(:U)))

Returns:

  • (T.type_parameter(:U))


7
8
9
10
11
12
13
14
15
16
17
# File 'utils/uid.rb', line 7

def self.drop_euid(&_block)
  return yield if Process.euid == Process.uid

  original_euid = Process.euid
  begin
    Process::Sys.seteuid(Process.uid)
    yield
  ensure
    Process::Sys.seteuid(original_euid)
  end
end