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);
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;
}

View File

@ -2551,7 +2551,7 @@ int config_parse_line_max(
r = parse_size(rvalue, 1024, &v);
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;
}
@ -2606,7 +2606,7 @@ int config_parse_compress(
if (r < 0) {
r = parse_size(rvalue, 1024, &compress->threshold_bytes);
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);
else
compress->enabled = true;

View File

@ -466,12 +466,14 @@ int config_parse_n_autovts(
r = safe_atou(rvalue, &o);
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;
}
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;
}

View File

@ -919,7 +919,7 @@ int config_parse_tmpfs_size(
if (r >= 0 && (k <= 0 || (uint64_t) (size_t) k != k))
r = -ERANGE;
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;
}

View File

@ -847,13 +847,16 @@ int config_parse_macsec_key_id(
return log_oom();
r = unhexmem(rvalue, strlen(rvalue), &p, &l);
if (r == -ENOMEM)
return log_oom();
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;
}
if (l > MACSEC_KEYID_LEN) {
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);
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
WireGuardPeer.AllowedIPs, config_parse_wireguard_allowed_ips, 0, 0
WireGuardPeer.Endpoint, config_parse_wireguard_endpoint, 0, 0
WireGuardPeer.PublicKey, config_parse_wireguard_public_key, 0, 0
WireGuardPeer.PresharedKey, config_parse_wireguard_preshared_key, 0, 0
WireGuardPeer.PublicKey, config_parse_wireguard_peer_key, 0, 0
WireGuardPeer.PresharedKey, config_parse_wireguard_peer_key, 0, 0
WireGuardPeer.PresharedKeyFile, config_parse_wireguard_preshared_key_file, 0, 0
WireGuardPeer.PersistentKeepalive, config_parse_wireguard_keepalive, 0, 0
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);
r = unbase64mem_full(rvalue, strlen(rvalue), true, &key, &len);
if (r == -ENOMEM)
return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"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);
assert(w);
(void) wireguard_decode_key_and_warn(rvalue, w->private_key, unit, filename, line, lvalue);
return 0;
return wireguard_decode_key_and_warn(rvalue, w->private_key, unit, filename, line, lvalue);
}
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);
}
int config_parse_wireguard_preshared_key(
int config_parse_wireguard_peer_key(
const char *unit,
const char *filename,
unsigned line,
@ -576,7 +577,7 @@ int config_parse_wireguard_preshared_key(
void *data,
void *userdata) {
WireguardPeer *peer;
_cleanup_(wireguard_peer_free_or_set_invalidp) WireguardPeer *peer = NULL;
Wireguard *w;
int r;
@ -588,7 +589,13 @@ int config_parse_wireguard_preshared_key(
if (r < 0)
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;
}
@ -635,38 +642,6 @@ int config_parse_wireguard_preshared_key_file(
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(
const char *unit,
const char *filename,
@ -821,7 +796,7 @@ int config_parse_wireguard_keepalive(
void *data,
void *userdata) {
WireguardPeer *peer;
_cleanup_(wireguard_peer_free_or_set_invalidp) WireguardPeer *peer = NULL;
uint16_t keepalive = 0;
Wireguard *w;
int r;
@ -849,6 +824,8 @@ int config_parse_wireguard_keepalive(
}
peer->persistent_keepalive_interval = keepalive;
TAKE_PTR(peer);
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_endpoint);
CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_listen_port);
CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_public_key);
CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_peer_key);
CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_private_key);
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_keepalive);

View File

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

View File

@ -947,7 +947,7 @@ static int config_parse_label(
r = specifier_printf(rvalue, specifier_table, NULL, &resolved);
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);
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_(sd_bus_track_unrefp) sd_bus_track *bus_track = NULL;
_cleanup_free_ char *path = NULL;
_cleanup_free_ char *instance_name = NULL;
Manager *m = userdata;
DnssdService *s = NULL;
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))
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);
if (!service->name)
return log_oom();
@ -1807,10 +1810,6 @@ static int bus_method_register_service(sd_bus_message *message, void *userdata,
if (!service->type)
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}");
if (r < 0)
return r;

View File

