rust-lang / rust-lang/rust

std::fs::copy unconditionally sets permission bits and fails

Open
#159,714 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-filesystem A-permissions C-bug E-needs-mcve O-linux O-unix T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I'm not writing any code in particular, but I encountered this issue in the software I use.

The software tries to copy a file using std::fs::copy
https://github.com/IntQuant/noita_entangled_worlds/blob/master/noita_proxy/src/player_cosmetics.rs#L586-L592
both source and destination are in a directory with ACLs which make all created files have me (lassebq) the owner of those files, even if they're created by another user.

  File: files/system/player/unmodified.png
  Size: 18680     	Blocks: 40         IO Block: 4096   regular file
Device: 8,17	Inode: 6689021     Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/ lassebq)   Gid: (  100/   users)
Access: 2026-07-22 11:54:33.889921747 +0300
Modify: 2026-07-22 11:54:33.889953747 +0300
Change: 2026-07-22 13:47:40.571769277 +0300
 Birth: 2026-07-22 11:54:33.889921747 +0300
  File: data/generated/sprite_uv_maps/mods.quant.ew.files.system.player.tmp.0000000000000001.png
  Size: 18680     	Blocks: 40         IO Block: 4096   regular file
Device: 8,17	Inode: 6689280     Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/ lassebq)   Gid: (  100/   users)
Access: 2026-07-22 11:56:41.143151945 +0300
Modify: 2026-07-22 14:32:49.975744501 +0300
Change: 2026-07-22 14:32:49.975744501 +0300
 Birth: 2026-07-22 11:56:41.143151945 +0300

ACLs:

# file: files/system/player/unmodified.png
# owner: lassebq
# group: users
user::rw-
group::rwx			#effective:rw-
group:users:rw-
mask::rw-
other::r--

# file: data/generated/sprite_uv_maps/mods.quant.ew.files.system.player.tmp.0000000000000001.png
# owner: lassebq
# group: users
user::rw-
group::rwx			#effective:rw-
group:users:rw-
mask::rw-
other::r--

So, when I run the software as user guest, it attempts to copy file and I get a permission denied error on that file

2026-07-22T11:47:01.492768Z ERROR noita_proxy: Panic occured at src/player_cosmetics.rs:592:6 : called `Result::unwrap()` on an `Err` value: Os { code: 1, kind: PermissionDenied, message: "Operation not permitted" }

But when I perform cp files/system/player/unmodified.png data/generated/sprite_uv_maps/mods.quant.ew.files.system.player.tmp.0000000000000001.png as guest there is no issue, and the files remain owned by lassebq

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the ACL setup described around noita_proxy/src/player_cosmetics.rs:586-592, then inspect std::fs::copy and its filesystem permission handling. Compare its behavior with the successful cp command. Done means copying under these ACLs no longer fails with PermissionDenied, with a regression test covering the case.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.