bwrap 1.0.0.pre.beta1 → 1.1.0.pre.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +20 -0
- data/lib/bwrap/args/args.rb +36 -1
- data/lib/bwrap/args/bind/library/ruby_binds.rb +45 -0
- data/lib/bwrap/args/bind/library.rb +47 -10
- data/lib/bwrap/args/bind/mime.rb +9 -2
- data/lib/bwrap/args/bind.rb +34 -15
- data/lib/bwrap/args/construct.rb +80 -42
- data/lib/bwrap/args/environment.rb +31 -4
- data/lib/bwrap/args/features/binds_base.rb +13 -0
- data/lib/bwrap/args/features/ruby_binds.rb +47 -0
- data/lib/bwrap/args/features.rb +27 -34
- data/lib/bwrap/args/library.rb +1 -3
- data/lib/bwrap/args/machine_id.rb +5 -3
- data/lib/bwrap/args/mount.rb +5 -4
- data/lib/bwrap/args/network.rb +43 -0
- data/lib/bwrap/bwrap.rb +10 -2
- data/lib/bwrap/bwrap_module.rb +26 -0
- data/lib/bwrap/config/features/base.rb +28 -0
- data/lib/bwrap/config/features/ruby.rb +86 -0
- data/lib/bwrap/config/features.rb +24 -61
- data/lib/bwrap/config.rb +54 -41
- data/lib/bwrap/execution/exceptions.rb +12 -0
- data/lib/bwrap/execution/execute.rb +14 -3
- data/lib/bwrap/execution/execution.rb +9 -9
- data/lib/bwrap/execution/path.rb +3 -3
- data/lib/bwrap/execution.rb +2 -0
- data/lib/bwrap/output/levels.rb +33 -3
- data/lib/bwrap/output/log.rb +16 -2
- data/lib/bwrap/output/output_impl.rb +55 -0
- data/lib/bwrap/output.rb +2 -0
- data/lib/bwrap/version.rb +1 -1
- data/lib/bwrap.rb +1 -26
- data.tar.gz.sig +0 -0
- metadata +39 -4
- metadata.gz.sig +0 -0
data/lib/bwrap/config.rb
CHANGED
@@ -18,8 +18,45 @@ require_relative "config/features"
|
|
18
18
|
#
|
19
19
|
# @todo Add some documentation about syntax where necessary, like for #binaries_from.
|
20
20
|
class Bwrap::Config
|
21
|
+
# Array of audio schemes usable inside chroot.
|
22
|
+
#
|
23
|
+
# Currently supports:
|
24
|
+
# - :pulseaudio
|
25
|
+
#
|
26
|
+
attr_accessor :audio
|
27
|
+
|
28
|
+
# Set to `true` if command given to {Bwrap::Bwrap#run} is expected to
|
29
|
+
# be inside sandbox, and not bound from host.
|
30
|
+
#
|
31
|
+
# @return [Boolean] `true` if executed command is inside sandbox
|
32
|
+
attr_accessor :command_inside_root
|
33
|
+
|
34
|
+
attr_accessor :extra_executables
|
35
|
+
|
36
|
+
# TODO: IIRC this doesn’t match the reality any more. So write correct documentation.
|
37
|
+
#
|
38
|
+
# Causes libraries required by the executable given to {Bwrap#run} to be
|
39
|
+
# mounted inside sandbox.
|
40
|
+
#
|
41
|
+
# Often it is enough to use this flag instead of binding all system libraries
|
42
|
+
# using {#libdir_mounts=}
|
43
|
+
#
|
44
|
+
# @return [Boolean] true if Linux library loaders are mounted inside chroot
|
45
|
+
attr_accessor :full_system_mounts
|
46
|
+
|
21
47
|
attr_accessor :hostname
|
22
48
|
|
49
|
+
# Set to true if basic system directories, like /usr/lib and /usr/lib64,
|
50
|
+
# should be bound inside chroot.
|
51
|
+
#
|
52
|
+
# /usr/bin can be mounted using {Config#binaries_from=}.
|
53
|
+
#
|
54
|
+
# Often it is enough to use {#full_system_mounts=} instead of binding all
|
55
|
+
# system libraries using this flag.
|
56
|
+
#
|
57
|
+
# @return [Boolean] true if libdirs are mounted to the chroot
|
58
|
+
attr_accessor :libdir_mounts
|
59
|
+
|
23
60
|
# What should be used as /etc/machine_id file.
|
24
61
|
#
|
25
62
|
# If not specified, no /etc/machine_id handling is done.
|
@@ -34,6 +71,9 @@ class Bwrap::Config
|
|
34
71
|
# Given file as bound as /etc/machine_id.
|
35
72
|
attr_accessor :machine_id
|
36
73
|
|
74
|
+
# @return [Boolean] true if network should be shared from host.
|
75
|
+
attr_accessor :share_net
|
76
|
+
|
37
77
|
# Name of the user inside chroot.
|
38
78
|
#
|
39
79
|
# This is optional and defaults to no user.
|
@@ -45,46 +85,23 @@ class Bwrap::Config
|
|
45
85
|
# @return [Boolean] Whether Xorg specific binds are used.
|
46
86
|
attr_accessor :xorg_application
|
47
87
|
|
48
|
-
# Array of
|
49
|
-
#
|
50
|
-
# Currently supports:
|
51
|
-
# - :pulseaudio
|
52
|
-
#
|
53
|
-
attr_accessor :audio
|
54
|
-
|
55
|
-
# @return [Boolean] true if network should be shared from host.
|
56
|
-
attr_accessor :share_net
|
57
|
-
|
58
|
-
# Causes libraries required by the executable given to {Bwrap#run} to be
|
59
|
-
# mounted inside sandbox.
|
60
|
-
#
|
61
|
-
# Often it is enough to use this flag instead of binding all system libraries
|
62
|
-
# using {#libdir_mounts=}
|
88
|
+
# Array of directories to be bind mounted in sandbox.
|
63
89
|
#
|
64
|
-
#
|
65
|
-
attr_accessor :full_system_mounts
|
66
|
-
|
67
|
-
# Set to true if basic system directories, like /usr/lib and /usr/lib64,
|
68
|
-
# should be bound inside chroot.
|
90
|
+
# Given paths are also added to PATH environment variable inside sandbox.
|
69
91
|
#
|
70
|
-
#
|
92
|
+
# @hint At least on SUSE, many executables are symlinks to /etc/alternatives/*,
|
93
|
+
# which in turn symlinks to versioned executable under the same bindir.
|
94
|
+
# To use these executables, /etc/alternatives should also be bound:
|
71
95
|
#
|
72
|
-
#
|
73
|
-
# system libraries using this flag.
|
96
|
+
# config.ro_binds["/etc/alternatives"] = "/etc/alternatives"
|
74
97
|
#
|
75
|
-
# @return [
|
76
|
-
|
98
|
+
# @return [Array] Paths to directories where binaries are looked from.
|
99
|
+
attr_reader :binaries_from
|
77
100
|
|
78
|
-
#
|
79
|
-
# be inside sandbox, and not bound from host.
|
101
|
+
# Paths to be added to sandbox instance’s PATH environment variable.
|
80
102
|
#
|
81
|
-
# @
|
82
|
-
|
83
|
-
|
84
|
-
attr_accessor :extra_executables
|
85
|
-
|
86
|
-
# Array of directories to be bind mounted and used to construct PATH environment variable.
|
87
|
-
attr_reader :binaries_from
|
103
|
+
# @see #add_env_path
|
104
|
+
attr_reader :env_paths
|
88
105
|
|
89
106
|
# TODO: Document this.
|
90
107
|
# TODO: I wonder if this should just be removed. I don’t know, this is a bit ...
|
@@ -116,16 +133,12 @@ class Bwrap::Config
|
|
116
133
|
# @param dir Path to temporary directory
|
117
134
|
attr_reader :tmpdir
|
118
135
|
|
119
|
-
# Paths to be added to sandbox instance’s PATH environment variable.
|
120
|
-
#
|
121
|
-
# @see #add_env_path
|
122
|
-
attr_reader :env_paths
|
123
|
-
|
124
136
|
def initialize
|
125
|
-
@binaries_from = []
|
126
|
-
@tmpdir = Dir.tmpdir
|
127
137
|
@audio = []
|
138
|
+
@binaries_from = []
|
128
139
|
@env_paths = []
|
140
|
+
@ro_binds = {}
|
141
|
+
@tmpdir = Dir.tmpdir
|
129
142
|
end
|
130
143
|
|
131
144
|
def binaries_from= array
|
@@ -7,6 +7,18 @@ module Bwrap::Execution
|
|
7
7
|
|
8
8
|
# Signifies that command execution has failed.
|
9
9
|
class ExecutionFailed < CommandError
|
10
|
+
# The command that was executed.
|
11
|
+
attr_reader :command
|
12
|
+
|
13
|
+
# Output of the command.
|
14
|
+
attr_reader :output
|
15
|
+
|
16
|
+
def initialize msg, command:, output:
|
17
|
+
@command = command
|
18
|
+
@output = output
|
19
|
+
|
20
|
+
super msg
|
21
|
+
end
|
10
22
|
end
|
11
23
|
|
12
24
|
# Thrown if given command was not found.
|
@@ -63,13 +63,17 @@ class Bwrap::Execution::Execute
|
|
63
63
|
end
|
64
64
|
|
65
65
|
# Checks whether execution failed and acts accordingly.
|
66
|
-
def self.handle_execution_fail fail:, error:, output:
|
67
|
-
return unless fail and
|
66
|
+
def self.handle_execution_fail fail:, error:, output:, command:
|
67
|
+
return unless fail and !execution_success?
|
68
68
|
|
69
69
|
if error == :show and !output.empty?
|
70
70
|
Bwrap::Output.warn_output "Command failed with output:\n“#{output}”"
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
|
+
exception = Bwrap::Execution::ExecutionFailed.new "Command execution failed",
|
74
|
+
command: command,
|
75
|
+
output: output
|
76
|
+
raise exception, caller
|
73
77
|
end
|
74
78
|
|
75
79
|
# @note It makes sense for caller to just return if wait has been set and not check output.
|
@@ -101,6 +105,13 @@ class Bwrap::Execution::Execute
|
|
101
105
|
"to add “self.prepend_rootcmd(command, rootcmd:)” method."
|
102
106
|
end
|
103
107
|
|
108
|
+
# A wrapper to get status of an execution.
|
109
|
+
#
|
110
|
+
# Mainly here so test implementation is easier.
|
111
|
+
private_class_method def self.execution_success?
|
112
|
+
$CHILD_STATUS.success?
|
113
|
+
end
|
114
|
+
|
104
115
|
# Used by `#handle_logging`.
|
105
116
|
private_class_method def self.calculate_log_command command
|
106
117
|
return command.dup unless command.respond_to?(:join)
|
@@ -61,7 +61,7 @@ module Bwrap::Execution
|
|
61
61
|
end
|
62
62
|
|
63
63
|
# If command is string, splat operator (the *) does not do anything. If array, it expand the arguments.
|
64
|
-
# This causes spawning work correctly, as that’s how spawn() expects to have the
|
64
|
+
# This causes spawning work correctly, as that’s how spawn() expects to have the arguments.
|
65
65
|
pid = spawn(env, *command, err: [ :child, :out ], out: Execute.w, unsetenv_others: clear_env)
|
66
66
|
output = Execute.finish_execution(log: log, wait: wait, direct_output: direct_output)
|
67
67
|
return pid unless wait
|
@@ -71,7 +71,7 @@ module Bwrap::Execution
|
|
71
71
|
@last_status = $CHILD_STATUS
|
72
72
|
|
73
73
|
output = Execute.process_output output: output
|
74
|
-
Execute.handle_execution_fail fail: fail, error: error, output: output
|
74
|
+
Execute.handle_execution_fail fail: fail, error: error, output: output, command: command
|
75
75
|
output
|
76
76
|
ensure
|
77
77
|
Execute.clean_variables
|
@@ -91,14 +91,14 @@ module Bwrap::Execution
|
|
91
91
|
# execute commands.
|
92
92
|
#
|
93
93
|
# @see .do_execute .do_execute for documentation of argument syntax
|
94
|
-
private def execute *args
|
94
|
+
private def execute *args, **kwargs
|
95
95
|
# Mangle proper location to error message.
|
96
|
-
if
|
97
|
-
|
96
|
+
if kwargs.is_a? Hash
|
97
|
+
kwargs[:log_callback] = 3
|
98
98
|
else
|
99
|
-
|
99
|
+
kwargs = { log_callback: 3 }
|
100
100
|
end
|
101
|
-
Bwrap::Execution.do_execute(*args)
|
101
|
+
Bwrap::Execution.do_execute(*args, **kwargs)
|
102
102
|
end
|
103
103
|
|
104
104
|
# Same as ::execute, but uses log: false to avoid unnecessary output when we’re just getting a
|
@@ -106,7 +106,7 @@ module Bwrap::Execution
|
|
106
106
|
#
|
107
107
|
# Defaults to fail: false, since when one just wants to get the value, there is not that much
|
108
108
|
# need to unconditionally die if getting bad exit code.
|
109
|
-
private def execvalue *args, fail: false,
|
109
|
+
private def execvalue *args, fail: false, log: false, **kwargs
|
110
110
|
# This logging handling is a bit of duplication from execute(), but to be extra safe, it is duplicated.
|
111
111
|
# The debug message contents will always be evaluated, so can just do it like this.
|
112
112
|
log_command = args[0].respond_to?(:join) && args[0].join(" ") || args[0]
|
@@ -121,7 +121,7 @@ module Bwrap::Execution
|
|
121
121
|
return
|
122
122
|
end
|
123
123
|
trace "Execvaluing “#{log_command}” at #{caller_locations(1, 1)[0]}"
|
124
|
-
execute(*args, fail: fail, log:
|
124
|
+
execute(*args, fail: fail, log: log, **kwargs)
|
125
125
|
end
|
126
126
|
|
127
127
|
private def exec_success?
|
data/lib/bwrap/execution/path.rb
CHANGED
@@ -20,7 +20,7 @@ module Bwrap::Execution::Path
|
|
20
20
|
#
|
21
21
|
# @yield Command appended to each path in PATH environment variable
|
22
22
|
# @yieldparam path [String] Full path to executable
|
23
|
-
def self.each_env_path command, env_path_var: ENV
|
23
|
+
def self.each_env_path command, env_path_var: ENV.fetch("PATH", nil)
|
24
24
|
exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [ "" ]
|
25
25
|
|
26
26
|
env_path_var.split(File::PATH_SEPARATOR).each do |env_path|
|
@@ -39,7 +39,7 @@ module Bwrap::Execution::Path
|
|
39
39
|
# @param command [String] executable to be resolved
|
40
40
|
# @param env_path_var [String] PATH environment variable as string.
|
41
41
|
# Defaults to `ENV["PATH"]`
|
42
|
-
private def command_available? command, env_path_var: ENV
|
42
|
+
private def command_available? command, env_path_var: ENV.fetch("PATH", nil)
|
43
43
|
# Special handling for absolute paths.
|
44
44
|
path = Pathname.new command
|
45
45
|
if path.absolute?
|
@@ -60,7 +60,7 @@ module Bwrap::Execution::Path
|
|
60
60
|
# Returns path to given executable.
|
61
61
|
#
|
62
62
|
# @param (see #command_available?)
|
63
|
-
private def which command, fail: true, env_path_var: ENV
|
63
|
+
private def which command, fail: true, env_path_var: ENV.fetch("PATH", nil)
|
64
64
|
# Special handling for absolute paths.
|
65
65
|
path = Pathname.new command
|
66
66
|
if path.absolute?
|
data/lib/bwrap/execution.rb
CHANGED
data/lib/bwrap/output/levels.rb
CHANGED
@@ -8,7 +8,8 @@ class Bwrap::Output::Levels
|
|
8
8
|
|
9
9
|
@@_verbose = false
|
10
10
|
@@_debug = false
|
11
|
-
@@_trace = ENV
|
11
|
+
@@_trace = ENV.fetch("BWRAP_TRACE", nil) && true || false
|
12
|
+
@@_quiet = false
|
12
13
|
|
13
14
|
# @see Bwrap::Output#verbose?
|
14
15
|
def self.verbose?
|
@@ -25,8 +26,18 @@ class Bwrap::Output::Levels
|
|
25
26
|
@@_trace
|
26
27
|
end
|
27
28
|
|
29
|
+
# @see Bwrap::Output##quiet?
|
30
|
+
def self.quiet?
|
31
|
+
@@_quiet
|
32
|
+
end
|
33
|
+
|
28
34
|
# Takes hash of options received from Optimist and checks output related flags.
|
29
35
|
def self.handle_output_options options
|
36
|
+
if options[:quiet] or options[:silent]
|
37
|
+
quiet!
|
38
|
+
return
|
39
|
+
end
|
40
|
+
|
30
41
|
# Set output level flags to true or false, if it was given.
|
31
42
|
unless options[:trace].nil?
|
32
43
|
@@_verbose = options[:trace]
|
@@ -64,6 +75,18 @@ class Bwrap::Output::Levels
|
|
64
75
|
out
|
65
76
|
end
|
66
77
|
|
78
|
+
# Formats given string and outputs it.
|
79
|
+
#
|
80
|
+
# @return formatted string
|
81
|
+
def self.info_print_formatted str, log_callback: 1
|
82
|
+
# TODO: Maybe have different color for NOTICE than for INFO?
|
83
|
+
out = "#{Bwrap::Output::Colors.color(130, 230, 130, bold: true)}[NOTICE]#{Bwrap::Output::Colors.stopcolor} #{str}"
|
84
|
+
out = append_caller out, log_callback: (log_callback + 1)
|
85
|
+
puts out
|
86
|
+
|
87
|
+
out
|
88
|
+
end
|
89
|
+
|
67
90
|
# Formats given string and outputs it.
|
68
91
|
#
|
69
92
|
# @return formatted string
|
@@ -98,9 +121,16 @@ class Bwrap::Output::Levels
|
|
98
121
|
# Appends caller information to given output.
|
99
122
|
#
|
100
123
|
# Used by *_print_formatted methods.
|
101
|
-
def self.append_caller out, log_callback: 1
|
124
|
+
private_class_method def self.append_caller out, log_callback: 1
|
102
125
|
out = "#{out} (called at #{caller_locations(log_callback, 1)[0]})" if @@_trace
|
103
126
|
out
|
104
127
|
end
|
105
|
-
|
128
|
+
|
129
|
+
# Sets variables so that no extra output is shown.
|
130
|
+
private_class_method def self.quiet!
|
131
|
+
@@_verbose = false
|
132
|
+
@@_debug = false
|
133
|
+
@@_trace = false
|
134
|
+
@@_quiet = true
|
135
|
+
end
|
106
136
|
end
|
data/lib/bwrap/output/log.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# force_encoding modifies string, so can’t freeze strings.
|
4
|
-
|
5
3
|
# Logging methods.
|
4
|
+
#
|
5
|
+
# @note One should require "bwrap/output" instead of this file directly, even
|
6
|
+
# if using only methods from this class.
|
7
|
+
#
|
8
|
+
# This is because Bwrap::Output module would be missing, or there could be
|
9
|
+
# a circular dependency, which is always bad, even if Ruby would break it for you.
|
6
10
|
class Bwrap::Output::Log
|
7
11
|
@@log_file = nil
|
8
12
|
|
@@ -13,11 +17,17 @@ class Bwrap::Output::Log
|
|
13
17
|
|
14
18
|
# Writes given string to log.
|
15
19
|
def self.write_to_log str
|
20
|
+
# Guard against invalid input.
|
21
|
+
return unless str.respond_to? :force_encoding
|
22
|
+
|
16
23
|
@@log_file&.write str.dup.force_encoding("UTF-8")
|
17
24
|
end
|
18
25
|
|
19
26
|
# Writes given string to log.
|
20
27
|
def self.puts_to_log str
|
28
|
+
# Guard against invalid input.
|
29
|
+
return unless str.respond_to? :force_encoding
|
30
|
+
|
21
31
|
@@log_file&.puts str.dup.force_encoding("UTF-8")
|
22
32
|
end
|
23
33
|
|
@@ -29,6 +39,10 @@ class Bwrap::Output::Log
|
|
29
39
|
|
30
40
|
# Starts logging to given file.
|
31
41
|
def self.log_to_file log_path
|
42
|
+
unless File.writable? log_path
|
43
|
+
warn "Given log file #{log_path} is not writable by current user."
|
44
|
+
return
|
45
|
+
end
|
32
46
|
log_file = File.open log_path, "w"
|
33
47
|
|
34
48
|
# In default mode, log messages disappears as Ruby’s own buffer gets full.
|
@@ -3,6 +3,7 @@
|
|
3
3
|
# Have variables like $CHILD_STATUS which is alias of $?.
|
4
4
|
require "English"
|
5
5
|
|
6
|
+
require "bwrap/bwrap_module"
|
6
7
|
require "bwrap/execution/labels"
|
7
8
|
|
8
9
|
require_relative "levels"
|
@@ -31,6 +32,8 @@ require_relative "log"
|
|
31
32
|
# When using {Bwrap::Bwrap}, {Bwrap::Bwrap#parse_command_line_arguments}
|
32
33
|
# causes output levels to be set if relevant CLI arguments have been
|
33
34
|
# given. TODO: Add documentation about CLI args somewhere. Maybe README?
|
35
|
+
#
|
36
|
+
# TODO: Add new method info() which can then be silenced using --quiet or --silent.
|
34
37
|
module Bwrap::Output
|
35
38
|
# @see #verbose?
|
36
39
|
def self.verbose?
|
@@ -42,6 +45,12 @@ module Bwrap::Output
|
|
42
45
|
Bwrap::Output::Levels.debug?
|
43
46
|
end
|
44
47
|
|
48
|
+
# @see #quiet?
|
49
|
+
# @see #info
|
50
|
+
def self.quiet?
|
51
|
+
Bwrap::Output::Levels.quiet?
|
52
|
+
end
|
53
|
+
|
45
54
|
# @see #trace?
|
46
55
|
def self.trace?
|
47
56
|
Bwrap::Output::Levels.trace?
|
@@ -88,6 +97,18 @@ module Bwrap::Output
|
|
88
97
|
Bwrap::Output::Log.puts_to_log out || str
|
89
98
|
end
|
90
99
|
|
100
|
+
# Handler used by #info to output given string.
|
101
|
+
def self.info_output str, raw: false, log_callback: 1
|
102
|
+
return if quiet?
|
103
|
+
|
104
|
+
if raw
|
105
|
+
print str
|
106
|
+
else
|
107
|
+
out = Bwrap::Output::Levels.info_print_formatted str, log_callback: (log_callback + 1)
|
108
|
+
end
|
109
|
+
Bwrap::Output::Log.puts_to_log out || str
|
110
|
+
end
|
111
|
+
|
91
112
|
# Handler used by #warn to output given string.
|
92
113
|
def self.warn_output str, raw: false, log_callback: 1
|
93
114
|
if raw
|
@@ -113,6 +134,13 @@ module Bwrap::Output
|
|
113
134
|
exit exit_code
|
114
135
|
end
|
115
136
|
|
137
|
+
# @see #info
|
138
|
+
#
|
139
|
+
# @return true if --quiet or --silent has been passed, false if not.
|
140
|
+
private def quiet?
|
141
|
+
Bwrap::Output::Levels.quiet?
|
142
|
+
end
|
143
|
+
|
116
144
|
# @return true if --verbose, --debug or --trace has been passed, false if not.
|
117
145
|
private def verbose?
|
118
146
|
Bwrap::Output::Levels.verbose?
|
@@ -160,6 +188,33 @@ module Bwrap::Output
|
|
160
188
|
Bwrap::Output.verb_output(str, raw: raw, log_callback: 2)
|
161
189
|
end
|
162
190
|
|
191
|
+
# Outputs given string if info flag has been set.
|
192
|
+
#
|
193
|
+
# This is meant for notices, and the log will be labeled with
|
194
|
+
# [NOTICE].
|
195
|
+
#
|
196
|
+
# Output flags can be set with {.handle_output_options}.
|
197
|
+
#
|
198
|
+
# == Implementation hint
|
199
|
+
#
|
200
|
+
# Usually implementing --quiet and/or --silent flag
|
201
|
+
# to control these messages (and all other output) may make
|
202
|
+
# sense.
|
203
|
+
#
|
204
|
+
# That way it would be possible to have some important
|
205
|
+
# informational messages that should be shown, but for script
|
206
|
+
# usage, those could be muted.
|
207
|
+
#
|
208
|
+
# Warning messages are meant to be shown always. Error messages
|
209
|
+
# will always be printed, as execution is halted after the
|
210
|
+
# error message has been printed.
|
211
|
+
#
|
212
|
+
# @param str String to be outputted
|
213
|
+
# @param raw [Boolean] If true, disables output formatting
|
214
|
+
private def info str, raw: false
|
215
|
+
Bwrap::Output.info_output(str, raw: raw, log_callback: 2)
|
216
|
+
end
|
217
|
+
|
163
218
|
# Outputs given string to `$stderr`.
|
164
219
|
#
|
165
220
|
# @param str String to be outputted
|
data/lib/bwrap/output.rb
CHANGED
data/lib/bwrap/version.rb
CHANGED
data/lib/bwrap.rb
CHANGED
@@ -1,28 +1,3 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "bwrap/bwrap"
|
4
|
-
|
5
|
-
# ruby-bwrap provides easy-to-use interface to run complex programs in sandboxes created with
|
6
|
-
# {https://github.com/containers/bubblewrap bubblewrap}.
|
7
|
-
#
|
8
|
-
# To run a program inside bubblewrap, a wrapper executable can be created. For example:
|
9
|
-
#
|
10
|
-
# require "bwrap"
|
11
|
-
#
|
12
|
-
# config = Bwrap::Config.new
|
13
|
-
# config.user = "dummy_user"
|
14
|
-
# config.full_system_mounts = true
|
15
|
-
# config.binaries_from = %w{
|
16
|
-
# /bin
|
17
|
-
# /usr/bin
|
18
|
-
# }
|
19
|
-
#
|
20
|
-
# bwrap = Bwrap::Bwrap.new config
|
21
|
-
# bwrap.parse_command_line_arguments
|
22
|
-
# bwrap.run "/bin/true"
|
23
|
-
#
|
24
|
-
# There also are few generic utilities, {Bwrap::Output} for handling output of scripts and
|
25
|
-
# {Bwrap::Execution} to run executables.
|
26
|
-
module Bwrap
|
27
|
-
# Empty module.
|
28
|
-
end
|
3
|
+
require "bwrap/bwrap"
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bwrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0.pre.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samu Voutilainen
|
@@ -34,7 +34,7 @@ cert_chain:
|
|
34
34
|
X4ioQwEn1/9tHs19VO1CLF58451HgEo1BXd7eWLmV1V5cqw0YWok1ly4L/Su/Phf
|
35
35
|
MRxVMHiVAqY=
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date:
|
37
|
+
date: 2022-05-28 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: bundler
|
@@ -92,20 +92,48 @@ dependencies:
|
|
92
92
|
- - "~>"
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '1.1'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rspec
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '3.11'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '3.11'
|
95
109
|
- !ruby/object:Gem::Dependency
|
96
110
|
name: rspec-expectations
|
97
111
|
requirement: !ruby/object:Gem::Requirement
|
98
112
|
requirements:
|
99
113
|
- - "~>"
|
100
114
|
- !ruby/object:Gem::Version
|
101
|
-
version: '3.
|
115
|
+
version: '3.11'
|
116
|
+
type: :development
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '3.11'
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: rspec-mocks
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '3.11'
|
102
130
|
type: :development
|
103
131
|
prerelease: false
|
104
132
|
version_requirements: !ruby/object:Gem::Requirement
|
105
133
|
requirements:
|
106
134
|
- - "~>"
|
107
135
|
- !ruby/object:Gem::Version
|
108
|
-
version: '3.
|
136
|
+
version: '3.11'
|
109
137
|
description: For now this is tailored to my needs, so this may or may not be of any
|
110
138
|
use.
|
111
139
|
email:
|
@@ -121,16 +149,23 @@ files:
|
|
121
149
|
- lib/bwrap/args/args.rb
|
122
150
|
- lib/bwrap/args/bind.rb
|
123
151
|
- lib/bwrap/args/bind/library.rb
|
152
|
+
- lib/bwrap/args/bind/library/ruby_binds.rb
|
124
153
|
- lib/bwrap/args/bind/mime.rb
|
125
154
|
- lib/bwrap/args/construct.rb
|
126
155
|
- lib/bwrap/args/environment.rb
|
127
156
|
- lib/bwrap/args/features.rb
|
157
|
+
- lib/bwrap/args/features/binds_base.rb
|
158
|
+
- lib/bwrap/args/features/ruby_binds.rb
|
128
159
|
- lib/bwrap/args/library.rb
|
129
160
|
- lib/bwrap/args/machine_id.rb
|
130
161
|
- lib/bwrap/args/mount.rb
|
162
|
+
- lib/bwrap/args/network.rb
|
131
163
|
- lib/bwrap/bwrap.rb
|
164
|
+
- lib/bwrap/bwrap_module.rb
|
132
165
|
- lib/bwrap/config.rb
|
133
166
|
- lib/bwrap/config/features.rb
|
167
|
+
- lib/bwrap/config/features/base.rb
|
168
|
+
- lib/bwrap/config/features/ruby.rb
|
134
169
|
- lib/bwrap/execution.rb
|
135
170
|
- lib/bwrap/execution/exceptions.rb
|
136
171
|
- lib/bwrap/execution/execute.rb
|
metadata.gz.sig
CHANGED
Binary file
|