Package: gdisk Version: 0.8.10-1 Severity: important X-Debbugs-Cc: u...@451f.org
Hi, tl;dr: * In Wheezy, gdisk correctly returns exit code 0 upon success. * In Jessie, gdisk mistakenly returns exit code 1 after various successful operations. This breaks any tool that uses gdisk for such operations... and bothers checking its exit code. No idea if the reverse-dependencies in Debian are affected, but it does break Tails Installer (not in Debian yet, will be uploaded by the end of August) on Jessie. * This regression has been identified upstream in March, 2014. It was fixed in upstream Git back then. It's the HEAD of their master branch, and no release was put out since. The attached patchset imports the fix from upstream (not the entire commit, that sadly is non-atomic and contains unrelated changes -- just the relevant changes), and updates d/changelog accordingly. I've generated with git format-patch from the Vcs-Git. The attached reproducer script allows anyone to confirm the summary I made above. The results I see on Wheezy, Jessie, and Jessie + the upstream fix follow. With my Tails hat, I'd love to see this bug fixed in Jessie (otherwise we'll have to ship a modified gdisk in Tails). With my Debian hat, I'm unsure. On the one hand, arguably it's not RC, and if nobody reported this bug at this stage of the release cycle, then it's probably big deal to release with it, and not worth taking the risk to modify the package. On the other hand that's a nasty regression, and we don't know how many home-made scripts running under `set -e' will be broken once their authors upgrade their systems to Jessie. Guillaume, what do you think? If you feel it's RC, please bump severity. I can take care of NMU'ing and talking to the release team if it helps — just let me know. Jessie ======================================================================== $ ~/tmp/test.sh /dev/sdb Resetting disk /dev/sdb... 32+0 records in 32+0 records out 33554432 bytes (34 MB) copied, 4.91898 s, 6.8 MB/s ----------------------------------------------------------------- Creating blank GPT from corrupted disk... GPT fdisk (gdisk) version 0.8.10 Caution: invalid main GPT header, but valid backup; regenerating main header from backup! Partition table scan: MBR: not present BSD: not present APM: not present GPT: damaged Found invalid MBR and corrupt GPT. What do you want to do? (Using the GPT MAY permit recovery of GPT data.) 1 - Use current GPT 2 - Create blank GPT Your answer: Command (? for help): Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): OK; writing new GUID partition table (GPT) to /dev/sdb. The operation has completed successfully. Exit code: 1 ----------------------------------------------------------------- Wiping GPT and MBR... GPT fdisk (gdisk) version 0.8.10 Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Command (? for help): Expert command (? for help): About to wipe out GPT on /dev/sdb. Proceed? (Y/N): GPT data structures destroyed! You may now partition the disk using fdisk or other utilities. Blank out MBR? (Y/N): Exit code: 1 ----------------------------------------------------------------- Creating new protective MBR... GPT fdisk (gdisk) version 0.8.10 Partition table scan: MBR: not present BSD: not present APM: not present GPT: not present Creating new GPT entries. Command (? for help): Expert command (? for help): Expert command (? for help): Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): OK; writing new GUID partition table (GPT) to /dev/sdb. The operation has completed successfully. Exit code: 1 Wheezy ======================================================================== Resetting disk /dev/sda... 32+0 records in 32+0 records out 33554432 bytes (34 MB) copied, 3.23598 s, 10.4 MB/s ----------------------------------------------------------------- Creating blank GPT from corrupted disk... GPT fdisk (gdisk) version 0.8.5 Partition table scan: MBR: not present BSD: not present APM: not present GPT: not present Creating new GPT entries. Command (? for help): b back up GPT data to a file c change a partition's name d delete a partition i show detailed information on a partition l list known partition types n add a new partition o create a new empty GUID partition table (GPT) p print the partition table q quit without saving changes r recovery and transformation options (experts only) s sort partitions t change a partition's type code v verify disk w write table to disk and exit x extra functionality (experts only) ? print this menu Command (? for help): Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): OK; writing new GUID partition table (GPT) to /dev/sda. The operation has completed successfully. Exit code: 0 ----------------------------------------------------------------- Wiping GPT and MBR... GPT fdisk (gdisk) version 0.8.5 Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Command (? for help): Expert command (? for help): About to wipe out GPT on /dev/sda. Proceed? (Y/N): GPT data structures destroyed! You may now partition the disk using fdisk or other utilities. Blank out MBR? (Y/N): Exit code: 0 ----------------------------------------------------------------- Creating new protective MBR... GPT fdisk (gdisk) version 0.8.5 Partition table scan: MBR: not present BSD: not present APM: not present GPT: not present Creating new GPT entries. Command (? for help): Expert command (? for help): Expert command (? for help): Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): OK; writing new GUID partition table (GPT) to /dev/sda. The operation has completed successfully. Exit code: 0 Jessie + upstream fix (attached patch) ======================================================================== Resetting disk /dev/sdb... 32+0 records in 32+0 records out 33554432 bytes (34 MB) copied, 3.08629 s, 10.9 MB/s ----------------------------------------------------------------- Creating blank GPT from corrupted disk... GPT fdisk (gdisk) version 0.8.10 Caution: invalid main GPT header, but valid backup; regenerating main header from backup! Partition table scan: MBR: not present BSD: not present APM: not present GPT: damaged Found invalid MBR and corrupt GPT. What do you want to do? (Using the GPT MAY permit recovery of GPT data.) 1 - Use current GPT 2 - Create blank GPT Your answer: Command (? for help): Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): OK; writing new GUID partition table (GPT) to /dev/sdb. The operation has completed successfully. Exit code: 0 ----------------------------------------------------------------- Wiping GPT and MBR... GPT fdisk (gdisk) version 0.8.10 Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Command (? for help): Expert command (? for help): About to wipe out GPT on /dev/sdb. Proceed? (Y/N): GPT data structures destroyed! You may now partition the disk using fdisk or other utilities. Blank out MBR? (Y/N): Exit code: 0 ----------------------------------------------------------------- Creating new protective MBR... GPT fdisk (gdisk) version 0.8.10 Partition table scan: MBR: not present BSD: not present APM: not present GPT: not present Creating new GPT entries. Command (? for help): Expert command (? for help): Expert command (? for help): Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): OK; writing new GUID partition table (GPT) to /dev/sdb. The operation has completed successfully. Exit code: 0 Cheers, -- intrigeri
#!/bin/sh set -u [ $# -eq 1 ] || exit 13 [ -n "$1" ] || exit 17 DISK="$1" echo "Resetting disk ${DISK}..." sudo dd if=/dev/zero of="$DISK" bs=1M count=32 echo echo "-----------------------------------------------------------------" echo "Creating blank GPT from corrupted disk..." echo "2\nw\ny\n" | sudo gdisk "$DISK" echo "Exit code: $?" echo "-----------------------------------------------------------------" echo "Wiping GPT and MBR..." echo "x\nz\ny\ny\n" | sudo gdisk "$DISK" echo "Exit code: $?" echo "-----------------------------------------------------------------" echo "Creating new protective MBR..." echo "x\nn\nw\ny\n" | sudo gdisk "$DISK" echo "Exit code: $?"
>From 66dccd7e0495c8c0dc8110c4991c6883812d7b1a Mon Sep 17 00:00:00 2001 From: intrigeri <intrig...@debian.org> Date: Wed, 4 Mar 2015 20:27:19 +0000 Subject: [PATCH 1/2] Fixed-bug-that-caused-spurious-1-exit-condition-in-g.patch: new patch, cherry-picked from upstream, that fixes spurious non-zero exit code in many cases. --- ...hat-caused-spurious-1-exit-condition-in-g.patch | 44 ++++++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 45 insertions(+) create mode 100644 debian/patches/Fixed-bug-that-caused-spurious-1-exit-condition-in-g.patch diff --git a/debian/patches/Fixed-bug-that-caused-spurious-1-exit-condition-in-g.patch b/debian/patches/Fixed-bug-that-caused-spurious-1-exit-condition-in-g.patch new file mode 100644 index 0000000..fa71cd4 --- /dev/null +++ b/debian/patches/Fixed-bug-that-caused-spurious-1-exit-condition-in-g.patch @@ -0,0 +1,44 @@ +From: "Roderick W. Smith" <rodsm...@rodsbooks.com> +Date: Sat, 29 Mar 2014 00:45:59 -0400 +Origin: http://sourceforge.net/p/gptfdisk/code/ci/a920398fa393f9d6301b32b191bc01e086ab8bc8 +Bug: http://sourceforge.net/p/gptfdisk/mailman/message/32068566/ +Subject: Fixed bug that caused spurious "1" exit condition in gdisk. + +--- + gdisk.cc | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/gdisk.cc b/gdisk.cc +index b3c6240..5768869 100644 +--- a/gdisk.cc ++++ b/gdisk.cc +@@ -15,6 +15,7 @@ int main(int argc, char* argv[]) { + GPTDataTextUI theGPT; + string device = ""; + UnicodeString uString; ++ int isError = 0; + + cout << "GPT fdisk (gdisk) version " << GPTFDISK_VERSION << "\n\n"; + +@@ -47,16 +48,20 @@ int main(int argc, char* argv[]) { + device = (string) argv[1]; + } else { // 3 arguments, but none is "-l" + cerr << "Usage: " << argv[0] << " [-l] device_file\n"; ++ isError = 1; + } // if/elseif/else + if (device != "") { + theGPT.JustLooking(); + if (theGPT.LoadPartitions(device)) + theGPT.DisplayGPTData(); ++ else ++ isError = 1; + } // if + break; + default: + cerr << "Usage: " << argv[0] << " [-l] device_file\n"; ++ isError = 1; + break; + } // switch +- return 1 ; ++ return (isError); + } // main diff --git a/debian/patches/series b/debian/patches/series index 0fdf244..ec30c99 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -4,3 +4,4 @@ manpages.diff kfreebsd_character_devices.diff fix-change_disk_uid-test.diff enable_make_test.diff +Fixed-bug-that-caused-spurious-1-exit-condition-in-g.patch -- 2.1.4
>From 8ff57fcf6e39d16e4e5d789309dc3e070992918c Mon Sep 17 00:00:00 2001 From: intrigeri <intrig...@debian.org> Date: Wed, 4 Mar 2015 20:29:45 +0000 Subject: [PATCH 2/2] gdisk (0.8.10-1.1) --- debian/changelog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/debian/changelog b/debian/changelog index bf5abfd..0077b17 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +gdisk (0.8.10-1.1) UNRELEASED; urgency=medium + + * Non-maintainer upload. + * Fixed-bug-that-caused-spurious-1-exit-condition-in-g.patch: new patch, + cherry-picked from upstream, that fixes spurious non-zero exit code + in many cases. + + -- intrigeri <intrig...@debian.org> Wed, 04 Mar 2015 21:28:11 +0100 + gdisk (0.8.10-1) unstable; urgency=medium * New upstream release: -- 2.1.4