E2B icon indicating copy to clipboard operation
E2B copied to clipboard

Permission denied after using a newly created directory

Open mlejva opened this issue 10 months ago • 1 comments

If you create a new directory with our SDK and then try to move a file into the newly created directory, you receive a permission denied error.

Reproducible Python example

from e2b import Sandbox
with Sandbox() as sandbox:
    sandbox.filesystem.make_dir("/new-dir")
    sandbox.filesystem.write("/file.txt", "hello")
    proc = sandbox.process.start_and_wait("mv /file.txt /new-dir/file.txt")
    print(proc)

Output

messages=[ProcessMessage(line="mv: cannot move '/file.txt' to '/new-dir/file.txt': Permission denied", error=True, timestamp=1713826346687143416)] error=True exit_code=1

mlejva avatar Apr 22 '24 22:04 mlejva

This is a problem with filesystem permissions — we don't expose user and use root for fs operations by default (so you have access to all files). When you then try to modify file as default user via process the permissions block this.

I'm taking this into account when thinking about new version of the API (https://github.com/e2b-dev/infra/blob/grpc/packages/envd/spec/filesystem.proto), but it might be possible to add this without breaking to the current API too.

ValentaTomas avatar Apr 22 '24 23:04 ValentaTomas

This is fixed in the new beta SDK (https://e2b.dev/docs/guide/beta-migration) — by default, all operations are executed as user.

ValentaTomas avatar Jul 23 '24 08:07 ValentaTomas