chiark / gitweb /
treewide: no need to negate errno for log_*_errno()
[elogind.git] / src / libsystemd / sd-bus / bus-util.c
index b8559e9826955dc1aeb4f76c46a60dc21a2b7a49..22a3766a02ced6159f2dcf97ec24df55b920c20d 100644 (file)
@@ -382,6 +382,9 @@ int bus_verify_polkit_async(
                 if (authorized)
                         return 1;
 
+                if (challenge)
+                        return sd_bus_error_set(error, SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED, "Interactive authentication required.");
+
                 return -EACCES;
         }
 #endif
@@ -637,8 +640,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;
         }
@@ -729,10 +739,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;
                         }
@@ -1247,12 +1263,12 @@ int bus_property_get_ulong(
 #endif
 
 int bus_log_parse_error(int r) {
-        log_error("Failed to parse bus message: %s", strerror(-r));
+        log_error_errno(r, "Failed to parse bus message: %m");
         return r;
 }
 
 int bus_log_create_error(int r) {
-        log_error("Failed to create bus message: %s", strerror(-r));
+        log_error_errno(r, "Failed to create bus message: %m");
         return r;
 }