Update (2011-04-22): Zach let me know in the meantime that there's a much easier way to implement stickfile in BASH:
And now to the original post:
My employer uses SonicWALL NetExtender for his VPN needs. Saying that I'm not a fan of IPsec would be definitely an understatement, but my major problem is that NetExtender overwrites my resolv.conf upon every connection which screws the hostname resolution on my LAN from my laptop. chmoding or chowning resolv.conf doesn't help because it gets re-chowned and re-chmoded by NetExtender.
I was thinking about overwriting resolv.conf on a regular basis from a script but it seemed rather inelegant. But how should I do it otherwise? With inotify, of course.
Here's the script I've written which you should save as "stickfile" to a directory that is featured in your $PATH.
After I created a valid resolv.conf and saved it as /etc/resolv.conf.orig I only had to execute the following as root before starting up NetExtender:
stickfile /etc/resolv.conf.orig /etc/resolv.conf