"Read only file system" when uploading #99

Closed
opened 2024-07-08 22:47:03 +02:00 by sney · 2 comments

Hi,

This is probably a support question rather than a bug. I have been attempting to host 0x0 on a vps. I am pretty familiar with linux administration but I've never used flask or uwsgi before.

I followed the instructions at https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html and https://uwsgi-docs.readthedocs.io/en/latest/Nginx.html. uwsgi and 0x0 are running and I can browse to the homepage: https://file.sney.ca/. However, when I try to upload a file, this happens:

jesse@bivouac:~/Pictures$ curl -F'file=@doFAZ.png' -Fexpires=24 https://file.sney.ca
<!doctype html>
<html lang=en>
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>

And the following is logged on the server:

Jul 08 16:37:58 vps262219 uwsgi[30246]: [2024-07-08 16:37:58,190] ERROR in app: Exception on / [POST]
Jul 08 16:37:58 vps262219 uwsgi[30246]: Traceback (most recent call last):
Jul 08 16:37:58 vps262219 uwsgi[30246]: File "/usr/lib/python3/dist-packages/flask/app.py", line 2525, in wsgi_app
Jul 08 16:37:58 vps262219 uwsgi[30246]: response = self.full_dispatch_request()
Jul 08 16:37:58 vps262219 uwsgi[30246]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 08 16:37:58 vps262219 uwsgi[30246]: File "/usr/lib/python3/dist-packages/flask/app.py", line 1822, in full_dispatch_request
Jul 08 16:37:58 vps262219 uwsgi[30246]: rv = self.handle_user_exception(e)
Jul 08 16:37:58 vps262219 uwsgi[30246]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 08 16:37:58 vps262219 uwsgi[30246]: File "/usr/lib/python3/dist-packages/flask/app.py", line 1820, in full_dispatch_request
Jul 08 16:37:58 vps262219 uwsgi[30246]: rv = self.dispatch_request()
Jul 08 16:37:58 vps262219 uwsgi[30246]: ^^^^^^^^^^^^^^^^^^^^^^^
Jul 08 16:37:58 vps262219 uwsgi[30246]: File "/usr/lib/python3/dist-packages/flask/app.py", line 1796, in dispatch_request
Jul 08 16:37:58 vps262219 uwsgi[30246]: return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
Jul 08 16:37:58 vps262219 uwsgi[30246]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 08 16:37:58 vps262219 uwsgi[30246]: File "fhost.py", line 500, in fhost
Jul 08 16:37:58 vps262219 uwsgi[30246]: return store_file(
Jul 08 16:37:58 vps262219 uwsgi[30246]: ^^^^^^^^^^^
Jul 08 16:37:58 vps262219 uwsgi[30246]: File "fhost.py", line 378, in store_file
Jul 08 16:37:58 vps262219 uwsgi[30246]: sf, isnew = File.store(f, requested_expiration, addr, ua, secret)
Jul 08 16:37:58 vps262219 uwsgi[30246]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 08 16:37:58 vps262219 uwsgi[30246]: File "fhost.py", line 298, in store
Jul 08 16:37:58 vps262219 uwsgi[30246]: with open(p, "wb") as of:
Jul 08 16:37:58 vps262219 uwsgi[30246]: ^^^^^^^^^^^^^
Jul 08 16:37:58 vps262219 uwsgi[30246]: OSError: [Errno 30] Read-only file system: 'up/dc008fcb785e9081579b2619baf354cb2e854c123b39c591eb3ede1e8898f33c'
Jul 08 16:37:58 vps262219 uwsgi[30246]: [pid: 30246|app: 0|req: 3/5] 38.49.164.71 () {38 vars in 562 bytes} [Mon Jul 8 16:37:58 2024] POST / => generated 265 bytes in 13 msecs (HTTP/1.1 500) 2 headers in 99 bytes (3 switches on core 0)

The nginx server block has location /up { internal; }, the dir exists, and the user running uwsgi has rw access to it. I also tried hardcoding the location in config.py but that made no difference, so I changed it back to the default.

Using Debian 12 with python 3.11.2-1+b1, flask 2.2.2-3, uwsgi 2.0.21-5.1, nginx 1.22.1-9.

Where do I go from here?

Thanks

Hi, This is probably a support question rather than a bug. I have been attempting to host 0x0 on a vps. I am pretty familiar with linux administration but I've never used flask or uwsgi before. I followed the instructions at https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html and https://uwsgi-docs.readthedocs.io/en/latest/Nginx.html. uwsgi and 0x0 are running and I can browse to the homepage: https://file.sney.ca/. However, when I try to upload a file, this happens: ` jesse@bivouac:~/Pictures$ curl -F'file=@doFAZ.png' -Fexpires=24 https://file.sney.ca` `<!doctype html>` `<html lang=en>` `<title>500 Internal Server Error</title>` `<h1>Internal Server Error</h1>` `<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>` And the following is logged on the server: > Jul 08 16:37:58 vps262219 uwsgi[30246]: [2024-07-08 16:37:58,190] ERROR in app: Exception on / [POST] > Jul 08 16:37:58 vps262219 uwsgi[30246]: Traceback (most recent call last): > Jul 08 16:37:58 vps262219 uwsgi[30246]: File "/usr/lib/python3/dist-packages/flask/app.py", line 2525, in wsgi_app > Jul 08 16:37:58 vps262219 uwsgi[30246]: response = self.full_dispatch_request() > Jul 08 16:37:58 vps262219 uwsgi[30246]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Jul 08 16:37:58 vps262219 uwsgi[30246]: File "/usr/lib/python3/dist-packages/flask/app.py", line 1822, in full_dispatch_request > Jul 08 16:37:58 vps262219 uwsgi[30246]: rv = self.handle_user_exception(e) > Jul 08 16:37:58 vps262219 uwsgi[30246]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Jul 08 16:37:58 vps262219 uwsgi[30246]: File "/usr/lib/python3/dist-packages/flask/app.py", line 1820, in full_dispatch_request > Jul 08 16:37:58 vps262219 uwsgi[30246]: rv = self.dispatch_request() > Jul 08 16:37:58 vps262219 uwsgi[30246]: ^^^^^^^^^^^^^^^^^^^^^^^ > Jul 08 16:37:58 vps262219 uwsgi[30246]: File "/usr/lib/python3/dist-packages/flask/app.py", line 1796, in dispatch_request > Jul 08 16:37:58 vps262219 uwsgi[30246]: return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) > Jul 08 16:37:58 vps262219 uwsgi[30246]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Jul 08 16:37:58 vps262219 uwsgi[30246]: File "fhost.py", line 500, in fhost > Jul 08 16:37:58 vps262219 uwsgi[30246]: return store_file( > Jul 08 16:37:58 vps262219 uwsgi[30246]: ^^^^^^^^^^^ > Jul 08 16:37:58 vps262219 uwsgi[30246]: File "fhost.py", line 378, in store_file > Jul 08 16:37:58 vps262219 uwsgi[30246]: sf, isnew = File.store(f, requested_expiration, addr, ua, secret) > Jul 08 16:37:58 vps262219 uwsgi[30246]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Jul 08 16:37:58 vps262219 uwsgi[30246]: File "fhost.py", line 298, in store > Jul 08 16:37:58 vps262219 uwsgi[30246]: with open(p, "wb") as of: > Jul 08 16:37:58 vps262219 uwsgi[30246]: ^^^^^^^^^^^^^ > Jul 08 16:37:58 vps262219 uwsgi[30246]: OSError: [Errno 30] Read-only file system: 'up/dc008fcb785e9081579b2619baf354cb2e854c123b39c591eb3ede1e8898f33c' > Jul 08 16:37:58 vps262219 uwsgi[30246]: [pid: 30246|app: 0|req: 3/5] 38.49.164.71 () {38 vars in 562 bytes} [Mon Jul 8 16:37:58 2024] POST / => generated 265 bytes in 13 msecs (HTTP/1.1 500) 2 headers in 99 bytes (3 switches on core 0) The nginx server block has `location /up { internal; }`, the dir exists, and the user running uwsgi has rw access to it. I also tried hardcoding the location in config.py but that made no difference, so I changed it back to the default. Using Debian 12 with python 3.11.2-1+b1, flask 2.2.2-3, uwsgi 2.0.21-5.1, nginx 1.22.1-9. Where do I go from here? Thanks
Owner

You can check whether the systemd unit for uwsgi has any hardening options preventing it from writing to that path.

You can check whether the systemd unit for uwsgi has any hardening options preventing it from writing to that path.
Author

Ah, yes, that was it, the example systemd unit for uwsgi from the debian package had DynamicUser=yes. Thanks for the tip. I am having a different problem now but I'll open a new issue if I can't figure it out.

Ah, yes, that was it, the example systemd unit for uwsgi from the debian package had DynamicUser=yes. Thanks for the tip. I am having a different problem now but I'll open a new issue if I can't figure it out.
sney closed this issue 2024-07-10 19:29:15 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: mia/0x0#99
No description provided.