mirror of
https://github.com/sigoden/dufs.git
synced 2026-04-08 16:49:02 +03:00
[GH-ISSUE #324] Support locking a file to prevent from deleting/moving #171
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jessehu on GitHub (Dec 21, 2023).
Original GitHub issue: https://github.com/sigoden/dufs/issues/324
@sigoden commented on GitHub (Dec 21, 2023):
If you don't want to edit the file, you may set read-only permissions.
Dufs allow you control the permissions of files or directorie with
--auth.@jessehu commented on GitHub (Dec 21, 2023):
do you mean setting read-only permission for a single file via 'chmod 400'? Can it be done on dufs UI?
@sigoden commented on GitHub (Dec 21, 2023):
Have you read the dufs readme? dufs can set permissions for paths. @jessehu
@jessehu commented on GitHub (Dec 21, 2023):
This solution requires restarting dufs for each file to be locked and unlocked. Not easy to use.
@sigoden commented on GitHub (Dec 21, 2023):
dufs is a stateless file server and does not support file dynamic locking.
@jessehu commented on GitHub (Dec 21, 2023):
I see. Just wondering if it can be archieved by:
<filename>.lockfile when locking/unlocking this file on dufs UI?@sigoden commented on GitHub (Dec 21, 2023):
The only way I recommend to protect files is through auth. Other methods are error prone.
@jessehu commented on GitHub (Dec 22, 2023):
Thanks. I tried the solution 1 and works well:

Code change:
e12f97e92f@sigoden commented on GitHub (Dec 22, 2023):
This solution is also error prone.
Here is the doc for

std::fs::Permissions:Permissions do not check ACLs. If the file permissions are "-rw-r--r-- ubuntu web..." and you run dufs in the "web" group, you may think dufs will think the file is readonly and return 403, but it's wrong, becase
permissions().readonly()returns false and dufs will return 500.There is no easy way to determine whether a file is truely readonly for a process.
@jessehu commented on GitHub (Dec 22, 2023):
Yup, it depends on which user used to run dufs, and this is controlled by the user who runs dufs.