Re: [PATCH] Do not pass exit code through on pipe failure
On Sun, 15 Feb 2009, Kees Cook wrote:
> Since "exit 2" has a special meaning, we must "exit 1" when the
> find/cpio/gzip pipe fails, otherwise "update-initramfs" will potentially
> ignore failures (it ignores return code "2" from mkinitramfs).
>
> Signed-off-by: Kees Cook <kees@debian.org>
thanks, applied.
> ---
> mkinitramfs | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mkinitramfs b/mkinitramfs
> index 2f5112c..d1d46b0 100755
> --- a/mkinitramfs
> +++ b/mkinitramfs
> @@ -268,7 +268,7 @@ fi
> [ "${verbose}" = y ] && echo "Building cpio ${outfile} initramfs"
> (
> # work around lack of "set -o pipefail" for the following pipe:
> -# cd "${DESTDIR}" && find . | cpio --quiet --dereference -o -H newc | gzip >"${outfile}"
> +# cd "${DESTDIR}" && find . | cpio --quiet --dereference -o -H newc | gzip >"${outfile}" || exit 1
> exec 3>&1
> eval `
> # http://cfaj.freeshell.org/shell/cus-faq-2.html
> @@ -284,7 +284,7 @@ eval `
> if [ "$ec1" -ne 0 ]; then exit "$ec1"; fi
> if [ "$ec2" -ne 0 ]; then exit "$ec2"; fi
> if [ "$ec3" -ne 0 ]; then exit "$ec3"; fi
> -) || exit $?
> +) || exit 1
>
> if [ -s "${__TMPCPIOGZ}" ]; then
> cat "${__TMPCPIOGZ}" >>"${outfile}" || exit 1
> --
> 1.6.0.4
>
> --
> Kees Cook @debian.org
--
maks
Reply to: