FIX(app): restore su - ubuntu -c for proper env and PATH
- su ubuntu -c may not set env vars properly - Change to su - ubuntu -c to use login shell environment - Projects path is hardcoded to /home/ubuntu/Projects
This commit is contained in:
@@ -91,16 +91,15 @@ def execute_host(command: str, timeout: int = 30, use_sudo: bool = False) -> str
|
||||
# -n: network namespace
|
||||
# -i: IPC namespace
|
||||
# Run as ubuntu user to avoid git "dubious ownership" errors
|
||||
# Use 'su ubuntu -c' (without -) to preserve current directory context
|
||||
# This allows commands to work from SSH initial directory
|
||||
# Use 'su - ubuntu -c' to get proper environment variables and PATH
|
||||
# Projects folder is at /home/ubuntu/Projects (hardcoded in prompts)
|
||||
if use_sudo:
|
||||
# For sudo commands, run directly with sudo
|
||||
nsenter_command = f"nsenter -t 1 -m -u -n -i -- sh -c {subprocess.list2cmdline([f'sudo {command}'])}"
|
||||
else:
|
||||
# For regular commands, run as ubuntu user
|
||||
# Use 'su ubuntu -c' (not 'su - ubuntu -c') to preserve current directory
|
||||
# This matches SSH behavior where you start from the initial directory
|
||||
nsenter_command = f"nsenter -t 1 -m -u -n -i -- su ubuntu -c {subprocess.list2cmdline([command])}"
|
||||
# For regular commands, run as ubuntu user with login shell
|
||||
# This ensures proper environment variables (PATH, HOME, etc.)
|
||||
nsenter_command = f"nsenter -t 1 -m -u -n -i -- su - ubuntu -c {subprocess.list2cmdline([command])}"
|
||||
|
||||
result = subprocess.run(
|
||||
nsenter_command,
|
||||
|
||||
Reference in New Issue
Block a user