Merge pull request #17003 from yuwata/conf-parser-downgrade-log-level

tree-wide: downgrade log level in conf-parsers
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-09-10 15:43:29 +02:00 committed by GitHub
commit f29d38b7d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 456 additions and 456 deletions

File diff suppressed because it is too large Load diff

View file

@ -45,7 +45,7 @@ int config_parse_default_file_system_type(
assert(s); assert(s);
if (!isempty(rvalue) && !supported_fstype(rvalue)) { if (!isempty(rvalue) && !supported_fstype(rvalue)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Unsupported file system, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Unsupported file system, ignoring: %s", rvalue);
return 0; return 0;
} }

View file

@ -2551,7 +2551,7 @@ int config_parse_line_max(
r = parse_size(rvalue, 1024, &v); r = parse_size(rvalue, 1024, &v);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse LineMax= value, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse LineMax= value, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -2606,7 +2606,7 @@ int config_parse_compress(
if (r < 0) { if (r < 0) {
r = parse_size(rvalue, 1024, &compress->threshold_bytes); r = parse_size(rvalue, 1024, &compress->threshold_bytes);
if (r < 0) if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse Compress= value, ignoring: %s", rvalue); "Failed to parse Compress= value, ignoring: %s", rvalue);
else else
compress->enabled = true; compress->enabled = true;

View file

@ -466,12 +466,14 @@ int config_parse_n_autovts(
r = safe_atou(rvalue, &o); r = safe_atou(rvalue, &o);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse number of autovts, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse number of autovts, ignoring: %s", rvalue);
return 0; return 0;
} }
if (o > 15) { if (o > 15) {
log_syntax(unit, LOG_ERR, filename, line, r, "A maximum of 15 autovts are supported, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0,
"A maximum of 15 autovts are supported, ignoring: %s", rvalue);
return 0; return 0;
} }

View file

@ -919,7 +919,7 @@ int config_parse_tmpfs_size(
if (r >= 0 && (k <= 0 || (uint64_t) (size_t) k != k)) if (r >= 0 && (k <= 0 || (uint64_t) (size_t) k != k))
r = -ERANGE; r = -ERANGE;
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse size value '%s', ignoring: %m", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse size value '%s', ignoring: %m", rvalue);
return 0; return 0;
} }

View file

@ -847,13 +847,16 @@ int config_parse_macsec_key_id(
return log_oom(); return log_oom();
r = unhexmem(rvalue, strlen(rvalue), &p, &l); r = unhexmem(rvalue, strlen(rvalue), &p, &l);
if (r == -ENOMEM)
return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse KeyId \"%s\": %m", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse KeyId=%s, ignoring assignment: %m", rvalue);
return 0; return 0;
} }
if (l > MACSEC_KEYID_LEN) { if (l > MACSEC_KEYID_LEN) {
log_syntax(unit, LOG_WARNING, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Specified KeyId is larger then the allowed maximum (%zu > %u), ignoring: %s", "Specified KeyId= is larger then the allowed maximum (%zu > %u), ignoring: %s",
l, MACSEC_KEYID_LEN, rvalue); l, MACSEC_KEYID_LEN, rvalue);
return 0; return 0;
} }

View file

@ -220,8 +220,8 @@ WireGuard.PrivateKey, config_parse_wireguard_private_key,
WireGuard.PrivateKeyFile, config_parse_wireguard_private_key_file, 0, 0 WireGuard.PrivateKeyFile, config_parse_wireguard_private_key_file, 0, 0
WireGuardPeer.AllowedIPs, config_parse_wireguard_allowed_ips, 0, 0 WireGuardPeer.AllowedIPs, config_parse_wireguard_allowed_ips, 0, 0
WireGuardPeer.Endpoint, config_parse_wireguard_endpoint, 0, 0 WireGuardPeer.Endpoint, config_parse_wireguard_endpoint, 0, 0
WireGuardPeer.PublicKey, config_parse_wireguard_public_key, 0, 0 WireGuardPeer.PublicKey, config_parse_wireguard_peer_key, 0, 0
WireGuardPeer.PresharedKey, config_parse_wireguard_preshared_key, 0, 0 WireGuardPeer.PresharedKey, config_parse_wireguard_peer_key, 0, 0
WireGuardPeer.PresharedKeyFile, config_parse_wireguard_preshared_key_file, 0, 0 WireGuardPeer.PresharedKeyFile, config_parse_wireguard_preshared_key_file, 0, 0
WireGuardPeer.PersistentKeepalive, config_parse_wireguard_keepalive, 0, 0 WireGuardPeer.PersistentKeepalive, config_parse_wireguard_keepalive, 0, 0
Xfrm.InterfaceId, config_parse_uint32, 0, offsetof(Xfrm, if_id) Xfrm.InterfaceId, config_parse_uint32, 0, offsetof(Xfrm, if_id)

