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:



82
83
84
# File 'extend/os/linux/sandbox.rb', line 82

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:



87
88
89
# File 'extend/os/linux/sandbox.rb', line 87

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:



92
93
94
# File 'extend/os/linux/sandbox.rb', line 92

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.



105
106
107
108
# File 'extend/os/linux/sandbox.rb', line 105

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.



111
112
113
114
115
116
# File 'extend/os/linux/sandbox.rb', line 111

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.



97
98
99
100
101
102
# File 'extend/os/linux/sandbox.rb', line 97

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:



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# File 'extend/os/linux/sandbox.rb', line 312

def run(*args)
  @prepared_writable_paths = T.let([], T.nilable(T::Array[::Pathname]))
  @masked_read_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
  @masked_read_paths&.reverse_each { |path| FileUtils.rm_rf(path) }
  @masked_read_paths = nil
end