adrianlopezroche / fdupes

FDUPES is a program for identifying or deleting duplicate files residing within specified directories.
2.42k stars 186 forks source link

please respect access permissions for -L #47

Open sandrotosi opened 8 years ago

sandrotosi commented 8 years ago

From @sandrotosi on December 20, 2015 14:5

From matrixhasu on August 01, 2011 15:36:46

I'm forwarding the debian bug 635158, http://bugs.debian.org/635158 :

fdupes should respect uid, gid and access permissions before replacing files by hard links. Sample session:

% umask 0022; echo hello >a; cp -p a b; ln b c; chmod go-r b; ls -li total 12 27394110 -rw-r--r-- 1 harri harri 6 Jul 23 11:36 a 27394111 -rw------- 2 harri harri 6 Jul 23 11:36 b 27394111 -rw------- 2 harri harri 6 Jul 23 11:36 c % fdupes -L . [+] ./c [h] ./a [h] ./b

% ls -li total 12 27394111 -rw------- 3 harri harri 6 Jul 23 11:36 a 27394111 -rw------- 3 harri harri 6 Jul 23 11:36 b 27394111 -rw------- 3 harri harri 6 Jul 23 11:36 c

See how a world readable file became unreadable for anybody but the owner?

Since "a" has different access permissions it shouldn't have been replaced by a hard link to b. Same goes for identical files with different owners. fdupes is loosing too much information here. <<<

Original issue: http://code.google.com/p/fdupes/issues/detail?id=18

Copied from original issue: sandrotosi/fdupes-issues#6

sandrotosi commented 8 years ago

From fszcze...@gmail.com on October 29, 2011 20:10:19

This patch applies to the patch set I posted to issue #8 . It adds a -M/--checkmeta flag that includes uid/gid/mode when determining matches.

$ (umask 0022; for f in a b c d e f ; do echo hello > $f ; done; chmod go-r c d; chmod o-r e f; ls -li) total 48 50234037 -rw-r--r-- 1 frank staff 6 Oct 29 23:04 a 50234038 -rw-r--r-- 1 frank staff 6 Oct 29 23:04 b 50234039 -rw------- 1 frank staff 6 Oct 29 23:04 c 50234040 -rw------- 1 frank staff 6 Oct 29 23:04 d 50234041 -rw-r----- 1 frank staff 6 Oct 29 23:04 e 50234042 -rw-r----- 1 frank staff 6 Oct 29 23:04 f $ ../fdupes -lM . [x] ./e
[h] ./f Saved 6 bytes on this group with 1 link [x] ./c [h] ./d Saved 6 bytes on this group with 1 link [x] ./a [h] ./b Saved 6 bytes on this group with 1 link Relinked 3 files in 3 groups Saved 18 bytes $ ls -l total 48 -rw-r--r-- 2 frank staff 6 Oct 29 23:04 a -rw-r--r-- 2 frank staff 6 Oct 29 23:04 b -rw------- 2 frank staff 6 Oct 29 23:04 c -rw------- 2 frank staff 6 Oct 29 23:04 d -rw-r----- 2 frank staff 6 Oct 29 23:04 e -rw-r----- 2 frank staff 6 Oct 29 23:04 f

Attachment: 0005-Add-checkmeta-flag.patch

sandrotosi commented 8 years ago

From hobbes1...@gmail.com on July 16, 2013 07:31:34

I am trying to update the fdupes package for Fedora to fix this problem but it appears the patch does not apply to the current 1.51 version. An updated patch would be greatly appreciated!