Module: OsCtld::Utils::SwitchUser
- Included in:
- Commands::Container::Attach, Commands::Container::Console, Commands::Container::Delete, Commands::Container::Exec, Commands::Container::List, Commands::Container::Restart, Commands::Container::Runscript, Commands::Container::Show, Commands::Container::Start, Commands::Container::Stop, Commands::Container::Su, Commands::Dataset::Delete, Commands::NetInterface::IpAdd, Commands::NetInterface::IpDel, Commands::NetInterface::RouteAdd, Commands::NetInterface::RouteDel, Commands::Self::Activate, Console::TTY, Container, Container::Builder, Container::DatasetBuilder, DistConfig::Distributions::Base, Mount::Manager, Mount::SharedDir, NetInterface::Bridge, NetInterface::Veth
- Defined in:
- lib/osctld/utils/switch_user.rb
Instance Method Summary collapse
- #ct_attach(ct, *args) ⇒ Object
-
#ct_syscmd(ct, cmd, opts = {}) ⇒ OsCtl::Lib::SystemCommandResult
Run a command ‘cmd` within container `ct`.
Instance Method Details
#ct_attach(ct, *args) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/osctld/utils/switch_user.rb', line 6 def ct_attach(ct, *args) CGroup.mkpath_all(ct.entry_cgroup_path.split('/'), chown: ct.user.ugid) { cmd: ::OsCtld.bin('osctld-ct-exec'), args: args.map(&:to_s), env: ENV.select { |k, _v| k.start_with?('BUNDLE') || k.start_with?('GEM') }.to_h, settings: { user: ct.user.sysusername, ugid: ct.user.ugid, homedir: ct.user.homedir, cgroup_path: ct.entry_cgroup_path, prlimits: ct.prlimits.export, syslogns_pid: ct.init_pid } } end |
#ct_syscmd(ct, cmd, opts = {}) ⇒ OsCtl::Lib::SystemCommandResult
Run a command ‘cmd` within container `ct`
35 36 37 38 39 40 |
# File 'lib/osctld/utils/switch_user.rb', line 35 def ct_syscmd(ct, cmd, opts = {}) opts[:valid_rcs] ||= [] log(:work, ct, cmd) ContainerControl::Commands::Syscmd.run!(ct, cmd, opts) end |