forked from Mirror/pmbootstrap
chroot: run: multi-commands for user (MR 2252)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
parent
0e3386e8f3
commit
b0ded94ca9
2 changed files with 8 additions and 3 deletions
|
@ -95,7 +95,7 @@ def root(cmds: Sequence[PathString], chroot: Chroot=Chroot.native(), working_dir
|
|||
disable_timeout, add_proxy_env_vars)
|
||||
|
||||
|
||||
def user(cmd, chroot: Chroot=Chroot.native(), working_dir: Path = Path("/"), output="log",
|
||||
def userm(cmds: Sequence[Sequence[PathString]], chroot: Chroot=Chroot.native(), working_dir: Path = Path("/"), output="log",
|
||||
output_return=False, check=None, env={}):
|
||||
"""
|
||||
Run a command inside a chroot as "user". We always use the BusyBox
|
||||
|
@ -114,13 +114,18 @@ def user(cmd, chroot: Chroot=Chroot.native(), working_dir: Path = Path("/"), out
|
|||
if "HOME" not in env:
|
||||
env["HOME"] = "/home/pmos"
|
||||
|
||||
flat_cmd = pmb.helpers.run_core.flat_cmd([cmd], env=env)
|
||||
flat_cmd = pmb.helpers.run_core.flat_cmd(cmds, env=env)
|
||||
cmd = ["busybox", "su", "pmos", "-c", flat_cmd]
|
||||
return pmb.chroot.root(cmd, chroot, working_dir, output,
|
||||
output_return, check, {},
|
||||
add_proxy_env_vars=False)
|
||||
|
||||
|
||||
def user(cmd: Sequence[PathString], chroot: Chroot=Chroot.native(), working_dir: Path = Path("/"), output="log",
|
||||
output_return=False, check=None, env={}):
|
||||
userm([cmd], chroot, working_dir, output, output_return, check, env)
|
||||
|
||||
|
||||
def exists(username, chroot: Chroot=Chroot.native()):
|
||||
"""
|
||||
Checks if username exists in the system
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue