A download directory reached through a symlink cannot be imported from at all

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

メンテナーはふだん 1 日以内に返信

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
csharp
領域
backend

調査の方向性

Start by reading FileMover.SourceCapability.cs and PinnedDirectoryCreation.Hierarchy.cs, then inspect CheckPublicationSource_LinkedAncestor_ReturnsUnsupported and the two linked-ancestor boundary tests. The issue frames this as an unresolved security-policy decision, not a straightforward fix; clarify whether source symlinks should be followed while preserving destination and lock-directory protections before proposing a change.

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

説明

Checked against canary a630572e (1.3.4). Every line number below is from that commit.

Summary

A download directory reached through a symbolic link cannot be imported from. Not slowly, not sometimes: every file, every time, refused before a destination is created.

Sonarr, Radarr and Readarr all import from such a directory without complaint, so this is a layout the ecosystem's users already have. Cache tiers, pooled mounts and alias directories all produce it.

I think the refusal is deliberate, which is why this is a question rather than a pull request.

The mechanism

FileMover.CheckAsync opens the source file's parent hierarchy through PinnedDirectoryCreation.OpenPinnedHierarchyNoFollow (FileMover.SourceCapability.cs:26). That walks every segment of the path with openat(..., O_DIRECTORY | O_NOFOLLOW) (PinnedDirectoryCreation.Hierarchy.cs:38-80, NativeOperations.cs:76-92).

O_NOFOLLOW on a symlinked component fails with ENOTDIR, which I confirmed rather than assumed; I would have guessed ELOOP. The createMissing branch at Hierarchy.cs:69-70 only rescues NativeErrorCode 2 or 3, so 20 propagates. Path.GetFullPath at :43 normalises . and .. and leaves symlinks in place, so nothing resolves the path before the walk.

The result reaches the operator as "The source file cannot be pinned to a durable physical generation and content proof", with the exception discarded. I have sent a separate pull request for that half; it is what made this findable at all.

Why I do not think you should simply follow links

The pinned walk is doing real work, and the tests say so. FileOperation_LinkedLockDirectoryAncestor_DoesNotCreateOutsideBoundary and PerformActionOn_LinkedApplicationLockAncestorFailsClosed both check that a symlinked ancestor cannot cause a write outside the boundary. That is a property worth keeping, and my first attempt at this removed it without my noticing until your suite failed.

The narrower question

On a destination, or a lock directory, O_NOFOLLOW prevents a swapped link redirecting a write outside the configured root. On a source, the operation is a read and a hash, and the capability proof is an inode plus a content digest. Both of those describe the object rather than the route taken to it, so resolving the route does not weaken the proof. What it gives up is the guarantee that the route cannot change during the operation.

So: is CheckPublicationSource_LinkedAncestor_ReturnsUnsupported a considered decision about sources specifically, or the destination rule applied uniformly?

What Readarr does, for comparison

Readarr resolves symlinks deliberately, but only where physical identity matters. SymbolicLinkResolver.GetCompleteRealPath (src/NzbDrone.Mono/Disk/SymbolicLinkResolver.cs:22) follows links iteratively, caps at 32 and warns with ELOOP beyond that. Its only caller is DiskProvider.GetMount (src/NzbDrone.Mono/Disk/DiskProvider.cs:53), for free space and drive detection, where an alias names the wrong filesystem. Everything else uses path based file API and follows links by construction. There is no O_NOFOLLOW anywhere in that codebase.

Its move guarantee is correspondingly weaker: DiskTransferService.TryMoveFileVerified (src/NzbDrone.Common/Disk/DiskTransferService.cs:493-514) moves the file and compares the target size to the original. A substitution of the same length would pass.

I am not suggesting you adopt that. Your model is stronger and catches things Readarr's cannot. The observation is only that the family resolves the real path where physical identity matters, and that Listenarr inherited those users without inheriting the permissiveness.

A branch, not a pull request

fix/resolve-symlinked-source-path resolves the source path once, for the purpose of opening the file and nothing else. The resolved path is never returned or used for a policy decision, so root containment and retirement policy see exactly what they saw before, and the shared hierarchy helper is untouched. The write side still fails closed and both boundary tests above still pass.

It contradicts exactly one existing test, CheckPublicationSource_LinkedAncestor_ReturnsUnsupported, which is the decision itself. The commit message says so.

I have run it on an install whose imports had failed for days against a symlinked download directory. The first retry imported: ffprobe ran, the file landed in the library, no block. So the change works, and the only question left is whether you want it.

I have not opened it because deleting a test you wrote on purpose is not mine to propose. If you would rather have it as a pull request, or shaped differently, say so and it is yours.


Worked through with Claude Code at my direction. The mechanism was checked by running it, including the errno and a reproduction on a stock container, and the fix was run on a real install. The comparison with Readarr is source reading against its develop branch. I reviewed this before posting.

主要言語
C#
スター
901
フォーク
70
平均マージ
16時間 27分
マージ済み PR(30日)
60

環境構築

はじめの一歩

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

Listenarrs/Listenarr のほかの issue

Listenarrs/Listenarr の issue をすべて見る

似ている issue

C# の issue をもっと見る

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

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