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
|
@ -2,6 +2,6 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
from pmb.chroot.init import init, init_keys, UsrMerge
|
from pmb.chroot.init import init, init_keys, UsrMerge
|
||||||
from pmb.chroot.mount import mount, mount_native_into_foreign, remove_mnt_pmbootstrap
|
from pmb.chroot.mount import mount, mount_native_into_foreign, remove_mnt_pmbootstrap
|
||||||
from pmb.chroot.run import root, rootm, user, exists as user_exists
|
from pmb.chroot.run import root, rootm, user, userm, exists as user_exists
|
||||||
from pmb.chroot.shutdown import shutdown
|
from pmb.chroot.shutdown import shutdown
|
||||||
from pmb.chroot.zap import zap
|
from pmb.chroot.zap import zap
|
||||||
|
|
|
@ -95,7 +95,7 @@ def root(cmds: Sequence[PathString], chroot: Chroot=Chroot.native(), working_dir
|
||||||
disable_timeout, add_proxy_env_vars)
|
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={}):
|
output_return=False, check=None, env={}):
|
||||||
"""
|
"""
|
||||||
Run a command inside a chroot as "user". We always use the BusyBox
|
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:
|
if "HOME" not in env:
|
||||||
env["HOME"] = "/home/pmos"
|
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]
|
cmd = ["busybox", "su", "pmos", "-c", flat_cmd]
|
||||||
return pmb.chroot.root(cmd, chroot, working_dir, output,
|
return pmb.chroot.root(cmd, chroot, working_dir, output,
|
||||||
output_return, check, {},
|
output_return, check, {},
|
||||||
add_proxy_env_vars=False)
|
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()):
|
def exists(username, chroot: Chroot=Chroot.native()):
|
||||||
"""
|
"""
|
||||||
Checks if username exists in the system
|
Checks if username exists in the system
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue