Class: OsCtld::ContainerControl::Commands::WithRootfs::Runner

Inherits:
Runner
  • Object
show all
Defined in:
lib/osctld/container_control/commands/with_rootfs.rb

Instance Attribute Summary

Attributes inherited from Runner

#ctid, #log_file, #lxc_home, #pool, #stderr, #stdin, #stdout, #user_home

Instance Method Summary collapse

Methods inherited from Runner

#error, #initialize, #lxc_ct, #ok, #setup_exec_env, #setup_exec_run_env, #system_path

Constructor Details

This class inherits a constructor from OsCtld::ContainerControl::Runner

Instance Method Details

#execute(opts) ⇒ Object

Parameters:

  • opts (Hash)

Options Hash (opts):



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/osctld/container_control/commands/with_rootfs.rb', line 33

def execute(opts)
  sys = OsCtl::Lib::Sys.new
  sys.chroot(opts[:ctrc].rootfs)

  SwitchUser.switch_to_system(
    '',
    opts[:ctrc].ct.root_host_uid,
    opts[:ctrc].ct.root_host_gid,
    '/'
  )

  # After chroot, we can no longer access syslog logger. Log to stdout
  # instead, which will be picked up by osctld supervisor and sent to
  # syslog from there.
  OsCtl::Lib::Logger.setup(:stdout)

  ok(opts[:block].call)
end