Class: Bwrap::Args::Construct
- Inherits:
-
Object
- Object
- Bwrap::Args::Construct
- Defined in:
- lib/bwrap/args/construct.rb
Overview
Constructs arguments for bwrap execution.
Instance Attribute Summary collapse
-
#config ⇒ Object
writeonly
Sets the attribute config.
Instance Method Summary collapse
-
#bwrap_arguments ⇒ Object
Returns arguments to pass to bwrap.
-
#calculate ⇒ Object
Parses data given with Config so it can be outputted in proper order by #bwrap_arguments.
-
#cleanup ⇒ Object
Performs cleanup operations after execution.
-
#command=(value) ⇒ Object
Command that is executed inside bwrap sandbox.
-
#initialize ⇒ Construct
constructor
A new instance of Construct.
Methods included from Output
debug?, debug_output, error_output, handle_output_options, info_output, quiet?, trace?, trace_output, verb_output, verbose?, warn_output
Constructor Details
Instance Attribute Details
#config=(value) ⇒ Object (writeonly)
Sets the attribute config
22 23 24 |
# File 'lib/bwrap/args/construct.rb', line 22 def config=(value) @config = value end |
Instance Method Details
#bwrap_arguments ⇒ Object
Command given to Bwrap#run is set to Bind#command=.
Returns arguments to pass to bwrap.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/bwrap/args/construct.rb', line 78 def bwrap_arguments args = [] # @args.fetch() could be used here to ensure the key is present, so catching some extra typos, # but for now it is not used, for convenience. args += @args[:root_mount] args += @args[:xauthority] args += @args[:machine_id] args += @args[:resolv_conf] # bind.rb args += @args[:bindir] args += @args[:libdir] # This is what is given to Bwrap#run. args += @args[:given_command] args += @args[:extra_executable_libraries] args += @args[:library_feature_binds] args += @args[:extra_executable_mounts] args += @args[:feature_binds] args += @args[:custom_ro_binds] args += @args[:user_dir] args += @args[:audio] args += @args[:dev_mounts] args += @args[:proc_mount] args += @args[:tmp_mount] args += @args[:home_directory] args += @args[:unshare_all] args += @args[:network] args += @args[:hostname] args += @args[:environment] args += @args[:die_with_parent] args += @args[:new_session] args.compact end |
#calculate ⇒ Object
Command given to Bwrap#run is set to Bind#command=.
Parses data given with Config so it can be outputted in proper order by #bwrap_arguments.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/bwrap/args/construct.rb', line 46 def calculate create_objects # If necessary, first handle command passed to Bwrap#run so feature binds can utilize # the command. @bind.handle_given_command root_mount machine_id = @machine_id.machine_id @args.add :machine_id, machine_id if machine_id @network.resolv_conf @bind.handle_system_mounts @features.feature_binds @bind.custom_read_only_binds @user.create_user_dir @user.read_only_pulseaudio @bind.device_binds proc_mount tmp_as_tmpfs @bind.bind_home_directory @namespace.shares @network.share_net @network.hostname @args.add :environment, @environment.environment_variables @args.add :die_with_parent, "--die-with-parent" # For security, and as intuition says how things should work. @args.add :new_session, "--new-session" # Very important for security. end |
#cleanup ⇒ Object
Performs cleanup operations after execution.
126 127 128 129 |
# File 'lib/bwrap/args/construct.rb', line 126 def cleanup @machine_id&.cleanup @bind&.cleanup end |
#command=(value) ⇒ Object
This is not used for anything vital, but some things, like setting Config#full_system_mounts= uses this to resolve some additional data.
Command that is executed inside bwrap sandbox.
38 39 40 |
# File 'lib/bwrap/args/construct.rb', line 38 def command= value @executable.command = value end |