Skip to content

run_code as a user instead of root #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

mishushakov
Copy link
Member

@mishushakov mishushakov commented Apr 28, 2025

  • Jupyter Server and Code Interpreter are started as a non-privileged user
  • Changes file paths to user home directory (/home/user)
  • Adds logging to Jupyter Server and Code Interpreter (before was /dev/zero, not sure if on purpose)

Sample code

const code = await sbx.runCode(`import getpass; print(getpass.getuser())`)
console.log(code.logs);

before

{
  stdout: [ "root\n" ],
  stderr: [],
}

after

{
  stdout: [ "user\n" ],
  stderr: [],
}

Copy link

linear bot commented Apr 28, 2025

@mishushakov mishushakov self-assigned this Apr 28, 2025
@mishushakov mishushakov added the improvement Improvement for current functionality label Apr 28, 2025
@mishushakov mishushakov marked this pull request as ready for review April 28, 2025 12:09
Copy link
Member

jakubno commented Apr 28, 2025

This won't be probably backwards compatible right?

Can I specify if I want run something as root?

@mishushakov
Copy link
Member Author

Not backwards-compatible. You cannot specify the user, the kernels start as same user as Jupyter. There is a possible some workaround suggested by ChatGPT but it's a bit inconvenient:

Screenshot 2025-04-28 at 14 32 17

Copy link
Member

@jakubno jakubno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we just need to be able to pass user. Otherwise, someone might need to run something as root, leading to the same issue.

@mishushakov mishushakov marked this pull request as draft April 30, 2025 16:12
@mishushakov mishushakov requested a review from jakubno May 2, 2025 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement for current functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants