chiark / gitweb /
tmpfiles: port to unquote_many_words()
authordaurnimator <quae@daurnimator.com>
Mon, 9 Mar 2015 19:11:44 +0000 (15:11 -0400)
committerLennart Poettering <lennart@poettering.net>
Tue, 10 Mar 2015 15:08:20 +0000 (16:08 +0100)
TODO
man/tmpfiles.d.xml
src/tmpfiles/tmpfiles.c

diff --git a/TODO b/TODO
index 6c1f23089e1d325e5c557b6666574b8671444278..6180077117067f4d59c1f31c2b0009f016405b9d 100644 (file)
--- a/TODO
+++ b/TODO
@@ -232,8 +232,6 @@ Features:
 
 * exponential backoff in timesyncd and resolved when we cannot reach a server
 
-* tmpfiles: port to unquote_many_words(), similar to sysusers
-
 * unquote_many_words() should probably be used by a lot of code that
   currently uses FOREACH_WORD and friends. For example, most conf
   parsing callbacks should use it.
index 4bd0fcf751d75a9e71ea64c1ee2485803006484a..bc98d8b9488758069c0497ae03a1c54c20114f91 100644 (file)
     d    /run/user   0755 root root 10d -
     L    /tmp/foobar -    -    -    -   /dev/null</programlisting>
 
+    <para>Fields may be enclosed within quotes and contain C-style escapes.</para>
+
     <refsect2>
       <title>Type</title>
 
index 652fe5f229ca653993f95cf89aa504dca0b947bf..10c5a63dbf4d7734db6121e0fa42c1b58db28af6 100644 (file)
@@ -1506,23 +1506,25 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
         _cleanup_(item_free_contents) Item i = {};
         ItemArray *existing;
         Hashmap *h;
-        int r, c = -1, pos;
+        int r, pos;
         bool force = false, boot = false;
 
         assert(fname);
         assert(line >= 1);
         assert(buffer);
 
-        r = sscanf(buffer,
-                   "%ms %ms %ms %ms %ms %ms %n",
+        r = unquote_many_words(&buffer,
                    &action,
                    &path,
                    &mode,
                    &user,
                    &group,
                    &age,
-                   &c);
-        if (r < 2) {
+                   &i.argument,
+                   NULL);
+        if (r < 0)
+                return log_error_errno(r, "[%s:%u] Failed to parse line: %m", fname, line);
+        else if (r < 2) {
                 log_error("[%s:%u] Syntax error.", fname, line);
                 return -EIO;
         }
@@ -1559,15 +1561,6 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
                 return r;
         }
 
-        if (c >= 0)  {
-                c += strspn(buffer+c, WHITESPACE);
-                if (buffer[c] != 0 && (buffer[c] != '-' || buffer[c+1] != 0)) {
-                        i.argument = unquote(buffer+c, "\"");
-                        if (!i.argument)
-                                return log_oom();
-                }
-        }
-
         switch (i.type) {
 
         case CREATE_FILE: