files_external occ commands crash with InvalidArgumentException for SMB mounts without credentials

オープン 初心者向け
#67,534 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php
領域
backend, cli

調査の方向性

apps/files_external/lib/Command/StorageAuthBase.php の createStorage() 周辺と関連する SMB バックエンドのコードを読み、認証情報がない場合の処理を追ってください。InvalidArgumentException の要求された処理とユニットテストを追加し、その後、該当するテストを実行してください。認証情報なしで SMB をマウントしたとき、生の例外ではなく「Username and/or password required」とコマンドに表示されれば完了です。

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

説明

bug feature: external storage feature: occ good first issue
Bug description

StorageAuthBase::createStorage() (used by files_external:notify and files_external:verify) only catches InsufficientDataForMeaningfulAnswerException and StorageNotAvailableException around manipulateStorageConfig():

https://github.com/nextcloud/server/blob/3a68340a6c806a18cdd0d9667a3b9ec5f096b135/apps/files_external/lib/Command/StorageAuthBase.php#L89-L96

The SMB backend throws an InvalidArgumentException when no user or password is available:

https://github.com/nextcloud/server/blob/3a68340a6c806a18cdd0d9667a3b9ec5f096b135/apps/files_external/lib/Lib/Backend/SMB.php#L65-L69

So for an SMB mount using login credentials (or without stored credentials) run without -u/-p, occ shows a raw exception instead of the intended "Username and/or password required" message (see the first log in #59519).

Steps to reproduce

Found by code reading.

  1. Create an SMB mount with "Log-in credentials, save in session".
  2. Run occ files_external:notify <mount_id> without -u/-p.
  3. An InvalidArgumentException: user or password is not set is printed.
Expected behavior

The command prints "Username and/or password required". Fix: also catch \InvalidArgumentException in the backend manipulateStorageConfig() block of StorageAuthBase::createStorage() and set $noAuth = true, with a unit test.

Nextcloud version

master

主要言語
PHP
スター
37.6k
フォーク
5.4k
平均マージ
1日 20時間
マージ済み PR(30日)
605

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

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

nextcloud/server のほかの issue

nextcloud/server の issue をすべて見る

似ている issue

PHP の issue をもっと見る

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

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