View file

@ -492,6 +492,8 @@ static int wireguard_decode_key_and_warn(
(void) warn_file_is_world_accessible(filename, NULL, unit, line); (void) warn_file_is_world_accessible(filename, NULL, unit, line);
r = unbase64mem_full(rvalue, strlen(rvalue), true, &key, &len); r = unbase64mem_full(rvalue, strlen(rvalue), true, &key, &len);
if (r == -ENOMEM)
return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to decode wireguard key provided by %s=, ignoring assignment: %m", lvalue); "Failed to decode wireguard key provided by %s=, ignoring assignment: %m", lvalue);
@ -526,8 +528,7 @@ int config_parse_wireguard_private_key(
w = WIREGUARD(data); w = WIREGUARD(data);
assert(w); assert(w);
(void) wireguard_decode_key_and_warn(rvalue, w->private_key, unit, filename, line, lvalue); return wireguard_decode_key_and_warn(rvalue, w->private_key, unit, filename, line, lvalue);
return 0;
} }
int config_parse_wireguard_private_key_file( int config_parse_wireguard_private_key_file(
@ -564,7 +565,7 @@ int config_parse_wireguard_private_key_file(
return free_and_replace(w->private_key_file, path); return free_and_replace(w->private_key_file, path);
} }
int config_parse_wireguard_preshared_key( int config_parse_wireguard_peer_key(
const char *unit, const char *unit,
const char *filename, const char *filename,
unsigned line, unsigned line,
@ -576,7 +577,7 @@ int config_parse_wireguard_preshared_key(
void *data, void *data,
void *userdata) { void *userdata) {
WireguardPeer *peer; _cleanup_(wireguard_peer_free_or_set_invalidp) WireguardPeer *peer = NULL;
Wireguard *w; Wireguard *w;
int r; int r;
@ -588,7 +589,13 @@ int config_parse_wireguard_preshared_key(
if (r < 0) if (r < 0)
return log_oom(); return log_oom();
(void) wireguard_decode_key_and_warn(rvalue, peer->preshared_key, unit, filename, line, lvalue); r = wireguard_decode_key_and_warn(rvalue,
streq(lvalue, "PublicKey") ? peer->public_key : peer->preshared_key,
unit, filename, line, lvalue);
if (r < 0)
return r;
TAKE_PTR(peer);
return 0; return 0;
} }
@ -635,38 +642,6 @@ int config_parse_wireguard_preshared_key_file(
return 0; return 0;
} }
int config_parse_wireguard_public_key(
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) {
_cleanup_(wireguard_peer_free_or_set_invalidp) WireguardPeer *peer = NULL;
Wireguard *w;
int r;
assert(data);
w = WIREGUARD(data);
assert(w);
r = wireguard_peer_new_static(w, filename, section_line, &peer);
if (r < 0)
return log_oom();
r = wireguard_decode_key_and_warn(rvalue, peer->public_key, unit, filename, line, lvalue);
if (r < 0)
return 0;
TAKE_PTR(peer);
return 0;
}
int config_parse_wireguard_allowed_ips( int config_parse_wireguard_allowed_ips(
const char *unit, const char *unit,
const char *filename, const char *filename,
@ -821,7 +796,7 @@ int config_parse_wireguard_keepalive(
void *data, void *data,
void *userdata) { void *userdata) {
WireguardPeer *peer; _cleanup_(wireguard_peer_free_or_set_invalidp) WireguardPeer *peer = NULL;
uint16_t keepalive = 0; uint16_t keepalive = 0;
Wireguard *w; Wireguard *w;
int r; int r;
@ -849,6 +824,8 @@ int config_parse_wireguard_keepalive(
} }
peer->persistent_keepalive_interval = keepalive; peer->persistent_keepalive_interval = keepalive;
TAKE_PTR(peer);
return 0; return 0;
} }

View file

@ -61,10 +61,8 @@ extern const NetDevVTable wireguard_vtable;
CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_allowed_ips); CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_allowed_ips);
CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_endpoint); CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_endpoint);
CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_listen_port); CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_listen_port);
CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_peer_key);
CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_public_key);
CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_private_key); CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_private_key);
CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_private_key_file); CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_private_key_file);
CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_preshared_key);
CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_preshared_key_file); CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_preshared_key_file);
CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_keepalive); CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_keepalive);

