extend sysctl functions to shadow values

Pass to all the sysctl_* functions a hashmap which can be used to
optionally save the value written in the sysctl.
This commit is contained in:
Matteo Croce
2024-09-11 23:01:25 +02:00
parent 2b735c7d71
commit 766bcf302a
6 changed files with 78 additions and 40 deletions
+2 -2
View File
@@ -53,14 +53,14 @@ TEST(sysctl_read) {
assert_se(sysctl_read_ip_property(AF_INET, "lo", "forwarding", &s));
assert_se(STR_IN_SET(s, "0", "1"));
r = sysctl_write_ip_property(AF_INET, "lo", "forwarding", s);
r = sysctl_write_ip_property(AF_INET, "lo", "forwarding", s, NULL);
assert_se(r >= 0 || ERRNO_IS_PRIVILEGE(r) || r == -EROFS);
s = mfree(s);
assert_se(sysctl_read_ip_property(AF_INET, NULL, "ip_forward", &s));
assert_se(STR_IN_SET(s, "0", "1"));
r = sysctl_write_ip_property(AF_INET, NULL, "ip_forward", s);
r = sysctl_write_ip_property(AF_INET, NULL, "ip_forward", s, NULL);
assert_se(r >= 0 || ERRNO_IS_PRIVILEGE(r) || r == -EROFS);
s = mfree(s);