a52f674
From 39899c866206a14dfdd19497763c84ea19f15f8a Mon Sep 17 00:00:00 2001
a52f674
From: Lennart Poettering <lennart@poettering.net>
a52f674
Date: Mon, 17 Feb 2014 01:58:33 +0100
a52f674
Subject: [PATCH] core: fix property changes in transient units
a52f674
a52f674
(cherry picked from commit 6d2357247b198314d972932415d65a42f83a9b6e)
a52f674
---
a52f674
 src/core/dbus-unit.c |  3 ---
a52f674
 src/core/unit.c      | 13 ++++++-------
a52f674
 2 files changed, 6 insertions(+), 10 deletions(-)
a52f674
a52f674
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
a52f674
index 2ea59b2..a185f5c 100644
a52f674
--- a/src/core/dbus-unit.c
a52f674
+++ b/src/core/dbus-unit.c
a52f674
@@ -962,9 +962,6 @@ int bus_unit_set_properties(
a52f674
         assert(u);
a52f674
         assert(iter);
a52f674
 
a52f674
-        if (u->transient)
a52f674
-                mode &= UNIT_RUNTIME;
a52f674
-
a52f674
         /* We iterate through the array twice. First run we just check
a52f674
          * if all passed data is valid, second run actually applies
a52f674
          * it. This is to implement transaction-like behaviour without
a52f674
diff --git a/src/core/unit.c b/src/core/unit.c
a52f674
index 49833d1..8e2a7c4 100644
a52f674
--- a/src/core/unit.c
a52f674
+++ b/src/core/unit.c
a52f674
@@ -2785,7 +2785,6 @@ static int drop_in_file(Unit *u, UnitSetPropertiesMode mode, const char *name, c
a52f674
         assert(name);
a52f674
         assert(_p);
a52f674
         assert(_q);
a52f674
-        assert(mode & (UNIT_PERSISTENT|UNIT_RUNTIME));
a52f674
 
a52f674
         b = xescape(name, "/.");
a52f674
         if (!b)
a52f674
@@ -2804,7 +2803,7 @@ static int drop_in_file(Unit *u, UnitSetPropertiesMode mode, const char *name, c
a52f674
                         return -ENOENT;
a52f674
 
a52f674
                 p = strjoin(c, "/", u->id, ".d", NULL);
a52f674
-        } else if (mode & UNIT_PERSISTENT)
a52f674
+        } else if (mode == UNIT_PERSISTENT && !u->transient)
a52f674
                 p = strjoin("/etc/systemd/system/", u->id, ".d", NULL);
a52f674
         else
a52f674
                 p = strjoin("/run/systemd/system/", u->id, ".d", NULL);
a52f674
@@ -2830,7 +2829,7 @@ int unit_write_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name, co
a52f674
         assert(name);
a52f674
         assert(data);
a52f674
 
a52f674
-        if (!(mode & (UNIT_PERSISTENT|UNIT_RUNTIME)))
a52f674
+        if (!IN_SET(mode, UNIT_PERSISTENT, UNIT_RUNTIME))
a52f674
                 return 0;
a52f674
 
a52f674
         r = drop_in_file(u, mode, name, &p, &q);
a52f674
@@ -2850,7 +2849,7 @@ int unit_write_drop_in_format(Unit *u, UnitSetPropertiesMode mode, const char *n
a52f674
         assert(name);
a52f674
         assert(format);
a52f674
 
a52f674
-        if (!(mode & (UNIT_PERSISTENT|UNIT_RUNTIME)))
a52f674
+        if (!IN_SET(mode, UNIT_PERSISTENT, UNIT_RUNTIME))
a52f674
                 return 0;
a52f674
 
a52f674
         va_start(ap, format);
a52f674
@@ -2873,7 +2872,7 @@ int unit_write_drop_in_private(Unit *u, UnitSetPropertiesMode mode, const char *
a52f674
         if (!UNIT_VTABLE(u)->private_section)
a52f674
                 return -EINVAL;
a52f674
 
a52f674
-        if (!(mode & (UNIT_PERSISTENT|UNIT_RUNTIME)))
a52f674
+        if (!IN_SET(mode, UNIT_PERSISTENT, UNIT_RUNTIME))
a52f674
                 return 0;
a52f674
 
a52f674
         ndata = strjoin("[", UNIT_VTABLE(u)->private_section, "]\n", data, NULL);
a52f674
@@ -2892,7 +2891,7 @@ int unit_write_drop_in_private_format(Unit *u, UnitSetPropertiesMode mode, const
a52f674
         assert(name);
a52f674
         assert(format);
a52f674
 
a52f674
-        if (!(mode & (UNIT_PERSISTENT|UNIT_RUNTIME)))
a52f674
+        if (!IN_SET(mode, UNIT_PERSISTENT, UNIT_RUNTIME))
a52f674
                 return 0;
a52f674
 
a52f674
         va_start(ap, format);
a52f674
@@ -2911,7 +2910,7 @@ int unit_remove_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name) {
a52f674
 
a52f674
         assert(u);
a52f674
 
a52f674
-        if (!(mode & (UNIT_PERSISTENT|UNIT_RUNTIME)))
a52f674
+        if (!IN_SET(mode, UNIT_PERSISTENT, UNIT_RUNTIME))
a52f674
                 return 0;
a52f674
 
a52f674
         r = drop_in_file(u, mode, name, &p, &q);