It gets generated on the fly by the web GUI, and the init script spaghetti.
That is why I said you will need to have some kind of user-init that runs last, that cleans house and sets everything right. That way your secrets file and pals are always what YOU want them to be.
WD made this device very difficult to properly administer. They went out of their way to make it that way, needlessly. (If what I am seeing from Fox_exe’s work is true, there is precisely ZERO reason for this huge ramdisk based root filesystem bologna, other than to hamfistedly try to enforce system policies on users. It apparently boots just fine with a real root filesystem, when you decide to screw the warranty coverage and take matters into your own hands.)
(sarcasm) The reason the files get created from scratch every time is because of the ramdisk based root filesystem. They did not feel that the secrets file, the allowed hosts, etc— needed to be modified by end users, so persistence was not necessary. After all, this is a consumer device, what are you doing trying to do real administrator type things with it, like doing scheduled rsync with a remote host? You are supposed to use this thing to watch all those movie files from! (that’s why it prioritizes their ■■■■■■■■ media scanner daemon!) (/sarcasm)
I wont bother trying to defend their bull on this, because it is indefensible in my opinion. Instead, I will just point out that you need some kind of user init script. If you dont mind voiding your warranty, you can use Fox_exe’s wdcrack package. It works great for that.
There are other things, like hijacking the config.xml, which you already mentioned, to add a cron job. One thing you could do would be to have the cron job md5 the files in question, and if the hash return is the same as the stock generic’s, it fires off the replacement process, otherwise does nothing.
How you would choose to go about that scripted replacement is entirely up to you, just that is what you will need to do.
(Changing the GUI so that it does not bootstomp your changes all the time is a wasted effort; WD made sure that they are in a read only cramfs container, so you cant just fix their stuff to not be arrogant without fully repackaging the container, etc. Like I said, they went out of their way to make it hard to actually administer.)