]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
Implement getter, setter for ALLOW_INTERACTIVE_AUTHORIZATION flag
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Thu, 25 Sep 2014 12:29:50 +0000 (13:29 +0100)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Tue, 28 Oct 2014 17:11:18 +0000 (17:11 +0000)
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83449
Reviewed-by: Lennart Poettering
dbus/dbus-message.c
dbus/dbus-message.h

index 974e8fa6b101831b8037ed44db3a6c85d08cf1c9..01c2367cb22b5b36b49bfc52fcd315c55603ca6c 100644 (file)
@@ -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 */
index 4fd44dabd096bea7d702d93d52cc9f91c34337bc..baa7d7b57b6cde8af4ea113f3d3b582de9aaff6d 100644 (file)
@@ -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