可以锁定目录,以便只有单个应用程序域可以访问它
是否可以锁定 Windows 和 Linux 上的目录(用于单声道访问),只有单个应用程序/用户可以访问它?
我需要将加密的 XML 消息写入目录,但不希望任何人删除它们。我怀疑在 Linux 上使用 Mono 会更容易。
如果可能的话,您将使用哪些类来检查以确保在开始写入之前它已被锁定。
谢谢。
Is it possible to lock down a directory in windows and on linux (for mono access) where only a single application/user can get access to it?
I need to write encrypted XML messages into a directory but don't want anybody deleting them. I suspect it would be easier using Mono on linux.
If it's possible, what are the classes you would use, to check to ensure it is locked down before you started writing to it.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您的目录位于 NTFS 文件系统上,您可以按照概述使用 NTFS 此处,或来自 Mono 的本机系统调用,如所述 此处。棘手的一点是每个 AppDomain 中的代码都需要以其自己的用户身份运行。
我认为使用文件系统支持的任何权限系统锁定父目录会更简单,这样用户就无法手动删除这些文件,但应用程序的用户可以创建和读取它们,然后确保程序逻辑执行不允许 AppDomain 侵犯他人的文件。
如果您只是寻求同步(意味着您不希望多个线程同时访问相同的文件),您可以使用中央注册表(数据库表或其他一些事务存储)来跟踪谁正在写什么。
Assuming your directories are on an NTFS filesystem, you could use NTFS as outlined here, or native syscall from Mono as outlined here. The tricky bit would be that code in each AppDomain would need to be running as it's own user.
I'd think it would be simpler to lock down the parent directory using whatever permissioning system is supported by your filesystem so that users cannot manually delete these files, but the application's user can create and read them, and then ensure that the program logic does not allow for an AppDomain to step on another's files.
If you are just looking for synchronization (meaning that you don't want multiple threads accessing the same files at the same time), you could just use a central registry (a database table, or some other transactional store) to keep track of who is writing to what.