nodejs / nodejs/node

fs.copyFile fails if source is readonly and target is a CIFS volume

オープン
#60,557 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

libuv
主要言語
JavaScript
スター
122k
フォーク
37.3k
平均マージ
4日 2時間
マージ済み PR(30日)
283

説明

Version

v22.21.1

Platform
Linux a7f6d3be6434 5.15.158-2-pve #1 SMP PVE 5.15.158-2 (2024-07-26T13:11Z) x86_64 Linux

Docker: Alpine release 3.22.2
Subsystem

fs

What steps will reproduce the bug?

Hi,

Copying sample.docx fails with EPERM because the source is read-only and the destination is a CIFS share.

Probably related to:

https://github.com/nodejs/node/issues/37284
https://github.com/libuv/libuv/issues/3117
https://github.com/nodejs/node/issues/44261

How often does it reproduce? Is there a required condition?

100% reproducible

What is the expected behavior? Why is that the expected behavior?

/mnt/smb is a CIFS-mounted volume.
sample.docx is a file with read-only permissions for the user running the below code.

Code

import {copyFile} from "fs/promises";

const src = "./sample.docx";
const dest = "/mnt/smb/sample.docx";

await copyFile(src, dest);

console.log("File copied successfully");

The fs.copyFile should be able to succeed in copying the file as long as the destination folder is writable.

What do you see instead?

Error

node:internal/modules/run_main:123
    triggerUncaughtException(
    ^
[Error: EPERM: operation not permitted, copyfile './sample.docx' -> '/mnt/smb/sample.docx'] {
  errno: -1,
  code: 'EPERM',
  syscall: 'copyfile',
  path: './sample.docx',
  dest: '/mnt/smb/sample.docx'
}
Additional information

Works with no error

cp ./sample.docx /mnt/smb/sample.docx

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

fs/promises の copyFile エントリーポイントから始め、読み取り専用のソースと書き込み可能な CIFS の宛先を使って Linux 上で失敗を再現します。Node の動作を cp と比較し、その後、リンクされている Node.js と libuv の issue を確認します。指定された権限のもとで、報告された EPERM エラーなしに copyFile が成功すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, linux, node.js
領域
operating-systems
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
52/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。