Class: Bwrap::Args::MachineId
- Inherits:
-
Object
- Object
- Bwrap::Args::MachineId
- Includes:
- Output
- Defined in:
- lib/bwrap/args/machine_id.rb
Overview
Calculate machine id data.
Instance Attribute Summary collapse
-
#config ⇒ Object
writeonly
Instance of Config.
Instance Method Summary collapse
-
#cleanup ⇒ Object
Removes opened temporary machine id file.
-
#machine_id ⇒ Object
machine_id == :random Generates random machine id for each launch and sets it as /etc/machine_id.
Methods included from Output
debug?, debug_output, error_output, handle_output_options, info_output, quiet?, trace?, trace_output, verb_output, verbose?, warn_output
Instance Attribute Details
#config=(value) ⇒ Object (writeonly)
Instance of Config.
14 15 16 |
# File 'lib/bwrap/args/machine_id.rb', line 14 def config=(value) @config = value end |
Instance Method Details
#cleanup ⇒ Object
Removes opened temporary machine id file.
Can be called safely even if no file is opened.
46 47 48 |
# File 'lib/bwrap/args/machine_id.rb', line 46 def cleanup @machine_id_file&.unlink end |
#machine_id ⇒ Object
machine_id == :random
Generates random machine id for each launch and sets it as /etc/machine_id.
machine_id == :dummy
Uses 10000000000000000000000000000000 as dummy machine id and sets it as /etc/machine_id.
machine_id == true
A file from `#{sandbox_directory}/machine_id` is bound as /etc/machine_id.
machine_id.is_a? String
Given file as bound as /etc/machine_id.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bwrap/args/machine_id.rb', line 24 def machine_id # Returning [] means that execute() will ignore this fully. # Nil would be converted to empty string, causing spawn() to pass it as argument, causing # bwrap to misbehave. return unless @config&.machine_id machine_id = @config.machine_id if machine_id == :random random_machine_id elsif machine_id == :dummy dummy_machine_id elsif machine_id == true machine_id_inside_sandbox_dir @config.sandbox_directory elsif machine_id.is_a? String string_machine_id machine_id end end |