From 527b7a421ff3927d4f3f170b1b143452e88ae1dc Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 6 Apr 2015 20:11:41 +0200 Subject: util: rework cunescape(), improve error handling Change cunescape() to return a normal error code, so that we can distuingish OOM errors from parse errors. This also adds a flags parameter to control whether "relaxed" or normal parsing shall be done. If set no parse failures are generated, and the only reason why cunescape() can fail is OOM. --- src/tmpfiles/tmpfiles.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/tmpfiles') diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 20972f6310..8c89fb33b8 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -913,13 +913,13 @@ static int write_one_file(Item *i, const char *path) { } if (i->argument) { - _cleanup_free_ char *unescaped; + _cleanup_free_ char *unescaped = NULL; log_debug("%s to \"%s\".", i->type == CREATE_FILE ? "Appending" : "Writing", path); - unescaped = cunescape(i->argument); - if (!unescaped) - return log_oom(); + r = cunescape(i->argument, 0, &unescaped); + if (r < 0) + return log_error_errno(r, "Failed to unescape parameter to write: %s", i->argument); r = loop_write(fd, unescaped, strlen(unescaped), false); if (r < 0) -- cgit v1.2.3-54-g00ecf