summaryrefslogtreecommitdiff
path: root/src/shared/conf-parser.c
diff options
context:
space:
mode:
authorDaniel Mack <daniel@zonque.org>2016-10-18 17:57:10 +0200
committerSven Eden <yamakuzure@gmx.net>2017-11-20 17:28:50 +0100
commitb605cf820c4831451fd009825a914d6f98045219 (patch)
tree6320971d755d18f28b3387d9de29ea28052d57a8 /src/shared/conf-parser.c
parent294d3039be600ee7fbe43222fcf7084c99e63b94 (diff)
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.
Diffstat (limited to 'src/shared/conf-parser.c')
-rw-r--r--src/shared/conf-parser.c49
1 files changed, 17 insertions, 32 deletions
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;