bwrap 1.1.0.pre.rc1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8b6393a69ed3aed4509adc16eb3f1cd6a91e0035d8460ab4a83b89aad6556c6
4
- data.tar.gz: 4d6b6482993d86b2f481b5bc941ac7ff4186f3393be11f7aa8b28aa7670218f5
3
+ metadata.gz: d341ff2f9550758a2fcbcdac6812c1b85a77acf6154015654d1d4980c3cf00e1
4
+ data.tar.gz: 680c94999f6c1bbe5524a11ead5e380d07c46a51978b5b51827f373a73836cee
5
5
  SHA512:
6
- metadata.gz: 04c68f504070bc0f1b5e4b6140430ce568c3c4aef5c3a61a62370c67e71638cd8e1ea5c0b410cc3852056165770af48758402c684b7d8887c127ea8986bfba4a
7
- data.tar.gz: e0ae2b57a5f7b131754a984351af597c5881bee8cc6464db11eaf58cd6fe057abb82846fa433592ae199790678ff854ebca7de8db667948bac914b41a0ad5bb5
6
+ metadata.gz: 9c28d8c5653480c209e00178ee0b78d0eda49eb5b75addeddfd2837425f66af0576939bf1c18374614350fac1032f468494d79964015bfd1e6f03422e2114171
7
+ data.tar.gz: d1f3febe2016fb724dda28e13e0b3f2ad054e3eb146794dbdca179e04a3641c9fdc8f92c91d79ec4e5614cd75946db5672c3397fd57a718e91e0050ae0f224b3
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changes
2
2
 
3
+ ## 1.2.0 (20.07.2022)
4
+
5
+ * Properly throw execution failure exception
6
+ * Config is now optional argument for Bwrap#initialize
7
+ * Allow passing kwargs to Bwrap#run
8
+ * Allow passing config to execute
9
+
10
+ ## 1.1.1 (07.06.2022)
11
+
12
+ * Added Bwrap::Execution.popen2e
13
+ * Fixed compatibility with ruby-2.5
14
+
15
+ ## 1.1.0 (01.06.2022)
16
+
17
+ * No changes.
18
+
3
19
  ## 1.1.0-rc1 (28.05.2022)
4
20
 
5
21
  * Added info log level
@@ -10,12 +10,12 @@ require "bwrap/version"
10
10
  module Bwrap::Args
11
11
  # Used as container for arguments constructed via {Construct}.
12
12
  #
13
- # Where {Hash} defaults to nil as default argument, `Args` defaults to
14
- # {Array}.
13
+ # Where `Hash` defaults to nil as default argument, {Args} defaults to
14
+ # `Array`.
15
15
  class Args < Hash
16
16
  # Creates new instance of a hash for storing arguments.
17
17
  #
18
- # Where {Hash} defaults to nil as default argument, `Args` defaults to
18
+ # Where `Hash` defaults to nil as default argument, {Args} defaults to
19
19
  # `[]`.
20
20
  #
21
21
  # @see Hash#initialize
@@ -31,9 +31,10 @@ module Bwrap::Args
31
31
  #
32
32
  # Following types are meant to be used, though everything is accepted:
33
33
  # - :mount
34
+ # - (and many others, they are not documented here)
34
35
  #
35
36
  # @param type [Symbol] Type of the argument
36
- # @returns self
37
+ # @return self
37
38
  def add(type, *data)
38
39
  if data.respond_to? :each
39
40
  self[type] += data.flatten
@@ -43,5 +44,33 @@ module Bwrap::Args
43
44
 
44
45
  self
45
46
  end
