Module: OS::Linux::Sandbox Private

Extended by:
T::Helpers
Included in:
Sandbox
Defined in:
extend/os/linux/sandbox.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.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.bubblewrap_candidate_paths::PATH

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.

Returns:



35
36
37
# File 'extend/os/linux/sandbox.rb', line 35

def self.bubblewrap_candidate_paths
  ::Sandbox.executable_candidate_paths
end

.bubblewrap_executable::Pathname?

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.

Returns:



40
41
42
# File 'extend/os/linux/sandbox.rb', line 40

def self.bubblewrap_executable
  ::Sandbox.executable
end

.bubblewrap_executable!::Pathname

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.

Returns:



45
46
47
# File 'extend/os/linux/sandbox.rb', line 45

def self.bubblewrap_executable!
  bubblewrap_executable || raise("Bubblewrap is required to use the Linux sandbox.")
end

Instance Method Details

#allow_cvsvoid

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.

This method returns an undefined value.



58
59
60
61
# File 'extend/os/linux/sandbox.rb', line 58

def allow_cvs
  cvspass = ::Pathname.new("#{Dir.home(ENV.fetch("USER"))}/.cvspass")
  allow_write path: cvspass, type: :literal if cvspass.exist?
end

#allow_fossilvoid

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.

This method returns an undefined value.



64
65
66
67
68
69
# File 'extend/os/linux/sandbox.rb', line 64

def allow_fossil
  [".fossil", ".fossil-journal"].each do |file|
    fossil_file = ::Pathname.new("#{Dir.home(ENV.fetch("USER"))}/#{file}")
    allow_write path: fossil_file, type: :literal if fossil_file.exist?
  end
end

#allow_write_temp_and_cachevoid

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.

This method returns an undefined value.



50
51
52
53
54
55
# File 'extend/os/linux/sandbox.rb', line 50

def allow_write_temp_and_cache
  allow_write_path "/tmp"
  allow_write_path "/var/tmp"
  allow_write_path HOMEBREW_TEMP
  allow_write_path HOMEBREW_CACHE
end

#run(*args) ⇒ void

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.

This method returns an undefined value.

Parameters:



160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'extend/os/linux/sandbox.rb', line 160

def run(*args)
  @prepared_writable_paths = T.let([], T.nilable(T::Array[::Pathname]))
  old_report_on_exception = T.let(Thread.report_on_exception, T.nilable(T::Boolean))
  Thread.report_on_exception = false
  super
ensure
  Thread.report_on_exception = old_report_on_exception unless old_report_on_exception.nil?
  @prepared_writable_paths&.reverse_each do |path|
    path.rmdir if path.directory?
  rescue Errno::ENOENT, Errno::ENOTEMPTY
    nil
  end
  @prepared_writable_paths = nil
end