code-interpreter icon indicating copy to clipboard operation
code-interpreter copied to clipboard

run_code as a user instead of root

Open mishushakov opened this issue 6 months ago • 4 comments

  • Jupyter Server and Code Interpreter are started as a non-privileged user
  • Adds ability to change user by creating a new context
  • BREAKING: Default user root > user to match the Sandbox commands.run behavior
  • POSSIBLY BREAKING: when cwd is not set and user is root, it will set cwd to /root

Sample code

const ctx = await sbx.createCodeContext({ language: "python", user: "user" })

const code = await sbx.runCode(`import getpass; print(getpass.getuser())`, { context })
console.log(code.logs);
{
    stdout: [ "user\n" ],
    stderr: [],
}

mishushakov avatar Apr 28 '25 11:04 mishushakov