47
+
48
+ # Adds ugiven data to array identified by given type if they
49
+ # have not been already added.
50
+ #
51
+ # Following types are meant to be used, though everything is accepted:
52
+ # - :mount
53
+ # - (and many others, they are not documented here)
54
+ #
55
+ # @param type [Symbol] Type of the argument
56
+ # @return self
57
+ def add_uniq(type, *data)
58
+ if data.respond_to? :each
59
+ self[type] |= data
60
+ else
61
+ self[type] << data unless include? data
62
+ end
63
+
64
+ self
65
+ end
66
+
67
+ # Adds a read-only bind to bind given path from host to same path inside sandbox.
68
+ #
69
+ # @see bwrap argument `--ro-bind`.
70
+ #
71
+ # TODO: doc for params
72
+ def ro_bind(type, path)
73
+ add(type, %W{ --ro-bind #{path} #{path} })
74
+ end
46
75
  end
47
76
  end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bwrap/output"
4
+
5
+ class Bwrap::Args::Bind
6
+ # Device related binds.
7
+ class Device
8
+ include Bwrap::Output
9
+
10
+ # Instance of {Config}.
11
+ attr_writer :config
12
+
13
+ # @param args [Args] Args created by {Construct}
14
+ def initialize args
15
+ @args = args
16
+ end
17
+
18
+ # Arguments for mounting devtmpfs to /dev.
19
+ def dev_mount
20
+ return unless @config&.dev_mount
21
+
22
+ debug "Mounting new devtmpfs to /dev"
23
+ @args.add :dev_mounts, "--dev", "/dev"
24
+ end
25
+
26
+ # Arguments to bind /dev/dri from host to sandbox.
27
+ def bind_dev_dri
28
+ return unless @config&.graphics_acceleration
29
+
30
+ @args.add :dev_mounts, %w{ --dev-bind /dev/dri /dev/dri }
31
+ end
32
+
33
+ # Arguments to bind /sys/dev/char from host to sandbox.
34
+ def bind_sys_dev_char
35
+ return unless @config&.graphics_acceleration
36
+
37
+ @args.add :dev_mounts, %w{ --ro-bind /sys/dev/char /sys/dev/char }
38
+ end
39
+
40
+ # Arguments to bind /sys/devices/pci0000:00 from host to sandbox.
41
+ def bind_pci_devices
42
+ return unless @config&.graphics_acceleration
43
+
44
+ @args.add :dev_mounts, %w{ --ro-bind /sys/devices/pci0000:00 /sys/devices/pci0000:00 }
45
+ end
46
+ end
47
+ end
48
+
@@ -2,8 +2,9 @@
2
2
 
3
3
  require "bwrap/execution/path"
4
4
  require "bwrap/output"
5
- require_relative "../library"
6
- require_relative "mime"
5
+ require "bwrap/resolvers/executable"
6
+ require "bwrap/resolvers/library"
7
+ require "bwrap/resolvers/mime"
7
8
 
8
9
  class Bwrap::Args::Bind
9
10
  # TODO: documentation
@@ -21,22 +22,20 @@ class Bwrap::Args::Bind
21
22
  include Bwrap::Execution::Path
22
23
  include Bwrap::Output
23
24
 
24
- # The command given to {Bwrap#run}.
25
- #
26
- # @see Bwrap::Args::Construct#command=
27
- #
28
- # @see (see Bwrap::Args::Construct#command=)
29
- attr_writer :command
30
-
31
25
  # Instance of {Bwrap::Config}.
32
26
  attr_writer :config
33
27
 
34
28
  # Instance of {Bwrap::Args::Environment}.
35
29
  attr_writer :environment
36
30
 
37
- attr_writer :executable_name
31
+ # Instance of {Bwrap::Resolvers::Executable}.
32
+ attr_writer :executable
38
33
 
39
- attr_writer :executable_path
34
+ # TODO: Remove?
35
+ #attr_writer :executable_name
36
+
37
+ # TODO: Remove?
38
+ #attr_writer :executable_path
40
39
 
41
40
  def initialize args
42
41
  @args = args
@@ -45,29 +44,15 @@ class Bwrap::Args::Bind
45
44
  def extra_executables_mounts
46
45
  return unless @config&.extra_executables
47
46
 
48
- @config.extra_executables.each do |executable|
49
- @executable_name = resolve_executable_name executable
50
- @executable_path = resolve_executable_path @executable_name, not_inside_root: true
51
-
52
- @args.add :extra_executable_mounts, %W{ --ro-bind #{@executable_path} #{@executable_path} }
47
+ @config.extra_executables.each do |extra_executable|
48
+ executable = Bwrap::Resolvers::Executable.new extra_executable
53
49
 
54
- resolve_executable_libraries
50
+ generate_binds_for_command :extra_executable_mounts, executable, inside_root: false
55
51
  end
56
52
  end
57
53
 
58
- # Checks the command given to {Bwrap#run} and adds the libraries it needs.
59
- #
60
- # Convenience method to call {#resolve_executable_libraries}.
61
54
  def handle_given_command
62
- @executable_name = resolve_executable_name @command
63
- @executable_path = resolve_executable_path @executable_name
64
-
65
- # Actually add the executable to be bound to the sandbox.
66
- unless @config&.command_inside_root
67
- @args.add :given_command, %W{ --ro-bind #{@executable_path} #{@executable_path} }
68
- end
69
-
70
- resolve_executable_libraries
55
+ generate_binds_for_command :given_command, @executable
71
56
  end
72
57
 
73
58
  # Does some inspection to find out libraries given executable needs in order to work.
@@ -77,14 +62,15 @@ class Bwrap::Args::Bind
77
62
  #
78
63
  # @todo Ensure scanelf is available (and throw proper error if it is not, telling to not use
79
64
  # full_system_mounts option.)
80
- def resolve_executable_libraries
81
- debug "Resolving executable libraries of #{@executable_path}"
65
+ #
66
+ # @param executable_name [String] Executable to be run inside bwrap
67
+ def resolve_executable_libraries executable_name, executable_path
68
+ debug "Resolving executable libraries of #{executable_path}"
82
69
 
83
- # TODO: Put this behind additional flag for extra control/sanity.
84
- # Some executables are shell scripts and similar. For them we need to use the interpreter.
70
+ mime = Bwrap::Resolvers::Mime.new executable_name, executable_path
71
+ mime.resolve_mime_type
85
72
 
86
- mime = Mime.new @executable_name, @executable_path
87
- return unless mime.resolve_mime_type
73
+ return if shell_executable_binds mime
88
74
 
89
75
  # TODO: Ideally mime stuff should be handled as config,
90
76
  # but then shebang parsing logic would be necessary to move to config classes.
@@ -101,7 +87,7 @@ class Bwrap::Args::Bind
101
87
 
102
88
  library_mounts = []
103
89
 
104
- library_object = ::Bwrap::Args::Library.new
90
+ library_object = ::Bwrap::Resolvers::Library.new
105
91
  libraries = library_object.libraries_needed_by mime.executable_path
106
92
 
107
93
  # TODO: following is bad?
@@ -110,7 +96,7 @@ class Bwrap::Args::Bind
110
96
  library_mounts << "--ro-bind" << library << library
111
97
  end
112
98
 
113
- @args.add :extra_executable_libraries, library_mounts
99
+ @args.add_uniq :extra_executable_libraries, library_mounts
114
100
  end
115
101
 
116
102
  # Some features, like {Bwrap::Config::Features::Nscd}, requires some binds
@@ -124,22 +110,52 @@ class Bwrap::Args::Bind
124
110
  ruby_binds_for_features
125
111
  end
126
112
 
127
- private def resolve_executable_name command
128
- if command.is_a? String
129
- return command
130
- end
113
+ private def shell_executable_binds mime
114
+ # TODO: Put this behind additional flag for extra control/sanity.
115
+ # Some executables are shell scripts and similar. For them we need to use the interpreter.
131
116
 
132
- # Array-like.
133
- if command.respond_to? :at
134
- return command.at(0)
117
+ if mime.mime_type[0..6] != "text/x-"
118
+ # All is good as this is not an interpreter.
119
+ elsif mime.interpreter?
120
+ # TODO: For less unmessiness, this should be done before actual
121
+ # handle_given_command() and extra_executable_mounts() are run.
122
+ # I guess that needs some refactoring...
123
+ mime_executable = Bwrap::Resolvers::Executable.new mime.resolve_real_executable
124
+ generate_binds_for_command :extra_executable_mounts, mime_executable
125
+ else
126
+ warn "Executable #{mime.executable_name} was recognized as #{mime.mime_type} but does not have " \
127
+ "proper shebang line. Skipping automatic library mounts."
128
+ return true
135
129
  end
136
130
 
137
- raise "Can’t recognize type of given command. Type: #{command.class}"
131
+ false
132
+ end
133
+
134
+ # @param executable [Bwrap::Resolvers::Executable] Executable to be resolved
135
+ private def generate_binds_for_command args_flag, executable, inside_root: true
136
+ # Type can be :path or :symlink. It is not used for now.
137
+ executable.executable_paths.each do |path, _type|
138
+ executable_path = resolve_executable_path path, inside_root: inside_root
139
+
140
+ # Actually add the executable to be bound to the sandbox.
141
+ if @config and !@config.command_inside_root
142
+ # Avoid double-binding the executable.
143
+ executable_dir = File.dirname(executable_path)
144
+ unless @config.binaries_from&.include? executable_dir
145
+ @args.ro_bind args_flag, executable_path
146
+
147
+ # Also add the directory where the executable is to PATH, for convenience.
148
+ @environment.add_to_path executable_dir unless executable.absolute_path?
149
+ end
150
+ end
151
+
152
+ resolve_executable_libraries path, executable_path
153
+ end
138
154
  end
139
155
 
140
156
  # @warning Requires environment paths to be resolved beforehand.
141
- private def resolve_executable_path executable_name, not_inside_root: nil
142
- if @config&.command_inside_root.nil? or not_inside_root
157
+ private def resolve_executable_path executable_name, inside_root: true
158
+ if @config&.command_inside_root.nil? or !inside_root
143
159
  return which executable_name
144
160
  end
145
161
 
@@ -3,6 +3,7 @@
3
3
  require "bwrap/execution"
4
4
  require "bwrap/output"
5
5
  require_relative "args"
6
+ require_relative "bind/device"
6
7
  require_relative "bind/library"
7
8
 
8
9
  # Bind arguments for bwrap.
@@ -13,40 +14,21 @@ class Bwrap::Args::Bind
13
14
  # Array of parameters passed to bwrap.
14
15
  attr_writer :args
15
16
 
16
- # The command given to {Bwrap#run}.
17
- #
18
- # @see Bwrap::Args::Construct#command=
19
- #
20
- # @see (see Bwrap::Args::Construct#command=)
21
- attr_writer :command
22
-
23
17
  # Instance of {Bwrap::Config}.
24
18
  attr_writer :config
25
19
 
26
20
  # Instance of {Bwrap::Args::Environment}.
27
21
  attr_writer :environment
28
22
 
29
- # Arguments to bind /dev/dri from host to sandbox.
30
- def bind_dev_dri
31
- @args.add :dev_mounts, %w{ --dev-bind /dev/dri /dev/dri }
32
- end
33
-
34
- # Arguments to bind /sys/dev/char from host to sandbox.
35
- def bind_sys_dev_char
36
- @args.add :dev_mounts, %w{ --ro-bind /sys/dev/char /sys/dev/char }
37
- end
38
-
39
- # Arguments to bind /sys/devices/pci0000:00 from host to sandbox.
40
- def bind_pci_devices
41
- @args.add :dev_mounts, %w{ --ro-bind /sys/devices/pci0000:00 /sys/devices/pci0000:00 }
42
- end
23
+ # Instance of {Bwrap::Resolvers::Executable}.
24
+ attr_writer :executable
43
25
 
44
26
  # Arguments to bind home directory from sandbox directory (`#{@config.sandbox_directory}/home`)
45
27
  # as `/home/#{@config.user}`.
46
28
  #
47
29
  # @note Requires @config.user to be set.
48
30
  def bind_home_directory
49
- return unless @config.user
31
+ return unless @config&.user
50
32
 
51
33
  home_directory = "#{@config.sandbox_directory}/home"
52
34
 
@@ -71,28 +53,20 @@ class Bwrap::Args::Bind
71
53
  #
72
54
  # Or maybe the data should be calculated and these are excluded in
73
55
  # Construct#bwrap_arguments?
74
- return unless @config.full_system_mounts
56
+ #
57
+ # NOTE: After making Config optional, now this requires config to be preset
58
+ # for full_system_mounts option to have any effect. Maybe it should always
59
+ # be like so by default...?
60
+ return if @config && !@config&.full_system_mounts
75
61
 
76
62
  @library_bind.handle_given_command
77
63
  end
78
64
 
79
65
  # Arguments to read-only bind whole system inside sandbox.
80
66
  def handle_system_mounts
81
- bindir_mounts = []
82
- binaries_from = @config.binaries_from
83
- binaries_from.each do |path|
84
- bindir_mounts << "--ro-bind" << path << path
85
- end
86
- @environment.add_to_path binaries_from
87
-
88
- @args.add :bindir, bindir_mounts
89
-
90
- if debug?
91
- debug "Using following bindir mounts:\n" \
92
- "#{bindir_mounts}\n" \
93
- "(Odd is key, even is value)"
94
- end
67
+ return unless @config&.binaries_from
95
68
 
69
+ bindir_mounts
96
70
  libdir_mounts
97
71
 
98
72
  binds_for_features
@@ -100,9 +74,19 @@ class Bwrap::Args::Bind
100
74
  @library_bind.extra_executables_mounts
101
75
  end
102
76
 
77
+ def device_binds
78
+ device = Bwrap::Args::Bind::Device.new @args
79
+ device.config = @config
80
+
81
+ device.dev_mount
82
+ device.bind_dev_dri
83
+ device.bind_sys_dev_char
84
+ device.bind_pci_devices
85
+ end
86
+
103
87
  # These are something user can specify to do custom --ro-bind binds.
104
88
  def custom_read_only_binds
105
- return unless @config.ro_binds
89
+ return unless @config&.ro_binds
106
90
 
107
91
  binds = []
108
92
  @config.ro_binds.each do |source_path, destination_path|
@@ -114,12 +98,30 @@ class Bwrap::Args::Bind
114
98
 
115
99
  # Performs cleanup operations after execution.
116
100
  def cleanup
117
- Bwrap::Args::Library.clear_needed_libraries_cache
101
+ Bwrap::Resolvers::Library.clear_needed_libraries_cache
102
+ end
103
+
104
+ # Used by {#handle_system_mounts}.
105
+ private def bindir_mounts
106
+ bindir_mounts = []
107
+ binaries_from = @config.binaries_from
108
+ binaries_from.each do |path|
109
+ bindir_mounts << "--ro-bind" << path << path
110
+ end
111
+ @environment.add_to_path binaries_from
112
+
113
+ @args.add :bindir, bindir_mounts
114
+
115
+ return unless debug? and !bindir_mounts.empty?
116
+
117
+ debug "Using following bindir mounts:\n" \
118
+ "#{bindir_mounts}\n" \
119
+ "(Odd is key, even is value)"
118
120
  end
119
121
 
120
122
  # Used by {#handle_system_mounts}.
121
123
  private def libdir_mounts
122
- return unless @config.libdir_mounts
124
+ return unless @config&.libdir_mounts
123
125
 
124
126
  libdir_mounts = %w{
125
127
  --ro-bind /lib /lib
@@ -139,9 +141,9 @@ class Bwrap::Args::Bind
139
141
 
140
142
  private def construct_library_bind
141
143
  library_bind = Bwrap::Args::Bind::Library.new @args
142
- library_bind.command = @command
143
144
  library_bind.config = @config
144
145
  library_bind.environment = @environment
146
+ library_bind.executable = @executable
145
147
 
146
148
  @library_bind = library_bind
147
149
  end
@@ -3,6 +3,7 @@
3
3
  require "tempfile"
4
4
 
5
5
  require "bwrap/output"
6
+ require "bwrap/resolvers/executable"
6
7
  require_relative "args"
7
8
  require_relative "bind"
8
9
  require_relative "environment"
@@ -10,6 +11,7 @@ require_relative "features"
10
11
  require_relative "machine_id"
11
12
  require_relative "mount"
12
13
  require_relative "network"
14
+ require_relative "user"
13
15
 
14
16
  # Constructs arguments for bwrap execution.
15
17
  class Bwrap::Args::Construct
@@ -18,6 +20,13 @@ class Bwrap::Args::Construct
18
20
 
19
21
  attr_writer :config
20
22
 
23
+ def initialize
24
+ # If a key is not found, it is initialized with an empty array.
25
+ @args = Bwrap::Args::Args.new
26
+
27
+ @executable = Bwrap::Resolvers::Executable.new
28
+ end
29
+
21
30
  # Command that is executed inside bwrap sandbox.
22
31
  #
23
32
  # @note This is not used for anything vital, but some things, like
@@ -25,17 +34,14 @@ class Bwrap::Args::Construct
25
34
  # additional data.
26
35
  #
27
36
  # @param value [Array, String] Command with arguments
28
- attr_writer :command
29
-
30
- def initialize
31
- # If a key is not found, it is initialized with an empty array.
32
- @args = Bwrap::Args::Args.new
37
+ def command= value
38
+ @executable.command = value
33
39
  end
34
40
 
35
41
  # Parses data given with {Config} so it can be outputted in proper
36
42
  # order by {#bwrap_arguments}.
37
43
  #
38
- # @note Command given to {Bwrap#run} is set to {Bind#command}.
44
+ # @note Command given to {Bwrap#run} is set to {Bind#command=}.
39
45
  def calculate
40
46
  create_objects
41
47
 
@@ -51,12 +57,9 @@ class Bwrap::Args::Construct
51
57
  @bind.handle_system_mounts
52
58
  @features.feature_binds
53
59
  @bind.custom_read_only_binds
54
- create_user_dir
55
- read_only_pulseaudio
56
- dev_mount
57
- @bind.bind_dev_dri
58
- @bind.bind_sys_dev_char
59
- @bind.bind_pci_devices
60
+ @user.create_user_dir
61
+ @user.read_only_pulseaudio
62
+ @bind.device_binds
60
63
  proc_mount
61
64
  tmp_as_tmpfs
62
65
  @bind.bind_home_directory
@@ -70,7 +73,7 @@ class Bwrap::Args::Construct
70
73
 
71
74
  # Returns arguments to pass to bwrap.
72
75
  #
73
- # @note Command given to {Bwrap#run} is set to {Bind#command}.
76
+ # @note Command given to {Bwrap#run} is set to {Bind#command=}.
74
77
  def bwrap_arguments
75
78
  args = []
76
79
 
@@ -124,11 +127,11 @@ class Bwrap::Args::Construct
124
127
  @bind&.cleanup
125
128
  end
126
129
 
127
- # Used by {#construct_bwrap_args}.
130
+ # Used by {#calculate}.
128
131
  private def create_objects
129
132
  @bind = Bwrap::Args::Bind.new
130
133
  @bind.args = @args
131
- @bind.command = @command
134
+ @bind.executable = @executable
132
135
  @bind.config = @config
133
136
 
134
137
  @environment = Bwrap::Args::Environment.new
@@ -144,33 +147,17 @@ class Bwrap::Args::Construct
144
147
 
145
148
  @network = Bwrap::Args::Network.new @args
146
149
  @network.config = @config
150
+
151
+ @user = Bwrap::Args::User.new @args
152
+ @user.config = @config
147
153
  end
148
154
 
149
155
  # Arguments for generating .Xauthority file.
150
156
  private def xauthority_args
151
- return unless @config.xorg_application
157
+ return unless @config&.xorg_application
152
158
 
153
159
  xauth_args = %W{ --ro-bind #{Dir.home}/.Xauthority #{Dir.home}/.Xauthority }
154
160
  debug "Binding following .Xauthority file: #{Dir.home}/.Xauthority"
155
161
  @args.add :xauthority, xauth_args
156
162
  end
157
-
158
- # Arguments to create `/run/user/#{uid}`.
159
- private def create_user_dir
160
- trace "Creating directory /run/user/#{uid}"
161
- @args.add :user_dir, %W{ --dir /run/user/#{uid} }
162
- end
163
-
164
- # Arguments to bind necessary pulseaudio data for audio support.
165
- private def read_only_pulseaudio
166
- return unless @config.audio.include? :pulseaudio
167
-
168
- debug "Binding pulseaudio"
169
- @args.add :audio, %W{ --ro-bind /run/user/#{uid}/pulse /run/user/#{uid}/pulse }
170
- end
171
-
172
- # Returns current user id.
173
- private def uid
174
- Process.uid
175
- end
176
163
  end
@@ -27,6 +27,9 @@ class Bwrap::Args::Environment < Hash
27
27
 
28
28
  env_paths
29
29
 
30
+ # If nothing has been added to path, the map would result to empty --setenv.
31
+ return self if empty?
32
+
30
33
  map do |key, value|
31
34
  if key == "PATH" and value.respond_to? :join
32
35
  value = value.join ":"
@@ -38,7 +41,7 @@ class Bwrap::Args::Environment < Hash
38
41
 
39
42
  # @return [Array] All environment paths added via {Config#add_env_path} and other parsing logic
40
43
  def env_paths
41
- if @config.env_paths.respond_to? :each
44
+ if @config and @config.env_paths.respond_to? :each
42
45
  self["PATH"] |= @config.env_paths
43
46
  end
44
47
 
@@ -66,6 +69,7 @@ class Bwrap::Args::Environment < Hash
66
69
 
67
70
  # Ruby feature specific environment path handling.
68
71
  private def ruby_env_paths
72
+ return unless @config
69
73
  return unless @config.features.ruby.enabled?
70
74
  return unless @config.features.ruby.gem_env_paths?
71
75
 
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "bwrap/resolvers/library"
4
+
3
5
  # Implementation for Ruby feature set.
4
6
  #
5
7
  # @api private
@@ -33,7 +35,7 @@ class Bwrap::Args::Features::RubyBinds < Bwrap::Args::Features::BindsBase
33
35
  ruby_config = @config.features.ruby.ruby_config
34
36
 
35
37
  library_mounts = []
36
- library = Bwrap::Args::Library.new
38
+ library = Bwrap::Resolvers::Library.new
37
39
  stdlib.each do |lib|
38
40
  path = "#{ruby_config["rubyarchdir"]}/#{lib}.so"
39
41
 
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "bwrap/output"
4
4
  require_relative "args"
5
- require_relative "library"
6
5
 
7
6
  # Feature parameter construction.
8
7
  #
@@ -68,7 +67,7 @@ class Bwrap::Args::Features < Hash
68
67
  end
69
68
 
70
69
  private def bash_binds
71
- return unless @config.features.bash.enabled?
70
+ return unless @config and @config.features.bash.enabled?
72
71
 
73
72
  binds = BashBinds.new
74
73
 
@@ -76,7 +75,7 @@ class Bwrap::Args::Features < Hash
76
75
  end
77
76
 
78
77
  private def nscd_binds
79
- return unless @config.features.nscd.enabled?
78
+ return unless @config and @config.features.nscd.enabled?
80
79
 
81
80
  binds = NscdBinds.new
82
81
 
@@ -86,7 +85,7 @@ class Bwrap::Args::Features < Hash
86
85
  # @note This does not allow development headers needed for compilation for now.
87
86
  # I’ll look at it after I have an use for it.
88
87
  private def ruby_binds
89
- return unless @config.features.ruby.enabled?
88
+ return unless @config and @config.features.ruby.enabled?
90
89
 
91
90
  binds = RubyBinds.new @config
92
91