]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ukify: deal with non-list values in config_list_prepend
authorWolfgang Bumiller <w.bumiller@errno.eu>
Thu, 4 Jun 2026 15:00:37 +0000 (17:00 +0200)
committerWolfgang Bumiller <w.bumiller@errno.eu>
Thu, 4 Jun 2026 15:13:03 +0000 (17:13 +0200)
`ConfigItem.config_list_prepend` assumed that the passed value was a
list. This just happens to be the case for the `--initrd` and
`--devicetree-auto` parameters, as those get special treatment in
`ConfigItem.apply_config` as they use space separated lists.

However, this is not generally the case: When trying to set
`UKI/Firmware` the following error occurred:

Traceback (most recent call last):
  File "/usr/bin/ukify", line 2565, in <module>
    main()
    ~~~~^^
  File "/usr/bin/ukify", line 2548, in main
    opts = UkifyConfig.from_namespace(parse_args())
                                      ~~~~~~~~~~^^
  File "/usr/bin/ukify", line 2542, in parse_args
    apply_config(opts)
    ~~~~~~~~~~~~^^^^^^
  File "/usr/bin/ukify", line 2295, in apply_config
    item.apply_config(namespace, section_name, group, key, value)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/ukify", line 1892, in apply_config
    self.config_push(namespace, group, dest, value)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/ukify", line 1765, in config_list_prepend
    setattr(namespace, dest, value + old)
                             ~~~~~~^~~~~
TypeError: unsupported operand type(s) for +: 'PosixPath' and 'list'

Since we can thus get both lists and strings, check the type and
convert non-list values to `[value]`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@errno.eu>
src/ukify/ukify.py

index 0377c57ea71cf4938dda3e34c1e44b884be082e5..59078c98aadfbdb116a8400861e8a4708cd1eb06 100755 (executable)
@@ -1762,6 +1762,8 @@ class ConfigItem:
         old = getattr(namespace, dest, [])
         if old is None:
             old = []
+        if not isinstance(value, list):
+            value = [value]
         setattr(namespace, dest, value + old)
 
     @staticmethod