WIP on root-exec
This commit is contained in:
parent
0ef4dccb8f
commit
d642a42fe9
|
@ -71,8 +71,15 @@ def root(args, cmd, suffix="native", working_dir="/", output="log",
|
|||
executables = executables_absolute_path()
|
||||
cmd_chroot = [executables["chroot"], chroot, "/bin/sh", "-c",
|
||||
pmb.helpers.run.flat_cmd(cmd, working_dir)]
|
||||
cmd_sudo = ["sudo", "env", "-i", executables["sh"], "-c",
|
||||
pmb.helpers.run.flat_cmd(cmd_chroot, env=env_all)]
|
||||
|
||||
if "sudo_askpass_program" in args:
|
||||
cmd_sudo = ["env", f"SUDO_ASKPASS={args.sudo_askpass_program}",
|
||||
"sudo", "--askpass", "env", "-i", executables["sh"], "-c",
|
||||
pmb.helpers.run.flat_cmd(cmd_chroot, env=env_all)]
|
||||
else:
|
||||
cmd_sudo = ["sudo", "env", "-i", executables["sh"], "-c",
|
||||
pmb.helpers.run.flat_cmd(cmd_chroot, env=env_all)]
|
||||
|
||||
return pmb.helpers.run_core.core(args, msg, cmd_sudo, None, output,
|
||||
output_return, check, True,
|
||||
disable_timeout)
|
||||
|
|
|
@ -72,7 +72,18 @@ def root(args, cmd, working_dir=None, output="log", output_return=False,
|
|||
"""
|
||||
if env:
|
||||
cmd = ["sh", "-c", flat_cmd(cmd, env=env)]
|
||||
cmd = ["sudo"] + cmd
|
||||
|
||||
# fom `man sudo`:
|
||||
# If the -A (askpass) option
|
||||
# is specified, a (possibly graphical) helper program is executed to
|
||||
# read the user's password and output the password to the standard output.
|
||||
# If the SUDO_ASKPASS environment variable is set, it specifies the path
|
||||
# to the helper program.
|
||||
if "sudo_askpass_program" in args:
|
||||
cmd = ["env", f"SUDO_ASKPASS={args.sudo_askpass_program}",
|
||||
"sudo", "--askpass"] + cmd
|
||||
else:
|
||||
cmd = ["sudo"] + cmd
|
||||
|
||||
return user(args, cmd, working_dir, output, output_return, check, env,
|
||||
True)
|
||||
|
|
Loading…
Reference in New Issue