gpt4 book ai didi

azure - Windows Azure 异常 : "Access to the path XYZ.exe is denied."

转载 作者:行者123 更新时间:2023-12-04 06:12:52 26 4
gpt4 key购买 nike

我使用 Windows Azure 上的本地存储来存储临时文件。在那里,我调用一个 .exe 文件来转换同一本地存储文件夹中的几个其他文件。问题是我总是收到异常“访问路径 XYZ.exe 被拒绝。”。

我应该提到以下几点:- 我正在使用 worker 角色- 在服务定义文件中设置

并尝试向我正在访问的文件夹添加权限:

    public static void AddPermission(string absoluteFolderPath)
{
DirectoryInfo myDirectoryInfo = new DirectoryInfo(absoluteFolderPath);

DirectorySecurity myDirectorySecurity = myDirectoryInfo.GetAccessControl();
myDirectorySecurity.AddAccessRule(new FileSystemAccessRule(
"NETWORK SERVICE",
FileSystemRights.FullControl,
AccessControlType.Allow));
myDirectoryInfo.SetAccessControl(myDirectorySecurity);
}

更新:我现在尝试使用此代码:

     public static void FixPermissions()
{
var tempDirectory = RoleEnvironment.GetLocalResource("localStorage").RootPath;
Helper.addPermission(tempDirectory);

var dir = new DirectoryInfo(tempDirectory);
foreach (var d in dir.GetDirectories())
Helper.addPermission(d.FullName);
}

private static void addPermission(string path)
{
FileSystemAccessRule everyoneFileSystemAccessRule = new FileSystemAccessRule("Everyone",
FileSystemRights.FullControl,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None, AccessControlType.Allow);
DirectoryInfo directoryInfo = new DirectoryInfo(path);
DirectorySecurity directorySecurity = directoryInfo.GetAccessControl();
directorySecurity.AddAccessRule(everyoneFileSystemAccessRule);
directoryInfo.SetAccessControl(directorySecurity);
}

我发现页面的行为非常奇怪。我仍然收到错误,但有时某些文件会被 ffmpeg.exe 文件转换。

有人可以帮我吗?

非常感谢。

解决方案:

看来问题是我在本地存储中运行了 .exe 文件,因此出现了给定的安全问题。将 .exe 放入应用程序并直接引用解决了我的问题。

感谢您的帮助。

最佳答案

默认情况下,您的辅助角色很可能无法以足够的权限运行以允许更改 Azure 文件夹上的访问控制列表。

有两种可能的选择:

<WebRole name="WebApplication2">
<Runtime executionContext="elevated" />
<Sites>

但是,我真的不建议这样做,因为对于在公共(public)云中运行的东西来说这是一个可怕的安全漏洞。

关于azure - Windows Azure 异常 : "Access to the path XYZ.exe is denied.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7568380/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com