summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2016-01-17 15:50:32 (EST)
committer P. J. McDermott <pj@pehjota.net>2016-01-17 15:50:32 (EST)
commit6736b550f112f14c17401329a6a2a63ddc53e68b (patch)
tree68e54ba4a7879189faaf3756cdd56c444eeb0b7d
parent9add17a7f4a24fe04a7a93782e51ce710d7e371e (diff)
cmd/*: Check return value of session_begin()
Also clean up on error now.
-rw-r--r--src/cmd/build.sh7
-rw-r--r--src/cmd/installer-pc.sh5
-rw-r--r--src/cmd/opkg.sh6
-rw-r--r--src/cmd/shell.sh5
4 files changed, 19 insertions, 4 deletions
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'