No closing quotation when label has trailing backslash

Bug #2069994 reported by lijinpeng
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
curtin
Confirmed
Undecided
Unassigned
subiquity
Triaged
Medium
Unassigned
ubuntu-desktop-provision
Confirmed
Undecided
Unassigned

Bug Description

Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: File "/snap/ubuntu-desktop-bootstrap/205/lib/python3.10/site-packages/curtin/commands/main.py", line 202, in main
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: ret = args.func(args)
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: File "/snap/ubuntu-desktop-bootstrap/205/lib/python3.10/site-packages/curtin/commands/curthooks.py", line 2224, in curthooks
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: builtin_curthooks(cfg, target, state)
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: File "/snap/ubuntu-desktop-bootstrap/205/lib/python3.10/site-packages/curtin/commands/curthooks.py", line 2100, in builtin_curthooks
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: detect_and_handle_multipath(cfg, target, osfamily=osfamily)
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: File "/snap/ubuntu-desktop-bootstrap/205/lib/python3.10/site-packages/curtin/commands/curthooks.py", line 1106, in detect_and_handle_multipath
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: mp_device = block.detect_multipath(target)
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: File "/snap/ubuntu-desktop-bootstrap/205/lib/python3.10/site-packages/curtin/block/__init__.py", line 685, in detect_multipath
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: return _legacy_detect_multipath(target_mountpoint)
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: File "/snap/ubuntu-desktop-bootstrap/205/lib/python3.10/site-packages/curtin/block/__init__.py", line 590, in _legacy_detect_multipath
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: binfo = blkid(cache=False)
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: File "/snap/ubuntu-desktop-bootstrap/205/lib/python3.10/site-packages/curtin/block/__init__.py", line 565, in blkid
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: for tok in util.shlex_split(curdata))
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: File "/snap/ubuntu-desktop-bootstrap/205/lib/python3.10/site-packages/curtin/util.py", line 1385, in shlex_split
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: return shlex.split(str_in)
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: File "/snap/ubuntu-desktop-bootstrap/205/usr/lib/python3.10/shlex.py", line 315, in split
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: return list(lex)
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: File "/snap/ubuntu-desktop-bootstrap/205/usr/lib/python3.10/shlex.py", line 300, in __next__
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: token = self.get_token()
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: File "/snap/ubuntu-desktop-bootstrap/205/usr/lib/python3.10/shlex.py", line 109, in get_token
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: raw = self.read_token()
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: File "/snap/ubuntu-desktop-bootstrap/205/usr/lib/python3.10/shlex.py", line 191, in read_token
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: raise ValueError("No closing quotation")
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: ValueError: No closing quotation
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: No closing quotation
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]:
Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: Stderr: ''
Jun 21 14:06:36 ubuntu subiquity_event.7400[7400]: curtin command install

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you for your bug report Could you add the logs from/var/log/installer after getting the problem?

Could you also provide some details on the partitioning choice you made?

Changed in ubuntu-desktop-provision:
status: New → Incomplete
Chris Peterson (cpete)
Changed in subiquity:
status: New → Incomplete
Revision history for this message
Xu Zhen (xuzhen666) wrote :

If the output of blkid has a backslash character at the end of the LABEL/PARTLABEL part, this problem will occur.

For example, if you run

e2label /dev/sdaX $'\xe5\xb7\xa5\xe4\xbd\x9c'

to set the label of a partition to "工作" (which means "work" in English), blkid will output something like this:

/dev/sdaX: LABEL="M-eM-7M-%M-dM-=M-^\" UUID="97711aa1-0cf2-4b7a-a56e-c957d6e82701" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="efdaf75d-03"

The shlex module in Python will fail when parsing the output of blkid

$ python3
Python 3.12.4 (main, Jun 27 2024, 13:53:59) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import shlex
>>> shlex.split('LABEL="M-eM-7M-%M-dM-=M-^\\"')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.12/shlex.py", line 313, in split
    return list(lex)
           ^^^^^^^^^
  File "/usr/lib/python3.12/shlex.py", line 300, in __next__
    token = self.get_token()
            ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/shlex.py", line 109, in get_token
    raw = self.read_token()
          ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/shlex.py", line 191, in read_token
    raise ValueError("No closing quotation")
ValueError: No closing quotation

Changed in ubuntu-desktop-provision:
status: Incomplete → Confirmed
Xu Zhen (xuzhen666)
Changed in curtin:
status: New → Confirmed
Changed in subiquity:
status: Incomplete → New
Revision history for this message
Olivier Gayot (ogayot) wrote (last edit ):

Yes, splitting based on the shell grammar rules seems like a bad idea. I think we should rely on lsblk instead of blkid. It supports the --json option so should probably handle the trailing backslash with no problem.

quote from man 8 blkid:

> It is recommended to use lsblk(8) command to get information about block devices, or lsblk --fs to get an overview of filesystems, or findmnt(8) to search in already mounted filesystems.

Changed in subiquity:
status: New → Triaged
importance: Undecided → Medium
summary: - Jun 21 14:06:35 ubuntu subiquity_log.7400[13454]: No closing
- quotation
+ No closing quotation when label has trailing backslash
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.