Bug 15499

Summary: SystemD unit file that is UTF-8 encoded causes uncaught exception in SYSTEMD_SERVICE postinst
Product: [Build System, Metadata & Runtime] OE-Core Reporter: martin.scheffler
Component: oe-core otherAssignee: martin.scheffler
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: Medium+ CC: JPEWhacker, randy.macleod
Version: 4.0.16   
Target Milestone: 4.0.20   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

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.