From b605cf820c4831451fd009825a914d6f98045219 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Tue, 18 Oct 2016 17:57:10 +0200 Subject: Add abstraction model for BPF programs This object takes a number of bpf_insn members and wraps them together with the in-kernel reference id. Will be needed by the firewall code. --- src/shared/conf-parser.c | 49 +++++++++++++++++------------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) (limited to 'src/shared/conf-parser.c') diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 2005671fe..ab66bfe60 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -28,10 +28,8 @@ #include "alloc-util.h" #include "conf-files.h" #include "conf-parser.h" -#include "def.h" #include "extract-word.h" #include "fd-util.h" -#include "fileio.h" #include "fs-util.h" #include "log.h" #include "macro.h" @@ -317,44 +315,24 @@ int config_parse(const char *unit, fd_warn_permissions(filename, fileno(f)); for (;;) { - _cleanup_free_ char *buf = NULL; - char *l, *p, *c = NULL, *e; + char buf[LINE_MAX], *l, *p, *c = NULL, *e; bool escaped = false; - r = read_line(f, LONG_LINE_MAX, &buf); - if (r == 0) - break; - if (r == -ENOBUFS) { - if (warn) - log_error_errno(r, "%s:%u: Line too long", filename, line); + if (!fgets(buf, sizeof buf, f)) { + if (feof(f)) + break; - return r; - } - if (r < 0) { - if (warn) - log_error_errno(r, "%s:%u: Error while reading configuration file: %m", filename, line); - - return r; + return log_error_errno(errno, "Failed to read configuration file '%s': %m", filename); } l = buf; - if (allow_bom) { - char *q; + if (allow_bom && startswith(l, UTF8_BYTE_ORDER_MARK)) + l += strlen(UTF8_BYTE_ORDER_MARK); + allow_bom = false; - q = startswith(buf, UTF8_BYTE_ORDER_MARK); - if (q) { - l = q; - allow_bom = false; - } - } + truncate_nl(l); if (continuation) { - if (strlen(continuation) + strlen(l) > LONG_LINE_MAX) { - if (warn) - log_error("%s:%u: Continuation line too long", filename, line); - return -ENOBUFS; - } - c = strappend(continuation, l); if (!c) { if (warn) @@ -408,7 +386,8 @@ int config_parse(const char *unit, if (r < 0) { if (warn) - log_warning_errno(r, "%s:%u: Failed to parse file: %m", filename, line); + log_warning_errno(r, "Failed to parse file '%s': %m", + filename); return r; } } @@ -755,6 +734,11 @@ int config_parse_path( assert(rvalue); assert(data); + if (isempty(rvalue)) { + n = NULL; + goto finalize; + } + if (!utf8_is_valid(rvalue)) { log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, rvalue); return fatal ? -ENOEXEC : 0; @@ -773,6 +757,7 @@ int config_parse_path( path_kill_slashes(n); +finalize: free(*s); *s = n; -- cgit v1.2.3