Skip to content

std: implement Unix set_permissions_nofollow via fchmodat#571

Open
SebTardif wants to merge 1 commit into
mainfrom
fix-unix-set-permissions-nofollow-fchmodat
Open

std: implement Unix set_permissions_nofollow via fchmodat#571
SebTardif wants to merge 1 commit into
mainfrom
fix-unix-set-permissions-nofollow-fchmodat

Conversation

@SebTardif

Copy link
Copy Markdown
Owner

Summary

Replace open+O_NOFOLLOW+fchmod with fchmodat(..., AT_SYMLINK_NOFOLLOW) so symlink paths can have permissions set on the link (or succeed as a no-op on filesystems that ignore symlink mode), instead of failing with ELOOP on Linux/macOS.

ESP-IDF / Horizon / Vita / VxWorks fall back to normal chmod via set_perm.

Closes #566

Origin

Test plan

  • Code review vs lchown / fstatat nofollow patterns in unix.rs
  • Unix smoke: symlink path + set_permissions_nofollow (manual / CI)

Opening with O_NOFOLLOW fails with ELOOP when the path is a symlink, so
the previous implementation could not chmod the link itself. Use
fchmodat(AT_FDCWD, path, mode, AT_SYMLINK_NOFOLLOW) on platforms that
support it; fall back to normal chmod on ESP-IDF/Horizon/Vita/VxWorks
stubs.

Closes #566

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unix set_permissions_nofollow uses O_NOFOLLOW open (ELOOP on symlinks), not fchmodat on the link

1 participant