version_is_valid() tweaks (#43025)
We have two validators, and neither really makes sense. Let's unify and clean things up.
This commit is contained in:
@@ -268,7 +268,7 @@ int pattern_match(const char *pattern, const char *s, InstanceMetadata *ret) {
|
||||
switch (e->type) {
|
||||
|
||||
case PATTERN_VERSION:
|
||||
if (!version_is_valid(t)) {
|
||||
if (!version_is_valid(t, VERSION_ALLOW_UNDERSCORE|VERSION_ALLOW_PLUS)) {
|
||||
log_debug("Version string is not valid, refusing: %s", t);
|
||||
goto nope;
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ static int config_parse_protect_version(
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!version_is_valid(resolved)) {
|
||||
if (!version_is_valid(resolved, VERSION_ALLOW_UNDERSCORE|VERSION_ALLOW_PLUS)) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||
"ProtectVersion= string is not valid, ignoring: %s", resolved);
|
||||
return 0;
|
||||
@@ -180,7 +180,7 @@ static int config_parse_min_version(
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!version_is_valid(rvalue)) {
|
||||
if (!version_is_valid(resolved, VERSION_ALLOW_UNDERSCORE|VERSION_ALLOW_PLUS)) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||
"MinVersion= string is not valid, ignoring: %s", resolved);
|
||||
return 0;
|
||||
|
||||
@@ -553,7 +553,7 @@ static int context_discover_update_sets_by_flag(Context *c, UpdateSetFlags flags
|
||||
if (boundary && strverscmp_improved(i->metadata.version, boundary) >= 0)
|
||||
continue; /* Not older than the boundary */
|
||||
|
||||
if (cursor && strverscmp(i->metadata.version, cursor) <= 0)
|
||||
if (cursor && strverscmp_improved(i->metadata.version, cursor) <= 0)
|
||||
break; /* Not newer than the cursor. The same will be true for all
|
||||
* subsequent instances (due to sorting) so let's skip to the
|
||||
* next transfer. */
|
||||
|
||||
@@ -952,7 +952,7 @@ static int target_method_describe(sd_bus_message *msg, void *userdata, sd_bus_er
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!version_is_valid(version))
|
||||
if (!version_is_valid(version, VERSION_ALLOW_UNDERSCORE|VERSION_ALLOW_PLUS))
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid version");
|
||||
|
||||
if ((flags & ~SD_SYSUPDATE_FLAGS_ALL) != 0)
|
||||
@@ -1102,7 +1102,7 @@ static int target_method_acquire(sd_bus_message *msg, void *userdata, sd_bus_err
|
||||
if (isempty(version))
|
||||
action = "org.freedesktop.sysupdate1.update";
|
||||
else {
|
||||
if (!version_is_valid(version))
|
||||
if (!version_is_valid(version, VERSION_ALLOW_UNDERSCORE|VERSION_ALLOW_PLUS))
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid version");
|
||||
|
||||
action = "org.freedesktop.sysupdate1.update-to-version";
|
||||
@@ -1190,7 +1190,7 @@ static int target_method_install(sd_bus_message *msg, void *userdata, sd_bus_err
|
||||
if (isempty(version))
|
||||
action = "org.freedesktop.sysupdate1.update";
|
||||
else {
|
||||
if (!version_is_valid(version))
|
||||
if (!version_is_valid(version, VERSION_ALLOW_UNDERSCORE|VERSION_ALLOW_PLUS))
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid version");
|
||||
|
||||
action = "org.freedesktop.sysupdate1.update-to-version";
|
||||
|
||||
Reference in New Issue
Block a user