balena-os / takeover

Migrate arbitrary devices to balena
12 stars 8 forks source link

Make and use copy of `telinit` if symliked to `init` #58

Closed lmbarros closed 7 months ago

lmbarros commented 8 months ago

At the end of stage1, we bind-mount takeover on top of init, and then call telinit u. Unfortunately, in some distributions (like Devuan) telinit is a symlink to init. In this case, we lose access to telinit, because the symlink now points to what is effectively takeover.

With this commit, we check if telinit is a symlink to init, and if so, we make a safe copy of telinit so that we can call it after the bind-mounting takes place.

Testing

Tried simple migrations from

to a fleet of device type raspberrypi3-64, on a Raspberry Pi 3 Model B+.

Checked the logs to confirm that the safety copy was made only for Devuan.

All migrations succeeded.