Compare commits
6 Commits
ba56e9c55b
...
c5bdfeb637
Author | SHA1 | Date |
---|---|---|
Mike Yuan | c5bdfeb637 | |
Luca Boccassi | b7eefa1996 | |
Luca Boccassi | 2e5b0412f9 | |
Yu Watanabe | 2b397d43ab | |
Yu Watanabe | 9ad294efd0 | |
Mike Yuan | 2890403e21 |
|
@ -799,7 +799,7 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **ret_path) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *path = strdup(e + 1);
|
_cleanup_free_ char *path = strdup(e + 1);
|
||||||
if (!path)
|
if (!path)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -812,7 +812,7 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **ret_path) {
|
||||||
if (e)
|
if (e)
|
||||||
*e = 0;
|
*e = 0;
|
||||||
|
|
||||||
*ret_path = path;
|
*ret_path = TAKE_PTR(path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -526,21 +526,23 @@ int merge_gid_lists(const gid_t *list1, size_t size1, const gid_t *list2, size_t
|
||||||
return (int)nresult;
|
return (int)nresult;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getgroups_alloc(gid_t** gids) {
|
int getgroups_alloc(gid_t **ret) {
|
||||||
gid_t *allocated;
|
|
||||||
_cleanup_free_ gid_t *p = NULL;
|
|
||||||
int ngroups = 8;
|
int ngroups = 8;
|
||||||
unsigned attempt = 0;
|
|
||||||
|
|
||||||
allocated = new(gid_t, ngroups);
|
assert(ret);
|
||||||
if (!allocated)
|
|
||||||
|
for (unsigned attempt = 0;;) {
|
||||||
|
_cleanup_free_ gid_t *p = NULL;
|
||||||
|
|
||||||
|
p = new(gid_t, ngroups);
|
||||||
|
if (!p)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
p = allocated;
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
ngroups = getgroups(ngroups, p);
|
ngroups = getgroups(ngroups, p);
|
||||||
if (ngroups >= 0)
|
if (ngroups >= 0) {
|
||||||
break;
|
*ret = TAKE_PTR(p);
|
||||||
|
return ngroups;
|
||||||
|
}
|
||||||
if (errno != EINVAL)
|
if (errno != EINVAL)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
|
@ -553,18 +555,11 @@ int getgroups_alloc(gid_t** gids) {
|
||||||
ngroups = getgroups(0, NULL);
|
ngroups = getgroups(0, NULL);
|
||||||
if (ngroups < 0)
|
if (ngroups < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
if (ngroups == 0)
|
if (ngroups == 0) {
|
||||||
return false;
|
*ret = NULL;
|
||||||
|
return 0;
|
||||||
free(allocated);
|
}
|
||||||
|
|
||||||
p = allocated = new(gid_t, ngroups);
|
|
||||||
if (!allocated)
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*gids = TAKE_PTR(p);
|
|
||||||
return ngroups;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_home_dir(char **ret) {
|
int get_home_dir(char **ret) {
|
||||||
|
|
|
@ -64,7 +64,7 @@ int in_gid(gid_t gid);
|
||||||
int in_group(const char *name);
|
int in_group(const char *name);
|
||||||
|
|
||||||
int merge_gid_lists(const gid_t *list1, size_t size1, const gid_t *list2, size_t size2, gid_t **result);
|
int merge_gid_lists(const gid_t *list1, size_t size1, const gid_t *list2, size_t size2, gid_t **result);
|
||||||
int getgroups_alloc(gid_t** gids);
|
int getgroups_alloc(gid_t **ret);
|
||||||
|
|
||||||
int get_home_dir(char **ret);
|
int get_home_dir(char **ret);
|
||||||
int get_shell(char **ret);
|
int get_shell(char **ret);
|
||||||
|
|
|
@ -1443,6 +1443,7 @@ int link_reconfigure_impl(Link *link, LinkReconfigurationFlag flags) {
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct LinkReconfigurationData {
|
typedef struct LinkReconfigurationData {
|
||||||
|
Manager *manager;
|
||||||
Link *link;
|
Link *link;
|
||||||
LinkReconfigurationFlag flags;
|
LinkReconfigurationFlag flags;
|
||||||
sd_bus_message *message;
|
sd_bus_message *message;
|
||||||
|
@ -1473,6 +1474,12 @@ static void link_reconfiguration_data_destroy_callback(LinkReconfigurationData *
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data->counter || *data->counter <= 0) {
|
if (!data->counter || *data->counter <= 0) {
|
||||||
|
/* Update the state files before replying the bus method. Otherwise,
|
||||||
|
* systemd-networkd-wait-online following networkctl reload/reconfigure may read an
|
||||||
|
* outdated state file and wrongly handle an interface is already in the configured
|
||||||
|
* state. */
|
||||||
|
(void) manager_clean_all(data->manager);
|
||||||
|
|
||||||
r = sd_bus_reply_method_return(data->message, NULL);
|
r = sd_bus_reply_method_return(data->message, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_warning_errno(r, "Failed to reply for DBus method, ignoring: %m");
|
log_warning_errno(r, "Failed to reply for DBus method, ignoring: %m");
|
||||||
|
@ -1521,6 +1528,7 @@ int link_reconfigure_full(Link *link, LinkReconfigurationFlag flags, sd_bus_mess
|
||||||
}
|
}
|
||||||
|
|
||||||
*data = (LinkReconfigurationData) {
|
*data = (LinkReconfigurationData) {
|
||||||
|
.manager = link->manager,
|
||||||
.link = link_ref(link),
|
.link = link_ref(link),
|
||||||
.flags = flags,
|
.flags = flags,
|
||||||
.message = sd_bus_message_ref(message), /* message may be NULL, but _ref() works fine. */
|
.message = sd_bus_message_ref(message), /* message may be NULL, but _ref() works fine. */
|
||||||
|
|
|
@ -6406,11 +6406,11 @@ class NetworkdRATests(unittest.TestCase, Utilities):
|
||||||
|
|
||||||
for i in [100, 200, 300, 512, 1024, 2048]:
|
for i in [100, 200, 300, 512, 1024, 2048]:
|
||||||
if i not in [metric_1, metric_2]:
|
if i not in [metric_1, metric_2]:
|
||||||
self.assertNotIn(f'{i}', output)
|
self.assertNotIn(f'metric {i} ', output)
|
||||||
|
|
||||||
for i in ['low', 'medium', 'high']:
|
for i in ['low', 'medium', 'high']:
|
||||||
if i not in [preference_1, preference_2]:
|
if i not in [preference_1, preference_2]:
|
||||||
self.assertNotIn(f'{i}', output)
|
self.assertNotIn(f'pref {i}', output)
|
||||||
|
|
||||||
def test_router_preference(self):
|
def test_router_preference(self):
|
||||||
copy_network_unit('25-veth-client.netdev',
|
copy_network_unit('25-veth-client.netdev',
|
||||||
|
|
Loading…
Reference in New Issue