View file

@ -233,14 +233,10 @@ int config_parse_expose_port(
assert(rvalue); assert(rvalue);
r = expose_port_parse(&s->expose_ports, rvalue); r = expose_port_parse(&s->expose_ports, rvalue);
if (r == -EEXIST) { if (r == -EEXIST)
log_syntax(unit, LOG_ERR, filename, line, r, "Duplicate port specification, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Duplicate port specification, ignoring: %s", rvalue);
return 0; else if (r < 0)
} log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse host port %s: %m", rvalue);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse host port %s: %m", rvalue);
return 0;
}
return 0; return 0;
} }
@ -268,8 +264,10 @@ int config_parse_capability(
_cleanup_free_ char *word = NULL; _cleanup_free_ char *word = NULL;
r = extract_first_word(&rvalue, &word, NULL, 0); r = extract_first_word(&rvalue, &word, NULL, 0);
if (r == -ENOMEM)
return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to extract capability string, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to extract capability string, ignoring: %s", rvalue);
return 0; return 0;
} }
if (r == 0) if (r == 0)
@ -280,7 +278,7 @@ int config_parse_capability(
else { else {
r = capability_from_name(word); r = capability_from_name(word);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse capability, ignoring: %s", word); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse capability, ignoring: %s", word);
continue; continue;
} }
@ -315,10 +313,8 @@ int config_parse_pivot_root(
assert(rvalue); assert(rvalue);
r = pivot_root_parse(&settings->pivot_root_new, &settings->pivot_root_old, rvalue); r = pivot_root_parse(&settings->pivot_root_new, &settings->pivot_root_old, rvalue);
if (r < 0) { if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r, "Invalid pivot root mount specification %s: %m", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid pivot root mount specification %s: %m", rvalue);
return 0;
}
return 0; return 0;
} }
@ -343,10 +339,8 @@ int config_parse_bind(
assert(rvalue); assert(rvalue);
r = bind_mount_parse(&settings->custom_mounts, &settings->n_custom_mounts, rvalue, ltype); r = bind_mount_parse(&settings->custom_mounts, &settings->n_custom_mounts, rvalue, ltype);
if (r < 0) { if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r, "Invalid bind mount specification %s: %m", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid bind mount specification %s: %m", rvalue);
return 0;
}
return 0; return 0;
} }
@ -371,10 +365,8 @@ int config_parse_tmpfs(
assert(rvalue); assert(rvalue);
r = tmpfs_mount_parse(&settings->custom_mounts, &settings->n_custom_mounts, rvalue); r = tmpfs_mount_parse(&settings->custom_mounts, &settings->n_custom_mounts, rvalue);
if (r < 0) { if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r, "Invalid temporary file system specification %s: %m", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid temporary file system specification %s: %m", rvalue);
return 0;
}
return 0; return 0;
} }
@ -399,10 +391,8 @@ int config_parse_inaccessible(
assert(rvalue); assert(rvalue);
r = inaccessible_mount_parse(&settings->custom_mounts, &settings->n_custom_mounts, rvalue); r = inaccessible_mount_parse(&settings->custom_mounts, &settings->n_custom_mounts, rvalue);
if (r < 0) { if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r, "Invalid inaccessible file system specification %s: %m", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid inaccessible file system specification %s: %m", rvalue);
return 0;
}
return 0; return 0;
} }
@ -428,7 +418,7 @@ int config_parse_overlay(
r = overlay_mount_parse(&settings->custom_mounts, &settings->n_custom_mounts, rvalue, ltype); r = overlay_mount_parse(&settings->custom_mounts, &settings->n_custom_mounts, rvalue, ltype);
if (r < 0) if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r, "Invalid overlay file system specification %s, ignoring: %m", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid overlay file system specification %s, ignoring: %m", rvalue);
return 0; return 0;
} }
@ -453,10 +443,8 @@ int config_parse_veth_extra(
assert(rvalue); assert(rvalue);
r = veth_extra_parse(&settings->network_veth_extra, rvalue); r = veth_extra_parse(&settings->network_veth_extra, rvalue);
if (r < 0) { if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r, "Invalid extra virtual Ethernet link specification %s: %m", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid extra virtual Ethernet link specification %s: %m", rvalue);
return 0;
}
return 0; return 0;
} }
@ -482,13 +470,11 @@ int config_parse_network_zone(
j = strjoin("vz-", rvalue); j = strjoin("vz-", rvalue);
if (!ifname_valid(j)) { if (!ifname_valid(j)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid network zone name, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid network zone name, ignoring: %s", rvalue);
return 0; return 0;
} }
free_and_replace(settings->network_zone, j); return free_and_replace(settings->network_zone, j);
return 0;
} }
int config_parse_boot( int config_parse_boot(
@ -512,11 +498,11 @@ int config_parse_boot(
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse Boot= parameter %s, ignoring: %m", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse Boot= parameter %s, ignoring: %m", rvalue);
return 0; return 0;
} }
if (r > 0) { if (r) {
if (settings->start_mode == START_PID2) if (settings->start_mode == START_PID2)
goto conflict; goto conflict;
@ -532,7 +518,7 @@ int config_parse_boot(
return 0; return 0;
conflict: conflict:
log_syntax(unit, LOG_ERR, filename, line, r, "Conflicting Boot= or ProcessTwo= setting found. Ignoring."); log_syntax(unit, LOG_WARNING, filename, line, 0, "Conflicting Boot= or ProcessTwo= setting found. Ignoring.");
return 0; return 0;
} }
@ -557,11 +543,11 @@ int config_parse_pid2(
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse ProcessTwo= parameter %s, ignoring: %m", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse ProcessTwo= parameter %s, ignoring: %m", rvalue);
return 0; return 0;
} }
if (r > 0) { if (r) {
if (settings->start_mode == START_BOOT) if (settings->start_mode == START_BOOT)
goto conflict; goto conflict;
@ -577,7 +563,7 @@ int config_parse_pid2(
return 0; return 0;
conflict: conflict:
log_syntax(unit, LOG_ERR, filename, line, r, "Conflicting Boot= or ProcessTwo= setting found. Ignoring."); log_syntax(unit, LOG_WARNING, filename, line, 0, "Conflicting Boot= or ProcessTwo= setting found. Ignoring.");
return 0; return 0;
} }
@ -629,7 +615,7 @@ int config_parse_private_users(
r = safe_atou32(range, &rn); r = safe_atou32(range, &rn);
if (r < 0 || rn <= 0) { if (r < 0 || rn <= 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "UID/GID range invalid, ignoring: %s", range); log_syntax(unit, LOG_WARNING, filename, line, r, "UID/GID range invalid, ignoring: %s", range);
return 0; return 0;
} }
} else { } else {
@ -639,7 +625,7 @@ int config_parse_private_users(
r = parse_uid(shift, &sh); r = parse_uid(shift, &sh);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "UID/GID shift invalid, ignoring: %s", range); log_syntax(unit, LOG_WARNING, filename, line, r, "UID/GID shift invalid, ignoring: %s", range);
return 0; return 0;
} }
@ -680,11 +666,12 @@ int config_parse_syscall_filter(
r = extract_first_word(&items, &word, NULL, 0); r = extract_first_word(&items, &word, NULL, 0);
if (r == 0) if (r == 0)
break; return 0;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse SystemCallFilter= parameter %s, ignoring: %m", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse SystemCallFilter= parameter %s, ignoring: %m", rvalue);
return 0; return 0;
} }
@ -695,8 +682,6 @@ int config_parse_syscall_filter(
if (r < 0) if (r < 0)
return log_oom(); return log_oom();
} }
return 0;
} }
int config_parse_hostname( int config_parse_hostname(
@ -717,7 +702,7 @@ int config_parse_hostname(
assert(s); assert(s);
if (!hostname_is_valid(rvalue, false)) { if (!hostname_is_valid(rvalue, false)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid hostname, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid hostname, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -752,11 +737,11 @@ int config_parse_oom_score_adjust(
r = parse_oom_score_adjust(rvalue, &oa); r = parse_oom_score_adjust(rvalue, &oa);
if (r == -ERANGE) { if (r == -ERANGE) {
log_syntax(unit, LOG_ERR, filename, line, r, "OOM score adjust value out of range, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "OOM score adjust value out of range, ignoring: %s", rvalue);
return 0; return 0;
} }
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse the OOM score adjust value, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse the OOM score adjust value, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -863,10 +848,8 @@ int config_parse_link_journal(
assert(settings); assert(settings);
r = parse_link_journal(rvalue, &settings->link_journal, &settings->link_journal_try); r = parse_link_journal(rvalue, &settings->link_journal, &settings->link_journal_try);
if (r < 0) { if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse link journal mode, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse link journal mode, ignoring: %s", rvalue);
return 0;
}
return 0; return 0;
} }

View file

@ -947,7 +947,7 @@ static int config_parse_label(
r = specifier_printf(rvalue, specifier_table, NULL, &resolved); r = specifier_printf(rvalue, specifier_table, NULL, &resolved);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to expand specifiers in Label=, ignoring: %s", rvalue); "Failed to expand specifiers in Label=, ignoring: %s", rvalue);
return 0; return 0;
} }

View file

@ -1754,7 +1754,6 @@ static int bus_method_register_service(sd_bus_message *message, void *userdata,
_cleanup_(dnssd_service_freep) DnssdService *service = NULL; _cleanup_(dnssd_service_freep) DnssdService *service = NULL;
_cleanup_(sd_bus_track_unrefp) sd_bus_track *bus_track = NULL; _cleanup_(sd_bus_track_unrefp) sd_bus_track *bus_track = NULL;
_cleanup_free_ char *path = NULL; _cleanup_free_ char *path = NULL;
_cleanup_free_ char *instance_name = NULL;
Manager *m = userdata; Manager *m = userdata;
DnssdService *s = NULL; DnssdService *s = NULL;
const char *name; const char *name;
@ -1795,6 +1794,10 @@ static int bus_method_register_service(sd_bus_message *message, void *userdata,
if (!dnssd_srv_type_is_valid(type)) if (!dnssd_srv_type_is_valid(type))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "DNS-SD service type '%s' is invalid", type); return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "DNS-SD service type '%s' is invalid", type);
r = dnssd_render_instance_name(name_template, NULL);
if (r < 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "DNS-SD service name '%s' is invalid", name_template);
service->name = strdup(name); service->name = strdup(name);
if (!service->name) if (!service->name)
return log_oom(); return log_oom();
@ -1807,10 +1810,6 @@ static int bus_method_register_service(sd_bus_message *message, void *userdata,
if (!service->type) if (!service->type)
return log_oom(); return log_oom();
r = dnssd_render_instance_name(service, &instance_name);
if (r < 0)
return r;
r = sd_bus_message_enter_container(message, SD_BUS_TYPE_ARRAY, "a{say}"); r = sd_bus_message_enter_container(message, SD_BUS_TYPE_ARRAY, "a{say}");
if (r < 0) if (r < 0)
return r; return r;

View file

@ -168,7 +168,8 @@ int config_parse_dns_servers(
/* Otherwise, add to the list */ /* Otherwise, add to the list */
r = manager_parse_dns_server_string_and_warn(m, ltype, rvalue); r = manager_parse_dns_server_string_and_warn(m, ltype, rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse DNS server string '%s'. Ignoring.", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse DNS server string '%s', ignoring.", rvalue);
return 0; return 0;
} }
} }
@ -210,7 +211,8 @@ int config_parse_search_domains(
/* Otherwise, add to the list */ /* Otherwise, add to the list */
r = manager_parse_search_domains_and_warn(m, rvalue); r = manager_parse_search_domains_and_warn(m, rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse search domains string '%s'. Ignoring.", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse search domains string '%s', ignoring.", rvalue);
return 0; return 0;
} }
} }
@ -222,21 +224,19 @@ int config_parse_search_domains(
return 0; return 0;
} }
int config_parse_dnssd_service_name(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) { int config_parse_dnssd_service_name(
static const Specifier specifier_table[] = { const char *unit,
{ 'm', specifier_machine_id, NULL }, const char *filename,
{ 'b', specifier_boot_id, NULL }, unsigned line,
{ 'H', specifier_host_name, NULL }, const char *section,
{ 'v', specifier_kernel_release, NULL }, unsigned section_line,
{ 'a', specifier_architecture, NULL }, const char *lvalue,
{ 'o', specifier_os_id, NULL }, int ltype,
{ 'w', specifier_os_version_id, NULL }, const char *rvalue,
{ 'B', specifier_os_build_id, NULL }, void *data,
{ 'W', specifier_os_variant_id, NULL }, void *userdata) {
{}
};
DnssdService *s = userdata; DnssdService *s = userdata;
_cleanup_free_ char *name = NULL;
int r; int r;
assert(filename); assert(filename);
@ -245,27 +245,38 @@ int config_parse_dnssd_service_name(const char *unit, const char *filename, unsi
assert(s); assert(s);
if (isempty(rvalue)) { if (isempty(rvalue)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Service instance name can't be empty. Ignoring."); s->name_template = mfree(s->name_template);
return -EINVAL; return 0;
}
r = dnssd_render_instance_name(rvalue, NULL);
if (r == -ENOMEM)
return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid service instance name template '%s', ignoring: %m", rvalue);
return 0;
} }
r = free_and_strdup(&s->name_template, rvalue); r = free_and_strdup(&s->name_template, rvalue);
if (r < 0) if (r < 0)
return log_oom(); return log_oom();
r = specifier_printf(s->name_template, specifier_table, NULL, &name);
if (r < 0)
return log_debug_errno(r, "Failed to replace specifiers: %m");
if (!dns_service_name_is_valid(name)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Service instance name template renders to invalid name '%s'. Ignoring.", name);
return -EINVAL;
}
return 0; return 0;
} }
int config_parse_dnssd_service_type(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) { int config_parse_dnssd_service_type(
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) {
DnssdService *s = userdata; DnssdService *s = userdata;
int r; int r;
@ -275,13 +286,13 @@ int config_parse_dnssd_service_type(const char *unit, const char *filename, unsi
assert(s); assert(s);
if (isempty(rvalue)) { if (isempty(rvalue)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Service type can't be empty. Ignoring."); s->type = mfree(s->type);
return -EINVAL; return 0;
} }
if (!dnssd_srv_type_is_valid(rvalue)) { if (!dnssd_srv_type_is_valid(rvalue)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Service type is invalid. Ignoring."); log_syntax(unit, LOG_WARNING, filename, line, 0, "Service type is invalid. Ignoring.");
return -EINVAL; return 0;
} }
r = free_and_strdup(&s->type, rvalue); r = free_and_strdup(&s->type, rvalue);
@ -291,7 +302,18 @@ int config_parse_dnssd_service_type(const char *unit, const char *filename, unsi
return 0; return 0;
} }
int config_parse_dnssd_txt(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) { int config_parse_dnssd_txt(
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) {
_cleanup_(dnssd_txtdata_freep) DnssdTxtData *txt_data = NULL; _cleanup_(dnssd_txtdata_freep) DnssdTxtData *txt_data = NULL;
DnssdService *s = userdata; DnssdService *s = userdata;
DnsTxtItem *last = NULL; DnsTxtItem *last = NULL;
@ -312,9 +334,7 @@ int config_parse_dnssd_txt(const char *unit, const char *filename, unsigned line
return log_oom(); return log_oom();
for (;;) { for (;;) {
_cleanup_free_ char *word = NULL; _cleanup_free_ char *word = NULL, *key = NULL, *value = NULL;
_cleanup_free_ char *key = NULL;
_cleanup_free_ char *value = NULL;
_cleanup_free_ void *decoded = NULL; _cleanup_free_ void *decoded = NULL;
size_t length = 0; size_t length = 0;
DnsTxtItem *i; DnsTxtItem *i;
@ -326,8 +346,10 @@ int config_parse_dnssd_txt(const char *unit, const char *filename, unsigned line
break; break;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, "Invalid syntax, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue);
return 0;
}
r = split_pair(word, "=", &key, &value); r = split_pair(word, "=", &key, &value);
if (r == -ENOMEM) if (r == -ENOMEM)
@ -336,8 +358,8 @@ int config_parse_dnssd_txt(const char *unit, const char *filename, unsigned line
key = TAKE_PTR(word); key = TAKE_PTR(word);
if (!ascii_is_valid(key)) { if (!ascii_is_valid(key)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid syntax, ignoring: %s", key); log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid key, ignoring: %s", key);
return -EINVAL; continue;
} }
switch (ltype) { switch (ltype) {
@ -347,9 +369,11 @@ int config_parse_dnssd_txt(const char *unit, const char *filename, unsigned line
r = unbase64mem(value, strlen(value), &decoded, &length); r = unbase64mem(value, strlen(value), &decoded, &length);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid base64 encoding, ignoring: %s", value); "Invalid base64 encoding, ignoring: %s", value);
continue;
}
} }
r = dnssd_txt_item_new_from_data(key, decoded, length, &i); r = dnssd_txt_item_new_from_data(key, decoded, length, &i);
@ -373,7 +397,7 @@ int config_parse_dnssd_txt(const char *unit, const char *filename, unsigned line
if (!LIST_IS_EMPTY(txt_data->txt)) { if (!LIST_IS_EMPTY(txt_data->txt)) {
LIST_PREPEND(items, s->txt_data_items, txt_data); LIST_PREPEND(items, s->txt_data_items, txt_data);
txt_data = NULL; TAKE_PTR(txt_data);
} }
return 0; return 0;

View file

@ -155,7 +155,7 @@ static int specifier_dnssd_host_name(char specifier, const void *data, const voi
return 0; return 0;
} }
int dnssd_render_instance_name(DnssdService *s, char **ret_name) { int dnssd_render_instance_name(const char *name_template, char **ret_name) {
static const Specifier specifier_table[] = { static const Specifier specifier_table[] = {
{ 'm', specifier_machine_id, NULL }, { 'm', specifier_machine_id, NULL },
{ 'b', specifier_boot_id, NULL }, { 'b', specifier_boot_id, NULL },
@ -171,19 +171,17 @@ int dnssd_render_instance_name(DnssdService *s, char **ret_name) {
_cleanup_free_ char *name = NULL; _cleanup_free_ char *name = NULL;
int r; int r;
assert(s); assert(name_template);
assert(s->name_template);
r = specifier_printf(s->name_template, specifier_table, s, &name); r = specifier_printf(name_template, specifier_table, NULL, &name);
if (r < 0) if (r < 0)
return log_debug_errno(r, "Failed to replace specifiers: %m"); return r;
if (!dns_service_name_is_valid(name)) if (!dns_service_name_is_valid(name))
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), return -EINVAL;
"Service instance name '%s' is invalid.",
name);
*ret_name = TAKE_PTR(name); if (ret_name)
*ret_name = TAKE_PTR(name);
return 0; return 0;
} }
@ -227,7 +225,7 @@ int dnssd_update_rrs(DnssdService *s) {
LIST_FOREACH(items, txt_data, s->txt_data_items) LIST_FOREACH(items, txt_data, s->txt_data_items)
txt_data->rr = dns_resource_record_unref(txt_data->rr); txt_data->rr = dns_resource_record_unref(txt_data->rr);
r = dnssd_render_instance_name(s, &n); r = dnssd_render_instance_name(s->name_template, &n);
if (r < 0) if (r < 0)
return r; return r;

View file

@ -51,7 +51,7 @@ DnssdTxtData *dnssd_txtdata_free_all(DnssdTxtData *txt_data);
DEFINE_TRIVIAL_CLEANUP_FUNC(DnssdService*, dnssd_service_free); DEFINE_TRIVIAL_CLEANUP_FUNC(DnssdService*, dnssd_service_free);
DEFINE_TRIVIAL_CLEANUP_FUNC(DnssdTxtData*, dnssd_txtdata_free); DEFINE_TRIVIAL_CLEANUP_FUNC(DnssdTxtData*, dnssd_txtdata_free);
int dnssd_render_instance_name(DnssdService *s, char **ret_name); int dnssd_render_instance_name(const char *name_template, char **ret_name);
int dnssd_load(Manager *manager); int dnssd_load(Manager *manager);
int dnssd_txt_item_new_from_string(const char *key, const char *value, DnsTxtItem **ret_item); int dnssd_txt_item_new_from_string(const char *key, const char *value, DnsTxtItem **ret_item);
int dnssd_txt_item_new_from_data(const char *key, const void *value, const size_t size, DnsTxtItem **ret_item); int dnssd_txt_item_new_from_data(const char *key, const void *value, const size_t size, DnsTxtItem **ret_item);

View file

@ -183,14 +183,12 @@ static int parse_line(
k = strlen(l); k = strlen(l);
assert(k > 0); assert(k > 0);
if (l[k-1] != ']') { if (l[k-1] != ']')
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid section header '%s'", l); return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EBADMSG), "Invalid section header '%s'", l);
return -EBADMSG;
}
n = strndup(l+1, k-2); n = strndup(l+1, k-2);
if (!n) if (!n)
return -ENOMEM; return log_oom();
if (sections && !nulstr_contains(sections, n)) { if (sections && !nulstr_contains(sections, n)) {
bool ignore = flags & CONFIG_PARSE_RELAXED; bool ignore = flags & CONFIG_PARSE_RELAXED;

View file

@ -938,12 +938,13 @@ int config_parse_channel(const char *unit,
r = safe_atou32(rvalue, &k); r = safe_atou32(rvalue, &k);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse channel value, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse channel value for %s=, ignoring: %s", lvalue, rvalue);
return 0; return 0;
} }
if (k < 1) { if (k < 1) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid %s value, ignoring: %s", lvalue, rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid %s= value, ignoring: %s", lvalue, rvalue);
return 0; return 0;
} }
@ -998,24 +999,24 @@ int config_parse_advertise(const char *unit,
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to split advertise modes '%s', ignoring: %m", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r,
break; "Failed to split advertise modes '%s', ignoring assignment: %m", rvalue);
return 0;
} }
if (r == 0) if (r == 0)
break; return 0;
mode = ethtool_link_mode_bit_from_string(w); mode = ethtool_link_mode_bit_from_string(w);
/* 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_ERR, filename, line, 0, "Failed to parse advertise mode, ignoring: %s", w); log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to parse advertise mode, ignoring: %s", w);
continue; continue;
} }
advertise[mode / 32] |= 1UL << (mode % 32); advertise[mode / 32] |= 1UL << (mode % 32);
} }
return 0;
} }
int config_parse_nic_buffer_size(const char *unit, int config_parse_nic_buffer_size(const char *unit,
@ -1040,12 +1041,13 @@ int config_parse_nic_buffer_size(const char *unit,
r = safe_atou32(rvalue, &k); r = safe_atou32(rvalue, &k);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse interface buffer value, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse interface buffer value, ignoring: %s", rvalue);
return 0; return 0;
} }
if (k < 1) { if (k < 1) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid %s value, ignoring: %s", lvalue, rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid %s= value, ignoring: %s", lvalue, rvalue);
return 0; return 0;
} }

View file

@ -86,11 +86,13 @@ int config_parse_vlanid(
r = parse_vlanid(rvalue, id); r = parse_vlanid(rvalue, id);
if (r == -ERANGE) { if (r == -ERANGE) {
log_syntax(unit, LOG_ERR, filename, line, r, "VLAN identifier outside of valid range 0…4094, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r,
"VLAN identifier outside of valid range 0…4094, ignoring: %s", rvalue);
return 0; return 0;
} }
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse VLAN identifier value, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse VLAN identifier value, ignoring: %s", rvalue);
return 0; return 0;
} }

View file

@ -89,7 +89,8 @@ int config_parse_servers(
else { else {
r = manager_parse_server_string(m, ltype, rvalue); r = manager_parse_server_string(m, ltype, rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse NTP server string '%s'. Ignoring.", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse NTP server string '%s', ignoring: %m", rvalue);
return 0; return 0;
} }
} }

View file

@ -118,8 +118,7 @@ int udev_builtin_run(sd_device *dev, UdevBuiltinCommand cmd, const char *command
if (!builtins[cmd]) if (!builtins[cmd])
return -EOPNOTSUPP; return -EOPNOTSUPP;
r = strv_split_full(&argv, command, NULL, r = strv_split_full(&argv, command, NULL, EXTRACT_UNQUOTE | EXTRACT_RELAX | EXTRACT_RETAIN_ESCAPE);
EXTRACT_UNQUOTE | EXTRACT_RELAX | EXTRACT_RETAIN_ESCAPE);
if (r < 0) if (r < 0)
return r; return r;

View file

@ -166,7 +166,7 @@ static int xdg_config_parse_string(
/* XDG does not allow duplicate definitions. */ /* XDG does not allow duplicate definitions. */
if (*out) { if (*out) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Key %s was defined multiple times, ignoring.", lvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Key %s was defined multiple times, ignoring.", lvalue);
return 0; return 0;
} }
@ -238,7 +238,7 @@ static int xdg_config_parse_strv(
/* XDG does not allow duplicate definitions. */ /* XDG does not allow duplicate definitions. */
if (*ret_sv) { if (*ret_sv) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Key %s was already defined, ignoring.", lvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Key %s was already defined, ignoring.", lvalue);
return 0; return 0;
} }
@ -256,7 +256,7 @@ static int xdg_config_parse_strv(
/* Move forward, and ensure it is a valid escape. */ /* Move forward, and ensure it is a valid escape. */
end++; end++;
if (!strchr("sntr\\;", *end)) { if (!strchr("sntr\\;", *end)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Undefined escape sequence \\%c.", *end); log_syntax(unit, LOG_WARNING, filename, line, 0, "Undefined escape sequence \\%c.", *end);
return 0; return 0;
} }
continue; continue;