chiark / gitweb /
bus: fix typo
[elogind.git] / src / libsystemd / sd-bus / bus-util.c
index 43acf5b9597774f55195c60be2d20705250a676c..2c3da3ce92fc56d9fbf8a9355891c834d0026fc2 100644 (file)
@@ -20,7 +20,6 @@
 ***/
 
 #include <sys/socket.h>
-#include <sys/capability.h>
 
 #include "systemd/sd-daemon.h"
 
@@ -521,7 +520,7 @@ int bus_open_system_systemd(sd_bus **_bus) {
         if (r < 0)
                 return r;
 
-        r = sd_bus_set_address(bus, KERNEL_SYSTEM_BUS_PATH);
+        r = sd_bus_set_address(bus, KERNEL_SYSTEM_BUS_ADDRESS);
         if (r < 0)
                 return r;
 
@@ -574,7 +573,7 @@ int bus_open_user_systemd(sd_bus **_bus) {
         if (r < 0)
                 return r;
 
-        if (asprintf(&bus->address, KERNEL_USER_BUS_FMT, getuid()) < 0)
+        if (asprintf(&bus->address, KERNEL_USER_BUS_ADDRESS_FMT, getuid()) < 0)
                 return -ENOMEM;
 
         bus->bus_client = true;
@@ -640,8 +639,15 @@ int bus_print_property(const char *name, sd_bus_message *property, bool all) {
                 if (r < 0)
                         return r;
 
-                if (all || !isempty(s))
-                        printf("%s=%s\n", name, s);
+                if (all || !isempty(s)) {
+                        _cleanup_free_ char *escaped = NULL;
+
+                        escaped = xescape(s, "\n");
+                        if (!escaped)
+                                return -ENOMEM;
+
+                        printf("%s=%s\n", name, escaped);
+                }
 
                 return 1;
         }
@@ -732,10 +738,16 @@ int bus_print_property(const char *name, sd_bus_message *property, bool all) {
                                 return r;
 
                         while((r = sd_bus_message_read_basic(property, SD_BUS_TYPE_STRING, &str)) > 0) {
+                                _cleanup_free_ char *escaped = NULL;
+
                                 if (first)
                                         printf("%s=", name);
 
-                                printf("%s%s", first ? "" : " ", str);
+                                escaped = xescape(str, "\n ");
+                                if (!escaped)
+                                        return -ENOMEM;
+
+                                printf("%s%s", first ? "" : " ", escaped);
 
                                 first = false;
                         }
@@ -1143,8 +1155,8 @@ int bus_open_transport(BusTransport transport, const char *host, bool user, sd_b
                 r = sd_bus_open_system_remote(bus, host);
                 break;
 
-        case BUS_TRANSPORT_CONTAINER:
-                r = sd_bus_open_system_container(bus, host);
+        case BUS_TRANSPORT_MACHINE:
+                r = sd_bus_open_system_machine(bus, host);
                 break;
 
         default:
@@ -1178,8 +1190,8 @@ int bus_open_transport_systemd(BusTransport transport, const char *host, bool us
                 r = sd_bus_open_system_remote(bus, host);
                 break;
 
-        case BUS_TRANSPORT_CONTAINER:
-                r = sd_bus_open_system_container(bus, host);
+        case BUS_TRANSPORT_MACHINE:
+                r = sd_bus_open_system_machine(bus, host);
                 break;
 
         default:
@@ -1250,13 +1262,11 @@ int bus_property_get_ulong(
 #endif
 
 int bus_log_parse_error(int r) {
-        log_error("Failed to parse bus message: %s", strerror(-r));
-        return r;
+        return log_error_errno(r, "Failed to parse bus message: %m");
 }
 
 int bus_log_create_error(int r) {
-        log_error("Failed to create bus message: %s", strerror(-r));
-        return r;
+        return log_error_errno(r, "Failed to create bus message: %m");
 }
 
 int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u) {
@@ -1361,7 +1371,8 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
 
         if (STR_IN_SET(field,
                        "CPUAccounting", "MemoryAccounting", "BlockIOAccounting",
-                       "SendSIGHUP", "SendSIGKILL")) {
+                       "SendSIGHUP", "SendSIGKILL",
+                       "WakeSystem")) {
 
                 r = parse_boolean(eq);
                 if (r < 0) {
@@ -1522,6 +1533,17 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
 
                 r = sd_bus_message_append(m, "v", "i", sig);
 
+        } else if (streq(field, "AccuracySec")) {
+                usec_t u;
+
+                r = parse_sec(eq, &u);
+                if (r < 0) {
+                        log_error("Failed to parse %s value %s", field, eq);
+                        return -EINVAL;
+                }
+
+                r = sd_bus_message_append(m, "v", "t", u);
+
         } else {
                 log_error("Unknown assignment %s.", assignment);
                 return -EINVAL;