1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 10:51:20 +03:00

resolved-resolv-conf: FOREACH_LINE excorcism

This commit is contained in:
Lennart Poettering 2018-10-18 16:17:23 +02:00
parent 7c777a7773
commit e1b9fc23eb

View File

@ -4,6 +4,7 @@
#include <stdio_ext.h>
#include "alloc-util.h"
#include "def.h"
#include "dns-domain.h"
#include "fd-util.h"
#include "fileio-label.h"
@ -89,7 +90,6 @@ static bool file_is_our_own(const struct stat *st) {
int manager_read_resolv_conf(Manager *m) {
_cleanup_fclose_ FILE *f = NULL;
struct stat st;
char line[LINE_MAX];
unsigned n = 0;
int r;
@ -137,10 +137,19 @@ int manager_read_resolv_conf(Manager *m) {
dns_server_mark_all(m->dns_servers);
dns_search_domain_mark_all(m->search_domains);
FOREACH_LINE(line, f, r = -errno; goto clear) {
for (;;) {
_cleanup_free_ char *line = NULL;
const char *a;
char *l;
r = read_line(f, LONG_LINE_MAX, &line);
if (r < 0) {
log_error_errno(r, "Failed to read /etc/resolv.conf: %m");
goto clear;
}
if (r == 0)
break;
n++;
l = strstrip(line);