From 4f584b4b6c917ea4a8942f04004f64fc98268a61 Mon Sep 17 00:00:00 2001 From: Tobias Mueller Date: Mon, 16 Oct 2023 15:15:29 +0200 Subject: [PATCH] mac-wipe: avoid accumulating mounts If we mount over and over again we may consume memory unnecessarily. --- files/lib/blue-merle/mac-wipe.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/files/lib/blue-merle/mac-wipe.sh b/files/lib/blue-merle/mac-wipe.sh index b32ce58..29a3fba 100644 --- a/files/lib/blue-merle/mac-wipe.sh +++ b/files/lib/blue-merle/mac-wipe.sh @@ -1,6 +1,6 @@ #!/usr/bin/env ash -# This script wipes all MAC address data from the device and is called upon boot +# This script ensures that MAC addresses are stored on volatile memory rather than flash tmpdir="$(mktemp -d)" # We mount a tmpfs so that the client database will be stored in memory only @@ -8,6 +8,8 @@ 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 +# If this script runs multiple times, we accumulate mounts; we try to avoid having mounts over mounts, so we unmount any existing tmpfs +umount -t tmpfs -l /etc/oui-tertf mount -t tmpfs / /etc/oui-tertf cp -a "$tmpdir/client.db" /etc/oui-tertf/client.db