Search code examples
clinuxinode

Determine UID that last modified a file in Linux?


I'm writing a program that will be monitoring select files and directories for changes. Some of the files are world writeable, some owner, some group.

What I need to do is be able to figure out the last person to modify (not just access) a file. Somehow I thought this would be simple, given that we know the inode of the file .. however I can not seem to find any way of obtaining this. I thought there was a practical way of correlating any given inode to the uid last accessing it.

I think I've squeezed google for all its going to give me on the topic.

Any help is appreciated. I'm writing the program in C.

Edit:

I need to be able to do this after the PID of whatever program modified the file is long gone.


Solution

  • If you are on a 2.6 kernel, you can take advantage of kernel's auditd daemon. Check this URL out. It might give you some hint on how to accomplish what you are trying to. I'm sure there is an API you could use in C.