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

File with wrong rights deleted on save attempt #1456

Closed
Bacto opened this issue Jul 2, 2021 · 1 comment
Closed

File with wrong rights deleted on save attempt #1456

Bacto opened this issue Jul 2, 2021 · 1 comment
Labels
bug 🐞 Something isn't working

Comments

@Bacto
Copy link

Bacto commented Jul 2, 2021

Hi,

First, thank you for Filebrowser, it is very useful :)

When I'm trying to save a file (after editing it in Filebrowser), the file on the server is deleted if the permissions are wrong.

In my case, the root directory is owned by the same user as filebrowser is running.
But the file I'm trying to edit is owned by root (with 644 rights).

Here is how to reproduce the bug:

  1. Start the container
docker run \
    -v /tmp/filebrowserTest:/srv \
    -p 8000:80 \
    --user $(id -u):$(id -g) \
    filebrowser/filebrowser --noauth -d /tmp/filebrowser.db
  1. Set the rights
chown $(id -u):$(id -g) /tmp/filebrowserTest

touch /tmp/filebrowserTest/myFile
chown root:root /tmp/filebrowserTest/myFile
chmod 644 /tmp/filebrowserTest/myFile
  1. open myFile in Filebrowser, edit it and save it. You will get a 403 (that's expected) but then go back to the directory and you will see that the file myFile has been removed by Filebrowser.

It seems related to this:
https://github.com/filebrowser/filebrowser/blob/master/http/resource.go#L178

Thanks,
Adrien

@ramiresviana
Copy link
Contributor

Thanks for the report, files should not be deleted when an error occurs with the PUT method, that must be fixed. This happens when the server cannot write on the file but can delete it, deleting is handled by the directory permissions and not by the permissions of the file.

@o1egl o1egl added the bug 🐞 Something isn't working label Jul 3, 2021
@o1egl o1egl closed this as completed in 6b19ab6 Jul 26, 2021
Alsan pushed a commit to Alsan/filebrowser that referenced this issue Aug 25, 2021
rahul-r pushed a commit to rahul-r/filebrowser that referenced this issue Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants