mac-wipe: copy existing database into a volatile memory

rather than deleting everything.
It seems that the device stops working when deleting the database. That
is, the connection to the Internet stops working which is very safe as
it does not leak any data but arguably defeats the purpose of the
device.
This commit is contained in:
Tobias Mueller 2023-10-16 14:51:59 +02:00
parent 6137fc0ea7
commit 4beae781a2
1 changed files with 9 additions and 2 deletions

View File

@ -2,10 +2,17 @@
# This script wipes all MAC address data from the device and is called upon boot
/etc/init.d/gl-tertf stop
shred /etc/oui-tertf/client.db || rm -f /etc/oui-tertf/client.db
tmpdir="$(mktemp -d)"
# We mount a tmpfs so that the client database will be stored in memory only
mount -t tmpfs / "$tmpdir"
/etc/init.d/gl-tertf stop
cp -a /etc/oui-tertf/client.db "$tmpdir"
shred /etc/oui-tertf/client.db || rm -f /etc/oui-tertf/client.db
mount -t tmpfs / /etc/oui-tertf
cp -a "$tmpdir/client.db" /etc/oui-tertf/client.db
umount -t tmpfs -l "$tmpdir"
logger -p notice -t blue-merle-mac-wipe "Restarting tertf..."
/etc/init.d/gl-tertf start
logger -p notice -t blue-merle-mac-wipe "... Finished"