]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/unit: append newline when writing drop ins
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 28 May 2016 20:06:44 +0000 (16:06 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 28 May 2016 20:17:54 +0000 (16:17 -0400)
unit_write_drop_in{,_private}{,_format} are all affected.

We already append a header to the file (and section markers), so those functions
can only be used to write a whole file at once. Including the newline at
the end feels natural.

After this commit newlines will be duplicated. They will be removed in
subsequent commit.

Also, rewrap the "autogenerated" header to fit within 80 columns.

src/core/unit.c

index 2fff3f2d8b22b5102218b3bde2cf6e7272cba877..e98086a3f6ddffdb6cfa1f02cd200d2bf4f482ea 100644 (file)
@@ -3355,7 +3355,7 @@ static const char* unit_drop_in_dir(Unit *u, UnitSetPropertiesMode mode) {
 
 int unit_write_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name, const char *data) {
         _cleanup_free_ char *p = NULL, *q = NULL;
-        const char *dir, *prefixed;
+        const char *dir, *wrapped;
         int r;
 
         assert(u);
@@ -3374,15 +3374,17 @@ int unit_write_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name, co
         if (!dir)
                 return -EINVAL;
 
-        prefixed = strjoina("# This is a drop-in unit file extension, created via \"systemctl set-property\" or an equivalent operation. Do not edit.\n",
-                            data);
+        wrapped = strjoina("# This is a drop-in unit file extension, created via \"systemctl set-property\"\n"
+                           "or an equivalent operation. Do not edit.\n",
+                           data,
+                           "\n");
 
         r = drop_in_file(dir, u->id, 50, name, &p, &q);
         if (r < 0)
                 return r;
 
         (void) mkdir_p(p, 0755);
-        r = write_string_file_atomic_label(q, prefixed);
+        r = write_string_file_atomic_label(q, wrapped);
         if (r < 0)
                 return r;