[Touch-packages] [Bug 1641832] Re: Bash ignores exit trap on success when part of a command string

2016-11-16 Thread Launchpad Bug Tracker
This bug was fixed in the package bash - 4.4-2ubuntu1

---
bash (4.4-2ubuntu1) zesty; urgency=medium

  * Merge with Debian; remaining changes:
- skel.bashrc:
  - Run lesspipe.
  - Enable ls aliases.
  - Set options in ll alias to -alF.
  - Define an alert alias.
  - Enabled colored grep aliases.
- etc.bash.bashrc:
  - Add sudo hint.

bash (4.4-2) unstable; urgency=medium

  * Apply upstream patches 001 - 005.
- Closes: #844299, LP: #1641832.
  * Don't build with PIE. Closes: #842037.

 -- Matthias Klose   Tue, 15 Nov 2016 20:06:17 +0100

** Changed in: bash (Ubuntu)
   Status: Triaged => Fix Released

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to bash in Ubuntu.
https://bugs.launchpad.net/bugs/1641832

Title:
  Bash ignores exit trap on success when part of a command string

Status in bash package in Ubuntu:
  Fix Released

Bug description:
  The MAAS team uses a script, lp:maas-images, which generates the
  images available at images.maas.io. As part of this process we use the
  following to convert a SquashFS image to an ext4 image.

  sudo bash -ec 'src="$1"; img="$2"; trgmp="$3";
  mounts=""
  cleanup() { for m in $mounts; do umount "$m"; done; }
  trap cleanup EXIT
  mount -o loop "$img" "$trgmp"
  mounts="$trgmp"
  unsquashfs -force -xattrs -dest "$trgmp" "$src"' \
  "squashimg-to-image" "$squashimg" "$output" "$trgmp"
  ret=$?
  rm -Rf "$mtmp" || return
  return $ret

  Prior to 4.4-1ubuntu1 the trap would always cause the cleanup function
  to always be called. Its now only called on failure. This causes the
  mount to remain and the following rm to fail. If I add 'false' to the
  end of the command script or downgrade to 4.3-15ubuntu1 the cleanup
  occurs.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1641832/+subscriptions

-- 
Mailing list: https://launchpad.net/~touch-packages
Post to : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp


[Touch-packages] [Bug 1641832] Re: Bash ignores exit trap on success when part of a command string

2016-11-15 Thread Lee Trager
I'm having trouble coming up with a simpler test case myself. Here is
how you can reproduce with lp:maas-images on Zesty with
bash-4.4-1ubuntu1

mkdir maas-images
cd maas-images
bzr init
bzr branch lp:maas-images
cd
export PATH=/home/ubuntu/maas-images/trunk/bin:$PATH
wget 
http://cloud-images.ubuntu.com/daily/server/zesty/2016/zesty-server-cloudimg-amd64.squashfs
meph2-build --image-format squashfs-image -vv --enable-di amd64 zesty 2016 
zesty-server-cloudimg-amd64.squashfs out.d

If you execute that with 4.4-1ubuntu1 it fails due to the loop back
mount still being mounted(mount | grep maas). If you downgrade to
4.3-15ubuntu1 or use the patch from lp:~ltrager/maas-
images/workaround_lp1641832 umount is called and the script executes
successfully.

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to bash in Ubuntu.
https://bugs.launchpad.net/bugs/1641832

Title:
  Bash ignores exit trap on success when part of a command string

Status in bash package in Ubuntu:
  Triaged

Bug description:
  The MAAS team uses a script, lp:maas-images, which generates the
  images available at images.maas.io. As part of this process we use the
  following to convert a SquashFS image to an ext4 image.

  sudo bash -ec 'src="$1"; img="$2"; trgmp="$3";
  mounts=""
  cleanup() { for m in $mounts; do umount "$m"; done; }
  trap cleanup EXIT
  mount -o loop "$img" "$trgmp"
  mounts="$trgmp"
  unsquashfs -force -xattrs -dest "$trgmp" "$src"' \
  "squashimg-to-image" "$squashimg" "$output" "$trgmp"
  ret=$?
  rm -Rf "$mtmp" || return
  return $ret

  Prior to 4.4-1ubuntu1 the trap would always cause the cleanup function
  to always be called. Its now only called on failure. This causes the
  mount to remain and the following rm to fail. If I add 'false' to the
  end of the command script or downgrade to 4.3-15ubuntu1 the cleanup
  occurs.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1641832/+subscriptions

-- 
Mailing list: https://launchpad.net/~touch-packages
Post to : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp


[Touch-packages] [Bug 1641832] Re: Bash ignores exit trap on success when part of a command string

2016-11-15 Thread Steve Langasek
The following seems like it should be a non-destructive reproducer case
for the bug, based tightly on the original example, but it also doesn't
let me reproduce the problem - the 'cleanup' trap definitely still
triggers.

