Skip to content

Commit

Permalink
(fix) restore sudo-capability after recent changes (All-Hands-AI#3964)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobitege authored Sep 19, 2024
1 parent 809903b commit 45066f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
15 changes: 5 additions & 10 deletions openhands/runtime/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,11 @@ def _init_user(self, username: str, user_id: int) -> None:
raise

# Add sudoer
sudoer_line = r'%sudo ALL=(ALL) NOPASSWD:ALL\n'
sudoers_path = '/etc/sudoers.d/99_sudo'
if not Path(sudoers_path).exists():
with open(sudoers_path, 'w') as f:
f.write(sudoer_line)
output = subprocess.run(['chmod', '0440', sudoers_path])
if output.returncode != 0:
logger.error('Failed to chmod 99_sudo file!')
else:
logger.debug('Added sudoer successfully.')
sudoer_line = r"echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers"
output = subprocess.run(sudoer_line, shell=True, capture_output=True)
if output.returncode != 0:
raise RuntimeError(f'Failed to add sudoer: {output.stderr.decode()}')
logger.debug(f'Added sudoer successfully. Output: [{output.stdout.decode()}]')

command = (
f'useradd -rm -d /home/{username} -s /bin/bash '
Expand Down
2 changes: 2 additions & 0 deletions openhands/runtime/client/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ def __init__(
# will initialize both the event stream and the env vars
super().__init__(config, event_stream, sid, plugins, env_vars)

self._wait_until_alive()

logger.info(
f'Container initialized with plugins: {[plugin.name for plugin in self.plugins]}'
)
Expand Down

0 comments on commit 45066f1

Please sign in to comment.