Merge ~ogayot/curtin:sfdisk-accept-utf8 into curtin:master
Status: | Merged |
---|---|
Merged at revision: | fb70e57035375abc63c7c2c757c4c64ab928d5b4 |
Proposed branch: | ~ogayot/curtin:sfdisk-accept-utf8 |
Merge into: | curtin:master |
Diff against target: |
192 lines (+87/-13) 5 files modified
curtin/commands/block_meta_v2.py (+22/-1) curtin/udev.py (+17/-3) tests/integration/test_block_meta.py (+6/-2) tests/unittests/helpers.py (+2/-2) tests/unittests/test_commands_block_meta.py (+40/-5) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Dan Bungert | Approve | ||
Server Team CI bot | continuous-integration | Approve | |
curtin developers | Pending | ||
Review via email: mp+442225@code.launchpad.net |
Commit message
block_meta_v2: make GPT partition name support more robust
In some cases, the sfdisk script will include GPT partition names. GPT
partition names support characters outside the ASCII range (they are
stored in UTF-16 in the GPT metadata). Therefore, it is currently a
wrong assumption that the sfdisk input is always valid ASCII.
Furthermore, we inject the name straight inside the sfdisk input script
(surrounded with double quotes)..
This can result in various problems if the name contains a '"' character
(the sfdisk field delimiter) or other characters such as '\\'.
Fixed by converting all the characters of the partition names into their
utf-8 \x notation. sfdisk natively supports reading this format. This
will have a slight implact on the readability of the sfdisk script, but
should make it way more robust.
udev: fix crash when PARTNAME is invalid utf-8
(We already merged a similar fix in probert)
GPT partition names are basically free-text fields but the udev PARTNAME
field ends up butchered by the kernel when it contains characters
outside the ASCII range.
When using pyudev, the values are all expected to be decodable using the
system's default encoding.
In curtin, it can result in a crash when iterating over all the
properties of a block device, that are mapped by pyudev.
To work around the issue, we now stop iterating over all the values. We
iterate over the keys and only access the value if we need it.
tests: make random_string a staticmethod instead of classmethod
CiTestCase.
I guess the purpose was to make the function usable without a CiTestCase
instance. However, @classmethod is used when a function should return an
instance of the class.
This is not what we want. @staticmethod is the right decorator in this
context.
Description of the change
GPT partition names are basically free-text, but curtin expects the sfdisk input script to be ASCII.
We also inject the partition name in the sfdisk script without properly sanitizing the name. This results in problems if the name contains '"' or other characters that have a special meaning in sfdisk.
Fixed by converting the partition name to a utf-8 hex notation.
e.g.
name="name is réservé"
becomes:
name="name\
PASSED: Continuous integration, rev:9cace115d30 979279febd44f11 a47882e3766970 /jenkins. canonical. com/server- team/job/ curtin- ci/100/ /jenkins. canonical. com/server- team/job/ curtin- ci/nodes= metal-amd64/ 100/ /jenkins. canonical. com/server- team/job/ curtin- ci/nodes= metal-arm64/ 100/ /jenkins. canonical. com/server- team/job/ curtin- ci/nodes= metal-ppc64el/ 100/ /jenkins. canonical. com/server- team/job/ curtin- ci/nodes= metal-s390x/ 100/
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/server- team/job/ curtin- ci/100/ /rebuild
https:/