windows 隔离存储误区
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2437484/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Isolated Storage misunderstanding
提问by Costa
This is a discussion between me and me to understand an Isolated Storageissue. Can you help me to convince me about Isolated Storage?
这是我和我之间的讨论,以了解隔离存储问题。你能帮我说服我关于隔离存储吗?
This is code written for a Windows Forms application (reader) that read the isolated storage of another Windows Forms application (writer) which is signed. Where is the security if the reader can read the writer's file? I thought only signed code can access the file!
这是为 Windows 窗体应用程序(读取器)编写的代码,该应用程序读取另一个已签名的 Windows 窗体应用程序(写入器)的隔离存储。如果读者可以阅读作者的文件,那么安全在哪里?我以为只有签名的代码才能访问该文件!
If all .NET applications are born equal and have all permissions to access Isolated Storage, where is the security then? If I can install and run an EXE file from Isolated Storage, why I don't install a virus and run it, I am trusted to access this area. But the virus or whatever will not be trusted to access the rest of file system, it only can access the memory, and this is dangerous enough.
如果所有 .NET 应用程序生来平等并拥有访问隔离存储的所有权限,那么安全性在哪里?如果我可以从独立存储安装并运行 EXE 文件,为什么我不安装病毒并运行它,我就可以访问该区域。但是病毒或其他任何东西都不会被信任访问文件系统的其余部分,它只能访问内存,这已经足够危险了。
I cannot see any difference between using the application data folder to save the state and using Isolated Storage except a long nasty path!!
我看不出使用应用程序数据文件夹来保存状态和使用隔离存储之间有什么区别,除了一条很长的讨厌的路径!!
I want to try give low trust to reader code and retest, but they said "Isolated storage is actually created for giving low trusted application the right to save its state".
我想尝试对阅读器代码给予低信任并重新测试,但他们说“实际上创建隔离存储是为了给予低信任应用程序保存其状态的权利”。
Reader code:
读者代码:
private void button1_Click(object sender, EventArgs e)
{
String path = @"C:\Documents and Settings\All Users\Application Data\IsolatedStorage\efv5cmbz.ewtehuny0c.qvv\StrongName.5v3airc2lkv0onfrhsm2h3uiio35oarw\AssemFiles\toto12\ABC.txt";
StreamReader reader = new StreamReader(path);
var test = reader.ReadLine();
reader.Close();
}
Writer:
作家:
private void button1_Click(object sender, EventArgs e)
{
IsolatedStorageFile isolatedFile = IsolatedStorageFile.GetMachineStoreForAssembly();
isolatedFile.CreateDirectory("toto12");
IsolatedStorageFileStream isolatedStorage = new IsolatedStorageFileStream(@"toto12\ABC.txt", System.IO.FileMode.Create, isolatedFile);
StreamWriter writer = new StreamWriter(isolatedStorage);
writer.WriteLine("Ana 2akol we ashrab kai a3eesh wa akbora");
writer.Close();
writer.Dispose();
}
采纳答案by slugster
Of course you can reach any (known) location on the hard drive using your reader code, assuming that you have adequate permissions to access that location.
当然,您可以使用阅读器代码访问硬盘驱动器上的任何(已知)位置,前提是您有足够的权限访问该位置。
There are no special permissions applied to the IsolatedStorage area, but there are rules that apply to the low trust applications that use IsolatedStorage how it was intended to be used. There is absolutely nothing to prevent you from encrypting what you store there if you want to keep it private.
没有应用到IsolatedStorage 区域的特殊权限,但是有一些规则适用于使用IsolatedStorage 的低信任应用程序的用途。如果您想将其保密,绝对没有什么可以阻止您对存储在那里的内容进行加密。
Edit:check out CLR Inside Out - Isolated Storage In Silverlight 2and Silverlight out-of-browser apps: Local Data Store.
编辑:查看CLR Inside Out - Silverlight 2 中的独立存储和Silverlight 浏览器外应用程序:本地数据存储。
回答by Conrad Albrecht
I agree about your "misunderstand" in the title; I think you're misunderstanding the purpose of isolated storage.
我同意你在标题中的“误解”;我认为您误解了隔离存储的目的。
As I understand it the "isolated" does notmean "private storage that other programs can't access". It means a "sandbox" to give your low-trust program a place where it can save data when it might not have permission to write to somewhere else.
据我了解了“隔离”并不能意味着“私人存储的其他程序无法访问”。这意味着一个“沙箱”,为您的低信任程序提供一个可以在它可能无权写入其他地方时保存数据的地方。