Merged PR #680 - improved installation.arch_chroot()

Improved run_as for installation.arch_chroot()
This commit is contained in:
Anton Hvornum 2021-11-05 16:33:41 +00:00 committed by GitHub
commit e411ff0abb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -2,6 +2,7 @@ import time
import logging
import os
import shutil
import shlex
import pathlib
import subprocess
import glob
@ -285,9 +286,9 @@ class Installer:
def run_command(self, cmd, *args, **kwargs):
return SysCommand(f'/usr/bin/arch-chroot {self.target} {cmd}')
def arch_chroot(self, cmd, *args, **kwargs):
if 'runas' in kwargs:
cmd = f"su - {kwargs['runas']} -c \"{cmd}\""
def arch_chroot(self, cmd, run_as=None):
if run_as:
cmd = f"su - {run_as} -c {shlex.quote(cmd)}"
return self.run_command(cmd)