transfer.sh icon indicating copy to clipboard operation
transfer.sh copied to clipboard

Uploading empty file: Permission denied

Open zurborg opened this issue 1 year ago • 7 comments

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

zurborg avatar Feb 06 '24 21:02 zurborg

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 avatar Feb 16 '24 09:02 DrackThor

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

DrackThor avatar Feb 16 '24 09:02 DrackThor

thanks for the report, I'll check on it

aspacca avatar Feb 22 '24 09:02 aspacca

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"

scolandrea avatar Apr 07 '24 00:04 scolandrea

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

zurborg avatar Apr 07 '24 07:04 zurborg

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

scolandrea avatar Apr 07 '24 13:04 scolandrea

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.

zurborg avatar Apr 07 '24 17:04 zurborg