mirror of
https://github.com/systemd/systemd
synced 2026-03-09 22:54:56 +01:00
Compare commits
No commits in common. "e7a8f6b66fa3efd298120ef5d6c972d7b4df51c7" and "0ef0c9caf7ea1ff5c534395cd28b9ebfe0e29979" have entirely different histories.
e7a8f6b66f
...
0ef0c9caf7
@ -290,11 +290,8 @@ bool is_efi_boot(void) {
|
|||||||
if (cache < 0) {
|
if (cache < 0) {
|
||||||
if (detect_container() > 0)
|
if (detect_container() > 0)
|
||||||
cache = false;
|
cache = false;
|
||||||
else {
|
else
|
||||||
cache = access("/sys/firmware/efi/", F_OK) >= 0;
|
cache = access("/sys/firmware/efi/", F_OK) >= 0;
|
||||||
if (!cache && errno != ENOENT)
|
|
||||||
log_debug_errno(errno, "Unable to test whether /sys/firmware/efi/ exists, assuming EFI not available: %m");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cache;
|
return cache;
|
||||||
|
|||||||
@ -81,15 +81,12 @@ ssize_t string_table_lookup(const char * const *table, size_t len, const char *k
|
|||||||
|
|
||||||
#define DEFINE_STRING_TABLE_LOOKUP(name,type) _DEFINE_STRING_TABLE_LOOKUP(name,type,)
|
#define DEFINE_STRING_TABLE_LOOKUP(name,type) _DEFINE_STRING_TABLE_LOOKUP(name,type,)
|
||||||
#define DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type) _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,)
|
#define DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type) _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,)
|
||||||
#define DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type) _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,)
|
|
||||||
#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP(name,type) _DEFINE_STRING_TABLE_LOOKUP(name,type,static)
|
#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP(name,type) _DEFINE_STRING_TABLE_LOOKUP(name,type,static)
|
||||||
#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(name,type) _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,static)
|
#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(name,type) _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,static)
|
||||||
#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(name,type) _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,static)
|
#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(name,type) _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,static)
|
||||||
|
|
||||||
#define DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(name,type,yes) _DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(name,type,yes,)
|
#define DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(name,type,yes) _DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(name,type,yes,)
|
||||||
#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(name,type,yes) _DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(name,type,yes,static)
|
#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(name,type,yes) _DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(name,type,yes,static)
|
||||||
#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING_WITH_BOOLEAN(name,type,yes) \
|
|
||||||
_DEFINE_STRING_TABLE_LOOKUP_FROM_STRING_WITH_BOOLEAN(name,type,yes,static)
|
|
||||||
|
|
||||||
/* For string conversions where numbers are also acceptable */
|
/* For string conversions where numbers are also acceptable */
|
||||||
#define DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(name,type,max) \
|
#define DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(name,type,max) \
|
||||||
|
|||||||
@ -1233,7 +1233,6 @@ static int verb_status(int argc, char *argv[], void *userdata) {
|
|||||||
printf(" Firmware: %s%s (%s)%s\n", ansi_highlight(), strna(fw_type), strna(fw_info), ansi_normal());
|
printf(" Firmware: %s%s (%s)%s\n", ansi_highlight(), strna(fw_type), strna(fw_info), ansi_normal());
|
||||||
printf(" Secure Boot: %sd\n", enable_disable(is_efi_secure_boot()));
|
printf(" Secure Boot: %sd\n", enable_disable(is_efi_secure_boot()));
|
||||||
printf(" Setup Mode: %s\n", is_efi_secure_boot_setup_mode() ? "setup" : "user");
|
printf(" Setup Mode: %s\n", is_efi_secure_boot_setup_mode() ? "setup" : "user");
|
||||||
printf(" TPM2 Support: %s\n", yes_no(efi_has_tpm2()));
|
|
||||||
|
|
||||||
k = efi_get_reboot_to_firmware();
|
k = efi_get_reboot_to_firmware();
|
||||||
if (k > 0)
|
if (k > 0)
|
||||||
|
|||||||
@ -660,7 +660,7 @@ int config_parse_kill_mode(
|
|||||||
|
|
||||||
m = kill_mode_from_string(rvalue);
|
m = kill_mode_from_string(rvalue);
|
||||||
if (m < 0) {
|
if (m < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, m,
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
"Failed to parse kill mode specification, ignoring: %s", rvalue);
|
"Failed to parse kill mode specification, ignoring: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -920,7 +920,10 @@ int config_parse_socket_bindtodevice(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return free_and_strdup_warn(&s->bind_to_device, rvalue);
|
if (free_and_strdup(&s->bind_to_device, rvalue) < 0)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int config_parse_exec_input(
|
int config_parse_exec_input(
|
||||||
@ -987,7 +990,7 @@ int config_parse_exec_input(
|
|||||||
} else {
|
} else {
|
||||||
ei = exec_input_from_string(rvalue);
|
ei = exec_input_from_string(rvalue);
|
||||||
if (ei < 0) {
|
if (ei < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, ei, "Failed to parse input specifier, ignoring: %s", rvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse input specifier, ignoring: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1216,7 +1219,7 @@ int config_parse_exec_output(
|
|||||||
} else {
|
} else {
|
||||||
eo = exec_output_from_string(rvalue);
|
eo = exec_output_from_string(rvalue);
|
||||||
if (eo < 0) {
|
if (eo < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, eo, "Failed to parse output specifier, ignoring: %s", rvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse output specifier, ignoring: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1275,7 +1278,7 @@ int config_parse_exec_io_class(const char *unit,
|
|||||||
|
|
||||||
x = ioprio_class_from_string(rvalue);
|
x = ioprio_class_from_string(rvalue);
|
||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, x, "Failed to parse IO scheduling class, ignoring: %s", rvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse IO scheduling class, ignoring: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1350,7 +1353,7 @@ int config_parse_exec_cpu_sched_policy(const char *unit,
|
|||||||
|
|
||||||
x = sched_policy_from_string(rvalue);
|
x = sched_policy_from_string(rvalue);
|
||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, x, "Failed to parse CPU scheduling policy, ignoring: %s", rvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse CPU scheduling policy, ignoring: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1524,8 +1527,7 @@ int config_parse_root_image_options(
|
|||||||
|
|
||||||
partition_designator = partition_designator_from_string(partition);
|
partition_designator = partition_designator_from_string(partition);
|
||||||
if (partition_designator < 0) {
|
if (partition_designator < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, partition_designator,
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid partition name %s, ignoring", partition);
|
||||||
"Invalid partition name %s, ignoring", partition);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
r = unit_full_printf(u, mount_options, &mount_options_resolved);
|
r = unit_full_printf(u, mount_options, &mount_options_resolved);
|
||||||
@ -2013,7 +2015,7 @@ int config_parse_trigger_unit(
|
|||||||
|
|
||||||
type = unit_name_to_type(p);
|
type = unit_name_to_type(p);
|
||||||
if (type < 0) {
|
if (type < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, type, "Unit type not valid, ignoring: %s", rvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Unit type not valid, ignoring: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (unit_has_name(u, p)) {
|
if (unit_has_name(u, p)) {
|
||||||
@ -2060,7 +2062,7 @@ int config_parse_path_spec(const char *unit,
|
|||||||
|
|
||||||
b = path_type_from_string(lvalue);
|
b = path_type_from_string(lvalue);
|
||||||
if (b < 0) {
|
if (b < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, b, "Failed to parse path type, ignoring: %s", lvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse path type, ignoring: %s", lvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3384,12 +3386,8 @@ int config_parse_syscall_errno(
|
|||||||
}
|
}
|
||||||
|
|
||||||
e = parse_errno(rvalue);
|
e = parse_errno(rvalue);
|
||||||
if (e < 0) {
|
if (e <= 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, e, "Failed to parse error number, ignoring: %s", rvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse error number, ignoring: %s", rvalue);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (e == 0) {
|
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid error number, ignoring: %s", rvalue);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3859,7 +3857,7 @@ int config_parse_managed_oom_mode(
|
|||||||
|
|
||||||
m = managed_oom_mode_from_string(rvalue);
|
m = managed_oom_mode_from_string(rvalue);
|
||||||
if (m < 0) {
|
if (m < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, m, "Invalid syntax, ignoring: %s", rvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid syntax, ignoring: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
*mode = m;
|
*mode = m;
|
||||||
@ -4670,7 +4668,7 @@ int config_parse_set_status(
|
|||||||
} else {
|
} else {
|
||||||
r = signal_from_string(word);
|
r = signal_from_string(word);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
"Failed to parse value, ignoring: %s", word);
|
"Failed to parse value, ignoring: %s", word);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -5087,8 +5085,7 @@ int config_parse_mount_images(
|
|||||||
|
|
||||||
partition_designator = partition_designator_from_string(partition);
|
partition_designator = partition_designator_from_string(partition);
|
||||||
if (partition_designator < 0) {
|
if (partition_designator < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, partition_designator,
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid partition name %s, ignoring", partition);
|
||||||
"Invalid partition name %s, ignoring", partition);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
r = unit_full_printf(u, mount_options, &mount_options_resolved);
|
r = unit_full_printf(u, mount_options, &mount_options_resolved);
|
||||||
@ -5777,7 +5774,7 @@ int config_parse_output_restricted(
|
|||||||
} else {
|
} else {
|
||||||
t = exec_output_from_string(rvalue);
|
t = exec_output_from_string(rvalue);
|
||||||
if (t < 0) {
|
if (t < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, t, "Failed to parse output type, ignoring: %s", rvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse output type, ignoring: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1249,9 +1249,8 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F
|
|||||||
if (streq(key, "state")) {
|
if (streq(key, "state")) {
|
||||||
MountState state;
|
MountState state;
|
||||||
|
|
||||||
state = mount_state_from_string(value);
|
if ((state = mount_state_from_string(value)) < 0)
|
||||||
if (state < 0)
|
log_unit_debug(u, "Failed to parse state value: %s", value);
|
||||||
log_unit_debug_errno(u, state, "Failed to parse state value: %s", value);
|
|
||||||
else
|
else
|
||||||
m->deserialized_state = state;
|
m->deserialized_state = state;
|
||||||
|
|
||||||
@ -1260,7 +1259,7 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F
|
|||||||
|
|
||||||
f = mount_result_from_string(value);
|
f = mount_result_from_string(value);
|
||||||
if (f < 0)
|
if (f < 0)
|
||||||
log_unit_debug_errno(u, f, "Failed to parse result value: %s", value);
|
log_unit_debug(u, "Failed to parse result value: %s", value);
|
||||||
else if (f != MOUNT_SUCCESS)
|
else if (f != MOUNT_SUCCESS)
|
||||||
m->result = f;
|
m->result = f;
|
||||||
|
|
||||||
@ -1269,7 +1268,7 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F
|
|||||||
|
|
||||||
f = mount_result_from_string(value);
|
f = mount_result_from_string(value);
|
||||||
if (f < 0)
|
if (f < 0)
|
||||||
log_unit_debug_errno(u, f, "Failed to parse reload result value: %s", value);
|
log_unit_debug(u, "Failed to parse reload result value: %s", value);
|
||||||
else if (f != MOUNT_SUCCESS)
|
else if (f != MOUNT_SUCCESS)
|
||||||
m->reload_result = f;
|
m->reload_result = f;
|
||||||
|
|
||||||
@ -1277,20 +1276,19 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F
|
|||||||
|
|
||||||
r = safe_atou(value, &m->n_retry_umount);
|
r = safe_atou(value, &m->n_retry_umount);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_unit_debug_errno(u, r, "Failed to parse n-retry-umount value: %s", value);
|
log_unit_debug(u, "Failed to parse n-retry-umount value: %s", value);
|
||||||
|
|
||||||
} else if (streq(key, "control-pid")) {
|
} else if (streq(key, "control-pid")) {
|
||||||
|
|
||||||
r = parse_pid(value, &m->control_pid);
|
if (parse_pid(value, &m->control_pid) < 0)
|
||||||
if (r < 0)
|
log_unit_debug(u, "Failed to parse control-pid value: %s", value);
|
||||||
log_unit_debug_errno(u, r, "Failed to parse control-pid value: %s", value);
|
|
||||||
|
|
||||||
} else if (streq(key, "control-command")) {
|
} else if (streq(key, "control-command")) {
|
||||||
MountExecCommand id;
|
MountExecCommand id;
|
||||||
|
|
||||||
id = mount_exec_command_from_string(value);
|
id = mount_exec_command_from_string(value);
|
||||||
if (id < 0)
|
if (id < 0)
|
||||||
log_unit_debug_errno(u, id, "Failed to parse exec-command value: %s", value);
|
log_unit_debug(u, "Failed to parse exec-command value: %s", value);
|
||||||
else {
|
else {
|
||||||
m->control_command_id = id;
|
m->control_command_id = id;
|
||||||
m->control_command = m->exec_command + id;
|
m->control_command = m->exec_command + id;
|
||||||
|
|||||||
@ -667,7 +667,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
|||||||
|
|
||||||
r = sscanf(value, "%m[0-9a-fA-F-]=%ms", &uuid, &uuid_value);
|
r = sscanf(value, "%m[0-9a-fA-F-]=%ms", &uuid, &uuid_value);
|
||||||
if (r != 2)
|
if (r != 2)
|
||||||
return free_and_strdup_warn(&arg_default_options, value);
|
return free_and_strdup(&arg_default_options, value) < 0 ? log_oom() : 0;
|
||||||
|
|
||||||
if (warn_uuid_invalid(uuid, key))
|
if (warn_uuid_invalid(uuid, key))
|
||||||
return 0;
|
return 0;
|
||||||
@ -691,8 +691,11 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
n = strspn(value, ALPHANUMERICAL "-");
|
n = strspn(value, ALPHANUMERICAL "-");
|
||||||
if (value[n] != '=')
|
if (value[n] != '=') {
|
||||||
return free_and_strdup_warn(&arg_default_keyfile, value);
|
if (free_and_strdup(&arg_default_keyfile, value) < 0)
|
||||||
|
return log_oom();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
uuid = strndup(value, n);
|
uuid = strndup(value, n);
|
||||||
if (!uuid)
|
if (!uuid)
|
||||||
|
|||||||
@ -68,21 +68,27 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
|||||||
else if (r > 0)
|
else if (r > 0)
|
||||||
t = skip_dev_prefix(DEBUGTTY);
|
t = skip_dev_prefix(DEBUGTTY);
|
||||||
|
|
||||||
return free_and_strdup_warn(&arg_debug_shell, t);
|
if (free_and_strdup(&arg_debug_shell, t) < 0)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
} else if (streq(key, "systemd.unit")) {
|
} else if (streq(key, "systemd.unit")) {
|
||||||
|
|
||||||
if (proc_cmdline_value_missing(key, value))
|
if (proc_cmdline_value_missing(key, value))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return free_and_strdup_warn(&arg_default_unit, value);
|
r = free_and_strdup(&arg_default_unit, value);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to set default unit %s: %m", value);
|
||||||
|
|
||||||
} else if (!value) {
|
} else if (!value) {
|
||||||
const char *target;
|
const char *target;
|
||||||
|
|
||||||
target = runlevel_to_target(key);
|
target = runlevel_to_target(key);
|
||||||
if (target)
|
if (target) {
|
||||||
return free_and_strdup_warn(&arg_default_unit, target);
|
r = free_and_strdup(&arg_default_unit, target);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to set default unit %s: %m", target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -210,7 +210,10 @@ static int prompt_loop(const char *text, char **l, unsigned percentage, bool (*i
|
|||||||
}
|
}
|
||||||
|
|
||||||
log_info("Selected '%s'.", l[u-1]);
|
log_info("Selected '%s'.", l[u-1]);
|
||||||
return free_and_strdup_warn(ret, l[u-1]);
|
if (free_and_strdup(ret, l[u-1]) < 0)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_valid(p)) {
|
if (!is_valid(p)) {
|
||||||
@ -1143,9 +1146,9 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ARG_MACHINE_ID:
|
case ARG_MACHINE_ID:
|
||||||
r = sd_id128_from_string(optarg, &arg_machine_id);
|
if (sd_id128_from_string(optarg, &arg_machine_id) < 0)
|
||||||
if (r < 0)
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||||
return log_error_errno(r, "Failed to parse machine id %s.", optarg);
|
"Failed to parse machine id %s.", optarg);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@ -827,14 +827,16 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
|||||||
if (proc_cmdline_value_missing(key, value))
|
if (proc_cmdline_value_missing(key, value))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return free_and_strdup_warn(&arg_root_what, value);
|
if (free_and_strdup(&arg_root_what, value) < 0)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
} else if (streq(key, "rootfstype")) {
|
} else if (streq(key, "rootfstype")) {
|
||||||
|
|
||||||
if (proc_cmdline_value_missing(key, value))
|
if (proc_cmdline_value_missing(key, value))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return free_and_strdup_warn(&arg_root_fstype, value);
|
if (free_and_strdup(&arg_root_fstype, value) < 0)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
} else if (streq(key, "rootflags")) {
|
} else if (streq(key, "rootflags")) {
|
||||||
|
|
||||||
@ -849,21 +851,24 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
|||||||
if (proc_cmdline_value_missing(key, value))
|
if (proc_cmdline_value_missing(key, value))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return free_and_strdup_warn(&arg_root_hash, value);
|
if (free_and_strdup(&arg_root_hash, value) < 0)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
} else if (streq(key, "mount.usr")) {
|
} else if (streq(key, "mount.usr")) {
|
||||||
|
|
||||||
if (proc_cmdline_value_missing(key, value))
|
if (proc_cmdline_value_missing(key, value))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return free_and_strdup_warn(&arg_usr_what, value);
|
if (free_and_strdup(&arg_usr_what, value) < 0)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
} else if (streq(key, "mount.usrfstype")) {
|
} else if (streq(key, "mount.usrfstype")) {
|
||||||
|
|
||||||
if (proc_cmdline_value_missing(key, value))
|
if (proc_cmdline_value_missing(key, value))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return free_and_strdup_warn(&arg_usr_fstype, value);
|
if (free_and_strdup(&arg_usr_fstype, value) < 0)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
} else if (streq(key, "mount.usrflags")) {
|
} else if (streq(key, "mount.usrflags")) {
|
||||||
|
|
||||||
|
|||||||
@ -241,15 +241,13 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
r = free_and_strdup_warn(&arg_mount_type, optarg);
|
if (free_and_strdup(&arg_mount_type, optarg) < 0)
|
||||||
if (r < 0)
|
return log_oom();
|
||||||
return r;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
r = free_and_strdup_warn(&arg_mount_options, optarg);
|
if (free_and_strdup(&arg_mount_options, optarg) < 0)
|
||||||
if (r < 0)
|
return log_oom();
|
||||||
return r;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARG_OWNER: {
|
case ARG_OWNER: {
|
||||||
@ -273,9 +271,8 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ARG_DESCRIPTION:
|
case ARG_DESCRIPTION:
|
||||||
r = free_and_strdup_warn(&arg_description, optarg);
|
if (free_and_strdup(&arg_description, optarg) < 0)
|
||||||
if (r < 0)
|
return log_oom();
|
||||||
return r;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
|
|||||||
@ -577,7 +577,7 @@ int config_parse_l2tp_session_l2spec(
|
|||||||
|
|
||||||
spec = l2tp_l2spec_type_from_string(rvalue);
|
spec = l2tp_l2spec_type_from_string(rvalue);
|
||||||
if (spec < 0) {
|
if (spec < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, spec,
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
"Failed to parse layer2 specific header type. Ignoring assignment: %s", rvalue);
|
"Failed to parse layer2 specific header type. Ignoring assignment: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -139,7 +139,7 @@ int config_parse_netdev_kind(
|
|||||||
|
|
||||||
k = netdev_kind_from_string(rvalue);
|
k = netdev_kind_from_string(rvalue);
|
||||||
if (k < 0) {
|
if (k < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, k, "Failed to parse netdev kind, ignoring assignment: %s", rvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse netdev kind, ignoring assignment: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -581,8 +581,7 @@ int config_parse_tunnel_key(const char *unit,
|
|||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
r = safe_atou32(rvalue, &k);
|
r = safe_atou32(rvalue, &k);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse tunnel key ignoring assignment: %s", rvalue);
|
||||||
"Failed to parse tunnel key ignoring assignment: %s", rvalue);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
|||||||
@ -93,7 +93,7 @@ int config_parse_duid_type(
|
|||||||
|
|
||||||
type = duid_type_from_string(type_string);
|
type = duid_type_from_string(type_string);
|
||||||
if (type < 0) {
|
if (type < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, type,
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
"Failed to parse DUID type '%s', ignoring.", type_string);
|
"Failed to parse DUID type '%s', ignoring.", type_string);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -283,9 +283,16 @@ int config_parse_dhcp(
|
|||||||
/* Previously, we had a slightly different enum here,
|
/* Previously, we had a slightly different enum here,
|
||||||
* support its values for compatibility. */
|
* support its values for compatibility. */
|
||||||
|
|
||||||
s = dhcp_deprecated_address_family_from_string(rvalue);
|
if (streq(rvalue, "none"))
|
||||||
if (s < 0) {
|
s = ADDRESS_FAMILY_NO;
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, s,
|
else if (streq(rvalue, "v4"))
|
||||||
|
s = ADDRESS_FAMILY_IPV4;
|
||||||
|
else if (streq(rvalue, "v6"))
|
||||||
|
s = ADDRESS_FAMILY_IPV6;
|
||||||
|
else if (streq(rvalue, "both"))
|
||||||
|
s = ADDRESS_FAMILY_YES;
|
||||||
|
else {
|
||||||
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
"Failed to parse DHCP option, ignoring: %s", rvalue);
|
"Failed to parse DHCP option, ignoring: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -664,7 +671,7 @@ int config_parse_dhcp_send_option(
|
|||||||
|
|
||||||
type = dhcp_option_data_type_from_string(word);
|
type = dhcp_option_data_type_from_string(word);
|
||||||
if (type < 0) {
|
if (type < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, type,
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
"Invalid DHCP option data type, ignoring assignment: %s", p);
|
"Invalid DHCP option data type, ignoring assignment: %s", p);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,6 @@
|
|||||||
#include "parse-util.h"
|
#include "parse-util.h"
|
||||||
#include "random-util.h"
|
#include "random-util.h"
|
||||||
#include "socket-util.h"
|
#include "socket-util.h"
|
||||||
#include "string-table.h"
|
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
#include "strv.h"
|
#include "strv.h"
|
||||||
#include "unaligned.h"
|
#include "unaligned.h"
|
||||||
@ -416,6 +415,46 @@ void link_lldp_emit_stop(Link *link) {
|
|||||||
link->lldp_emit_event_source = sd_event_source_unref(link->lldp_emit_event_source);
|
link->lldp_emit_event_source = sd_event_source_unref(link->lldp_emit_event_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int config_parse_lldp_emit(
|
||||||
|
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) {
|
||||||
|
|
||||||
|
LLDPEmit *emit = data;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(filename);
|
||||||
|
assert(lvalue);
|
||||||
|
assert(rvalue);
|
||||||
|
|
||||||
|
if (isempty(rvalue))
|
||||||
|
*emit = LLDP_EMIT_NO;
|
||||||
|
else if (streq(rvalue, "nearest-bridge"))
|
||||||
|
*emit = LLDP_EMIT_NEAREST_BRIDGE;
|
||||||
|
else if (streq(rvalue, "non-tpmr-bridge"))
|
||||||
|
*emit = LLDP_EMIT_NON_TPMR_BRIDGE;
|
||||||
|
else if (streq(rvalue, "customer-bridge"))
|
||||||
|
*emit = LLDP_EMIT_CUSTOMER_BRIDGE;
|
||||||
|
else {
|
||||||
|
r = parse_boolean(rvalue);
|
||||||
|
if (r < 0) {
|
||||||
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse LLDP emission setting, ignoring: %s", rvalue);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*emit = r ? LLDP_EMIT_NEAREST_BRIDGE : LLDP_EMIT_NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int config_parse_lldp_mud(
|
int config_parse_lldp_mud(
|
||||||
const char *unit,
|
const char *unit,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
@ -452,13 +491,3 @@ int config_parse_lldp_mud(
|
|||||||
|
|
||||||
return free_and_replace(n->lldp_mud, unescaped);
|
return free_and_replace(n->lldp_mud, unescaped);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char * const lldp_emit_table[_LLDP_EMIT_MAX] = {
|
|
||||||
[LLDP_EMIT_NO] = "no",
|
|
||||||
[LLDP_EMIT_NEAREST_BRIDGE] = "nearest-bridge",
|
|
||||||
[LLDP_EMIT_NON_TPMR_BRIDGE] = "non-tpmr-bridge",
|
|
||||||
[LLDP_EMIT_CUSTOMER_BRIDGE] = "customer-bridge",
|
|
||||||
};
|
|
||||||
|
|
||||||
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING_WITH_BOOLEAN(lldp_emit, LLDPEmit, LLDP_EMIT_NEAREST_BRIDGE);
|
|
||||||
DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_lldp_emit, lldp_emit, LLDPEmit, LLDP_EMIT_NO, "Failed to parse LLDP emission setting");
|
|
||||||
|
|||||||
@ -13,7 +13,6 @@ typedef enum LLDPEmit {
|
|||||||
LLDP_EMIT_NON_TPMR_BRIDGE,
|
LLDP_EMIT_NON_TPMR_BRIDGE,
|
||||||
LLDP_EMIT_CUSTOMER_BRIDGE,
|
LLDP_EMIT_CUSTOMER_BRIDGE,
|
||||||
_LLDP_EMIT_MAX,
|
_LLDP_EMIT_MAX,
|
||||||
_LLDP_EMIT_INVALID = -EINVAL,
|
|
||||||
} LLDPEmit;
|
} LLDPEmit;
|
||||||
|
|
||||||
bool link_lldp_emit_enabled(Link *link);
|
bool link_lldp_emit_enabled(Link *link);
|
||||||
|
|||||||
@ -1178,9 +1178,8 @@ int manager_set_hostname(Manager *m, const char *hostname) {
|
|||||||
|
|
||||||
log_debug("Setting transient hostname: '%s'", strna(hostname));
|
log_debug("Setting transient hostname: '%s'", strna(hostname));
|
||||||
|
|
||||||
r = free_and_strdup_warn(&m->dynamic_hostname, hostname);
|
if (free_and_strdup(&m->dynamic_hostname, hostname) < 0)
|
||||||
if (r < 0)
|
return log_oom();
|
||||||
return r;
|
|
||||||
|
|
||||||
if (!m->bus || sd_bus_is_ready(m->bus) <= 0) {
|
if (!m->bus || sd_bus_is_ready(m->bus) <= 0) {
|
||||||
log_debug("Not connected to system bus, setting hostname later.");
|
log_debug("Not connected to system bus, setting hostname later.");
|
||||||
@ -1228,9 +1227,8 @@ int manager_set_timezone(Manager *m, const char *tz) {
|
|||||||
assert(tz);
|
assert(tz);
|
||||||
|
|
||||||
log_debug("Setting system timezone: '%s'", tz);
|
log_debug("Setting system timezone: '%s'", tz);
|
||||||
r = free_and_strdup_warn(&m->dynamic_timezone, tz);
|
if (free_and_strdup(&m->dynamic_timezone, tz) < 0)
|
||||||
if (r < 0)
|
return log_oom();
|
||||||
return r;
|
|
||||||
|
|
||||||
if (!m->bus || sd_bus_is_ready(m->bus) <= 0) {
|
if (!m->bus || sd_bus_is_ready(m->bus) <= 0) {
|
||||||
log_debug("Not connected to system bus, setting timezone later.");
|
log_debug("Not connected to system bus, setting timezone later.");
|
||||||
|
|||||||
@ -948,7 +948,7 @@ int config_parse_router_prefix_delegation(
|
|||||||
/* For backward compatibility */
|
/* For backward compatibility */
|
||||||
val = radv_prefix_delegation_from_string(rvalue);
|
val = radv_prefix_delegation_from_string(rvalue);
|
||||||
if (val < 0) {
|
if (val < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, val,
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
"Invalid %s= setting, ignoring assignment: %s", lvalue, rvalue);
|
"Invalid %s= setting, ignoring assignment: %s", lvalue, rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,8 +65,21 @@ static const char * const route_scope_table[] = {
|
|||||||
[RT_SCOPE_NOWHERE] = "nowhere",
|
[RT_SCOPE_NOWHERE] = "nowhere",
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(route_scope, int);
|
DEFINE_PRIVATE_STRING_TABLE_LOOKUP(route_scope, int);
|
||||||
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(route_scope, int, UINT8_MAX);
|
|
||||||
|
#define ROUTE_SCOPE_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("nowhere") + 1)
|
||||||
|
static const char *format_route_scope(int scope, char *buf, size_t size) {
|
||||||
|
const char *s;
|
||||||
|
char *p = buf;
|
||||||
|
|
||||||
|
s = route_scope_to_string(scope);
|
||||||
|
if (s)
|
||||||
|
strpcpy(&p, size, s);
|
||||||
|
else
|
||||||
|
strpcpyf(&p, size, "%d", scope);
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
static const char * const route_table_table[] = {
|
static const char * const route_table_table[] = {
|
||||||
[RT_TABLE_DEFAULT] = "default",
|
[RT_TABLE_DEFAULT] = "default",
|
||||||
@ -144,7 +157,7 @@ static const char * const route_protocol_table[] = {
|
|||||||
[RTPROT_STATIC] = "static",
|
[RTPROT_STATIC] = "static",
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING_FALLBACK(route_protocol, int, UINT8_MAX);
|
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(route_protocol, int);
|
||||||
|
|
||||||
static const char * const route_protocol_full_table[] = {
|
static const char * const route_protocol_full_table[] = {
|
||||||
[RTPROT_REDIRECT] = "redirect",
|
[RTPROT_REDIRECT] = "redirect",
|
||||||
@ -169,7 +182,21 @@ static const char * const route_protocol_full_table[] = {
|
|||||||
[RTPROT_EIGRP] = "eigrp",
|
[RTPROT_EIGRP] = "eigrp",
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(route_protocol_full, int, UINT8_MAX);
|
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(route_protocol_full, int);
|
||||||
|
|
||||||
|
#define ROUTE_PROTOCOL_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("redirect") + 1)
|
||||||
|
static const char *format_route_protocol(int protocol, char *buf, size_t size) {
|
||||||
|
const char *s;
|
||||||
|
char *p = buf;
|
||||||
|
|
||||||
|
s = route_protocol_full_to_string(protocol);
|
||||||
|
if (s)
|
||||||
|
strpcpy(&p, size, s);
|
||||||
|
else
|
||||||
|
strpcpyf(&p, size, "%d", protocol);
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned routes_max(void) {
|
static unsigned routes_max(void) {
|
||||||
static thread_local unsigned cached = 0;
|
static thread_local unsigned cached = 0;
|
||||||
@ -613,8 +640,8 @@ static void log_route_debug(const Route *route, const char *str, const Link *lin
|
|||||||
/* link may be NULL. */
|
/* link may be NULL. */
|
||||||
|
|
||||||
if (DEBUG_LOGGING) {
|
if (DEBUG_LOGGING) {
|
||||||
_cleanup_free_ char *dst = NULL, *dst_prefixlen = NULL, *src = NULL, *gw = NULL,
|
_cleanup_free_ char *dst = NULL, *dst_prefixlen = NULL, *src = NULL, *gw = NULL, *prefsrc = NULL, *table = NULL;
|
||||||
*prefsrc = NULL, *table = NULL, *scope = NULL, *proto = NULL;
|
char scope[ROUTE_SCOPE_STR_MAX], protocol[ROUTE_PROTOCOL_STR_MAX];
|
||||||
|
|
||||||
if (!in_addr_is_null(route->family, &route->dst)) {
|
if (!in_addr_is_null(route->family, &route->dst)) {
|
||||||
(void) in_addr_to_string(route->family, &route->dst, &dst);
|
(void) in_addr_to_string(route->family, &route->dst, &dst);
|
||||||
@ -626,14 +653,14 @@ static void log_route_debug(const Route *route, const char *str, const Link *lin
|
|||||||
(void) in_addr_to_string(route->gw_family, &route->gw, &gw);
|
(void) in_addr_to_string(route->gw_family, &route->gw, &gw);
|
||||||
if (!in_addr_is_null(route->family, &route->prefsrc))
|
if (!in_addr_is_null(route->family, &route->prefsrc))
|
||||||
(void) in_addr_to_string(route->family, &route->prefsrc, &prefsrc);
|
(void) in_addr_to_string(route->family, &route->prefsrc, &prefsrc);
|
||||||
(void) route_scope_to_string_alloc(route->scope, &scope);
|
|
||||||
(void) manager_get_route_table_to_string(m, route->table, &table);
|
(void) manager_get_route_table_to_string(m, route->table, &table);
|
||||||
(void) route_protocol_full_to_string_alloc(route->protocol, &proto);
|
|
||||||
|
|
||||||
log_link_debug(link,
|
log_link_debug(link,
|
||||||
"%s route: dst: %s%s, src: %s, gw: %s, prefsrc: %s, scope: %s, table: %s, proto: %s, type: %s",
|
"%s route: dst: %s%s, src: %s, gw: %s, prefsrc: %s, scope: %s, table: %s, proto: %s, type: %s",
|
||||||
str, strna(dst), strempty(dst_prefixlen), strna(src), strna(gw), strna(prefsrc),
|
str, strna(dst), strempty(dst_prefixlen), strna(src), strna(gw), strna(prefsrc),
|
||||||
strna(scope), strna(table), strna(proto),
|
format_route_scope(route->scope, scope, sizeof(scope)),
|
||||||
|
strna(table),
|
||||||
|
format_route_protocol(route->protocol, protocol, sizeof(protocol)),
|
||||||
strna(route_type_to_string(route->type)));
|
strna(route_type_to_string(route->type)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1882,7 +1909,7 @@ int config_parse_route_scope(
|
|||||||
|
|
||||||
r = route_scope_from_string(rvalue);
|
r = route_scope_from_string(rvalue);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, r, "Unknown route scope: %s", rvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Unknown route scope: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2055,13 +2082,16 @@ int config_parse_route_protocol(
|
|||||||
}
|
}
|
||||||
|
|
||||||
r = route_protocol_from_string(rvalue);
|
r = route_protocol_from_string(rvalue);
|
||||||
|
if (r >= 0)
|
||||||
|
n->protocol = r;
|
||||||
|
else {
|
||||||
|
r = safe_atou8(rvalue , &n->protocol);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||||
"Failed to parse route protocol \"%s\", ignoring assignment: %m", rvalue);
|
"Could not parse route protocol \"%s\", ignoring assignment: %m", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
n->protocol = r;
|
|
||||||
|
|
||||||
TAKE_PTR(n);
|
TAKE_PTR(n);
|
||||||
return 0;
|
return 0;
|
||||||
@ -2094,7 +2124,7 @@ int config_parse_route_type(
|
|||||||
|
|
||||||
t = route_type_from_string(rvalue);
|
t = route_type_from_string(rvalue);
|
||||||
if (t < 0) {
|
if (t < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
"Could not parse route type \"%s\", ignoring assignment: %m", rvalue);
|
"Could not parse route type \"%s\", ignoring assignment: %m", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1422,7 +1422,7 @@ int config_parse_routing_policy_rule_family(
|
|||||||
|
|
||||||
a = routing_policy_rule_address_family_from_string(rvalue);
|
a = routing_policy_rule_address_family_from_string(rvalue);
|
||||||
if (a < 0) {
|
if (a < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, a,
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
"Invalid address family '%s', ignoring.", rvalue);
|
"Invalid address family '%s', ignoring.", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1547,7 +1547,7 @@ int config_parse_routing_policy_rule_type(
|
|||||||
|
|
||||||
t = fr_act_type_from_string(rvalue);
|
t = fr_act_type_from_string(rvalue);
|
||||||
if (t < 0) {
|
if (t < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, t,
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
"Could not parse FIB rule type \"%s\", ignoring assignment: %m", rvalue);
|
"Could not parse FIB rule type \"%s\", ignoring assignment: %m", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,13 +28,6 @@ static const char* const duplicate_address_detection_address_family_table[_ADDRE
|
|||||||
[ADDRESS_FAMILY_IPV6] = "ipv6",
|
[ADDRESS_FAMILY_IPV6] = "ipv6",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char* const dhcp_deprecated_address_family_table[_ADDRESS_FAMILY_MAX] = {
|
|
||||||
[ADDRESS_FAMILY_NO] = "none",
|
|
||||||
[ADDRESS_FAMILY_YES] = "both",
|
|
||||||
[ADDRESS_FAMILY_IPV4] = "v4",
|
|
||||||
[ADDRESS_FAMILY_IPV6] = "v6",
|
|
||||||
};
|
|
||||||
|
|
||||||
static const char* const dhcp_lease_server_type_table[_SD_DHCP_LEASE_SERVER_TYPE_MAX] = {
|
static const char* const dhcp_lease_server_type_table[_SD_DHCP_LEASE_SERVER_TYPE_MAX] = {
|
||||||
[SD_DHCP_LEASE_DNS] = "DNS servers",
|
[SD_DHCP_LEASE_DNS] = "DNS servers",
|
||||||
[SD_DHCP_LEASE_NTP] = "NTP servers",
|
[SD_DHCP_LEASE_NTP] = "NTP servers",
|
||||||
@ -58,7 +51,6 @@ DEFINE_STRING_TABLE_LOOKUP(routing_policy_rule_address_family, AddressFamily);
|
|||||||
DEFINE_STRING_TABLE_LOOKUP(duplicate_address_detection_address_family, AddressFamily);
|
DEFINE_STRING_TABLE_LOOKUP(duplicate_address_detection_address_family, AddressFamily);
|
||||||
DEFINE_CONFIG_PARSE_ENUM(config_parse_link_local_address_family, link_local_address_family,
|
DEFINE_CONFIG_PARSE_ENUM(config_parse_link_local_address_family, link_local_address_family,
|
||||||
AddressFamily, "Failed to parse option");
|
AddressFamily, "Failed to parse option");
|
||||||
DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(dhcp_deprecated_address_family, AddressFamily);
|
|
||||||
DEFINE_STRING_TABLE_LOOKUP(dhcp_lease_server_type, sd_dhcp_lease_server_type);
|
DEFINE_STRING_TABLE_LOOKUP(dhcp_lease_server_type, sd_dhcp_lease_server_type);
|
||||||
|
|
||||||
int config_parse_address_family_with_kernel(
|
int config_parse_address_family_with_kernel(
|
||||||
|
|||||||
@ -40,8 +40,6 @@ AddressFamily routing_policy_rule_address_family_from_string(const char *s) _pur
|
|||||||
const char *duplicate_address_detection_address_family_to_string(AddressFamily b) _const_;
|
const char *duplicate_address_detection_address_family_to_string(AddressFamily b) _const_;
|
||||||
AddressFamily duplicate_address_detection_address_family_from_string(const char *s) _pure_;
|
AddressFamily duplicate_address_detection_address_family_from_string(const char *s) _pure_;
|
||||||
|
|
||||||
AddressFamily dhcp_deprecated_address_family_from_string(const char *s) _pure_;
|
|
||||||
|
|
||||||
const char *dhcp_lease_server_type_to_string(sd_dhcp_lease_server_type t) _const_;
|
const char *dhcp_lease_server_type_to_string(sd_dhcp_lease_server_type t) _const_;
|
||||||
sd_dhcp_lease_server_type dhcp_lease_server_type_from_string(const char *s) _pure_;
|
sd_dhcp_lease_server_type dhcp_lease_server_type_from_string(const char *s) _pure_;
|
||||||
|
|
||||||
|
|||||||
@ -706,7 +706,10 @@ int config_parse_hostname(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return free_and_strdup_warn(s, empty_to_null(rvalue));
|
if (free_and_strdup(s, empty_to_null(rvalue)) < 0)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int config_parse_oom_score_adjust(
|
int config_parse_oom_score_adjust(
|
||||||
|
|||||||
@ -39,14 +39,16 @@ static int parse(const char *key, const char *value, void *data) {
|
|||||||
if (proc_cmdline_value_missing(key, value))
|
if (proc_cmdline_value_missing(key, value))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return free_and_strdup_warn(&arg_success_action, value);
|
if (free_and_strdup(&arg_success_action, value) < 0)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
} else if (proc_cmdline_key_streq(key, "systemd.run_failure_action")) {
|
} else if (proc_cmdline_key_streq(key, "systemd.run_failure_action")) {
|
||||||
|
|
||||||
if (proc_cmdline_value_missing(key, value))
|
if (proc_cmdline_value_missing(key, value))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return free_and_strdup_warn(&arg_failure_action, value);
|
if (free_and_strdup(&arg_failure_action, value) < 0)
|
||||||
|
return log_oom();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -487,17 +487,6 @@ static int has_tpm2(void) {
|
|||||||
* class device */
|
* class device */
|
||||||
|
|
||||||
r = dir_is_empty("/sys/class/tpmrm");
|
r = dir_is_empty("/sys/class/tpmrm");
|
||||||
if (r == 0)
|
|
||||||
return true; /* nice! we have a device */
|
|
||||||
|
|
||||||
/* Hmm, so Linux doesn't know of the TPM2 device (or we couldn't check for it), most likely because
|
|
||||||
* the driver wasn't loaded yet. Let's see if the firmware knows about a TPM2 device, in this
|
|
||||||
* case. This way we can answer the TPM2 question already during early boot (where we most likely
|
|
||||||
* need it) */
|
|
||||||
if (efi_has_tpm2())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
/* OK, this didn't work either, in this case propagate the original errors */
|
|
||||||
if (r == -ENOENT)
|
if (r == -ENOENT)
|
||||||
return false;
|
return false;
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
|||||||
@ -731,7 +731,10 @@ int config_parse_string(
|
|||||||
assert(rvalue);
|
assert(rvalue);
|
||||||
assert(data);
|
assert(data);
|
||||||
|
|
||||||
return free_and_strdup_warn(s, empty_to_null(rvalue));
|
if (free_and_strdup(s, empty_to_null(rvalue)) < 0)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int config_parse_path(
|
int config_parse_path(
|
||||||
@ -871,7 +874,7 @@ int config_parse_log_facility(
|
|||||||
|
|
||||||
x = log_facility_unshifted_from_string(rvalue);
|
x = log_facility_unshifted_from_string(rvalue);
|
||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, x, "Failed to parse log facility, ignoring: %s", rvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse log facility, ignoring: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -901,7 +904,7 @@ int config_parse_log_level(
|
|||||||
|
|
||||||
x = log_level_from_string(rvalue);
|
x = log_level_from_string(rvalue);
|
||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, x, "Failed to parse log level, ignoring: %s", rvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse log level, ignoring: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -934,7 +937,7 @@ int config_parse_signal(
|
|||||||
|
|
||||||
r = signal_from_string(rvalue);
|
r = signal_from_string(rvalue);
|
||||||
if (r <= 0) {
|
if (r <= 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse signal name, ignoring: %s", rvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse signal name, ignoring: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -207,7 +207,7 @@ typedef enum Disabled {
|
|||||||
\
|
\
|
||||||
x = from_string(rvalue); \
|
x = from_string(rvalue); \
|
||||||
if (x < 0) { \
|
if (x < 0) { \
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, x, \
|
log_syntax(unit, LOG_WARNING, filename, line, 0, \
|
||||||
msg ", ignoring: %s", rvalue); \
|
msg ", ignoring: %s", rvalue); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
@ -235,7 +235,7 @@ typedef enum Disabled {
|
|||||||
\
|
\
|
||||||
x = name##_from_string(rvalue); \
|
x = name##_from_string(rvalue); \
|
||||||
if (x < 0) { \
|
if (x < 0) { \
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, x, \
|
log_syntax(unit, LOG_WARNING, filename, line, 0, \
|
||||||
msg ", ignoring: %s", rvalue); \
|
msg ", ignoring: %s", rvalue); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
@ -269,17 +269,14 @@ typedef enum Disabled {
|
|||||||
r = extract_first_word(&p, &en, NULL, 0); \
|
r = extract_first_word(&p, &en, NULL, 0); \
|
||||||
if (r == -ENOMEM) \
|
if (r == -ENOMEM) \
|
||||||
return log_oom(); \
|
return log_oom(); \
|
||||||
if (r < 0) { \
|
if (r < 0) \
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, r, \
|
return log_syntax(unit, LOG_ERR, filename, line, 0, \
|
||||||
msg ", ignoring: %s", en); \
|
msg ": %s", en); \
|
||||||
return 0; \
|
|
||||||
} \
|
|
||||||
if (r == 0) \
|
if (r == 0) \
|
||||||
break; \
|
break; \
|
||||||
\
|
\
|
||||||
x = name##_from_string(en); \
|
if ((x = name##_from_string(en)) < 0) { \
|
||||||
if (x < 0) { \
|
log_syntax(unit, LOG_WARNING, filename, line, 0, \
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, x, \
|
|
||||||
msg ", ignoring: %s", en); \
|
msg ", ignoring: %s", en); \
|
||||||
continue; \
|
continue; \
|
||||||
} \
|
} \
|
||||||
|
|||||||
@ -783,29 +783,6 @@ int efi_loader_update_entry_one_shot_cache(char **cache, struct stat *cache_stat
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool efi_has_tpm2(void) {
|
|
||||||
static int cache = -1;
|
|
||||||
|
|
||||||
/* Returns whether the system has a TPM2 chip which is known to the EFI firmware. */
|
|
||||||
|
|
||||||
if (cache < 0) {
|
|
||||||
|
|
||||||
/* First, check if we are on an EFI boot at all. */
|
|
||||||
if (!is_efi_boot())
|
|
||||||
cache = false;
|
|
||||||
else {
|
|
||||||
/* Then, check if the ACPI table "TPM2" exists, which is the TPM2 event log table, see:
|
|
||||||
* https://trustedcomputinggroup.org/wp-content/uploads/TCG_ACPIGeneralSpecification_v1.20_r8.pdf
|
|
||||||
* This table exists whenever the firmware is hooked up to TPM2. */
|
|
||||||
cache = access("/sys/firmware/acpi/tables/TPM2", F_OK) >= 0;
|
|
||||||
if (!cache && errno != ENOENT)
|
|
||||||
log_debug_errno(errno, "Unable to test whether /sys/firmware/acpi/tables/TPM2 exists, assuming it doesn't: %m");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return cache;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool efi_loader_entry_name_valid(const char *s) {
|
bool efi_loader_entry_name_valid(const char *s) {
|
||||||
|
|||||||
@ -29,8 +29,6 @@ int efi_loader_get_features(uint64_t *ret);
|
|||||||
int efi_loader_get_config_timeout_one_shot(usec_t *ret);
|
int efi_loader_get_config_timeout_one_shot(usec_t *ret);
|
||||||
int efi_loader_update_entry_one_shot_cache(char **cache, struct stat *cache_stat);
|
int efi_loader_update_entry_one_shot_cache(char **cache, struct stat *cache_stat);
|
||||||
|
|
||||||
bool efi_has_tpm2(void);
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static inline int efi_reboot_to_firmware_supported(void) {
|
static inline int efi_reboot_to_firmware_supported(void) {
|
||||||
@ -93,10 +91,6 @@ static inline int efi_loader_update_entry_one_shot_cache(char **cache, struct st
|
|||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool efi_has_tpm2(void) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool efi_loader_entry_name_valid(const char *s);
|
bool efi_loader_entry_name_valid(const char *s);
|
||||||
|
|||||||
@ -1092,7 +1092,7 @@ int config_parse_advertise(const char *unit,
|
|||||||
/* We reuse the kernel provided enum which does not contain negative value. So, the cast
|
/* We reuse the kernel provided enum which does not contain negative value. So, the cast
|
||||||
* below is mandatory. Otherwise, the check below always passes and access an invalid address. */
|
* below is mandatory. Otherwise, the check below always passes and access an invalid address. */
|
||||||
if ((int) mode < 0) {
|
if ((int) mode < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, mode,
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
"Failed to parse advertise mode, ignoring: %s", w);
|
"Failed to parse advertise mode, ignoring: %s", w);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -702,7 +702,10 @@ int config_parse_ifalias(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return free_and_strdup_warn(s, rvalue);
|
if (free_and_strdup(s, rvalue) < 0)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int config_parse_rx_tx_queues(
|
int config_parse_rx_tx_queues(
|
||||||
|
|||||||
@ -2055,9 +2055,8 @@ static int udev_rule_apply_token_to_event(
|
|||||||
token->value);
|
token->value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
r = free_and_strdup_warn(&event->name, buf);
|
if (free_and_strdup(&event->name, buf) < 0)
|
||||||
if (r < 0)
|
return log_oom();
|
||||||
return r;
|
|
||||||
|
|
||||||
log_rule_debug(dev, rules, "NAME '%s'", event->name);
|
log_rule_debug(dev, rules, "NAME '%s'", event->name);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -210,21 +210,16 @@ int trigger_main(int argc, char *argv[], void *userdata) {
|
|||||||
else
|
else
|
||||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown type --type=%s", optarg);
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown type --type=%s", optarg);
|
||||||
break;
|
break;
|
||||||
case 'c': {
|
case 'c':
|
||||||
DeviceAction a;
|
|
||||||
|
|
||||||
if (streq(optarg, "help")) {
|
if (streq(optarg, "help")) {
|
||||||
dump_device_action_table();
|
dump_device_action_table();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (device_action_from_string(optarg) < 0)
|
||||||
a = device_action_from_string(optarg);
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown action '%s'", optarg);
|
||||||
if (a < 0)
|
|
||||||
return log_error_errno(a, "Unknown action '%s'", optarg);
|
|
||||||
|
|
||||||
action = optarg;
|
action = optarg;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case 's':
|
case 's':
|
||||||
r = sd_device_enumerator_add_match_subsystem(e, optarg, true);
|
r = sd_device_enumerator_add_match_subsystem(e, optarg, true);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user