certificates: add support for finding certificates on dual boot devices

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2022-04-20 12:08:30 +02:00
parent dfeddc0d89
commit 1ab99d50b2

View File

@@ -2,6 +2,17 @@
START=80
copy_certificates() {
[ -f /certificates/dev-id ] || return
cp /certificates/*.pem /etc/ucentral/
cp /certificates/dev-id /etc/ucentral/
chown root.network /etc/ucentral/*.pem
chmod 0440 root.network /etc/ucentral/*.pem
chmod 0400 /etc/ucentral/dev-id
exit 0
}
boot() {
[ -f /etc/ucentral/dev-id ] && return
. /lib/functions.sh
@@ -17,11 +28,41 @@ boot() {
[ -e /dev/ubi1 ] && mount -t ubifs ubi1:certificates /certificates
fi
fi
[ -f /certificates/dev-id ] && {
cp /certificates/*.pem /etc/ucentral/
cp /certificates/dev-id /etc/ucentral/
chown root.network /etc/ucentral/*.pem
chmod 0440 root.network /etc/ucentral/*.pem
chmod 0400 /etc/ucentral/dev-id
}
copy_certificates
# if we get here no valid certificates were found
. /lib/functions.sh
local PART_NAME
case "$(board_name)" in
actiontec,web7200)
if grep -q bootselect=0 /proc/cmdline; then
PART_NAME=firmware2
else
PART_NAME=firmware1
fi
;;
edgecore,ecw5211|\
edgecore,eap101|\
edgecore,eap102)
if grep -q rootfs1 /proc/cmdline; then
PART_NAME=rootfs2
else
PART_NAME=rootfs1
fi
;;
*)
return 1
;;
esac
local MTD=$(find_mtd_index $PART_NAME)
[ -z "$MTD" ] && return 1
ubiattach -m $MTD -d 3
[ -e /dev/ubi3 ] && mount -t ubifs ubi3:certificates /certificates
copy_certificates
}