In /etc/init.d/rcS there is this scriptlet:
Code:
any_usb=`sg_map -x -i|grep -v " 0 0 0 0"|grep -v " 1 0 0 0"|awk '{print $7}'`
echo "${any_usb}"
if [ -n "${any_usb}" ]; then
for usb in ${any_usb}
do
mount "${usb}"1 /mnt
/sbin/check_key /mnt/nsa220_check_file
if [ $? == 0 ] ; then
/mnt/usb_key_func.sh
test $? -eq 0 && exit 0
fi
umount /mnt
done
fi
When /sbin/check_key returns 0, the script usb_key_func.sh on the root of an usb stick is executed on boot. I downloaded the sources on
ftp://opensource.zyxel.com (btw, the mirror on
http://gpl.nas-central.org/ZYXEL/NSA220_GPL/ seems to be corrupt) to find out what check_key does. Unfortunately the only reference I could find is in nsa220build/nsa220/Makefile:
Code:
# Makefile for NSA-220
# system tools
CP=/bin/cp -rfl
RM=/bin/rm
FIND=/usr/bin/find
MKDIR=mkdir
MODEL=NSA220
# toolchain path
export PATH=/opt/montavista/pro/devkit/arm/v5t_le/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:${HOME}/bin
export CROSS=arm_v5t_le-
export CROSS_CC=${CROSS}gcc
export CROSS_CXX=${CROSS}cpp
export CROSS_AR=${CROSS}ar
export CROSS_LD=${CROSS}ld
export CROSS_RANLIB=${CROSS}ranlib
export CROSS_STRIP=${CROSS}strip
export HOST_CC=gcc
# for configure --build=$PLATFORM_BUILD --host=$PLATFORM_HOST
export PLATFORM_BUILD=i386-linux
export PLATFORM_HOST=arm-linux
export PLATFORM_TARGET=arm-linux
export PLATFORM_PREFIX=/opt/montavista/pro/devkit/arm/v5t_le/target
# path for build
export PRODUCT_ROOT=${PWD}
export SYSAPPS_PATH=${PRODUCT_ROOT}/sysapps
export DEST_PATH=${PRODUCT_ROOT}/build/apptarget
export RAS_PATH=${PRODUCT_ROOT}/build/fs
# the kernel from MontaVista. Some special header files and definitions are here.
export MV_KERNEL_PATH=/opt/montavista/pro/devkit/lsp/arm-versatile926ejs-arm_v5t_le/linux-2.6.10_mv1401
# the kernel for system
kversion=2.6.18.6
ifeq ($(kernel), 2.6.12)
kversion=2.6.12.6-1.10.3
else
kernel=2.6.18
endif
export KERNEL_PATH=${PRODUCT_ROOT}/linux-${kversion}
# specify root file system
# Allowable value: ext2, squash
rfs=squash
ifeq ($(rootfs), ext2)
rfs=ext2
endif
# native target path which contains a native environment
export TARGET_PATH=/opt/montavista/pro/devkit/arm/v5t_le/target
.PHONY: help
help:
@echo "make - Thi help menu."
@echo ""
@echo "make all - Build everything and create RAS image file."
@echo ""
@echo "make world [kernel=] - Build everything."
@echo ""
# @echo "make clean - Clean all object files; this is not available now."
# @echo ""
@echo "make buildkernel [kernel=] - Build kernel image."
@echo ""
@echo "make <package> - Build the package."
@echo " package list : busybox samba zysh nduagent uam fauthd mlogin ntpdate"
@echo " syslog-ng libzyboot"
@echo " zysh-cgi file_export file_upload file_download"
@echo " htp lm-sensors btnd backdoor mtd-util check_key"
@echo ""
@echo "make ras [kernel=] [rootfs=] - Create RAS image file."
@echo " Make sure you already make world."
@echo ""
@echo "[kernel=] : "
@echo " to specify kernel version, by using kernel=kernel_version, "
@echo " default is 2.6.18, allowable value are 2.6.18, 2.6.12"
@echo " e.g."
@echo " make buildkernel kernel=2.6.12, build kernel 2.6.12.6-1.10.3"
@echo " make ras , build kernel 2.6.18.6"
@echo "[rootfs=]: "
@echo " to specify root file system type"
@echo " default is squash, allowable value are squash, ext2"
@echo " e.g."
@echo " make ras rootfs=ext2 to make EXT2 root file system"
@echo "Some environment variables:"
@echo " CROSS_CC=${CROSS_CC}"
@echo " DEST_PATH=${DEST_PATH}"
@echo " RAS_PATH=${RAS_PATH}"
world: prebuild buildkernel busybox dev
@echo "==> The end of the world!"
clean: kernel.clean busybox.clean
prebuild:
@echo "==> $@"
${MKDIR} -p ${RAS_PATH}
${RM} -rf ${RAS_PATH}/*
${CP} --preserve=all ${PRODUCT_ROOT}/basicfs/* ${RAS_PATH}
${CP} --preserve=all ${PRODUCT_ROOT}/basicfs/.mtoolsrc ${RAS_PATH}
${FIND} ${RAS_PATH} -name .svn | xargs rm -rf
chmod 777 ${RAS_PATH}/tmp
chmod 777 ${RAS_PATH}/tmp/users/home
chmod 777 ${RAS_PATH}/tmp/users/shares
@echo "==> Clear tmporary build dir"
${RM} -rf ${DEST_PATH}/bin/*
${RM} -rf ${DEST_PATH}/sbin/*
${RM} -rf ${DEST_PATH}/usr/bin/*
${RM} -rf ${DEST_PATH}/usr/sbin/*
${RM} -rf ${DEST_PATH}/lib/*
${RM} -rf ${DEST_PATH}/usr/lib/*
${RM} -rf ${DEST_PATH}/usr/include/*
${RM} -rf ${DEST_PATH}/util/*
${RM} -rf ${DEST_PATH}/root/*
ras:
@echo "==> $@"
${RM} -rf ${RAS_PATH}/lib/modules
${RM} -rf ${RAS_PATH}/lib/modules_kernel_2.6.12
ifeq ($(kernel), 2.6.12)
${CP} --preserve=all ${PRODUCT_ROOT}/basicfs/lib/modules_kernel_2.6.12 ${RAS_PATH}/lib/modules
else
${CP} --preserve=all ${PRODUCT_ROOT}/basicfs/lib/modules ${RAS_PATH}/lib/modules
endif
${FIND} ${RAS_PATH} -name .svn | xargs rm -rf
cd build ; ./makeras.sh -k ${kernel} -f ${rfs} -b "${beta_ver}" -c "${fcs_ver}"
buildkernel:
@echo "==> $@, Kernel version is ${kernel}"
make -C ${KERNEL_PATH} zImage
${CP} --remove-destination ${KERNEL_PATH}/arch/arm/boot/zImage ${PRODUCT_ROOT}/build
all: world ras
@echo "==> The end of the all!"
kernel.clean:
@echo "==> $@"
make -C ${KERNEL_PATH} clean
busybox:
@echo "==> $@"
cd ${SYSAPPS_PATH}/busybox-1.1.1 ; make install
chmod +s ${RAS_PATH}/bin/busybox
busybox.clean:
@echo "==> $@"
cd ${SYSAPPS_PATH}/busybox-1.1.1 ; make clean
# DO NOT make distclean
dev:
@echo "==> $@"
./makedev.sh
In section help is mentioned that you can 'make check_key'. Can anybody tell me what this file does when you run 'make check_key'?
Another possibly related thing I found: In nsa220build/nsa220/build/zytools/USB_KEY there is a tree:
nsa220_check_file
nsa220/function/usb_key_func.sh
nsa220/function/run_htp_external
nsa220/upgrade/usb_key_func.sh
nsa220/upgrade/ras.bin
nsa220/upgrade/Upgrade
the contents of nsa220_check_file:
Code:
/mnt/nsa220/upgrade/usb_key_func.sh
/mnt/nsa220/upgrade/ras.bin
/mnt/nsa220/upgrade/Upgrade
The contents of Upgrade and run_htp_external looks like an MD5 checksum, but if so I couldn't find out from what. ras.bin seems to be a complete firmware binary (15MB).