naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
84b277
From e091fcc1cc628b9e2192104c47e2be103bc8577a Mon Sep 17 00:00:00 2001
84b277
From: Lennart Poettering <lennart@poettering.net>
84b277
Date: Mon, 17 Feb 2014 01:58:33 +0100
84b277
Subject: [PATCH] core: fix property changes in transient units
84b277
84b277
(cherry-picked from 6d2357247b198314d972932415d65a42f83a9b6e)
84b277
84b277
Resolves: #1147524
84b277
---
84b277
 src/core/dbus-unit.c |  3 ---
84b277
 src/core/unit.c      | 13 ++++++-------
84b277
 2 files changed, 6 insertions(+), 10 deletions(-)
84b277
84b277
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
84b277
index 2ea59b2..a185f5c 100644
84b277
--- a/src/core/dbus-unit.c
84b277
+++ b/src/core/dbus-unit.c
84b277
@@ -962,9 +962,6 @@ int bus_unit_set_properties(
84b277
         assert(u);
84b277
         assert(iter);
84b277
 
84b277
-        if (u->transient)
84b277
-                mode &= UNIT_RUNTIME;
84b277
-
84b277
         /* We iterate through the array twice. First run we just check
84b277
          * if all passed data is valid, second run actually applies
84b277
          * it. This is to implement transaction-like behaviour without
84b277
diff --git a/src/core/unit.c b/src/core/unit.c
84b277
index 87a6385..e56971b 100644
84b277
--- a/src/core/unit.c
84b277
+++ b/src/core/unit.c
84b277
@@ -2904,7 +2904,6 @@ static int drop_in_file(Unit *u, UnitSetPropertiesMode mode, const char *name, c
84b277
         assert(name);
84b277
         assert(_p);
84b277
         assert(_q);
84b277
-        assert(mode & (UNIT_PERSISTENT|UNIT_RUNTIME));
84b277
 
84b277
         b = xescape(name, "/.");
84b277
         if (!b)
84b277
@@ -2923,7 +2922,7 @@ static int drop_in_file(Unit *u, UnitSetPropertiesMode mode, const char *name, c
84b277
                         return -ENOENT;
84b277
 
84b277
                 p = strjoin(c, "/", u->id, ".d", NULL);
84b277
-        } else if (mode & UNIT_PERSISTENT)
84b277
+        } else if (mode == UNIT_PERSISTENT && !u->transient)
84b277
                 p = strjoin("/etc/systemd/system/", u->id, ".d", NULL);
84b277
         else
84b277
                 p = strjoin("/run/systemd/system/", u->id, ".d", NULL);
84b277
@@ -2949,7 +2948,7 @@ int unit_write_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name, co
84b277
         assert(name);
84b277
         assert(data);
84b277
 
84b277
-        if (!(mode & (UNIT_PERSISTENT|UNIT_RUNTIME)))
84b277
+        if (!IN_SET(mode, UNIT_PERSISTENT, UNIT_RUNTIME))
84b277
                 return 0;
84b277
 
84b277
         r = drop_in_file(u, mode, name, &p, &q);
84b277
@@ -2969,7 +2968,7 @@ int unit_write_drop_in_format(Unit *u, UnitSetPropertiesMode mode, const char *n
84b277
         assert(name);
84b277
         assert(format);
84b277
 
84b277
-        if (!(mode & (UNIT_PERSISTENT|UNIT_RUNTIME)))
84b277
+        if (!IN_SET(mode, UNIT_PERSISTENT, UNIT_RUNTIME))
84b277
                 return 0;
84b277
 
84b277
         va_start(ap, format);
84b277
@@ -2992,7 +2991,7 @@ int unit_write_drop_in_private(Unit *u, UnitSetPropertiesMode mode, const char *
84b277
         if (!UNIT_VTABLE(u)->private_section)
84b277
                 return -EINVAL;
84b277
 
84b277
-        if (!(mode & (UNIT_PERSISTENT|UNIT_RUNTIME)))
84b277
+        if (!IN_SET(mode, UNIT_PERSISTENT, UNIT_RUNTIME))
84b277
                 return 0;
84b277
 
84b277
         ndata = strjoin("[", UNIT_VTABLE(u)->private_section, "]\n", data, NULL);
84b277
@@ -3011,7 +3010,7 @@ int unit_write_drop_in_private_format(Unit *u, UnitSetPropertiesMode mode, const
84b277
         assert(name);
84b277
         assert(format);
84b277
 
84b277
-        if (!(mode & (UNIT_PERSISTENT|UNIT_RUNTIME)))
84b277
+        if (!IN_SET(mode, UNIT_PERSISTENT, UNIT_RUNTIME))
84b277
                 return 0;
84b277
 
84b277
         va_start(ap, format);
84b277
@@ -3030,7 +3029,7 @@ int unit_remove_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name) {
84b277
 
84b277
         assert(u);
84b277
 
84b277
-        if (!(mode & (UNIT_PERSISTENT|UNIT_RUNTIME)))
84b277
+        if (!IN_SET(mode, UNIT_PERSISTENT, UNIT_RUNTIME))
84b277
                 return 0;
84b277
 
84b277
         r = drop_in_file(u, mode, name, &p, &q);