From 6736b550f112f14c17401329a6a2a63ddc53e68b Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sun, 17 Jan 2016 15:50:32 -0500 Subject: cmd/*: Check return value of session_begin() Also clean up on error now. --- (limited to 'src') diff --git a/src/cmd/build.sh b/src/cmd/build.sh index a366a01..1d0ad52 100644 --- a/src/cmd/build.sh +++ b/src/cmd/build.sh @@ -88,7 +88,12 @@ cmd_build_main() fi package_set_substvars "${arch}" "${plat}" - session_begin "${root}" "${cmd_build_pkg_dir}" cmd_build_fini false + if ! session_begin "${root}" "${cmd_build_pkg_dir}" cmd_build_fini false + then + cmd_build_fini + [ "x${dev}" != 'x' ] && block_umount "${root}" + return 2 + fi cmd_build_build_deps="$(package_get_build_deps "${arch}" "${plat}")" if [ "x${cmd_build_build_deps}" != 'x' ]; then diff --git a/src/cmd/installer-pc.sh b/src/cmd/installer-pc.sh index a96a7cf..348838e 100644 --- a/src/cmd/installer-pc.sh +++ b/src/cmd/installer-pc.sh @@ -86,7 +86,10 @@ cmd_installer_pc_main() EOF # This ln command won't be needed once lilo 24.1-1 is uploaded. ln "${root}/boot/vmlinuz" "${root}/boot/vmlinuz.old" - session_begin "${root}" . : false + if ! session_begin "${root}" . : false + block_umount "${root}" + return 2 + fi session_exec install-lilo \ "${dev}" "PARTUUID=${b1}${b2}${b3}${b4}-01" session_end diff --git a/src/cmd/opkg.sh b/src/cmd/opkg.sh index e6a304f..b99a977 100644 --- a/src/cmd/opkg.sh +++ b/src/cmd/opkg.sh @@ -85,7 +85,11 @@ cmd_opkg_main() return 2 fi - session_begin "${root}" . cmd_opkg_fini false + if ! session_begin "${root}" . cmd_opkg_fini false; then + cmd_opkg_fini + [ "x${dev}" != 'x' ] && block_umount "${root}" + return 2 + fi session_exec opkg "${@}" diff --git a/src/cmd/shell.sh b/src/cmd/shell.sh index 314b79b..8d5cd16 100644 --- a/src/cmd/shell.sh +++ b/src/cmd/shell.sh @@ -44,7 +44,10 @@ cmd_shell_main() return 2 fi - session_begin "${root}" . : false + if ! session_begin "${root}" . : false; then + [ "x${dev}" != 'x' ] && block_umount "${root}" + return 2 + fi if [ ${#} -eq 0 ]; then session_exec /bin/sh printf '\n' -- cgit v0.9.1