Skip to content

Commit

Permalink
Update opendevin/sandbox/sandbox.py
Browse files Browse the repository at this point in the history
Co-authored-by: Anas DORBANI <[email protected]>
  • Loading branch information
xingyaoww and dorbanianas authored Apr 8, 2024
1 parent 14388de commit 01c1265
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions opendevin/sandbox/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,21 @@ def __init__(
atexit.register(self.cleanup)

def setup_user(self):
# Check if the opendevin user exists
exit_code, logs = self.container.exec_run(
['/bin/bash', '-c', 'id -u opendevin'],
workdir='/workspace',
)
if exit_code == 0:
# User exists, delete it
exit_code, logs = self.container.exec_run(
['/bin/bash', '-c', 'userdel -r opendevin'],
workdir='/workspace',
)
if exit_code != 0:
raise Exception(f'Failed to remove opendevin user in sandbox: {logs}')

# Create the opendevin user
exit_code, logs = self.container.exec_run(
['/bin/bash', '-c',
f'useradd -rm -d /home/opendevin -s /bin/bash -g root -G sudo -u {USER_ID} opendevin'],
Expand Down

0 comments on commit 01c1265

Please sign in to comment.