简体   繁体   English

pyinotify文件删除用户

[英]pyinotify file deletion user

I'm trying to use pyinotify to alert me whenever files are deleted, but I want to know what user deleted the files. 每当删除文件时,我都试图使用pyinotify提醒我,但我想知道是什么用户删除了这些文件。 Is there a way to find this information? 有没有找到此信息的方法?

That information isn't exposed by the underlying inotify system. 底层的inotify系统不会公开该信息。 This is the main change notification API for the Linux kernel, so you aren't going to find another notification system that provides this. 这是Linux内核的主要变更通知API,因此您将不会找到提供此功能的另一个通知系统。

If you want to track who deleted the file, it would be easiest to make the deleter announce what it is going to do. 如果要跟踪谁删除了该文件,最简单的方法是让删除程序宣布该文件将要执行的操作。 If you don't have control over the deleter (that is, you still have to maintain a POSIX interface for deleting the file), you could look at writing a custom file system wrapper in FUSE , which might expose the UID of the process that called unlink(). 如果您无法控制删除程序(也就是说,您仍然必须维护POSIX接口来删除文件),则可以考虑在FUSE中编写自定义文件系统包装程序,这可能会公开该进程的UID称为unlink()。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM