diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-07-06 13:38:47 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-07-06 13:41:51 +0200 |
commit | 15dee3f07c646fd345b0aa30c6566071b3365db7 (patch) | |
tree | df46683e0b92a473722be313f4ab77f0fb00332e /src/basic/fileio.c | |
parent | 1361205099406d2a19d64547448638a6b665af81 (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/basic/fileio.c')
-rw-r--r-- | src/basic/fileio.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/basic/fileio.c b/src/basic/fileio.c index ff6b1a7ed7..00fb6f8b5c 100644 --- a/src/basic/fileio.c +++ b/src/basic/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; |