netblue30 / fdns

Firejail DNS-over-HTTPS Proxy Server
GNU General Public License v3.0
115 stars 29 forks source link

stats don't get cleared after shutting down the systemd service #14

Closed glitsj16 closed 6 months ago

glitsj16 commented 4 years ago

Fdns stats in /dev/shm/fdns-stats stay lingering on the system after stopping the systemd service. I suspect this also affects users who don't use the systemd unit. This has two side-effects that I find confusing:

Perhaps this could be improved upon. For now I added an ExecPostStop command to clean it up, but that's not a full alternative. IMHO this should be done by fdns itself.

Side-note: I realize the decision to put the stats into /dev/shm probably has to do with the original plan to integrate fdns into firejail, but rkhunter and the likes frown upon finding files in /dev/shm. Perhaps a small note is welcome that informs the user of what's going on exactly...

startx2017 commented 4 years ago

Fixed in fdns, need to port it to firetools. There is an up to 10s delay until the monitor detects fdns went down.

glitsj16 commented 4 years ago

@startx2017 Thanks for the work on this. The monitor now makes much more sense. But /dev/shm/fdns.stats still stays present after fdns stop (at least on Arch Linux, haven't tested Ubuntu yet). Maybe that's the 'new' intended behaviour? As stated above it can be easily cleaned up in the systemd service via a simple ExecStopPost command. But users that don't use the systemd service will have to take some other action.

netblue30 commented 4 years ago

But /dev/shm/fdns.stats still stays present after fdns stop

If the user does a "sudo pkill fdns" we get a chance to remove the file by intercepting the signal before the process gets killed. However if the kernel decides to kill the process (equivelent to kill -9), the process will just be killed without receiving a signal first.

I'll bring in the signal part, but let's put in ExecStopPost also, is like a best effort.

glitsj16 commented 4 years ago

... let's put in ExecStopPost also, is like a best effort

Done in https://github.com/netblue30/fdns/commit/bd89850302fad7c5b75e339d1f11f0abc403e858. We can adjust the ExecStopPost command later when the signal part is implemented. Although 'rm -f /dev/shm/fdns-stats' does the job for now, it would be cleaner to have something like '/usr/bin/fdns --clear-stats'. Just a thought...