.net-core - 使用带有 samba 挂载的 C# dotnet core CENTOS 对 File.Copy 的权限被拒绝
问题描述
使用 File.Copy 时,
File.Copy(file.FullName, Path.Combine(config.DestinationDir, file.Name), true);
我遇到了以下问题:
"ClassName": "System.UnauthorizedAccessException",
"Message": "Access to the path is denied.",
"Data": null,
"InnerException": {
"ClassName": "System.IO.IOException",
"Message": "Operation not permitted",
"Data": null,
"InnerException": null,
"HelpURL": null,
"StackTraceString": null,
"RemoteStackTraceString": null,
"RemoteStackIndex": 0,
"ExceptionMethod": null,
"HResult": 1,
"Source": null,
"WatsonBuckets": null
}
这看起来是一个权限问题。然而:
- 我对源文件夹和目标文件夹都有正确的权限
- 我可以毫无问题地在目标文件夹上执行 mv/cp/touch 之类的命令
- 仅当目标文件夹是 SAMBA mnt 时才会出现此问题。
- 使用 File.Read 和 File.Write 没有问题(如果它与一些基本权限问题相关联,应该会触发异常)
- 如果我用 SUDO 运行命令,没问题。
这是目标文件夹上 ls -ld 的结果:
drwxrwxr-x. 2 svc_smb_share grp_smb_share 0 24 jui 14:49 DestinationFolder
我的用户属于 grp_smb_share,因此具有读/写/执行权限。
关于我的配置的说明:
- 服务器使用 Centos (centos-release-7-7.1908.0.el7.centos.x86_64)
- dotnet 核心 (3.1.100)
你有什么线索吗?
解决方案
推荐阅读
- excel - 循环搜索workbook1中的数据,将偏移单元格复制到workbook2
- laravel - 我正在尝试在 eloquent laravel 5.8 中渴望加载参数
- css - 如何在 Bootstrap 4 中为垂直选项卡设置透明右边框
- tensorflow - Seq to Seq 模型训练
- mysql - 如何计算条件中的行数?
- php - 模型连接无法正常工作 - Laravel
- c - 奇怪的盒装输出
- email - Laravel Mailable | ->from($this->input->mail)
- google-analytics - histogram or group users by number of campaigns they received
- python - C struct encoded binary data file read in python