chiark / gitweb /
dbus: fix minor memory leak when sending job change signals
[elogind.git] / src / core / unit.c
index be554dac2082840297d88602a5afb14ae94f0e43..afeb15c1542ac10e3b90ceccb2c23bafd2be3c88 100644 (file)
@@ -2675,7 +2675,7 @@ static int drop_in_file(Unit *u, UnitSetPropertiesMode mode, const char *name, c
         if (!p)
                 return -ENOMEM;
 
-        q = strjoin(p, "/50-", name, ".conf", NULL);
+        q = strjoin(p, "/90-", name, ".conf", NULL);
         if (!q) {
                 free(p);
                 return -ENOMEM;
@@ -2691,6 +2691,8 @@ int unit_write_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name, co
         int r;
 
         assert(u);
+        assert(name);
+        assert(data);
 
         if (!(mode & (UNIT_PERSISTENT|UNIT_RUNTIME)))
                 return 0;
@@ -2703,6 +2705,23 @@ int unit_write_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name, co
         return write_string_file_atomic_label(q, data);
 }
 
+int unit_write_drop_in_private_section(Unit *u, UnitSetPropertiesMode mode, const char *name, const char *data) {
+        _cleanup_free_ char *ndata = NULL;
+
+        assert(u);
+        assert(name);
+        assert(data);
+
+        if (!UNIT_VTABLE(u)->private_section)
+                return -EINVAL;
+
+        ndata = strjoin("[", UNIT_VTABLE(u)->private_section, "]\n", data, NULL);
+        if (!ndata)
+                return -ENOMEM;
+
+        return unit_write_drop_in(u, mode, name, ndata);
+}
+
 int unit_remove_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name) {
         _cleanup_free_ char *p = NULL, *q = NULL;
         int r;
@@ -2714,9 +2733,9 @@ int unit_remove_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name) {
 
         r = drop_in_file(u, mode, name, &p, &q);
         if (unlink(q) < 0)
-                r = -errno;
+                r = errno == ENOENT ? 0 : -errno;
         else
-                r = 0;
+                r = 1;
 
         rmdir(p);
         return r;