linsomniac / drbdlinks

A helper for DRBD which makes/reverts links into DRBD volumes.
GNU General Public License v2.0
8 stars 5 forks source link

drbdlinks doesn't claim if managed symlink is a file (rather a symlink) #7

Open robert-scheck opened 6 years ago

robert-scheck commented 6 years ago

If my /etc/drbdlinks.conf contains

mountpoint('/drbd')
link('/etc/crontab')

unfortunately drbdlinks status still says

$ drbdlinks status
info: DRBD Links OK (present)
$ 

even if it looks like this

$ ls -l /etc/crontab /drbd/etc/crontab
-rw-r--r--. 1 root root 1699 Apr  9 08:10 /etc/crontab
-rw-r--r--. 1 root root 1751 Apr  9 08:04 /drbd/etc/crontab
$ 

while it should be

$ ls -l /etc/crontab /drbd/etc/crontab
lrwxrwxrwx. 1 root root   24 Apr 17 10:09 /etc/crontab -> /drbd/etc/crontab
-rw-r--r--. 1 root root 1751 Apr  9 08:04 /drbd/etc/crontab
$ 

In this case, something dereferenced /etc/crontab symlink outside of drbdlinks by accident, but drbdlinks does not detect this scenario (unfortunately). Note, this also could happen for a directory, so the check likely should be if managed symlink is really a symlink.

linsomniac commented 5 years ago

I don't really have a way currently to fix this. I agree it should be fixed, but I think it's going to need some refactoring to get there so I'm going to defer it. It gets complicated by bind mounts.

robert-scheck commented 5 years ago

Oh, bind mounts! I didn't think about these…

linsomniac commented 5 years ago

I'm imagining something that takes the config and the state (started or stopped) and generates a list of the desired state ("/etc/crontab is a symlink to ...", "/etc/cron.d/batchjobs is a bindmount to ..."), and then the start/stop/status could go through and make the system look like the desired state.

That seems like a cleaner way to do it, but not something I can do today. But I also admit I may have just been using Ansible too long. :-)