Skip to content

removePathForcibly can affect the permissions of files outside the path being deleted #135

Description

@joeyh

When a file is a hard link, removePathForcibly will modify the permissions of files outside the directory being deleted:

joey@darkstar:~/tmp>mkdir test
joey@darkstar:~/tmp>cd test
joey@darkstar:~/tmp/test>l
joey@darkstar:~/tmp/test>mkdir foo
joey@darkstar:~/tmp/test>mkdir bar
joey@darkstar:~/tmp/test>echo hi > bar/f
joey@darkstar:~/tmp/test>chmod 400 bar/f
joey@darkstar:~/tmp/test>ln bar/f foo/f
joey@darkstar:~/tmp/test>ghci
GHCi, version 8.8.4: https://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/joey/.etc/.ghci
ghci> import System.Directory
ghci> removePathForcibly "foo"
ghci> 
Leaving GHCi.
joey@darkstar:~/tmp/test>ls -l bar
total 4
-rwx------ 1 joey joey 3 May  2 13:34 f*

I doubt that changing the permissions of a file is ever necessary to let it be deleted.

If it only changed the permissions of directories, which can be necessary, it would avoid this problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: (1) bugThe described behavior is not working as intended.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions