Skip to content

ln, cp: replacing an entry in a write-only directory fails with EACCES #15112

Open

Description

@abendrothj

ln -sf and cp -sf can't replace an existing entry in a directory that is writable and searchable but not readable. GNU 9.12 replaces it.

$ echo hi > f && mkdir wx && ln -s old wx/link && touch wx/c && chmod 300 wx
$ ln -sf new wx/link
ln: failed to create symbolic link 'wx/link': Permission denied
$ cp -sf "$PWD/f" wx/c
cp: Permission denied (os error 13)

Replacing a name only needs write and search permission on the directory. The replace path opens the parent with O_RDONLY, which also needs read.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions