mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 10:10:46 +00:00
module/cgroups: Execute command as root when launching cmd in cgroup
On some devices root is required to configure cgroups therefore run the command as root if available unless otherwise specified.
This commit is contained in:
parent
22a5945460
commit
f1b7fd184a
@ -432,16 +432,20 @@ class CgroupsModule(Module):
|
||||
.format(self.cgroup_root, self.target.shutils,
|
||||
cgroup, cmdline)
|
||||
|
||||
def run_into(self, cgroup, cmdline):
|
||||
def run_into(self, cgroup, cmdline, as_root=None):
|
||||
"""
|
||||
Run the specified command into the specified CGroup
|
||||
|
||||
:param cmdline: Command to be run into cgroup
|
||||
:param cgroup: Name of cgroup to run command into
|
||||
:param as_root: Specify whether to run the command as root, if not
|
||||
specified will default to whether the target is rooted.
|
||||
:returns: Output of command.
|
||||
"""
|
||||
if as_root is None:
|
||||
as_root = self.target.is_rooted
|
||||
cmd = self.run_into_cmd(cgroup, cmdline)
|
||||
raw_output = self.target.execute(cmd)
|
||||
raw_output = self.target.execute(cmd, as_root=as_root)
|
||||
|
||||
# First line of output comes from shutils; strip it out.
|
||||
return raw_output.split('\n', 1)[1]
|
||||
|
Loading…
x
Reference in New Issue
Block a user