1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-25 01:34:28 +03:00

network: also read mtime of drop-in configs

Fixes #15521.
This commit is contained in:
Yu Watanabe 2020-06-01 14:53:06 +09:00
parent c4473dec34
commit 9f83091e3c
5 changed files with 31 additions and 7 deletions

View File

@ -689,7 +689,7 @@ int netdev_load_one(Manager *manager, const char *filename) {
r = config_parse_many(filename, NETWORK_DIRS, dropin_dirname,
NETDEV_COMMON_SECTIONS NETDEV_OTHER_SECTIONS,
config_item_perf_lookup, network_netdev_gperf_lookup,
CONFIG_PARSE_WARN, netdev_raw);
CONFIG_PARSE_WARN, netdev_raw, NULL);
if (r < 0)
return r;
@ -729,7 +729,7 @@ int netdev_load_one(Manager *manager, const char *filename) {
r = config_parse_many(filename, NETWORK_DIRS, dropin_dirname,
NETDEV_VTABLE(netdev)->sections,
config_item_perf_lookup, network_netdev_gperf_lookup,
CONFIG_PARSE_WARN, netdev);
CONFIG_PARSE_WARN, netdev, NULL);
if (r < 0)
return r;

View File

@ -335,6 +335,7 @@ int network_verify(Network *network) {
int network_load_one(Manager *manager, OrderedHashmap **networks, const char *filename) {
_cleanup_free_ char *fname = NULL, *name = NULL;
_cleanup_(network_unrefp) Network *network = NULL;
_cleanup_strv_free_ char **dropins = NULL;
_cleanup_fclose_ FILE *file = NULL;
const char *dropin_dirname;
char *d;
@ -522,7 +523,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
"TokenBucketFilter\0"
"TrivialLinkEqualizer\0",
config_item_perf_lookup, network_network_gperf_lookup,
CONFIG_PARSE_WARN, network);
CONFIG_PARSE_WARN, network, &dropins);
if (r < 0)
return r;
@ -541,6 +542,20 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
if (stat(filename, &stats) >= 0)
network->timestamp = timespec_load(&stats.st_mtim);
char **f;
STRV_FOREACH(f, dropins) {
usec_t t;
if (stat(*f, &stats) < 0) {
network->timestamp = 0;
break;
}
t = timespec_load(&stats.st_mtim);
if (t > network->timestamp)
network->timestamp = t;
}
if (network_verify(network) < 0)
/* Ignore .network files that do not match the conditions. */
return 0;

View File

@ -89,7 +89,7 @@ static int dnssd_service_load(Manager *manager, const char *filename) {
r = config_parse_many(filename, DNSSD_SERVICE_DIRS, dropin_dirname,
"Service\0",
config_item_perf_lookup, resolved_dnssd_gperf_lookup,
false, service);
false, service, NULL);
if (r < 0)
return r;

View File

@ -493,7 +493,8 @@ int config_parse_many(
ConfigItemLookup lookup,
const void *table,
ConfigParseFlags flags,
void *userdata) {
void *userdata,
char ***ret_dropins) {
_cleanup_strv_free_ char **dropin_dirs = NULL;
_cleanup_strv_free_ char **files = NULL;
@ -509,7 +510,14 @@ int config_parse_many(
if (r < 0)
return r;
return config_parse_many_files(conf_file, files, sections, lookup, table, flags, userdata);
r = config_parse_many_files(conf_file, files, sections, lookup, table, flags, userdata);
if (r < 0)
return r;
if (ret_dropins)
*ret_dropins = TAKE_PTR(files);
return 0;
}
#define DEFINE_PARSER(type, vartype, conv_func) \

View File

@ -107,7 +107,8 @@ int config_parse_many(
ConfigItemLookup lookup,
const void *table,
ConfigParseFlags flags,
void *userdata);
void *userdata,
char ***ret_dropins); /* possibly NULL */
CONFIG_PARSER_PROTOTYPE(config_parse_int);
CONFIG_PARSER_PROTOTYPE(config_parse_unsigned);