Skip to content
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

Uploading empty file: Permission denied #601

Open
zurborg opened this issue Feb 6, 2024 · 7 comments
Open

Uploading empty file: Permission denied #601

zurborg opened this issue Feb 6, 2024 · 7 comments

Comments

@zurborg
Copy link

zurborg commented Feb 6, 2024

I started transfer.sh in a container with this arguments: --provider=local, --basedir=/data/

When I upload an empty file, I got this error:

HTTP/2 500 
content-type: text/plain; charset=utf-8
server: Transfer.sh HTTP Server
x-content-type-options: nosniff
x-made-with: <3 by DutchCoders
x-served-by: Proudly served by DutchCoders
date: Tue, 06 Feb 2024 20:50:00 GMT
content-length: 49

open /tmp/transfer-4122496938: permission denied

Same message appears in log.

Tested with this command:

curl -sST /dev/null -i http://localhost/null

Image used: dutchcoders/transfer.sh:latest-noroot

Image ID: 4d51e3998a08

@DrackThor
Copy link

Same problem here - I tried the simple example from the README.md docs:
image ID: 92f2b0b2f3ff

# started the container
docker run --publish 8080:8080 dutchcoders/transfer.sh:latest-noroot --provider local --basedir /tmp/

# tried to upload a random file
curl -v \
--upload-file ./README.md \
https://localhost:8080/README.md

CURL:

curl -v \
--upload-file ./README.md \
http://localhost:8080/README.md
*   Trying [::1]:8080...
* connect to ::1 port 8080 failed: Connection refused
*   Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080
> PUT /README.md HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/8.4.0
> Accept: */*
> Content-Length: 6173
>
* We are completely uploaded and fine
< HTTP/1.1 500 Internal Server Error
< Content-Type: text/plain; charset=utf-8
< Server: Transfer.sh HTTP Server
< X-Content-Type-Options: nosniff
< X-Made-With: <3 by DutchCoders
< X-Served-By: Proudly served by DutchCoders
< Date: Fri, 16 Feb 2024 09:29:59 GMT
< Content-Length: 24
<
Could not save metadata
* Connection #0 to host localhost left intact

Container LOG:

[transfer.sh]2024/02/16 09:29:43 Transfer.sh server started.
using temp folder: /tmp/
using storage provider: local
[transfer.sh]2024/02/16 09:29:43 starting to listen on: :8080
[transfer.sh]2024/02/16 09:29:43 ---------------------------
[transfer.sh]2024/02/16 09:29:59 mkdir /tmp/uYP5HPT8wo: permission denied
[transfer.sh]2024/02/16 09:29:59 172.17.0.1:54290 - - [2024-02-16T09:29:59Z] "PUT /README.md HTTP/1.1" 500  "" "curl/8.4.0"
^C[transfer.sh]2024/02/16 09:30:32 Server stopped.

@DrackThor
Copy link

I also tried the same thing with the :latest (root) image - this works fine.
So this very much looks like a -noroot image issue

@aspacca
Copy link
Collaborator

aspacca commented Feb 22, 2024

thanks for the report, I'll check on it

@scolandrea
Copy link

scolandrea commented Apr 7, 2024

I fixed the issues by mapping the volume from host to container.

Example: docker run --publish 8080:8080 --volume "./tmp:/data" dutchcoders/transfer.sh:latest-noroot --provider local --basedir "/data"

@zurborg
Copy link
Author

zurborg commented Apr 7, 2024

I've tried adding /tmp as volume, and now I get this error:

HTTP/2 400 
content-type: text/plain; charset=utf-8
server: Transfer.sh HTTP Server
x-content-type-options: nosniff
x-made-with: <3 by DutchCoders
x-served-by: Proudly served by DutchCoders
date: Sun, 07 Apr 2024 07:11:19 GMT
content-length: 28

Could not upload empty file

Logfile says:

Empty content-length

@scolandrea
Copy link

I've tried adding /tmp as volume, and now I get this error:

HTTP/2 400 
content-type: text/plain; charset=utf-8
server: Transfer.sh HTTP Server
x-content-type-options: nosniff
x-made-with: <3 by DutchCoders
x-served-by: Proudly served by DutchCoders
date: Sun, 07 Apr 2024 07:11:19 GMT
content-length: 28

Could not upload empty file

Logfile says:

Empty content-length

If you run as I posted, first, you must create a directory "tmp" in your current directory. My reply is just trying to explain that you need to make sure the directory exists in the container and you have mapped it on the host.

Good luck

@zurborg
Copy link
Author

zurborg commented Apr 7, 2024

I created the directory before and set the uid and gid both to 5000. Permission is 0775. I can upload any non-empty file. Except for empty files I got the mentioned error.

I think this is fine. Sharing empty files is a bit of useless, so this error don't need to be fixed. Besides, with this setup the error code changed from 500 to 400.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants