mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
@@ -39,14 +39,14 @@ int ordered_set_consume(OrderedSet *s, void *p) {
|
||||
return r;
|
||||
}
|
||||
|
||||
int ordered_set_put_strdup(OrderedSet **s, const char *p) {
|
||||
int ordered_set_put_strdup_full(OrderedSet **s, const struct hash_ops *hash_ops, const char *p) {
|
||||
char *c;
|
||||
int r;
|
||||
|
||||
assert(s);
|
||||
assert(p);
|
||||
|
||||
r = ordered_set_ensure_allocated(s, &string_hash_ops_free);
|
||||
r = ordered_set_ensure_allocated(s, hash_ops);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -60,11 +60,13 @@ int ordered_set_put_strdup(OrderedSet **s, const char *p) {
|
||||
return ordered_set_consume(*s, c);
|
||||
}
|
||||
|
||||
int ordered_set_put_strdupv(OrderedSet **s, char **l) {
|
||||
int ordered_set_put_strdupv_full(OrderedSet **s, const struct hash_ops *hash_ops, char **l) {
|
||||
int n = 0, r;
|
||||
|
||||
assert(s);
|
||||
|
||||
STRV_FOREACH(i, l) {
|
||||
r = ordered_set_put_strdup(s, *i);
|
||||
r = ordered_set_put_strdup_full(s, hash_ops, *i);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -74,14 +76,16 @@ int ordered_set_put_strdupv(OrderedSet **s, char **l) {
|
||||
return n;
|
||||
}
|
||||
|
||||
int ordered_set_put_string_set(OrderedSet **s, OrderedSet *l) {
|
||||
int ordered_set_put_string_set_full(OrderedSet **s, const struct hash_ops *hash_ops, OrderedSet *l) {
|
||||
int n = 0, r;
|
||||
char *p;
|
||||
|
||||
assert(s);
|
||||
|
||||
/* Like ordered_set_put_strv, but for an OrderedSet of strings */
|
||||
|
||||
ORDERED_SET_FOREACH(p, l) {
|
||||
r = ordered_set_put_strdup(s, p);
|
||||
r = ordered_set_put_strdup_full(s, hash_ops, p);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -67,9 +67,14 @@ static inline int ordered_set_reserve(OrderedSet *s, unsigned entries_add) {
|
||||
}
|
||||
|
||||
int ordered_set_consume(OrderedSet *s, void *p);
|
||||
int ordered_set_put_strdup(OrderedSet **s, const char *p);
|
||||
int ordered_set_put_strdupv(OrderedSet **s, char **l);
|
||||
int ordered_set_put_string_set(OrderedSet **s, OrderedSet *l);
|
||||
|
||||
int ordered_set_put_strdup_full(OrderedSet **s, const struct hash_ops *hash_ops, const char *p);
|
||||
#define ordered_set_put_strdup(s, p) ordered_set_put_strdup_full(s, &string_hash_ops_free, p)
|
||||
int ordered_set_put_strdupv_full(OrderedSet **s, const struct hash_ops *hash_ops, char **l);
|
||||
#define ordered_set_put_strdupv(s, l) ordered_set_put_strdupv_full(s, &string_hash_ops_free, l)
|
||||
int ordered_set_put_string_set_full(OrderedSet **s, const struct hash_ops *hash_ops, OrderedSet *l);
|
||||
#define ordered_set_put_string_set(s, l) ordered_set_put_string_set_full(s, &string_hash_ops_free, l)
|
||||
|
||||
void ordered_set_print(FILE *f, const char *field, OrderedSet *s);
|
||||
|
||||
#define _ORDERED_SET_FOREACH(e, s, i) \
|
||||
|
||||
@@ -200,7 +200,7 @@ int config_parse_domains(
|
||||
}
|
||||
|
||||
OrderedSet **set = is_route ? &n->route_domains : &n->search_domains;
|
||||
r = ordered_set_put_strdup(set, domain);
|
||||
r = ordered_set_put_strdup_full(set, &dns_name_hash_ops_free, domain);
|
||||
if (r == -EEXIST)
|
||||
continue;
|
||||
if (r < 0)
|
||||
|
||||
@@ -197,11 +197,13 @@ int bus_link_method_set_domains(sd_bus_message *message, void *userdata, sd_bus_
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
search_domains = ordered_set_new(&string_hash_ops_free);
|
||||
/* The method accepts an empty strv, to override the domains set in .network.
|
||||
* Hence, we need to explicitly allocate empty sets here. */
|
||||
search_domains = ordered_set_new(&dns_name_hash_ops_free);
|
||||
if (!search_domains)
|
||||
return -ENOMEM;
|
||||
|
||||
route_domains = ordered_set_new(&string_hash_ops_free);
|
||||
route_domains = ordered_set_new(&dns_name_hash_ops_free);
|
||||
if (!route_domains)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -506,12 +508,14 @@ int bus_link_method_set_dnssec_negative_trust_anchors(sd_bus_message *message, v
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid negative trust anchor domain: %s", *i);
|
||||
}
|
||||
|
||||
/* The method accepts an empty strv, to override the negative trust anchors set in .network.
|
||||
* Hence, we need to explicitly allocate an empty set here. */
|
||||
ns = set_new(&dns_name_hash_ops_free);
|
||||
if (!ns)
|
||||
return -ENOMEM;
|
||||
|
||||
STRV_FOREACH(i, ntas) {
|
||||
r = set_put_strdup(&ns, *i);
|
||||
r = set_put_strdup_full(&ns, &dns_name_hash_ops_free, *i);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "sd-dhcp6-lease.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "dns-domain.h"
|
||||
#include "dns-resolver-internal.h"
|
||||
#include "errno-util.h"
|
||||
#include "escape.h"
|
||||
@@ -280,9 +281,9 @@ static int link_put_domains(Link *link, bool is_route, OrderedSet **s) {
|
||||
use_domains = is_route ? USE_DOMAINS_ROUTE : USE_DOMAINS_YES;
|
||||
|
||||
if (link_domains)
|
||||
return ordered_set_put_string_set(s, link_domains);
|
||||
return ordered_set_put_string_set_full(s, &dns_name_hash_ops_free, link_domains);
|
||||
|
||||
r = ordered_set_put_string_set(s, network_domains);
|
||||
r = ordered_set_put_string_set_full(s, &dns_name_hash_ops_free, network_domains);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -292,14 +293,14 @@ static int link_put_domains(Link *link, bool is_route, OrderedSet **s) {
|
||||
|
||||
r = sd_dhcp_lease_get_domainname(link->dhcp_lease, &domainname);
|
||||
if (r >= 0) {
|
||||
r = ordered_set_put_strdup(s, domainname);
|
||||
r = ordered_set_put_strdup_full(s, &dns_name_hash_ops_free, domainname);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
r = sd_dhcp_lease_get_search_domains(link->dhcp_lease, &domains);
|
||||
if (r >= 0) {
|
||||
r = ordered_set_put_strdupv(s, domains);
|
||||
r = ordered_set_put_strdupv_full(s, &dns_name_hash_ops_free, domains);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
@@ -310,7 +311,7 @@ static int link_put_domains(Link *link, bool is_route, OrderedSet **s) {
|
||||
|
||||
r = sd_dhcp6_lease_get_domains(link->dhcp6_lease, &domains);
|
||||
if (r >= 0) {
|
||||
r = ordered_set_put_strdupv(s, domains);
|
||||
r = ordered_set_put_strdupv_full(s, &dns_name_hash_ops_free, domains);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
@@ -320,7 +321,7 @@ static int link_put_domains(Link *link, bool is_route, OrderedSet **s) {
|
||||
NDiscDNSSL *a;
|
||||
|
||||
SET_FOREACH(a, link->ndisc_dnssl) {
|
||||
r = ordered_set_put_strdup(s, ndisc_dnssl_domain(a));
|
||||
r = ordered_set_put_strdup_full(s, &dns_name_hash_ops_free, ndisc_dnssl_domain(a));
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user