OSDN Git Service

ucm: Fix opening of master-configs by the card's longname
authorHans de Goede <hdegoede@redhat.com>
Tue, 19 Nov 2019 10:48:19 +0000 (11:48 +0100)
committerJaroslav Kysela <perex@perex.cz>
Tue, 19 Nov 2019 11:25:19 +0000 (12:25 +0100)
commit86c449d231e63e149f21ccd98dbc2ead46c90c92
treed3a95cdf816986237d36ac7ee70b98385097efbf
parentc28618353b3f5d90e144bef56c52619ad8769520
ucm: Fix opening of master-configs by the card's longname

Prior to commit aba2260ae7b5 ("ucm: switch to ucm2 directory and v2 format,
keep backward compatibility").

The filename build in parse_verb_file() was build like this:
<prefix>/<uc_mgr->conf_file_name>/<file>

Where uc_mgr->conf_file_name would contain either the card_name or the
card's longname depending on the detection of a longname based config in
uc_mgr_import_master_config().

While the filename used in load_master_config() was build like this:
<prefix>/<card_name>/<card_name>.conf

And uc_mgr_import_master_config() first calls load_master_config()
with the card's longname and if that succeeds it overwrites
uc_mgr->conf_file_name with the longname so that the subsequent uses
of uc_mgr->conf_file_name in parse_verb_file() correctly use the longname.

But the new configuration_filename() helper added in commit aba2260ae7b5
_always_ builds the filename like this:
<prefix>/<uc_mgr->conf_file_name>/<file><suffix>

This breaks the loading of the master-config by its longname, as when
the longname is tried uc_mgr->conf_file_name still contains the card_name.

This commit fixes this by adding a dir parameter to configuration_filename()
and restoring the old behavior by passing card_name as dir in
load_master_config().

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