kornelski / dupe-krill

A fast file deduplicator
https://lib.rs/dupe-krill
MIT License
186 stars 10 forks source link

Preserve file access permissions #18

Open Fell opened 6 months ago

Fell commented 6 months ago

It would be nice to add an option that ensures that anyone who had access to the file before hardlinking also has access afterwards.

Example: Before hardlinking:

-rw-r--r-- 1 alice alice 120000 Apr 29 20:31 image.jpg
-rw-r--r-- 1 bob   bob   120000 Apr 23 16:41 image2.jpg

After hardlinking:

-rw-r--r-- 2 alice alice 120000 Apr 29 20:31 image.jpg
-rw-r--r-- 2 alice alice 120000 Apr 29 20:31 image2.jpg

User bob has essentially lost write access to the file.

Since there are multiple ways of solving this problem, I want to discuss possible solutions, such as:

I would be willing on working on the implementation if neccessary.

kornelski commented 6 months ago

Yes, PRs for this are welcome.

I think the principle should be that access is never relaxed beyond original permissions (no new users/groups can access the file). It may be ok to skip hardlinking files when the permissions can't be changed to match (limiting dedupe to a single user, or requiring running under sudo).

I'm not sure what are the consequences of using ACLs. I'm worried that changing access from old-primitive-unix style could confuse some programs, or users would have harder time undestanding and changing permissions afterwards.