Compare commits

...

10 Commits

Author SHA1 Message Date
chuckbutkus
4d1cdb976e Merge branch 'main' into custom-username 2025-09-03 21:45:46 -04:00
Chuck Butkus
1f09296136 Fix username checks 2025-09-03 21:40:13 -04:00
Chuck Butkus
70e5d12ba9 Revert "Change to a non-login shell"
This reverts commit bcb3160d95.
2025-08-29 01:48:47 -04:00
Chuck Butkus
bcb3160d95 Change to a non-login shell 2025-08-29 01:37:02 -04:00
Chuck Butkus
174c691744 Update 2025-08-28 02:25:05 -04:00
Chuck Butkus
af34d446e9 Remove vscode username restriction 2025-08-28 02:22:27 -04:00
Chuck Butkus
6604924f76 Fix bash username 2025-08-28 02:21:41 -04:00
chuckbutkus
b2def1e438 Merge branch 'main' into test-user 2025-08-27 23:33:45 -04:00
Chuck Butkus
2b8e47aca9 Add runtime user env vars 2025-08-27 23:02:39 -04:00
Chuck Butkus
dba8b28824 Logging 2025-08-27 21:30:47 -04:00
3 changed files with 23 additions and 6 deletions

View File

@@ -15,6 +15,8 @@ from openhands.runtime.plugins.requirement import Plugin, PluginRequirement
from openhands.runtime.utils.system import check_port_available
from openhands.utils.shutdown_listener import should_continue
RUNTIME_USERNAME = os.getenv('RUNTIME_USERNAME')
@dataclass
class VSCodeRequirement(PluginRequirement):
@@ -37,7 +39,7 @@ class VSCodePlugin(Plugin):
)
return
if username not in ['root', 'openhands']:
if username not in filter(None, [RUNTIME_USERNAME, 'root', 'openhands']):
self.vscode_port = None
self.vscode_connection_token = None
logger.warning(

View File

@@ -20,6 +20,8 @@ from openhands.events.observation.commands import (
from openhands.runtime.utils.bash_constants import TIMEOUT_MESSAGE_TEMPLATE
from openhands.utils.shutdown_listener import should_continue
RUNTIME_USERNAME = os.getenv('RUNTIME_USERNAME')
def split_bash_commands(commands: str) -> list[str]:
if not commands.strip():
@@ -193,7 +195,7 @@ class BashSession:
def initialize(self) -> None:
self.server = libtmux.Server()
_shell_command = '/bin/bash'
if self.username in ['root', 'openhands']:
if self.username in list(filter(None, [RUNTIME_USERNAME, 'root', 'openhands'])):
# This starts a non-login (new) shell for the given user
_shell_command = f'su {self.username} -'

View File

@@ -1,3 +1,5 @@
import os
from openhands.core.config import OpenHandsConfig
from openhands.core.logger import openhands_logger as logger
from openhands.runtime.plugins import PluginRequirement
@@ -12,6 +14,9 @@ DEFAULT_PYTHON_PREFIX = [
]
DEFAULT_MAIN_MODULE = 'openhands.runtime.action_execution_server'
RUNTIME_USERNAME = os.getenv('RUNTIME_USERNAME')
RUNTIME_UID = os.getenv('RUNTIME_UID')
def get_action_execution_server_startup_command(
server_port: int,
@@ -26,7 +31,10 @@ def get_action_execution_server_startup_command(
sandbox_config = app_config.sandbox
logger.debug(f'app_config {vars(app_config)}')
logger.debug(f'sandbox_config {vars(sandbox_config)}')
logger.debug(f'override_user_id {override_user_id}')
logger.debug(f'RUNTIME_USERNAME {RUNTIME_USERNAME}, RUNTIME_UID {RUNTIME_UID}')
logger.debug(
f'override_username {override_username}, override_user_id {override_user_id}'
)
# Plugin args
plugin_args = []
@@ -40,10 +48,15 @@ def get_action_execution_server_startup_command(
'--browsergym-eval-env'
] + sandbox_config.browsergym_eval_env.split(' ')
username = override_username or (
'openhands' if app_config.run_as_openhands else 'root'
username = (
override_username
or RUNTIME_USERNAME
or ('openhands' if app_config.run_as_openhands else 'root')
)
user_id = override_user_id or (1000 if app_config.run_as_openhands else 0)
user_id = (
override_user_id or RUNTIME_UID or (1000 if app_config.run_as_openhands else 0)
)
logger.debug(f'username {username}, user_id {user_id}')
base_cmd = [
*python_prefix,