From 3c82ba7f348284a4dfc04d08d4df00450b9a77ed Mon Sep 17 00:00:00 2001 From: Xingyao Wang Date: Mon, 8 Apr 2024 22:54:06 +0800 Subject: [PATCH] support running sudo in a passwordless manner (#906) --- opendevin/sandbox/sandbox.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/opendevin/sandbox/sandbox.py b/opendevin/sandbox/sandbox.py index abc40bd661..d7c7aafb3c 100644 --- a/opendevin/sandbox/sandbox.py +++ b/opendevin/sandbox/sandbox.py @@ -140,6 +140,18 @@ class DockerInteractive(CommandExecutor): atexit.register(self.cleanup) def setup_user(self): + + # Make users sudoers passwordless + # TODO(sandbox): add this line in the Dockerfile for next minor version of docker image + exit_code, logs = self.container.exec_run( + ['/bin/bash', '-c', + r"echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers"], + workdir='/workspace', + ) + if exit_code != 0: + raise Exception( + f'Failed to make all users passwordless sudoers in sandbox: {logs}') + # Check if the opendevin user exists exit_code, logs = self.container.exec_run( ['/bin/bash', '-c', 'id -u opendevin'],