virtualmin / virtualmin-gpl

Virtualmin web hosting control panel for Webmin
https://www.virtualmin.com
GNU General Public License v3.0
331 stars 102 forks source link

Feature Request. Status Monitor, File Monitor, check permissions of file(s) #92

Open micoots opened 5 years ago

micoots commented 5 years ago

Hi. For some reason file permissions keep changing on a file.

I'd like to have the Webmin Status Module, File Monitor updated to check for file permissions, and if changed, I can then trigger a script to chown them back.

I'm using Virtualmin GPL on those machines where I have this problem.

iliajie commented 5 years ago

Hi,

What are you trying to achieve? (be more specific)

What file exactly is getting changed in unattended way? It could represent underlying issues.

micoots commented 5 years ago

Hi. yes, I've spoken to Jamie directly about this some time ago and I believe he may have already have it on his to-do list. We trouble-shooted it for a while and it is unrelated to Webmin, Virtualmin.

There's something that changes the permissions on my file:

/var/run/named/stats

from named:named to root:root, which causes the Bind stats to be lost until I manually change it back.

I've tried to track this down but don't have too much time to spend on finding the root cause (maybe it's logrotate), so I'd rather have this workaround by getting Webmin status module to check for permissions, if changed, change it back to named:named and notify me via email.

At least then I can see a regular time when it happens, and can try and correlate that to anything doing it.

iliajie commented 5 years ago

It seems like the file is getting deleted and then recreated by some process running as root.

In case of logrotate , you can check its configuration. There is an option to keep permissions.

iliajie commented 5 years ago

This might help as well.

https://superuser.com/questions/181517/how-to-execute-a-command-whenever-a-file-changes

jcameron commented 5 years ago

There is a monitor type in the System and Server Status module that can check file permissions (and run a command if wrong)

micoots commented 5 years ago

Excellent, I didn't know this was already implemented.

I found the module called "File or Directory Change" and have set the monitor. Will hopefully see the results soon. Thank you kindly Jamie.