You are not logged in.
I have a configuration file on my server for a program that runs on Windows desktops. For some reason, the permissions on that file keep getting changed, and it isn't being done manually by anyone. I'm not sure why this is happening, and it seems to happen at random intervals.
Is there a way to monitor when the permissions on this file get changed?
Last edited by timm (2009-04-03 19:47:00)
Offline
while sleep 1; do echo $(date) $(ls -l FILENAME); done > logfile.txt
Like this? Maybe make it sleep longer. If you want more specific data I think it's only worth it to run sed/awk on it only when you want to see the data, because putting it in here will either run those programs a lot or all the time, which isn't very nice.
Offline
Install inotify-tools from the AUR (Any TU's reading this thread who want another package? Someone should bring that to [community]).
Then run something like:
inotifywait -m -e attrib /that/file/that/is/changing ; echo "omg it changed"
Unless you want to use the C API and write your own app.. but I feel like that's not what you want.
Offline
A couple questions: Is there any way to get the inotify output to be used to change the permissions back? It would seem I might be able to run a script using inotify at startup so that when the permissions get changed, they get changed back either immediately or on some set schedule. Is a cron job the right tool for this?
And you're right; I have no idea what an API even is.
Offline
I don't think it should be in crontab, if I understand codemac's example right, it will sleep until the attributes change, and then echo.
So if you want a constant monitor, wrap it around a while, and change the permissions right after the inotify command.
So
while true; do
inotifywait -m -e attrib /that/file/that/is/changing
chmod 644 /that/file/that/is/changing
done
Offline
http://fileschanged.sourceforge.net/
fileschanged is a GNU/Linux command-line utility that reports when files have been altered.
You'll need either fam or gamin installed to use this. I was gonna write a similar program myself. It'll most likely be better than having an infinitely look in a script or having crontab calling a script every second.
Offline
And script might as well be just `chmod 644 /path/file` who cares if it already is 644.
Offline
I tried automating the process using a couple of the ideas above, but while it seemed to work, the windows program that is served with this data started spewing all kinds of errors about various problems with the file. I'm going back to fixing this manually for now. It should work automatically, but for some reason it doesn't, and I'm wondering if it is because the file gets changed from r to rw at some point when the windows program is expecting something else.
Offline