mirror of
https://github.com/systemd/systemd
synced 2026-04-23 07:24:51 +02:00
Compare commits
No commits in common. "e8aba093b405bb53cd26d82d26436aa4836b2e83" and "da29de23ef200b17bb780e5a0efb6cff28c72287" have entirely different histories.
e8aba093b4
...
da29de23ef
@ -6080,11 +6080,9 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) {
|
||||
}
|
||||
|
||||
#if HAVE_LIBBPF
|
||||
if (exec_context_restrict_filesystems_set(c)) {
|
||||
char *fs;
|
||||
SET_FOREACH(fs, c->restrict_filesystems)
|
||||
fprintf(f, "%sRestrictFileSystems: %s\n", prefix, fs);
|
||||
}
|
||||
if (exec_context_restrict_filesystems_set(c))
|
||||
SET_FOREACH(e, c->restrict_filesystems)
|
||||
fprintf(f, "%sRestrictFileSystems: %s\n", prefix, *e);
|
||||
#endif
|
||||
|
||||
if (c->network_namespace_path)
|
||||
|
||||
@ -578,7 +578,8 @@ int sd_radv_set_preference(sd_radv *ra, unsigned preference) {
|
||||
|
||||
int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p) {
|
||||
_cleanup_free_ char *addr_p = NULL;
|
||||
sd_radv_prefix *cur, *found = NULL;
|
||||
sd_radv_prefix *cur;
|
||||
bool update = false;
|
||||
int r;
|
||||
|
||||
assert_return(ra, -EINVAL);
|
||||
@ -603,7 +604,7 @@ int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p) {
|
||||
continue;
|
||||
|
||||
if (cur->opt.prefixlen == p->opt.prefixlen) {
|
||||
found = cur;
|
||||
update = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -614,13 +615,15 @@ int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p) {
|
||||
strna(addr_p), strna(addr_cur));
|
||||
}
|
||||
|
||||
if (found) {
|
||||
if (update) {
|
||||
assert(cur);
|
||||
|
||||
/* p and cur may be equivalent. First increment the reference counter. */
|
||||
sd_radv_prefix_ref(p);
|
||||
|
||||
/* Then, remove the old entry. */
|
||||
LIST_REMOVE(prefix, ra->prefixes, found);
|
||||
sd_radv_prefix_unref(found);
|
||||
LIST_REMOVE(prefix, ra->prefixes, cur);
|
||||
sd_radv_prefix_unref(cur);
|
||||
|
||||
/* Finally, add the new entry. */
|
||||
LIST_APPEND(prefix, ra->prefixes, p);
|
||||
@ -656,20 +659,15 @@ int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sd_radv_remove_prefix(
|
||||
sd_radv *ra,
|
||||
sd_radv_prefix *sd_radv_remove_prefix(sd_radv *ra,
|
||||
const struct in6_addr *prefix,
|
||||
unsigned char prefixlen) {
|
||||
sd_radv_prefix *cur, *next;
|
||||
|
||||
sd_radv_prefix *cur;
|
||||
assert_return(ra, NULL);
|
||||
assert_return(prefix, NULL);
|
||||
|
||||
if (!ra)
|
||||
return;
|
||||
|
||||
if (!prefix)
|
||||
return;
|
||||
|
||||
LIST_FOREACH(prefix, cur, ra->prefixes) {
|
||||
LIST_FOREACH_SAFE(prefix, cur, next, ra->prefixes) {
|
||||
if (prefixlen != cur->opt.prefixlen)
|
||||
continue;
|
||||
|
||||
@ -679,13 +677,17 @@ void sd_radv_remove_prefix(
|
||||
LIST_REMOVE(prefix, ra->prefixes, cur);
|
||||
ra->n_prefixes--;
|
||||
sd_radv_prefix_unref(cur);
|
||||
return;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return cur;
|
||||
}
|
||||
|
||||
int sd_radv_add_route_prefix(sd_radv *ra, sd_radv_route_prefix *p) {
|
||||
_cleanup_free_ char *addr_p = NULL;
|
||||
sd_radv_route_prefix *cur, *found = NULL;
|
||||
sd_radv_route_prefix *cur;
|
||||
bool update = false;
|
||||
int r;
|
||||
|
||||
assert_return(ra, -EINVAL);
|
||||
@ -706,7 +708,7 @@ int sd_radv_add_route_prefix(sd_radv *ra, sd_radv_route_prefix *p) {
|
||||
continue;
|
||||
|
||||
if (cur->opt.prefixlen == p->opt.prefixlen) {
|
||||
found = cur;
|
||||
update = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -717,13 +719,15 @@ int sd_radv_add_route_prefix(sd_radv *ra, sd_radv_route_prefix *p) {
|
||||
strna(addr_p), strna(addr_cur));
|
||||
}
|
||||
|
||||
if (found) {
|
||||
if (update) {
|
||||
assert(cur);
|
||||
|
||||
/* p and cur may be equivalent. First increment the reference counter. */
|
||||
sd_radv_route_prefix_ref(p);
|
||||
|
||||
/* Then, remove the old entry. */
|
||||
LIST_REMOVE(prefix, ra->route_prefixes, found);
|
||||
sd_radv_route_prefix_unref(found);
|
||||
LIST_REMOVE(prefix, ra->route_prefixes, cur);
|
||||
sd_radv_route_prefix_unref(cur);
|
||||
|
||||
/* Finally, add the new entry. */
|
||||
LIST_APPEND(prefix, ra->route_prefixes, p);
|
||||
@ -758,12 +762,8 @@ int sd_radv_add_route_prefix(sd_radv *ra, sd_radv_route_prefix *p) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_radv_set_rdnss(
|
||||
sd_radv *ra,
|
||||
uint32_t lifetime,
|
||||
const struct in6_addr *dns,
|
||||
size_t n_dns) {
|
||||
|
||||
int sd_radv_set_rdnss(sd_radv *ra, uint32_t lifetime,
|
||||
const struct in6_addr *dns, size_t n_dns) {
|
||||
_cleanup_free_ struct sd_radv_opt_dns *opt_rdnss = NULL;
|
||||
size_t len;
|
||||
|
||||
@ -796,11 +796,8 @@ int sd_radv_set_rdnss(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_radv_set_dnssl(
|
||||
sd_radv *ra,
|
||||
uint32_t lifetime,
|
||||
int sd_radv_set_dnssl(sd_radv *ra, uint32_t lifetime,
|
||||
char **search_list) {
|
||||
|
||||
_cleanup_free_ struct sd_radv_opt_dns *opt_dnssl = NULL;
|
||||
size_t len = 0;
|
||||
char **s;
|
||||
@ -879,11 +876,8 @@ int sd_radv_prefix_new(sd_radv_prefix **ret) {
|
||||
|
||||
DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC(sd_radv_prefix, sd_radv_prefix, mfree);
|
||||
|
||||
int sd_radv_prefix_set_prefix(
|
||||
sd_radv_prefix *p,
|
||||
const struct in6_addr *in6_addr,
|
||||
int sd_radv_prefix_set_prefix(sd_radv_prefix *p, const struct in6_addr *in6_addr,
|
||||
unsigned char prefixlen) {
|
||||
|
||||
assert_return(p, -EINVAL);
|
||||
assert_return(in6_addr, -EINVAL);
|
||||
|
||||
@ -900,11 +894,8 @@ int sd_radv_prefix_set_prefix(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_radv_prefix_get_prefix(
|
||||
sd_radv_prefix *p,
|
||||
struct in6_addr *ret_in6_addr,
|
||||
int sd_radv_prefix_get_prefix(sd_radv_prefix *p, struct in6_addr *ret_in6_addr,
|
||||
unsigned char *ret_prefixlen) {
|
||||
|
||||
assert_return(p, -EINVAL);
|
||||
assert_return(ret_in6_addr, -EINVAL);
|
||||
assert_return(ret_prefixlen, -EINVAL);
|
||||
@ -923,7 +914,8 @@ int sd_radv_prefix_set_onlink(sd_radv_prefix *p, int onlink) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_radv_prefix_set_address_autoconfiguration(sd_radv_prefix *p, int address_autoconfiguration) {
|
||||
int sd_radv_prefix_set_address_autoconfiguration(sd_radv_prefix *p,
|
||||
int address_autoconfiguration) {
|
||||
assert_return(p, -EINVAL);
|
||||
|
||||
SET_FLAG(p->opt.flags, ND_OPT_PI_FLAG_AUTO, address_autoconfiguration);
|
||||
@ -975,11 +967,8 @@ int sd_radv_route_prefix_new(sd_radv_route_prefix **ret) {
|
||||
|
||||
DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC(sd_radv_route_prefix, sd_radv_route_prefix, mfree);
|
||||
|
||||
int sd_radv_route_prefix_set_prefix(
|
||||
sd_radv_route_prefix *p,
|
||||
const struct in6_addr *in6_addr,
|
||||
int sd_radv_route_prefix_set_prefix(sd_radv_route_prefix *p, const struct in6_addr *in6_addr,
|
||||
unsigned char prefixlen) {
|
||||
|
||||
assert_return(p, -EINVAL);
|
||||
assert_return(in6_addr, -EINVAL);
|
||||
|
||||
|
||||
@ -187,7 +187,7 @@ int dhcp_pd_remove(Link *link, bool only_marked) {
|
||||
continue;
|
||||
|
||||
if (link->radv)
|
||||
sd_radv_remove_prefix(link->radv, &route->dst.in6, 64);
|
||||
(void) sd_radv_remove_prefix(link->radv, &route->dst.in6, 64);
|
||||
|
||||
link_remove_dhcp_pd_subnet_prefix(link, &route->dst.in6);
|
||||
|
||||
@ -212,7 +212,7 @@ int dhcp_pd_remove(Link *link, bool only_marked) {
|
||||
in6_addr_mask(&prefix, 64);
|
||||
|
||||
if (link->radv)
|
||||
sd_radv_remove_prefix(link->radv, &prefix, 64);
|
||||
(void) sd_radv_remove_prefix(link->radv, &prefix, 64);
|
||||
|
||||
link_remove_dhcp_pd_subnet_prefix(link, &prefix);
|
||||
|
||||
|
||||
@ -1778,11 +1778,11 @@ static int context_load_partition_table(
|
||||
}
|
||||
|
||||
sz = fdisk_partition_get_size(p);
|
||||
assert(sz <= UINT64_MAX/secsz);
|
||||
assert_se(sz <= UINT64_MAX/secsz);
|
||||
sz *= secsz;
|
||||
|
||||
start = fdisk_partition_get_start(p);
|
||||
assert(start <= UINT64_MAX/secsz);
|
||||
assert_se(start <= UINT64_MAX/secsz);
|
||||
start *= secsz;
|
||||
|
||||
partno = fdisk_partition_get_partno(p);
|
||||
@ -4799,7 +4799,7 @@ static int determine_auto_size(Context *c) {
|
||||
uint64_t sum;
|
||||
Partition *p;
|
||||
|
||||
assert(c);
|
||||
assert_se(c);
|
||||
|
||||
sum = round_up_size(GPT_METADATA_SIZE, 4096);
|
||||
|
||||
@ -4981,7 +4981,7 @@ static int run(int argc, char *argv[]) {
|
||||
/* Flush out everything again, and let's grow the file first, then start fresh */
|
||||
context_unload_partition_table(context);
|
||||
|
||||
assert(arg_size != UINT64_MAX);
|
||||
assert_se(arg_size != UINT64_MAX);
|
||||
r = resize_backing_fd(
|
||||
node,
|
||||
&backing_fd,
|
||||
|
||||
@ -1660,7 +1660,6 @@ int varlink_errorb(Varlink *v, const char *error_id, ...) {
|
||||
}
|
||||
|
||||
int varlink_error_invalid_parameter(Varlink *v, JsonVariant *parameters) {
|
||||
int r;
|
||||
|
||||
assert_return(v, -EINVAL);
|
||||
assert_return(parameters, -EINVAL);
|
||||
@ -1670,33 +1669,13 @@ int varlink_error_invalid_parameter(Varlink *v, JsonVariant *parameters) {
|
||||
* variant in which case we'll pull out the first key. The latter mode is useful in functions that
|
||||
* don't expect any arguments. */
|
||||
|
||||
/* varlink_error(...) expects a json object as the third parameter. Passing a string variant causes
|
||||
* parameter sanitization to fail, and it returns -EINVAL. */
|
||||
|
||||
if (json_variant_is_string(parameters)) {
|
||||
_cleanup_(json_variant_unrefp) JsonVariant *parameters_obj = NULL;
|
||||
|
||||
r = json_build(¶meters_obj,
|
||||
JSON_BUILD_OBJECT(
|
||||
JSON_BUILD_PAIR("parameter", JSON_BUILD_VARIANT(parameters))));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return varlink_error(v, VARLINK_ERROR_INVALID_PARAMETER, parameters_obj);
|
||||
}
|
||||
if (json_variant_is_string(parameters))
|
||||
return varlink_error(v, VARLINK_ERROR_INVALID_PARAMETER, parameters);
|
||||
|
||||
if (json_variant_is_object(parameters) &&
|
||||
json_variant_elements(parameters) > 0) {
|
||||
_cleanup_(json_variant_unrefp) JsonVariant *parameters_obj = NULL;
|
||||
|
||||
r = json_build(¶meters_obj,
|
||||
JSON_BUILD_OBJECT(
|
||||
JSON_BUILD_PAIR("parameter", JSON_BUILD_VARIANT(json_variant_by_index(parameters, 0)))));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return varlink_error(v, VARLINK_ERROR_INVALID_PARAMETER, parameters_obj);
|
||||
}
|
||||
json_variant_elements(parameters) > 0)
|
||||
return varlink_error(v, VARLINK_ERROR_INVALID_PARAMETER,
|
||||
json_variant_by_index(parameters, 0));
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -59,7 +59,8 @@ int sd_radv_set_other_information(sd_radv *ra, int other);
|
||||
int sd_radv_set_preference(sd_radv *ra, unsigned preference);
|
||||
int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p);
|
||||
int sd_radv_add_route_prefix(sd_radv *ra, sd_radv_route_prefix *p);
|
||||
void sd_radv_remove_prefix(sd_radv *ra, const struct in6_addr *prefix, unsigned char prefixlen);
|
||||
sd_radv_prefix *sd_radv_remove_prefix(sd_radv *ra, const struct in6_addr *prefix,
|
||||
unsigned char prefixlen);
|
||||
int sd_radv_set_rdnss(sd_radv *ra, uint32_t lifetime,
|
||||
const struct in6_addr *dns, size_t n_dns);
|
||||
int sd_radv_set_dnssl(sd_radv *ra, uint32_t lifetime, char **search_list);
|
||||
|
||||
@ -102,18 +102,15 @@ static void unit_status_info_clear(UnitStatusInfo *p) {
|
||||
p->active_state = mfree(p->active_state);
|
||||
}
|
||||
|
||||
static UnitStatusInfo *unit_status_info_free(UnitStatusInfo *p) {
|
||||
if (!p)
|
||||
return NULL;
|
||||
static void unit_status_info_free(UnitStatusInfo *p) {
|
||||
assert(p);
|
||||
|
||||
unit_status_info_clear(p);
|
||||
free(p->name);
|
||||
free(p->path);
|
||||
return mfree(p);
|
||||
free(p);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(UnitStatusInfo*, unit_status_info_free);
|
||||
|
||||
static void context_clear(Context *c) {
|
||||
UnitStatusInfo *p;
|
||||
|
||||
@ -132,13 +129,8 @@ static void context_clear(Context *c) {
|
||||
}
|
||||
|
||||
static int context_add_ntp_service(Context *c, const char *s, const char *source) {
|
||||
_cleanup_(unit_status_info_freep) UnitStatusInfo *unit = NULL;
|
||||
UnitStatusInfo *u;
|
||||
|
||||
assert(c);
|
||||
assert(s);
|
||||
assert(source);
|
||||
|
||||
if (!unit_name_is_valid(s, UNIT_NAME_PLAIN))
|
||||
return -EINVAL;
|
||||
|
||||
@ -147,17 +139,18 @@ static int context_add_ntp_service(Context *c, const char *s, const char *source
|
||||
if (streq(u->name, s))
|
||||
return 0;
|
||||
|
||||
unit = new0(UnitStatusInfo, 1);
|
||||
if (!unit)
|
||||
u = new0(UnitStatusInfo, 1);
|
||||
if (!u)
|
||||
return -ENOMEM;
|
||||
|
||||
unit->name = strdup(s);
|
||||
if (!unit->name)
|
||||
u->name = strdup(s);
|
||||
if (!u->name) {
|
||||
free(u);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
LIST_APPEND(units, c->units, unit);
|
||||
log_unit_debug(unit, "added from %s.", source);
|
||||
TAKE_PTR(unit);
|
||||
LIST_APPEND(units, c->units, u);
|
||||
log_unit_debug(u, "added from %s.", source);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user