summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-07-06 13:38:47 +0200
committerSven Eden <yamakuzure@gmx.net>2017-03-14 10:05:56 +0100
commit74dee2a59ee0aeea915e1f17883f9007621d58e8 (patch)
treec574fe82a17fa4f09df4f64d4c3c923b7eb37165 /src
parent093cf10b14f9e6b101927a8e356def54391c5d65 (diff)
networkd: be more defensive when writing to ipv4/ipv6 forwarding settings
1) never bother with setting the flag for loopback devices 2) if we fail to write the flag due to EROFS (which is likely to happen in containers where /proc/sys is read-only) or any other error, check if the flag already has the right value. If so, don't complain. Closes #469
Diffstat (limited to 'src')
-rw-r--r--src/shared/fileio.c11
-rw-r--r--src/shared/fileio.h2
2 files changed, 13 insertions, 0 deletions
diff --git a/src/shared/fileio.c b/src/shared/fileio.c
index ff6b1a7ed..00fb6f8b5 100644
--- a/src/shared/fileio.c
+++ b/src/shared/fileio.c
@@ -134,6 +134,17 @@ int read_one_line_file(const char *fn, char **line) {
return 0;
}
+int verify_one_line_file(const char *fn, const char *line) {
+ _cleanup_free_ char *value = NULL;
+ int r;
+
+ r = read_one_line_file(fn, &value);
+ if (r < 0)
+ return r;
+
+ return streq(value, line);
+}
+
int read_full_stream(FILE *f, char **contents, size_t *size) {
size_t n, l;
_cleanup_free_ char *buf = NULL;
diff --git a/src/shared/fileio.h b/src/shared/fileio.h
index 5ae51c1e2..91d4a0d2d 100644
--- a/src/shared/fileio.h
+++ b/src/shared/fileio.h
@@ -34,6 +34,8 @@ int read_one_line_file(const char *fn, char **line);
int read_full_file(const char *fn, char **contents, size_t *size);
int read_full_stream(FILE *f, char **contents, size_t *size);
+int verify_one_line_file(const char *fn, const char *line);
+
int parse_env_file(const char *fname, const char *separator, ...) _sentinel_;
int load_env_file(FILE *f, const char *fname, const char *separator, char ***l);
int load_env_file_pairs(FILE *f, const char *fname, const char *separator, char ***l);