Commit cb753dfd authored by David Zeuthen's avatar David Zeuthen

GDBus: Rename ::deny-authentication-peer to ::authorize-authenticated-peer

parent 9e90b381
......@@ -2240,7 +2240,7 @@ g_dbus_is_interface_name
GDBusAuthObserver
GDBusAuthObserverClass
g_dbus_auth_observer_new
g_dbus_auth_observer_deny_authenticated_peer
g_dbus_auth_observer_authorize_authenticated_peer
<SUBSECTION Standard>
G_DBUS_AUTH_OBSERVER
G_IS_DBUS_AUTH_OBSERVER
......
......@@ -1132,15 +1132,15 @@ _g_dbus_auth_run_server (GDBusAuth *auth,
{
case G_DBUS_AUTH_MECHANISM_STATE_ACCEPTED:
if (observer != NULL &&
g_dbus_auth_observer_deny_authenticated_peer (observer,
auth->priv->stream,
credentials))
!g_dbus_auth_observer_authorize_authenticated_peer (observer,
auth->priv->stream,
credentials))
{
/* disconnect */
g_set_error_literal (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
_("Cancelled via GDBusAuthObserver::deny-authenticated-peer"));
_("Cancelled via GDBusAuthObserver::authorize-authenticated-peer"));
goto out;
}
else
......
......@@ -46,24 +46,24 @@
* processes owned by the same uid as the server, you would do this:
* <example id="auth-observer"><title>Controlling Authentication</title><programlisting>
* static gboolean
* on_deny_authenticated_peer (GDBusAuthObserver *observer,
* GIOStream *stream,
* GCredentials *credentials,
* gpointer user_data)
* on_authorize_authenticated_peer (GDBusAuthObserver *observer,
* GIOStream *stream,
* GCredentials *credentials,
* gpointer user_data)
* {
* GCredentials *me;
* gboolean deny;
* gboolean authorized;
*
* deny = TRUE;
* authorized = FALSE;
* me = g_credentials_new ();
*
* if (credentials != NULL &&
* !g_credentials_is_same_user (credentials, me))
* deny = FALSE;
* authorized = TRUE;
*
* g_object_unref (me);
*
* return deny;
* return authorized;
* }
*
* static gboolean
......@@ -88,8 +88,8 @@
* NULL, /<!-- -->* GCancellable *<!-- -->/
* &error);
* g_signal_connect (observer,
* "deny-authenticated-peer",
* G_CALLBACK (on_deny_authenticated_peer),
* "authorize-authenticated-peer",
* G_CALLBACK (on_authorize_authenticated_peer),
* NULL);
* g_signal_connect (server,
* "new-connection",
......@@ -107,7 +107,7 @@ struct _GDBusAuthObserverPrivate
enum
{
DENY_AUTHENTICATED_PEER_SIGNAL,
AUTHORIZE_AUTHENTICATED_PEER_SIGNAL,
LAST_SIGNAL,
};
......@@ -124,11 +124,27 @@ g_dbus_auth_observer_finalize (GObject *object)
}
static gboolean
g_dbus_auth_observer_deny_authenticated_peer_real (GDBusAuthObserver *observer,
GIOStream *stream,
GCredentials *credentials)
g_dbus_auth_observer_authorize_authenticated_peer_real (GDBusAuthObserver *observer,
GIOStream *stream,
GCredentials *credentials)
{
return TRUE;
}
gboolean
_g_signal_accumulator_false_handled (GSignalInvocationHint *ihint,
GValue *return_accu,
const GValue *handler_return,
gpointer dummy)
{
return FALSE;
gboolean continue_emission;
gboolean signal_handled;
signal_handled = g_value_get_boolean (handler_return);
g_value_set_boolean (return_accu, signal_handled);
continue_emission = signal_handled;
return continue_emission;
}
static void
......@@ -138,27 +154,27 @@ g_dbus_auth_observer_class_init (GDBusAuthObserverClass *klass)
gobject_class->finalize = g_dbus_auth_observer_finalize;
klass->deny_authenticated_peer = g_dbus_auth_observer_deny_authenticated_peer_real;
klass->authorize_authenticated_peer = g_dbus_auth_observer_authorize_authenticated_peer_real;
/**
* GDBusAuthObserver::deny-authenticated-peer:
* GDBusAuthObserver::authorize-authenticated-peer:
* @observer: The #GDBusAuthObserver emitting the signal.
* @stream: A #GIOStream for the #GDBusConnection.
* @credentials: Credentials received from the peer or %NULL.
*
* Emitted to check if a peer that is successfully authenticated
* should be denied.
* is authorized.
*
* Returns: %TRUE if the peer should be denied, %FALSE otherwise.
* Returns: %TRUE if the peer is authorized, %FALSE if not.
*
* Since: 2.26
*/
signals[DENY_AUTHENTICATED_PEER_SIGNAL] =
g_signal_new ("deny-authenticated-peer",
signals[AUTHORIZE_AUTHENTICATED_PEER_SIGNAL] =
g_signal_new ("authorize-authenticated-peer",
G_TYPE_DBUS_AUTH_OBSERVER,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GDBusAuthObserverClass, deny_authenticated_peer),
g_signal_accumulator_true_handled,
G_STRUCT_OFFSET (GDBusAuthObserverClass, authorize_authenticated_peer),
_g_signal_accumulator_false_handled,
NULL, /* accu_data */
_gio_marshal_BOOLEAN__OBJECT_OBJECT,
G_TYPE_BOOLEAN,
......@@ -197,27 +213,27 @@ g_dbus_auth_observer_new (void)
/* ---------------------------------------------------------------------------------------------------- */
/**
* g_dbus_auth_observer_deny_authenticated_peer:
* g_dbus_auth_observer_authorize_authenticated_peer:
* @observer: A #GDBusAuthObserver.
* @stream: A #GIOStream for the #GDBusConnection.
* @credentials: Credentials received from the peer or %NULL.
*
* Emits the #GDBusAuthObserver::deny-authenticated-peer signal on @observer.
* Emits the #GDBusAuthObserver::authorize-authenticated-peer signal on @observer.
*
* Returns: %TRUE if the peer should be denied, %FALSE otherwise.
*
* Since: 2.26
*/
gboolean
g_dbus_auth_observer_deny_authenticated_peer (GDBusAuthObserver *observer,
GIOStream *stream,
GCredentials *credentials)
g_dbus_auth_observer_authorize_authenticated_peer (GDBusAuthObserver *observer,
GIOStream *stream,
GCredentials *credentials)
{
gboolean denied;
denied = FALSE;
g_signal_emit (observer,
signals[DENY_AUTHENTICATED_PEER_SIGNAL],
signals[AUTHORIZE_AUTHENTICATED_PEER_SIGNAL],
0,
stream,
credentials,
......
......@@ -40,7 +40,7 @@ typedef struct _GDBusAuthObserverPrivate GDBusAuthObserverPrivate;
/**
* GDBusAuthObserverClass:
* @deny_authenticated_peer: Signal class handler for the #GDBusAuthObserver::deny-authenticated-peer signal.
* @authorize_authenticated_peer: Signal class handler for the #GDBusAuthObserver::authorize-authenticated-peer signal.
*
* Class structure for #GDBusAuthObserverClass.
*
......@@ -54,9 +54,9 @@ struct _GDBusAuthObserverClass
/*< public >*/
/* Signals */
gboolean (*deny_authenticated_peer) (GDBusAuthObserver *observer,
GIOStream *stream,
GCredentials *credentials);
gboolean (*authorize_authenticated_peer) (GDBusAuthObserver *observer,
GIOStream *stream,
GCredentials *credentials);
/*< private >*/
......@@ -93,11 +93,11 @@ struct _GDBusAuthObserver
GDBusAuthObserverPrivate *priv;
};
GType g_dbus_auth_observer_get_type (void) G_GNUC_CONST;
GDBusAuthObserver *g_dbus_auth_observer_new (void);
gboolean g_dbus_auth_observer_deny_authenticated_peer (GDBusAuthObserver *observer,
GIOStream *stream,
GCredentials *credentials);
GType g_dbus_auth_observer_get_type (void) G_GNUC_CONST;
GDBusAuthObserver *g_dbus_auth_observer_new (void);
gboolean g_dbus_auth_observer_authorize_authenticated_peer (GDBusAuthObserver *observer,
GIOStream *stream,
GCredentials *credentials);
G_END_DECLS
......
......@@ -100,8 +100,6 @@
* when the returned GVariant is floating.
*
* - Consistent timeout handling (25s vs 30s?)
*
* - Update GDBusAuthObserver (s/deny/authorize/)
*/
#include "config.h"
......
......@@ -1475,7 +1475,7 @@ g_dbus_address_get_stream_sync
#if IN_FILE(__G_DBUS_AUTH_OBSERVER_C__)
g_dbus_auth_observer_get_type G_GNUC_CONST
g_dbus_auth_observer_new
g_dbus_auth_observer_deny_authenticated_peer
g_dbus_auth_observer_authorize_authenticated_peer
#endif
#endif
......
......@@ -203,24 +203,24 @@ on_proxy_signal_received (GDBusProxy *proxy,
/* ---------------------------------------------------------------------------------------------------- */
static gboolean
on_deny_authenticated_peer (GDBusAuthObserver *observer,
GIOStream *stream,
GCredentials *credentials,
gpointer user_data)
on_authorize_authenticated_peer (GDBusAuthObserver *observer,
GIOStream *stream,
GCredentials *credentials,
gpointer user_data)
{
PeerData *data = user_data;
gboolean deny_peer;
gboolean authorized;
data->num_connection_attempts++;
deny_peer = FALSE;
authorized = TRUE;
if (!data->accept_connection)
{
deny_peer = TRUE;
authorized = FALSE;
g_main_loop_quit (loop);
}
return deny_peer;
return authorized;
}
/* Runs in thread we created GDBusServer in (since we didn't pass G_DBUS_SERVER_FLAGS_RUN_IN_THREAD) */
......@@ -280,8 +280,8 @@ service_thread_func (gpointer user_data)
G_CALLBACK (on_new_connection),
data);
g_signal_connect (observer,
"deny-authenticated-peer",
G_CALLBACK (on_deny_authenticated_peer),
"authorize-authenticated-peer",
G_CALLBACK (on_authorize_authenticated_peer),
data);
g_object_unref (observer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment