Skip to content

Commit 45066f1

Browse files
authored
(fix) restore sudo-capability after recent changes (All-Hands-AI#3964)
1 parent 809903b commit 45066f1

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

openhands/runtime/client/client.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,11 @@ def _init_user(self, username: str, user_id: int) -> None:
184184
raise
185185

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

198193
command = (
199194
f'useradd -rm -d /home/{username} -s /bin/bash '

openhands/runtime/client/runtime.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ def __init__(
171171
# will initialize both the event stream and the env vars
172172
super().__init__(config, event_stream, sid, plugins, env_vars)
173173

174+
self._wait_until_alive()
175+
174176
logger.info(
175177
f'Container initialized with plugins: {[plugin.name for plugin in self.plugins]}'
176178
)

0 commit comments

Comments
 (0)