Bug 15499 - SystemD unit file that is UTF-8 encoded causes uncaught exception in SYSTEMD_SERVICE postinst
Summary: SystemD unit file that is UTF-8 encoded causes uncaught exception in SYSTEMD_...
Status: RESOLVED WORKSFORME
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: oe-core other (show other bugs)
Version: 4.0.16
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 4.0.20
Assignee: martin.scheffler
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2024-05-31 07:39 UTC by martin.scheffler
Modified: 2024-07-25 15:09 UTC (History)
2 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description martin.scheffler 2024-05-31 07:39:47 UTC
I have a UTF-8 encoded SystemD unit file that I want to autostart with 

SYSTEMD_SERVICE:${PN} = "my.service"

This causes the following exception:

Traceback (most recent call last):
  File "/build/lmp/build-lmp/tmp-lmp/work/intel_corei7_64-lmp-linux/lmp-factory-image/1.0-r0/recipe-sysroot-native/usr/bin/systemctl", line 351, in <module>
    main()
  File "/build/lmp/build-lmp/tmp-lmp/work/intel_corei7_64-lmp-linux/lmp-factory-image/1.0-r0/recipe-sysroot-native/usr/bin/systemctl", line 337, in main
    SystemdUnit(root, service).enable()
  File "/build/lmp/build-lmp/tmp-lmp/work/intel_corei7_64-lmp-linux/lmp-factory-image/1.0-r0/recipe-sysroot-native/usr/bin/systemctl", line 222, in enable
    config = SystemdFile(self.root, path, instance_unit_name)
  File "/build/lmp/build-lmp/tmp-lmp/work/intel_corei7_64-lmp-linux/lmp-factory-image/1.0-r0/recipe-sysroot-native/usr/bin/systemctl", line 31, in __init__
    self._parse(root, path)
  File "/build/lmp/build-lmp/tmp-lmp/work/intel_corei7_64-lmp-linux/lmp-factory-image/1.0-r0/recipe-sysroot-native/usr/bin/systemctl", line 80, in _parse
    k = m.group('key')
AttributeError: 'NoneType' object has no attribute 'group'

I hacked the systemctl python script to print out the path of the unit file and the currently examined line, and the exception occurs right at the first line containing "[Unit]".
Comment 1 Joshua Watt 2024-06-06 14:33:42 UTC
Can you attach the unit file that causes the problem please?
Comment 2 Randy MacLeod 2024-07-25 15:09:44 UTC
Please re-open if you are able to provide the requested information.
We can't reproduce the issue easily if at all.