mirror of
https://github.com/systemd/systemd
synced 2024-10-15 04:24:19 +00:00
networkd: split runtime config dir from state dir
Configuration will be in root:root /run/systemd/network and state will be in systemd-network:systemd-network /run/systemd/netif This matches what we do for logind's seat/session state.
This commit is contained in:
parent
e918a1b5a9
commit
85b5673b33
|
@ -75,12 +75,12 @@ static int link_new(Manager *manager, sd_rtnl_message *message, Link **ret) {
|
||||||
if (!link->ifname)
|
if (!link->ifname)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
r = asprintf(&link->state_file, "/run/systemd/network/links/%"PRIu64,
|
r = asprintf(&link->state_file, "/run/systemd/netif/links/%"PRIu64,
|
||||||
link->ifindex);
|
link->ifindex);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
r = asprintf(&link->lease_file, "/run/systemd/network/leases/%"PRIu64,
|
r = asprintf(&link->lease_file, "/run/systemd/netif/leases/%"PRIu64,
|
||||||
link->ifindex);
|
link->ifindex);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
|
@ -83,7 +83,7 @@ int manager_new(Manager **ret) {
|
||||||
if (!m)
|
if (!m)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
m->state_file = strdup("/run/systemd/network/state");
|
m->state_file = strdup("/run/systemd/netif/state");
|
||||||
if (!m->state_file)
|
if (!m->state_file)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
|
|
@ -52,17 +52,17 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
/* Always create the directories people can create inotify
|
/* Always create the directories people can create inotify
|
||||||
* watches in. */
|
* watches in. */
|
||||||
r = mkdir_safe_label("/run/systemd/network", 0755, uid, gid);
|
r = mkdir_safe_label("/run/systemd/netif", 0755, uid, gid);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_error("Could not create runtime directory: %s",
|
log_error("Could not create runtime directory: %s",
|
||||||
strerror(-r));
|
strerror(-r));
|
||||||
|
|
||||||
r = mkdir_safe_label("/run/systemd/network/links", 0755, uid, gid);
|
r = mkdir_safe_label("/run/systemd/netif/links", 0755, uid, gid);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_error("Could not create runtime directory 'links': %s",
|
log_error("Could not create runtime directory 'links': %s",
|
||||||
strerror(-r));
|
strerror(-r));
|
||||||
|
|
||||||
r = mkdir_safe_label("/run/systemd/network/leases", 0755, uid, gid);
|
r = mkdir_safe_label("/run/systemd/netif/leases", 0755, uid, gid);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_error("Could not create runtime directory 'leases': %s",
|
log_error("Could not create runtime directory 'leases': %s",
|
||||||
strerror(-r));
|
strerror(-r));
|
||||||
|
|
|
@ -42,7 +42,7 @@ static int link_get_flags(unsigned index, unsigned *flags) {
|
||||||
assert(index);
|
assert(index);
|
||||||
assert(flags);
|
assert(flags);
|
||||||
|
|
||||||
if (asprintf(&p, "/run/systemd/network/links/%u", index) < 0)
|
if (asprintf(&p, "/run/systemd/netif/links/%u", index) < 0)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
r = parse_env_file(p, NEWLINE, "FLAGS", &s, NULL);
|
r = parse_env_file(p, NEWLINE, "FLAGS", &s, NULL);
|
||||||
|
@ -74,7 +74,7 @@ _public_ int sd_network_get_link_state(unsigned index, char **state) {
|
||||||
assert_return(index, -EINVAL);
|
assert_return(index, -EINVAL);
|
||||||
assert_return(state, -EINVAL);
|
assert_return(state, -EINVAL);
|
||||||
|
|
||||||
if (asprintf(&p, "/run/systemd/network/links/%u", index) < 0)
|
if (asprintf(&p, "/run/systemd/netif/links/%u", index) < 0)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
r = parse_env_file(p, NEWLINE, "ADMIN_STATE", &s, NULL);
|
r = parse_env_file(p, NEWLINE, "ADMIN_STATE", &s, NULL);
|
||||||
|
@ -102,7 +102,7 @@ _public_ int sd_network_get_operational_state(char **state) {
|
||||||
|
|
||||||
assert_return(state, -EINVAL);
|
assert_return(state, -EINVAL);
|
||||||
|
|
||||||
r = parse_env_file("/run/systemd/network/state", NEWLINE, "OPER_STATE",
|
r = parse_env_file("/run/systemd/netif/state", NEWLINE, "OPER_STATE",
|
||||||
&s, NULL);
|
&s, NULL);
|
||||||
if (r == -ENOENT)
|
if (r == -ENOENT)
|
||||||
return -ENODATA;
|
return -ENODATA;
|
||||||
|
@ -124,7 +124,7 @@ _public_ int sd_network_get_link_operational_state(unsigned index, char **state)
|
||||||
assert_return(index, -EINVAL);
|
assert_return(index, -EINVAL);
|
||||||
assert_return(state, -EINVAL);
|
assert_return(state, -EINVAL);
|
||||||
|
|
||||||
if (asprintf(&p, "/run/systemd/network/links/%u", index) < 0)
|
if (asprintf(&p, "/run/systemd/netif/links/%u", index) < 0)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
r = parse_env_file(p, NEWLINE, "OPER_STATE", &s, NULL);
|
r = parse_env_file(p, NEWLINE, "OPER_STATE", &s, NULL);
|
||||||
|
@ -149,7 +149,7 @@ _public_ int sd_network_get_dhcp_lease(unsigned index, sd_dhcp_lease **ret) {
|
||||||
assert_return(index, -EINVAL);
|
assert_return(index, -EINVAL);
|
||||||
assert_return(ret, -EINVAL);
|
assert_return(ret, -EINVAL);
|
||||||
|
|
||||||
if (asprintf(&p, "/run/systemd/network/links/%u", index) < 0)
|
if (asprintf(&p, "/run/systemd/netif/links/%u", index) < 0)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
r = parse_env_file(p, NEWLINE, "DHCP_LEASE", &s, NULL);
|
r = parse_env_file(p, NEWLINE, "DHCP_LEASE", &s, NULL);
|
||||||
|
@ -176,7 +176,7 @@ static int network_get_in_addr(const char *key, unsigned index, struct in_addr *
|
||||||
assert_return(addr, -EINVAL);
|
assert_return(addr, -EINVAL);
|
||||||
assert_return(addr_size, -EINVAL);
|
assert_return(addr_size, -EINVAL);
|
||||||
|
|
||||||
if (asprintf(&p, "/run/systemd/network/links/%u", index) < 0)
|
if (asprintf(&p, "/run/systemd/netif/links/%u", index) < 0)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
r = parse_env_file(p, NEWLINE, key, &s, NULL);
|
r = parse_env_file(p, NEWLINE, key, &s, NULL);
|
||||||
|
@ -204,7 +204,7 @@ static int network_get_in6_addr(const char *key, unsigned index, struct in6_addr
|
||||||
assert_return(addr, -EINVAL);
|
assert_return(addr, -EINVAL);
|
||||||
assert_return(addr_size, -EINVAL);
|
assert_return(addr_size, -EINVAL);
|
||||||
|
|
||||||
if (asprintf(&p, "/run/systemd/network/links/%u", index) < 0)
|
if (asprintf(&p, "/run/systemd/netif/links/%u", index) < 0)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
r = parse_env_file(p, NEWLINE, key, &s, NULL);
|
r = parse_env_file(p, NEWLINE, key, &s, NULL);
|
||||||
|
@ -230,7 +230,7 @@ static int network_get_boolean(const char *key, unsigned index) {
|
||||||
|
|
||||||
assert_return(index, -EINVAL);
|
assert_return(index, -EINVAL);
|
||||||
|
|
||||||
if (asprintf(&p, "/run/systemd/network/links/%u", index) < 0)
|
if (asprintf(&p, "/run/systemd/netif/links/%u", index) < 0)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
r = parse_env_file(p, NEWLINE, key, &s, NULL);
|
r = parse_env_file(p, NEWLINE, key, &s, NULL);
|
||||||
|
@ -256,7 +256,7 @@ _public_ int sd_network_get_ifindices(unsigned **indices) {
|
||||||
unsigned n = 0;
|
unsigned n = 0;
|
||||||
_cleanup_free_ uid_t *l = NULL;
|
_cleanup_free_ uid_t *l = NULL;
|
||||||
|
|
||||||
d = opendir("/run/systemd/network/links/");
|
d = opendir("/run/systemd/netif/links/");
|
||||||
if (!d)
|
if (!d)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ _public_ int sd_network_monitor_new(const char *category, sd_network_monitor **m
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
if (!category || streq(category, "links")) {
|
if (!category || streq(category, "links")) {
|
||||||
k = inotify_add_watch(fd, "/run/systemd/network/links/", IN_MOVED_TO|IN_DELETE);
|
k = inotify_add_watch(fd, "/run/systemd/netif/links/", IN_MOVED_TO|IN_DELETE);
|
||||||
if (k < 0) {
|
if (k < 0) {
|
||||||
safe_close(fd);
|
safe_close(fd);
|
||||||
return -errno;
|
return -errno;
|
||||||
|
@ -337,7 +337,7 @@ _public_ int sd_network_monitor_new(const char *category, sd_network_monitor **m
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!category || streq(category, "leases")) {
|
if (!category || streq(category, "leases")) {
|
||||||
k = inotify_add_watch(fd, "/run/systemd/network/leases/", IN_MOVED_TO|IN_DELETE);
|
k = inotify_add_watch(fd, "/run/systemd/netif/leases/", IN_MOVED_TO|IN_DELETE);
|
||||||
if (k < 0) {
|
if (k < 0) {
|
||||||
safe_close(fd);
|
safe_close(fd);
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
|
@ -21,9 +21,9 @@ d /run/systemd/sessions 0755 root root -
|
||||||
d /run/systemd/users 0755 root root -
|
d /run/systemd/users 0755 root root -
|
||||||
d /run/systemd/machines 0755 root root -
|
d /run/systemd/machines 0755 root root -
|
||||||
d /run/systemd/shutdown 0755 root root -
|
d /run/systemd/shutdown 0755 root root -
|
||||||
d /run/systemd/network 0755 systemd-network systemd-network -
|
d /run/systemd/netif 0755 systemd-network systemd-network -
|
||||||
d /run/systemd/network/links 0755 systemd-network systemd-network -
|
d /run/systemd/netif/links 0755 systemd-network systemd-network -
|
||||||
d /run/systemd/network/leases 0755 systemd-network systemd-network -
|
d /run/systemd/netif/leases 0755 systemd-network systemd-network -
|
||||||
|
|
||||||
m /var/log/journal 2755 root systemd-journal - -
|
m /var/log/journal 2755 root systemd-journal - -
|
||||||
Z /var/log/journal/%m 2755 root systemd-journal - -
|
Z /var/log/journal/%m 2755 root systemd-journal - -
|
||||||
|
|
Loading…
Reference in a new issue