summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2014-09-25 13:29:50 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-10-28 17:11:18 +0000
commit13d8bc76291693c0fe9a36646023b53d44d19448 (patch)
treecedbec9d0889c63887ce9d98d1a2b5daca15aa17
parenta400f9ac25c16165a754546bf99314cc8d9d46db (diff)
downloaddbus-13d8bc76291693c0fe9a36646023b53d44d19448.tar.gz
Implement getter, setter for ALLOW_INTERACTIVE_AUTHORIZATION flag
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83449 Reviewed-by: Lennart Poettering
-rw-r--r--dbus/dbus-message.c48
-rw-r--r--dbus/dbus-message.h8
2 files changed, 56 insertions, 0 deletions
diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c
index 974e8fa6..01c2367c 100644
--- a/dbus/dbus-message.c
+++ b/dbus/dbus-message.c
@@ -4876,6 +4876,54 @@ dbus_message_demarshal_bytes_needed(const char *buf,
}
}
+/**
+ * Sets a flag indicating that the caller of the method is prepared
+ * to wait for interactive authorization to take place (for instance
+ * via Polkit) before the actual method is processed.
+ *
+ * The flag is #FALSE by default; that is, by default the other end is
+ * expected to make any authorization decisions non-interactively
+ * and promptly. It may use the error
+ * #DBUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED to signal that
+ * authorization failed, but could have succeeded if this flag had
+ * been used.
+ *
+ * For messages whose type is not #DBUS_MESSAGE_TYPE_METHOD_CALL,
+ * this flag is meaningless and should not be set.
+ *
+ * On the protocol level this toggles
+ * #DBUS_HEADER_FLAG_ALLOW_INTERACTIVE_AUTHORIZATION.
+ *
+ * @param message the message
+ * @param allow #TRUE if interactive authorization is acceptable
+ */
+void
+dbus_message_set_allow_interactive_authorization (DBusMessage *message,
+ dbus_bool_t allow)
+{
+ _dbus_return_if_fail (message != NULL);
+ _dbus_return_if_fail (!message->locked);
+
+ _dbus_header_toggle_flag (&message->header,
+ DBUS_HEADER_FLAG_ALLOW_INTERACTIVE_AUTHORIZATION,
+ allow);
+}
+
+/**
+ * Returns whether the flag controlled by
+ * dbus_message_set_allow_interactive_authorization() has been set.
+ *
+ * @param message the message
+ */
+dbus_bool_t
+dbus_message_get_allow_interactive_authorization (DBusMessage *message)
+{
+ _dbus_return_val_if_fail (message != NULL, FALSE);
+
+ return _dbus_header_get_flag (&message->header,
+ DBUS_HEADER_FLAG_ALLOW_INTERACTIVE_AUTHORIZATION);
+}
+
/** @} */
/* tests in dbus-message-util.c */
diff --git a/dbus/dbus-message.h b/dbus/dbus-message.h
index 4fd44dab..baa7d7b5 100644
--- a/dbus/dbus-message.h
+++ b/dbus/dbus-message.h
@@ -302,6 +302,14 @@ DBUS_EXPORT
int dbus_message_demarshal_bytes_needed (const char *str,
int len);
+DBUS_EXPORT
+void dbus_message_set_allow_interactive_authorization (DBusMessage *message,
+ dbus_bool_t allow);
+
+DBUS_EXPORT
+dbus_bool_t dbus_message_get_allow_interactive_authorization (
+ DBusMessage *message);
+
/** @} */
DBUS_END_DECLS