mirror of
https://github.com/systemd/systemd.git
synced 2025-03-09 12:58:26 +03:00
core: remove support for ConditionNull=
The concept is flawed, and mostly useless. Let's finally remove it. It has been deprecated since 90a2ec10f2d43a8530aae856013518eb567c4039 (6 years ago) and we started to warn since 55dadc5c57ef1379dbc984938d124508a454be55 (1.5 years ago). Let's get rid of it altogether.
This commit is contained in:
parent
4f55a5b0bf
commit
476cfe626d
@ -1092,9 +1092,6 @@
|
||||
<para>Except for <varname>ConditionPathIsSymbolicLink=</varname>, all path checks follow symlinks.</para>
|
||||
|
||||
<variablelist class='unit-directives'>
|
||||
<!-- We do not document ConditionNull= here, as it is not particularly useful and probably just
|
||||
confusing. -->
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>ConditionArchitecture=</varname></term>
|
||||
|
||||
|
@ -38,9 +38,7 @@ static int parse_condition(Unit *u, const char *line) {
|
||||
|
||||
p += strspn(p, WHITESPACE);
|
||||
|
||||
if (t == CONDITION_NULL) /* deprecated, but we should still parse this for now */
|
||||
callback = config_parse_unit_condition_null;
|
||||
else if (condition_takes_path(t))
|
||||
if (condition_takes_path(t))
|
||||
callback = config_parse_unit_condition_path;
|
||||
else
|
||||
callback = config_parse_unit_condition_string;
|
||||
|
@ -1974,14 +1974,11 @@ static int bus_set_transient_conditions(
|
||||
if (t < 0)
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid condition type: %s", type_name);
|
||||
|
||||
if (t != CONDITION_NULL) {
|
||||
if (isempty(param))
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Condition parameter in %s is empty", type_name);
|
||||
if (isempty(param))
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Condition parameter in %s is empty", type_name);
|
||||
|
||||
if (condition_takes_path(t) && !path_is_absolute(param))
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path in condition %s is not absolute: %s", type_name, param);
|
||||
} else
|
||||
param = NULL;
|
||||
if (condition_takes_path(t) && !path_is_absolute(param))
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path in condition %s is not absolute: %s", type_name, param);
|
||||
|
||||
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
|
||||
Condition *c;
|
||||
@ -1992,14 +1989,9 @@ static int bus_set_transient_conditions(
|
||||
|
||||
LIST_PREPEND(conditions, *list, c);
|
||||
|
||||
if (t != CONDITION_NULL)
|
||||
unit_write_settingf(u, flags|UNIT_ESCAPE_SPECIFIERS, name,
|
||||
"%s=%s%s%s", type_name,
|
||||
trigger ? "|" : "", negate ? "!" : "", param);
|
||||
else
|
||||
unit_write_settingf(u, flags, name,
|
||||
"%s=%s%s", type_name,
|
||||
trigger ? "|" : "", yes_no(!negate));
|
||||
unit_write_settingf(u, flags|UNIT_ESCAPE_SPECIFIERS, name,
|
||||
"%s=%s%s%s", type_name,
|
||||
trigger ? "|" : "", negate ? "!" : "", param);
|
||||
}
|
||||
|
||||
empty = false;
|
||||
|
@ -292,7 +292,6 @@ Unit.ConditionEnvironment, config_parse_unit_condition_string, CONDITION_E
|
||||
Unit.ConditionUser, config_parse_unit_condition_string, CONDITION_USER, offsetof(Unit, conditions)
|
||||
Unit.ConditionGroup, config_parse_unit_condition_string, CONDITION_GROUP, offsetof(Unit, conditions)
|
||||
Unit.ConditionControlGroupController, config_parse_unit_condition_string, CONDITION_CONTROL_GROUP_CONTROLLER, offsetof(Unit, conditions)
|
||||
Unit.ConditionNull, config_parse_unit_condition_null, 0, offsetof(Unit, conditions)
|
||||
Unit.AssertPathExists, config_parse_unit_condition_path, CONDITION_PATH_EXISTS, offsetof(Unit, asserts)
|
||||
Unit.AssertPathExistsGlob, config_parse_unit_condition_path, CONDITION_PATH_EXISTS_GLOB, offsetof(Unit, asserts)
|
||||
Unit.AssertPathIsDirectory, config_parse_unit_condition_path, CONDITION_PATH_IS_DIRECTORY, offsetof(Unit, asserts)
|
||||
@ -319,7 +318,6 @@ Unit.AssertEnvironment, config_parse_unit_condition_string, CONDITION_E
|
||||
Unit.AssertUser, config_parse_unit_condition_string, CONDITION_USER, offsetof(Unit, asserts)
|
||||
Unit.AssertGroup, config_parse_unit_condition_string, CONDITION_GROUP, offsetof(Unit, asserts)
|
||||
Unit.AssertControlGroupController, config_parse_unit_condition_string, CONDITION_CONTROL_GROUP_CONTROLLER, offsetof(Unit, asserts)
|
||||
Unit.AssertNull, config_parse_unit_condition_null, 0, offsetof(Unit, asserts)
|
||||
Unit.CollectMode, config_parse_collect_mode, 0, offsetof(Unit, collect_mode)
|
||||
m4_dnl
|
||||
Service.PIDFile, config_parse_pid_file, 0, offsetof(Service, pid_file)
|
||||
|
@ -2999,60 +2999,6 @@ int config_parse_unit_condition_string(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_unit_condition_null(
|
||||
const char *unit,
|
||||
const char *filename,
|
||||
unsigned line,
|
||||
const char *section,
|
||||
unsigned section_line,
|
||||
const char *lvalue,
|
||||
int ltype,
|
||||
const char *rvalue,
|
||||
void *data,
|
||||
void *userdata) {
|
||||
|
||||
Condition **list = data, *c;
|
||||
bool trigger, negate;
|
||||
int b;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
log_syntax(unit, LOG_WARNING, filename, line, 0, "%s= is deprecated, please do not use.", lvalue);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
/* Empty assignment resets the list */
|
||||
*list = condition_free_list(*list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
trigger = rvalue[0] == '|';
|
||||
if (trigger)
|
||||
rvalue++;
|
||||
|
||||
negate = rvalue[0] == '!';
|
||||
if (negate)
|
||||
rvalue++;
|
||||
|
||||
b = parse_boolean(rvalue);
|
||||
if (b < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, b, "Failed to parse boolean value in condition, ignoring: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!b)
|
||||
negate = !negate;
|
||||
|
||||
c = condition_new(CONDITION_NULL, NULL, trigger, negate);
|
||||
if (!c)
|
||||
return log_oom();
|
||||
|
||||
LIST_PREPEND(conditions, *list, c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_unit_requires_mounts_for(
|
||||
const char *unit,
|
||||
const char *filename,
|
||||
@ -5266,7 +5212,6 @@ void unit_dump_config_items(FILE *f) {
|
||||
{ config_parse_ip_tos, "TOS" },
|
||||
{ config_parse_unit_condition_path, "CONDITION" },
|
||||
{ config_parse_unit_condition_string, "CONDITION" },
|
||||
{ config_parse_unit_condition_null, "CONDITION" },
|
||||
{ config_parse_unit_slice, "SLICE" },
|
||||
{ config_parse_documentation, "URL" },
|
||||
{ config_parse_service_timeout, "SECONDS" },
|
||||
|
@ -58,7 +58,6 @@ CONFIG_PARSER_PROTOTYPE(config_parse_unit_env_file);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_ip_tos);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_unit_condition_path);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_unit_condition_string);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_unit_condition_null);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_kill_mode);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_notify_access);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_emergency_action);
|
||||
|
@ -52,7 +52,7 @@ Condition* condition_new(ConditionType type, const char *parameter, bool trigger
|
||||
|
||||
assert(type >= 0);
|
||||
assert(type < _CONDITION_TYPE_MAX);
|
||||
assert((!parameter) == (type == CONDITION_NULL));
|
||||
assert(parameter);
|
||||
|
||||
c = new(Condition, 1);
|
||||
if (!c)
|
||||
@ -776,15 +776,6 @@ static int condition_test_file_is_executable(Condition *c, char **env) {
|
||||
(st.st_mode & 0111));
|
||||
}
|
||||
|
||||
static int condition_test_null(Condition *c, char **env) {
|
||||
assert(c);
|
||||
assert(c->type == CONDITION_NULL);
|
||||
|
||||
/* Note that during parsing we already evaluate the string and
|
||||
* store it in c->negate */
|
||||
return true;
|
||||
}
|
||||
|
||||
int condition_test(Condition *c, char **env) {
|
||||
|
||||
static int (*const condition_tests[_CONDITION_TYPE_MAX])(Condition *c, char **env) = {
|
||||
@ -811,7 +802,6 @@ int condition_test(Condition *c, char **env) {
|
||||
[CONDITION_USER] = condition_test_user,
|
||||
[CONDITION_GROUP] = condition_test_group,
|
||||
[CONDITION_CONTROL_GROUP_CONTROLLER] = condition_test_control_group_controller,
|
||||
[CONDITION_NULL] = condition_test_null,
|
||||
[CONDITION_CPUS] = condition_test_cpus,
|
||||
[CONDITION_MEMORY] = condition_test_memory,
|
||||
[CONDITION_ENVIRONMENT] = condition_test_environment,
|
||||
@ -859,23 +849,20 @@ bool condition_test_list(
|
||||
r = condition_test(c, env);
|
||||
|
||||
if (logger) {
|
||||
const char *p = c->type == CONDITION_NULL ? "true" : c->parameter;
|
||||
assert(p);
|
||||
|
||||
if (r < 0)
|
||||
logger(userdata, LOG_WARNING, r, PROJECT_FILE, __LINE__, __func__,
|
||||
"Couldn't determine result for %s=%s%s%s, assuming failed: %m",
|
||||
to_string(c->type),
|
||||
c->trigger ? "|" : "",
|
||||
c->negate ? "!" : "",
|
||||
p);
|
||||
c->parameter);
|
||||
else
|
||||
logger(userdata, LOG_DEBUG, 0, PROJECT_FILE, __LINE__, __func__,
|
||||
"%s=%s%s%s %s.",
|
||||
to_string(c->type),
|
||||
c->trigger ? "|" : "",
|
||||
c->negate ? "!" : "",
|
||||
p,
|
||||
c->parameter,
|
||||
condition_result_to_string(c->result));
|
||||
}
|
||||
|
||||
@ -937,7 +924,6 @@ static const char* const condition_type_table[_CONDITION_TYPE_MAX] = {
|
||||
[CONDITION_USER] = "ConditionUser",
|
||||
[CONDITION_GROUP] = "ConditionGroup",
|
||||
[CONDITION_CONTROL_GROUP_CONTROLLER] = "ConditionControlGroupController",
|
||||
[CONDITION_NULL] = "ConditionNull",
|
||||
[CONDITION_CPUS] = "ConditionCPUs",
|
||||
[CONDITION_MEMORY] = "ConditionMemory",
|
||||
[CONDITION_ENVIRONMENT] = "ConditionEnvironment",
|
||||
@ -969,7 +955,6 @@ static const char* const assert_type_table[_CONDITION_TYPE_MAX] = {
|
||||
[CONDITION_USER] = "AssertUser",
|
||||
[CONDITION_GROUP] = "AssertGroup",
|
||||
[CONDITION_CONTROL_GROUP_CONTROLLER] = "AssertControlGroupController",
|
||||
[CONDITION_NULL] = "AssertNull",
|
||||
[CONDITION_CPUS] = "AssertCPUs",
|
||||
[CONDITION_MEMORY] = "AssertMemory",
|
||||
[CONDITION_ENVIRONMENT] = "AssertEnvironment",
|
||||
|
@ -34,8 +34,6 @@ typedef enum ConditionType {
|
||||
CONDITION_FILE_NOT_EMPTY,
|
||||
CONDITION_FILE_IS_EXECUTABLE,
|
||||
|
||||
CONDITION_NULL,
|
||||
|
||||
CONDITION_USER,
|
||||
CONDITION_GROUP,
|
||||
|
||||
|
@ -438,20 +438,6 @@ static void test_condition_test_kernel_version(void) {
|
||||
condition_free(condition);
|
||||
}
|
||||
|
||||
static void test_condition_test_null(void) {
|
||||
Condition *condition;
|
||||
|
||||
condition = condition_new(CONDITION_NULL, NULL, false, false);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) > 0);
|
||||
condition_free(condition);
|
||||
|
||||
condition = condition_new(CONDITION_NULL, NULL, false, true);
|
||||
assert_se(condition);
|
||||
assert_se(condition_test(condition, environ) == 0);
|
||||
condition_free(condition);
|
||||
}
|
||||
|
||||
static void test_condition_test_security(void) {
|
||||
Condition *condition;
|
||||
|
||||
@ -868,7 +854,6 @@ int main(int argc, char *argv[]) {
|
||||
test_condition_test_architecture();
|
||||
test_condition_test_kernel_command_line();
|
||||
test_condition_test_kernel_version();
|
||||
test_condition_test_null();
|
||||
test_condition_test_security();
|
||||
print_securities();
|
||||
test_condition_test_virtualization();
|
||||
|
@ -15,9 +15,6 @@ Documentation=https://www.freedesktop.org/wiki/Software/systemd/machined
|
||||
Wants=machine.slice
|
||||
After=machine.slice
|
||||
RequiresMountsFor=/var/lib/machines
|
||||
ConditionNull=true
|
||||
ConditionNull=
|
||||
ConditionNull=|!false
|
||||
OnFailureIsolate=false
|
||||
FailureActionExitStatus=222
|
||||
FailureActionExitStatus=
|
||||
|
Loading…
x
Reference in New Issue
Block a user