Wrong parsing of sfdisk output in french locale

Bug #1860479 reported by Gaël Bonithon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-utils (Ubuntu)
Fix Released
Medium
Paride Legovini

Bug Description

When using growpart with french locale, one encounters the following error:
"/usr/bin/growpart: 242: /usr/bin/growpart: Illegal number"
The reason is that, at lines 215 and 241, the script parses the output of sfdisk:
215: rqe sfd_list sfdisk --list --unit=S "$DISK" >"$tmp"
241: read _x _x _x _x disk_size _x sector_num _x < "$tmp"
But, with french locale, this output contains non-breaking spaces, so the parsing is wrong.
A workaround is to use "LC_ALL=C growpart", but this should not be necessary.

Revision history for this message
Paride Legovini (paride) wrote :

Thanks for reporting this bug. This can be fixed by using `sfdisk --dump`, which is intended to be machine readable.

Changed in cloud-utils:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Nicolas Chauvet (kwizart) wrote :

I've reproduced this bug and I'm suggesting a fix at https://github.com/canonical/cloud-utils/pull/28

Before the fix: (with centos8)
./growpart -N /dev/vda 2
./growpart: ligne 322: 22548578304 octets, : erreur de syntaxe : opérateur arithmétique non valable (le symbole erroné est «  octets, »)

After the fix:

./growpart -N /dev/vda 2
CHANGE: partition=2 start=2099200 old: size=39843840 end=41943040 new: size=41940959 end=44040159
# === old sfdisk -d ===
label: dos
label-id: 0x2ea6aa65
device: /dev/vda
unit: sectors

/dev/vda1 : start= 2048, size= 2097152, type=83, bootable
/dev/vda2 : start= 2099200, size= 39843840, type=8e
# === new sfdisk -d ===
label: dos
label-id: 0x2ea6aa65
device: /dev/vda
unit: sectors

/dev/vda1 : start= 2048, size= 2097152, type=83, bootable
/dev/vda2 : start= 2099200, size= 41940959, type=8e

Using sfdisk --dump will not shape well into the current code as --list expects to have the sectors size and this information isn't provided by the --dump command.

Also I would raise the importance of this issue because It really break the resize capability as soon as a(/any?) non-en locale is set.

Paride Legovini (paride)
Changed in cloud-utils:
assignee: nobody → Paride Legovini (paride)
Paride Legovini (paride)
Changed in cloud-utils:
status: Triaged → Fix Committed
Paride Legovini (paride)
affects: cloud-utils → cloud-utils (Ubuntu)
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cloud-utils - 0.32-22-g45fe84a5-0ubuntu1

---------------
cloud-utils (0.32-22-g45fe84a5-0ubuntu1) impish; urgency=medium

  * New upstream snapshot.
    - Merge test changes from test-growpart to test-growpart-lvm
      [Dan Bungert] (LP: #1929885)
    - Fix issue LP: #1928167 growpart doesn't work when LANG=cs_CZ.UTF-8
      [Amy Chen]
    - growpart: change flock call to use short option for Busybox
      compatibility [Dermot Bradley]
    - growpart: Use LANG=C to parse sfdisk output [Nicolas Chauvet]
      (LP: #1860479)

 -- Paride Legovini <email address hidden> Thu, 05 Aug 2021 11:58:37 +0200

Changed in cloud-utils (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.