Merge pull request #24457 from poettering/smbios-condition-fix
SMBIOS condition fix
This commit is contained in:
@@ -659,7 +659,7 @@ static int condition_test_firmware(Condition *c, char **env) {
|
||||
_cleanup_free_ char *dtc_arg = NULL;
|
||||
char *end;
|
||||
|
||||
end = strchr(arg, ')');
|
||||
end = strrchr(arg, ')');
|
||||
if (!end || *(end + 1) != '\0') {
|
||||
log_debug("Malformed ConditionFirmware=%s", c->parameter);
|
||||
return false;
|
||||
@@ -676,7 +676,7 @@ static int condition_test_firmware(Condition *c, char **env) {
|
||||
_cleanup_free_ char *smbios_arg = NULL;
|
||||
char *end;
|
||||
|
||||
end = strchr(arg, ')');
|
||||
end = strrchr(arg, ')');
|
||||
if (!end || *(end + 1) != '\0')
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Malformed ConditionFirmware=%s: %m", c->parameter);
|
||||
|
||||
|
||||
@@ -362,13 +362,13 @@ TEST(condition_test_firmware_smbios_field) {
|
||||
expression = strjoina("smbios-field(bios_vendor =$ ", quote, bios_vendor, quote, ")");
|
||||
condition = condition_new(CONDITION_FIRMWARE, expression, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ));
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
expression = strjoina("smbios-field(bios_vendor=$", quote, bios_vendor, quote, ")");
|
||||
condition = condition_new(CONDITION_FIRMWARE, expression, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ));
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
expression = strjoina("smbios-field(bios_vendor !=$ ", quote, bios_vendor, quote, ")");
|
||||
@@ -386,7 +386,7 @@ TEST(condition_test_firmware_smbios_field) {
|
||||
expression = strjoina("smbios-field(bios_vendor =$ ", quote, bios_vendor, "*", quote, ")");
|
||||
condition = condition_new(CONDITION_FIRMWARE, expression, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ));
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
/* Test version comparison with bios_version, if available */
|
||||
@@ -402,7 +402,7 @@ TEST(condition_test_firmware_smbios_field) {
|
||||
expression = strjoina("smbios-field(bios_version = ", quote, bios_version, quote, ")");
|
||||
condition = condition_new(CONDITION_FIRMWARE, expression, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ));
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
expression = strjoina("smbios-field(bios_version != ", quote, bios_version, quote, ")");
|
||||
@@ -414,19 +414,19 @@ TEST(condition_test_firmware_smbios_field) {
|
||||
expression = strjoina("smbios-field(bios_version <= ", quote, bios_version, quote, ")");
|
||||
condition = condition_new(CONDITION_FIRMWARE, expression, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ));
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
expression = strjoina("smbios-field(bios_version >= ", quote, bios_version, quote, ")");
|
||||
condition = condition_new(CONDITION_FIRMWARE, expression, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ));
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
expression = strjoina("smbios-field(bios_version < ", quote, bios_version, ".1", quote, ")");
|
||||
condition = condition_new(CONDITION_FIRMWARE, expression, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ));
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
expression = strjoina("smbios-field(bios_version > ", quote, bios_version, ".1", quote, ")");
|
||||
|
||||
Reference in New Issue
Block a user