mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-11-02 11:27:48 +00:00
Ensure PKI2.0 certificates are properly backed up when /certificates is mounted as squashfs (read-only). Enhance the persistent storage mechanism to retain PKI2.0 certificates across factory resets. Following the current enrollment behavior, `operational.ca` and `operational.pem` - though restored to `/certificates` after a factory reset - are not directly used during enrollment. The `est_client` will still download both certificates again as part of the enrollment process. This patch does not modify that behavior, but simply ensures the certificates are persistently stored across resets. Impacted models: SonicFi RAP6* series. Signed-off-by: jackcybertan <jack.tsai@cybertan.com.tw>
43 lines
1.0 KiB
Bash
Executable File
43 lines
1.0 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
tar_part_lookup() {
|
|
part="$(fw_printenv -n cert_part)"
|
|
if [ "$part" -eq 0 ]; then
|
|
echo "$2"
|
|
part=1
|
|
else
|
|
echo "$1"
|
|
part=0
|
|
fi
|
|
fw_setenv cert_part $part
|
|
}
|
|
|
|
. /lib/functions.sh
|
|
case "$(board_name)" in
|
|
sonicfi,rap7110c-341x)
|
|
cd /certificates
|
|
tar cf /tmp/certs.tar .
|
|
part=$(tar_part_lookup "0:BOOTCONFIG" "0:BOOTCONFIG1")
|
|
mmc_dev=$(echo $(find_mmc_part $part) | sed 's/^.\{5\}//')
|
|
dd if=/tmp/certs.tar of=/dev/$mmc_dev
|
|
;;
|
|
udaya,a5-id2)
|
|
cd /certificates
|
|
tar cf /tmp/certs.tar .
|
|
part=$(tar_part_lookup "insta1" "insta2")
|
|
mtd=$(find_mtd_index $part)
|
|
dd if=/tmp/certs.tar of=/dev/mtdblock$mtd
|
|
;;
|
|
sonicfi,rap6*)
|
|
if [ "$(fw_printenv -n store_certs_disabled)" != "1" ]; then
|
|
tar cf /tmp/certs.tar -C /certificates .
|
|
bootconfig=$(bootconfig_lookup)
|
|
mtd_dev=$(find_mtd_index $bootconfig)
|
|
block_size=$(cat /sys/class/mtd/mtd$mtd_dev/size)
|
|
dd if=/tmp/certs.tar of=/tmp/certs_pad.tar bs=$block_size conv=sync
|
|
mtd write /tmp/certs_pad.tar /dev/mtd$mtd_dev
|
|
rm -f /tmp/certs.tar /tmp/certs_pad.tar
|
|
fi
|
|
;;
|
|
esac
|