OSDN Git Service

ucm: Fix fallback to card_name (shortname) config for ucm1 profiles
authorHans de Goede <hdegoede@redhat.com>
Tue, 19 Nov 2019 10:48:20 +0000 (11:48 +0100)
committerJaroslav Kysela <perex@perex.cz>
Tue, 19 Nov 2019 11:45:30 +0000 (12:45 +0100)
commit77119d83a1f42b648671cf856e699500d89dc651
tree800afee815d59d7a80d1bdccb9b3f65f2b141509
parent86c449d231e63e149f21ccd98dbc2ead46c90c92
ucm: Fix fallback to card_name (shortname) config for ucm1 profiles

uc_mgr_import_master_config() first calls load_master_config()
with the card's longname and if that fails then calls it again with the
card_name.

Before this commit configuration_filename() would force conf_format to 2
when it the access(fn, R_OK) test failed for the ucm1 longname
master-config filename.

This would cause configuration_filename() to blindly return a filename
under <prefix>/ucm2 without seeing if that is actually there and without
trying to fallback to the old profiles under <prefix>/ucm, breaking the
loading of UCM1 profiles by card_name.

This commit fixes this by modifying configuration_filename() to not set
conf_format when checking for the UCM1 config filename fails.
Instead, to make sure that any errors about opening the file still report
the new path, configuration_filename() now resets the filename to the UCM2
path if the access() check has failed for both the UCM2 and UCM1 paths,
without touching conf_format.

Fixes: aba2260ae7b5 ("ucm: switch to ucm2 directory and v2 format, keep backward compatibility")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/ucm/parser.c