growpart doesn't work when LANG=cs_CZ.UTF-8

Bug #1928167 reported by xiaoyi chen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-utils (Ubuntu)
Fix Released
Undecided
Paride Legovini

Bug Description

Using growpart with locale cs_CZ on RHEL7/RHEL8 encounters the following error,
  # growpart /dev/xvda 2 -v -N
    unexpected output in sfdisk --version [sfdisk z util-linux 2.23.2]

I found that,
when LANG=cs_CZ.UTF-8, run command "sfdisk --version" would get "sfdisk z util-linux 2.32.1".
It is weird that the char between z and util-linux is not a space char but a char of UTF-8 code 302.

$ set -- sfdisk z util-linux 2.32.1
$ echo $2
z util-linux

$ echo $2 |od -b
0000000 172 302 240 165 164 151 154 055 154 151 156 165 170 012
0000016

$ echo $3
2.32.1

$ echo $4

so the growpart command failed because the $4 is unset in this case.

        # expected output: sfdisk from util-linux 2.25.2
        out=$(sfdisk --version) ||
                { error "failed to get sfdisk version"; return 1; }
        set -- $out
        ver=$4
        case "$ver" in
                [0-9]*.[0-9]*.[0-9]|[0-9].[0-9]*)
                        IFS="."; set -- $ver; IFS="$oifs"
                        SFDISK_VERSION=$(($1*10000+$2*100+${3:-0}))
                        return 0;;
                *) error "unexpected output in sfdisk --version [$out]"
                        return 1;;
        esac

[Solution]
one simple fix for growpart could be adding LANG=C before the command sfdisk --version, e.g.
        out=$(LANG=C sfdisk --version) ||

Related branches

Revision history for this message
xiaoyi chen (xiachen-rh) wrote :

Hi Project Owner,
I sent a pull request https://github.com/canonical/cloud-utils/pull/30,
could anyone help to review please?

thanks,
Amy

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

Hello Amy and thanks for this bug report. Octal "302 240" is hex "C2 A0" which is a non-breaking space [1]. I guess it was used for cosmetic reasons, to avoid a newline right after the "z".

I'll review your PR on GitHub.

[1] https://en.wikipedia.org/wiki/Non-breaking_space

Changed in cloud-utils:
status: New → Triaged
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.