chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
treewide: auto-convert the simple cases to log_*_errno()
[elogind.git]
/
src
/
libsystemd
/
sd-bus
/
bus-util.c
diff --git
a/src/libsystemd/sd-bus/bus-util.c
b/src/libsystemd/sd-bus/bus-util.c
index a85d36180e124b1d2802095e15ae0740c95c1646..4b5c1a6d36b5463edaf0a363f38e1f9d09b57319 100644
(file)
--- a/
src/libsystemd/sd-bus/bus-util.c
+++ b/
src/libsystemd/sd-bus/bus-util.c
@@
-212,13
+212,19
@@
int bus_verify_polkit(
#ifdef ENABLE_POLKIT
else {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
#ifdef ENABLE_POLKIT
else {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
- int authorized = false, challenge = false;
+ int authorized = false, challenge = false
, c
;
const char *sender;
sender = sd_bus_message_get_sender(call);
if (!sender)
return -EBADMSG;
const char *sender;
sender = sd_bus_message_get_sender(call);
if (!sender)
return -EBADMSG;
+ c = sd_bus_message_get_allow_interactive_authorization(call);
+ if (c < 0)
+ return c;
+ if (c > 0)
+ interactive = true;
+
r = sd_bus_call_method(
call->bus,
"org.freedesktop.PolicyKit1",
r = sd_bus_call_method(
call->bus,
"org.freedesktop.PolicyKit1",
@@
-231,7
+237,7
@@
int bus_verify_polkit(
"system-bus-name", 1, "name", "s", sender,
action,
0,
"system-bus-name", 1, "name", "s", sender,
action,
0,
-
interactive ? 1 : 0
,
+
!!interactive
,
"");
if (r < 0) {
"");
if (r < 0) {
@@
-334,6
+340,7
@@
int bus_verify_polkit_async(
const char *sender;
sd_bus_message_handler_t callback;
void *userdata;
const char *sender;
sd_bus_message_handler_t callback;
void *userdata;
+ int c;
#endif
int r;
#endif
int r;
@@
-375,6
+382,9
@@
int bus_verify_polkit_async(
if (authorized)
return 1;
if (authorized)
return 1;
+ if (challenge)
+ return sd_bus_error_set(error, SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED, "Interactive authentication required.");
+
return -EACCES;
}
#endif
return -EACCES;
}
#endif
@@
-399,7
+409,13
@@
int bus_verify_polkit_async(
if (!sender)
return -EBADMSG;
if (!sender)
return -EBADMSG;
- r = hashmap_ensure_allocated(registry, trivial_hash_func, trivial_compare_func);
+ c = sd_bus_message_get_allow_interactive_authorization(call);
+ if (c < 0)
+ return c;
+ if (c > 0)
+ interactive = true;
+
+ r = hashmap_ensure_allocated(registry, NULL);
if (r < 0)
return r;
if (r < 0)
return r;
@@
-419,7
+435,7
@@
int bus_verify_polkit_async(
"system-bus-name", 1, "name", "s", sender,
action,
0,
"system-bus-name", 1, "name", "s", sender,
action,
0,
-
interactive ? 1 : 0
,
+
!!interactive
,
NULL);
if (r < 0)
return r;
NULL);
if (r < 0)
return r;
@@
-624,14
+640,21
@@
int bus_print_property(const char *name, sd_bus_message *property, bool all) {
if (r < 0)
return r;
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;
}
case SD_BUS_TYPE_BOOLEAN: {
return 1;
}
case SD_BUS_TYPE_BOOLEAN: {
-
bool
b;
+
int
b;
r = sd_bus_message_read_basic(property, type, &b);
if (r < 0)
r = sd_bus_message_read_basic(property, type, &b);
if (r < 0)
@@
-716,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) {
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);
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;
}
first = false;
}
@@
-1234,12
+1263,12
@@
int bus_property_get_ulong(
#endif
int bus_log_parse_error(int r) {
#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) {
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;
}
return r;
}