π OpenHands: AI-Driven Development
(fix) restore sudo-capability after recent changes (#3964)
tobitege45066f19dcec
diff --git a/openhands/runtime/client/client.py b/openhands/runtime/client/client.pyindex 0481a200d0..987fddf909 100644--- a/openhands/runtime/client/client.py+++ b/openhands/runtime/client/client.py@@ -184,16 +184,11 @@ class RuntimeClient: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 'diff --git a/openhands/runtime/client/runtime.py b/openhands/runtime/client/runtime.pyindex d1bba56110..2e0d664a6e 100644--- a/openhands/runtime/client/runtime.py+++ b/openhands/runtime/client/runtime.py@@ -171,6 +171,8 @@ class EventStreamRuntime(Runtime):# will initialize both the event stream and the env varssuper().__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]}')