@ -168,7 +168,8 @@ int config_parse_dns_servers(
/* Otherwise, add to the list */
r = manager_parse_dns_server_string_and_warn(m, ltype, rvalue);
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;
}
}
@ -210,7 +211,8 @@ int config_parse_search_domains(
/* Otherwise, add to the list */
r = manager_parse_search_domains_and_warn(m, rvalue);
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;
}
}
@ -222,21 +224,19 @@ int config_parse_search_domains(
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) {
static const Specifier specifier_table[] = {
{ 'm', specifier_machine_id, NULL },
{ 'b', specifier_boot_id, NULL },
{ 'H', specifier_host_name, NULL },
{ 'v', specifier_kernel_release, NULL },
{ 'a', specifier_architecture, NULL },
{ 'o', specifier_os_id, NULL },
{ 'w', specifier_os_version_id, NULL },
{ 'B', specifier_os_build_id, NULL },
{ 'W', specifier_os_variant_id, NULL },
{}
};
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) {
DnssdService *s = userdata;
_cleanup_free_ char *name = NULL;
int r;
assert(filename);
@ -245,27 +245,38 @@ int config_parse_dnssd_service_name(const char *unit, const char *filename, unsi
assert(s);
if (isempty(rvalue)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Service instance name can't be empty. Ignoring.");
return -EINVAL;
s->name_template = mfree(s->name_template);
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);
if (r < 0)
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;
}
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;
int r;
@ -275,13 +286,13 @@ int config_parse_dnssd_service_type(const char *unit, const char *filename, unsi
assert(s);
if (isempty(rvalue)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Service type can't be empty. Ignoring.");
return -EINVAL;
s->type = mfree(s->type);
return 0;
}
if (!dnssd_srv_type_is_valid(rvalue)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Service type is invalid. Ignoring.");
return -EINVAL;
log_syntax(unit, LOG_WARNING, filename, line, 0, "Service type is invalid. Ignoring.");
return 0;
}
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;
}
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;
DnssdService *s = userdata;
DnsTxtItem *last = NULL;
@ -312,9 +334,7 @@ int config_parse_dnssd_txt(const char *unit, const char *filename, unsigned line
return log_oom();
for (;;) {
_cleanup_free_ char *word = NULL;
_cleanup_free_ char *key = NULL;
_cleanup_free_ char *value = NULL;
_cleanup_free_ char *word = NULL, *key = NULL, *value = NULL;
_cleanup_free_ void *decoded = NULL;
size_t length = 0;
DnsTxtItem *i;
@ -326,8 +346,10 @@ int config_parse_dnssd_txt(const char *unit, const char *filename, unsigned line
break;
if (r == -ENOMEM)
return log_oom();
if (r < 0)
return log_syntax(unit, LOG_ERR, filename, line, r, "Invalid syntax, ignoring: %s", rvalue);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue);
return 0;
}
r = split_pair(word, "=", &key, &value);
if (r == -ENOMEM)
@ -336,8 +358,8 @@ int config_parse_dnssd_txt(const char *unit, const char *filename, unsigned line
key = TAKE_PTR(word);
if (!ascii_is_valid(key)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid syntax, ignoring: %s", key);
return -EINVAL;
log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid key, ignoring: %s", key);
continue;
}
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);
if (r == -ENOMEM)
return log_oom();
if (r < 0)
return log_syntax(unit, LOG_ERR, filename, line, r,
"Invalid base64 encoding, ignoring: %s", value);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid base64 encoding, ignoring: %s", value);
continue;
}
}
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)) {
LIST_PREPEND(items, s->txt_data_items, txt_data);
txt_data = NULL;
TAKE_PTR(txt_data);
}
return 0;

View File

@ -155,7 +155,7 @@ static int specifier_dnssd_host_name(char specifier, const void *data, const voi
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[] = {
{ 'm', specifier_machine_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;
int r;
assert(s);
assert(s->name_template);
assert(name_template);
r = specifier_printf(s->name_template, specifier_table, s, &name);
r = specifier_printf(name_template, specifier_table, NULL, &name);
if (r < 0)
return log_debug_errno(r, "Failed to replace specifiers: %m");
return r;
if (!dns_service_name_is_valid(name))
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
"Service instance name '%s' is invalid.",
name);
return -EINVAL;
*ret_name = TAKE_PTR(name);
if (ret_name)
*ret_name = TAKE_PTR(name);
return 0;
}
@ -227,7 +225,7 @@ int dnssd_update_rrs(DnssdService *s) {
LIST_FOREACH(items, txt_data, s->txt_data_items)
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)
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(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_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);

View File

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

View File

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

View File

@ -86,11 +86,13 @@ int config_parse_vlanid(
r = parse_vlanid(rvalue, id);
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;
}
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;
}

View File

@ -89,7 +89,8 @@ int config_parse_servers(
else {
r = manager_parse_server_string(m, ltype, rvalue);
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;
}
}

View File

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

View File

@ -166,7 +166,7 @@ static int xdg_config_parse_string(
/* XDG does not allow duplicate definitions. */
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;
}
@ -238,7 +238,7 @@ static int xdg_config_parse_strv(
/* XDG does not allow duplicate definitions. */
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;
}
@ -256,7 +256,7 @@ static int xdg_config_parse_strv(
/* Move forward, and ensure it is a valid escape. */
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;
}
continue;