Class: Bwrap::Args::Network
- Inherits:
-
Object
- Object
- Bwrap::Args::Network
- Includes:
- Output
- Defined in:
- lib/bwrap/args/network.rb
Overview
Network related binds.
Instance Attribute Summary collapse
-
#config ⇒ Object
writeonly
Instance of Config.
Instance Method Summary collapse
-
#hostname ⇒ Object
Arguments to set hostname to whatever is configured.
-
#initialize(args) ⇒ Network
constructor
A new instance of Network.
-
#resolv_conf ⇒ Object
Arguments to read-only bind /etc/resolv.conf.
-
#share_net ⇒ Object
Arguments to allow network connection inside sandbox.
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
#initialize(args) ⇒ Network
Returns a new instance of Network.
14 15 16 |
# File 'lib/bwrap/args/network.rb', line 14 def initialize args @args = args end |
Instance Attribute Details
#config=(value) ⇒ Object (writeonly)
Instance of Config.
11 12 13 |
# File 'lib/bwrap/args/network.rb', line 11 def config=(value) @config = value end |
Instance Method Details
#hostname ⇒ Object
Arguments to set hostname to whatever is configured.
19 20 21 22 23 24 |
# File 'lib/bwrap/args/network.rb', line 19 def hostname return unless @config&.hostname debug "Setting hostname to #{@config.hostname}" @args.add :hostname, %W{ --hostname #{@config.hostname} } end |
#resolv_conf ⇒ Object
Arguments to read-only bind /etc/resolv.conf.
TODO: Probably it should be checked if target will have the symlink present before
doing this automatically. For that reason, now this will need a flag.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bwrap/args/network.rb', line 30 def resolv_conf return unless @config&.resolv_conf # We can’t really bind symlinks, so let’s resolve real path to resolv.conf, in case it is symlinked. source_resolv_conf = Pathname.new "/etc/resolv.conf" source_resolv_conf = source_resolv_conf.realpath debug "Binding #{source_resolv_conf} as /etc/resolv.conf" @args.add :resolv_conf, %W{ --ro-bind #{source_resolv_conf} /etc/resolv.conf } end |
#share_net ⇒ Object
Arguments to allow network connection inside sandbox.
42 43 44 45 46 47 |
# File 'lib/bwrap/args/network.rb', line 42 def share_net return unless @config&.share_net verb "Sharing network" @args.add :network, %w{ --share-net } end |