$ sudo bash -ec 'src="$1"; img="$2"; trgmp="$3";
mounts=""
cleanup() { for m in $mounts; do echo umount "$m"; done; }
trap cleanup EXIT
echo mount -o loop "$img" "$trgmp"
mounts="$trgmp"
echo unsquashfs -force -xattrs -dest "$trgmp" "$src"' 
"squashimg-to-image" foo bar baz
mount -o loop bar baz
unsquashfs -force -xattrs -dest baz foo
umount baz
$

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to bash in Ubuntu.
https://bugs.launchpad.net/bugs/1641832

Title:
  Bash ignores exit trap on success when part of a command string

Status in bash package in Ubuntu:
  Triaged

Bug description:
  The MAAS team uses a script, lp:maas-images, which generates the
  images available at images.maas.io. As part of this process we use the
  following to convert a SquashFS image to an ext4 image.

  sudo bash -ec 'src="$1"; img="$2"; trgmp="$3";
  mounts=""
  cleanup() { for m in $mounts; do umount "$m"; done; }
  trap cleanup EXIT
  mount -o loop "$img" "$trgmp"
  mounts="$trgmp"
  unsquashfs -force -xattrs -dest "$trgmp" "$src"' \
  "squashimg-to-image" "$squashimg" "$output" "$trgmp"
  ret=$?
  rm -Rf "$mtmp" || return
  return $ret

  Prior to 4.4-1ubuntu1 the trap would always cause the cleanup function
  to always be called. Its now only called on failure. This causes the
  mount to remain and the following rm to fail. If I add 'false' to the
  end of the command script or downgrade to 4.3-15ubuntu1 the cleanup
  occurs.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1641832/+subscriptions

-- 
Mailing list: https://launchpad.net/~touch-packages
Post to : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp


[Touch-packages] [Bug 1641832] Re: Bash ignores exit trap on success when part of a command string

2016-11-15 Thread Steve Langasek
Can someone show a minimal test case for this bug?  The following
command works as expected under either 4.3 or 4.4:

$ bash -ec 'cleanup() { echo foo; }; trap cleanup EXIT; echo bar'
bar
foo
$

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to bash in Ubuntu.
https://bugs.launchpad.net/bugs/1641832

Title:
  Bash ignores exit trap on success when part of a command string

Status in bash package in Ubuntu:
  Triaged

Bug description:
  The MAAS team uses a script, lp:maas-images, which generates the
  images available at images.maas.io. As part of this process we use the
  following to convert a SquashFS image to an ext4 image.

  sudo bash -ec 'src="$1"; img="$2"; trgmp="$3";
  mounts=""
  cleanup() { for m in $mounts; do umount "$m"; done; }
  trap cleanup EXIT
  mount -o loop "$img" "$trgmp"
  mounts="$trgmp"
  unsquashfs -force -xattrs -dest "$trgmp" "$src"' \
  "squashimg-to-image" "$squashimg" "$output" "$trgmp"
  ret=$?
  rm -Rf "$mtmp" || return
  return $ret

  Prior to 4.4-1ubuntu1 the trap would always cause the cleanup function
  to always be called. Its now only called on failure. This causes the
  mount to remain and the following rm to fail. If I add 'false' to the
  end of the command script or downgrade to 4.3-15ubuntu1 the cleanup
  occurs.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1641832/+subscriptions

-- 
Mailing list: https://launchpad.net/~touch-packages
Post to : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp


[Touch-packages] [Bug 1641832] Re: Bash ignores exit trap on success when part of a command string

2016-11-15 Thread Steve Langasek
Per 
the expected behavior is that an 'EXIT' trap is called at exit from the
shell regardless of circumstances.  This appears to be a regression in
bash.

Matthias, can you follow this up, please?

** Changed in: bash (Ubuntu)
   Importance: Undecided => Critical

** Changed in: bash (Ubuntu)
   Status: New => Triaged

** Changed in: bash (Ubuntu)
 Assignee: (unassigned) => Matthias Klose (doko)

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to bash in Ubuntu.
https://bugs.launchpad.net/bugs/1641832

Title:
  Bash ignores exit trap on success when part of a command string

Status in bash package in Ubuntu:
  Triaged

Bug description:
  The MAAS team uses a script, lp:maas-images, which generates the
  images available at images.maas.io. As part of this process we use the
  following to convert a SquashFS image to an ext4 image.

  sudo bash -ec 'src="$1"; img="$2"; trgmp="$3";
  mounts=""
  cleanup() { for m in $mounts; do umount "$m"; done; }
  trap cleanup EXIT
  mount -o loop "$img" "$trgmp"
  mounts="$trgmp"
  unsquashfs -force -xattrs -dest "$trgmp" "$src"' \
  "squashimg-to-image" "$squashimg" "$output" "$trgmp"
  ret=$?
  rm -Rf "$mtmp" || return
  return $ret

  Prior to 4.4-1ubuntu1 the trap would always cause the cleanup function
  to always be called. Its now only called on failure. This causes the
  mount to remain and the following rm to fail. If I add 'false' to the
  end of the command script or downgrade to 4.3-15ubuntu1 the cleanup
  occurs.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1641832/+subscriptions

-- 
Mailing list: https://launchpad.net/~touch-packages
Post to : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp