]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/shared/bus-unit-util.c
tree-wide: use TAKE_PTR() and TAKE_FD() macros
[thirdparty/systemd.git] / src / shared / bus-unit-util.c
index 78b9b69557764d1894c17c9d1772d1b67c35a54c..a9c17d29e2a0a25813539f179f661107a674b254 100644 (file)
@@ -91,8 +91,7 @@ int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u) {
                         return bus_log_create_error(r);                 \
                                                                         \
                 return 1;                                               \
-        }                                                               \
-        struct __useless_struct_to_allow_trailing_semicolon__
+        }
 
 #define DEFINE_BUS_APPEND_PARSE(bus_type, parse_func)                   \
         static int bus_append_##parse_func(                             \
@@ -113,8 +112,7 @@ int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u) {
                         return bus_log_create_error(r);                 \
                                                                         \
                 return 1;                                               \
-        }                                                               \
-        struct __useless_struct_to_allow_trailing_semicolon__
+        }
 
 DEFINE_BUS_APPEND_PARSE("b", parse_boolean);
 DEFINE_BUS_APPEND_PARSE("i", ioprio_class_from_string);
@@ -462,7 +460,6 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
                         return bus_append_safe_atou64(m, field, eq);
 
                 return bus_append_parse_size(m, field, eq, 1024);
-
         }
 
         if (streq(field, "CPUQuota")) {
@@ -1135,6 +1132,62 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
                 return 1;
         }
 
+        if (streq(field, "TemporaryFileSystem")) {
+                const char *p = eq;
+
+                r = sd_bus_message_open_container(m, SD_BUS_TYPE_STRUCT, "sv");
+                if (r < 0)
+                        return bus_log_create_error(r);
+
+                r = sd_bus_message_append_basic(m, SD_BUS_TYPE_STRING, field);
+                if (r < 0)
+                        return bus_log_create_error(r);
+
+                r = sd_bus_message_open_container(m, 'v', "a(ss)");
+                if (r < 0)
+                        return bus_log_create_error(r);
+
+                r = sd_bus_message_open_container(m, 'a', "(ss)");
+                if (r < 0)
+                        return bus_log_create_error(r);
+
+                for (;;) {
+                        _cleanup_free_ char *word = NULL, *path = NULL;
+                        const char *w;
+
+                        r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES);
+                        if (r < 0)
+                                return log_error_errno(r, "Failed to parse argument: %m");
+                        if (r == 0)
+                                break;
+
+                        w = word;
+                        r = extract_first_word(&w, &path, ":", EXTRACT_DONT_COALESCE_SEPARATORS);
+                        if (r < 0)
+                                return log_error_errno(r, "Failed to parse argument: %m");
+                        if (r == 0)
+                                return log_error("Failed to parse argument: %m");
+
+                        r = sd_bus_message_append(m, "(ss)", path, w);
+                        if (r < 0)
+                                return bus_log_create_error(r);
+                }
+
+                r = sd_bus_message_close_container(m);
+                if (r < 0)
+                        return bus_log_create_error(r);
+
+                r = sd_bus_message_close_container(m);
+                if (r < 0)
+                        return bus_log_create_error(r);
+
+                r = sd_bus_message_close_container(m);
+                if (r < 0)
+                        return bus_log_create_error(r);
+
+                return 1;
+        }
+
         return 0;
 }
 
@@ -1263,13 +1316,13 @@ static int bus_append_service_property(sd_bus_message *m, const char *field, con
                                 if (val < 0)
                                         return log_error_errno(r, "Invalid status or signal %s in %s: %m", word, field);
 
-                                signal = realloc_multiply(signal, sizeof(int), sz_signal + 1);
+                                signal = reallocarray(signal, sz_signal + 1, sizeof(int));
                                 if (!signal)
                                         return log_oom();
 
                                 signal[sz_signal++] = val;
                         } else {
-                                status = realloc_multiply(status, sizeof(int), sz_status + 1);
+                                status = reallocarray(status, sz_status + 1, sizeof(int));
                                 if (!status)
                                         return log_oom();
 
@@ -1752,8 +1805,7 @@ int bus_wait_for_jobs_new(sd_bus *bus, BusWaitForJobs **ret) {
         if (r < 0)
                 return r;
 
-        *ret = d;
-        d = NULL;
+        *ret = TAKE_PTR(d);
 
         return 0;
 }