mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-15 20:18:05 +02:00
GDBus: Rename ::deny-authentication-peer to ::authorize-authenticated-peer
This commit is contained in:
parent
9e90b381f5
commit
cb753dfd49
@ -2240,7 +2240,7 @@ g_dbus_is_interface_name
|
|||||||
GDBusAuthObserver
|
GDBusAuthObserver
|
||||||
GDBusAuthObserverClass
|
GDBusAuthObserverClass
|
||||||
g_dbus_auth_observer_new
|
g_dbus_auth_observer_new
|
||||||
g_dbus_auth_observer_deny_authenticated_peer
|
g_dbus_auth_observer_authorize_authenticated_peer
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
G_DBUS_AUTH_OBSERVER
|
G_DBUS_AUTH_OBSERVER
|
||||||
G_IS_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:
|
case G_DBUS_AUTH_MECHANISM_STATE_ACCEPTED:
|
||||||
if (observer != NULL &&
|
if (observer != NULL &&
|
||||||
g_dbus_auth_observer_deny_authenticated_peer (observer,
|
!g_dbus_auth_observer_authorize_authenticated_peer (observer,
|
||||||
auth->priv->stream,
|
auth->priv->stream,
|
||||||
credentials))
|
credentials))
|
||||||
{
|
{
|
||||||
/* disconnect */
|
/* disconnect */
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
G_IO_ERROR,
|
G_IO_ERROR,
|
||||||
G_IO_ERROR_FAILED,
|
G_IO_ERROR_FAILED,
|
||||||
_("Cancelled via GDBusAuthObserver::deny-authenticated-peer"));
|
_("Cancelled via GDBusAuthObserver::authorize-authenticated-peer"));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -46,24 +46,24 @@
|
|||||||
* processes owned by the same uid as the server, you would do this:
|
* processes owned by the same uid as the server, you would do this:
|
||||||
* <example id="auth-observer"><title>Controlling Authentication</title><programlisting>
|
* <example id="auth-observer"><title>Controlling Authentication</title><programlisting>
|
||||||
* static gboolean
|
* static gboolean
|
||||||
* on_deny_authenticated_peer (GDBusAuthObserver *observer,
|
* on_authorize_authenticated_peer (GDBusAuthObserver *observer,
|
||||||
* GIOStream *stream,
|
* GIOStream *stream,
|
||||||
* GCredentials *credentials,
|
* GCredentials *credentials,
|
||||||
* gpointer user_data)
|
* gpointer user_data)
|
||||||
* {
|
* {
|
||||||
* GCredentials *me;
|
* GCredentials *me;
|
||||||
* gboolean deny;
|
* gboolean authorized;
|
||||||
*
|
*
|
||||||
* deny = TRUE;
|
* authorized = FALSE;
|
||||||
* me = g_credentials_new ();
|
* me = g_credentials_new ();
|
||||||
*
|
*
|
||||||
* if (credentials != NULL &&
|
* if (credentials != NULL &&
|
||||||
* !g_credentials_is_same_user (credentials, me))
|
* !g_credentials_is_same_user (credentials, me))
|
||||||
* deny = FALSE;
|
* authorized = TRUE;
|
||||||
*
|
*
|
||||||
* g_object_unref (me);
|
* g_object_unref (me);
|
||||||
*
|
*
|
||||||
* return deny;
|
* return authorized;
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* static gboolean
|
* static gboolean
|
||||||
@ -88,8 +88,8 @@
|
|||||||
* NULL, /<!-- -->* GCancellable *<!-- -->/
|
* NULL, /<!-- -->* GCancellable *<!-- -->/
|
||||||
* &error);
|
* &error);
|
||||||
* g_signal_connect (observer,
|
* g_signal_connect (observer,
|
||||||
* "deny-authenticated-peer",
|
* "authorize-authenticated-peer",
|
||||||
* G_CALLBACK (on_deny_authenticated_peer),
|
* G_CALLBACK (on_authorize_authenticated_peer),
|
||||||
* NULL);
|
* NULL);
|
||||||
* g_signal_connect (server,
|
* g_signal_connect (server,
|
||||||
* "new-connection",
|
* "new-connection",
|
||||||
@ -107,7 +107,7 @@ struct _GDBusAuthObserverPrivate
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
DENY_AUTHENTICATED_PEER_SIGNAL,
|
AUTHORIZE_AUTHENTICATED_PEER_SIGNAL,
|
||||||
LAST_SIGNAL,
|
LAST_SIGNAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -124,11 +124,27 @@ g_dbus_auth_observer_finalize (GObject *object)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
g_dbus_auth_observer_deny_authenticated_peer_real (GDBusAuthObserver *observer,
|
g_dbus_auth_observer_authorize_authenticated_peer_real (GDBusAuthObserver *observer,
|
||||||
GIOStream *stream,
|
GIOStream *stream,
|
||||||
GCredentials *credentials)
|
GCredentials *credentials)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_g_signal_accumulator_false_handled (GSignalInvocationHint *ihint,
|
||||||
|
GValue *return_accu,
|
||||||
|
const GValue *handler_return,
|
||||||
|
gpointer dummy)
|
||||||
|
{
|
||||||
|
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
|
static void
|
||||||
@ -138,27 +154,27 @@ g_dbus_auth_observer_class_init (GDBusAuthObserverClass *klass)
|
|||||||
|
|
||||||
gobject_class->finalize = g_dbus_auth_observer_finalize;
|
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.
|
* @observer: The #GDBusAuthObserver emitting the signal.
|
||||||
* @stream: A #GIOStream for the #GDBusConnection.
|
* @stream: A #GIOStream for the #GDBusConnection.
|
||||||
* @credentials: Credentials received from the peer or %NULL.
|
* @credentials: Credentials received from the peer or %NULL.
|
||||||
*
|
*
|
||||||
* Emitted to check if a peer that is successfully authenticated
|
* 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
|
* Since: 2.26
|
||||||
*/
|
*/
|
||||||
signals[DENY_AUTHENTICATED_PEER_SIGNAL] =
|
signals[AUTHORIZE_AUTHENTICATED_PEER_SIGNAL] =
|
||||||
g_signal_new ("deny-authenticated-peer",
|
g_signal_new ("authorize-authenticated-peer",
|
||||||
G_TYPE_DBUS_AUTH_OBSERVER,
|
G_TYPE_DBUS_AUTH_OBSERVER,
|
||||||
G_SIGNAL_RUN_LAST,
|
G_SIGNAL_RUN_LAST,
|
||||||
G_STRUCT_OFFSET (GDBusAuthObserverClass, deny_authenticated_peer),
|
G_STRUCT_OFFSET (GDBusAuthObserverClass, authorize_authenticated_peer),
|
||||||
g_signal_accumulator_true_handled,
|
_g_signal_accumulator_false_handled,
|
||||||
NULL, /* accu_data */
|
NULL, /* accu_data */
|
||||||
_gio_marshal_BOOLEAN__OBJECT_OBJECT,
|
_gio_marshal_BOOLEAN__OBJECT_OBJECT,
|
||||||
G_TYPE_BOOLEAN,
|
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.
|
* @observer: A #GDBusAuthObserver.
|
||||||
* @stream: A #GIOStream for the #GDBusConnection.
|
* @stream: A #GIOStream for the #GDBusConnection.
|
||||||
* @credentials: Credentials received from the peer or %NULL.
|
* @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.
|
* Returns: %TRUE if the peer should be denied, %FALSE otherwise.
|
||||||
*
|
*
|
||||||
* Since: 2.26
|
* Since: 2.26
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
g_dbus_auth_observer_deny_authenticated_peer (GDBusAuthObserver *observer,
|
g_dbus_auth_observer_authorize_authenticated_peer (GDBusAuthObserver *observer,
|
||||||
GIOStream *stream,
|
GIOStream *stream,
|
||||||
GCredentials *credentials)
|
GCredentials *credentials)
|
||||||
{
|
{
|
||||||
gboolean denied;
|
gboolean denied;
|
||||||
|
|
||||||
denied = FALSE;
|
denied = FALSE;
|
||||||
g_signal_emit (observer,
|
g_signal_emit (observer,
|
||||||
signals[DENY_AUTHENTICATED_PEER_SIGNAL],
|
signals[AUTHORIZE_AUTHENTICATED_PEER_SIGNAL],
|
||||||
0,
|
0,
|
||||||
stream,
|
stream,
|
||||||
credentials,
|
credentials,
|
||||||
|
@ -40,7 +40,7 @@ typedef struct _GDBusAuthObserverPrivate GDBusAuthObserverPrivate;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* GDBusAuthObserverClass:
|
* 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.
|
* Class structure for #GDBusAuthObserverClass.
|
||||||
*
|
*
|
||||||
@ -54,9 +54,9 @@ struct _GDBusAuthObserverClass
|
|||||||
/*< public >*/
|
/*< public >*/
|
||||||
|
|
||||||
/* Signals */
|
/* Signals */
|
||||||
gboolean (*deny_authenticated_peer) (GDBusAuthObserver *observer,
|
gboolean (*authorize_authenticated_peer) (GDBusAuthObserver *observer,
|
||||||
GIOStream *stream,
|
GIOStream *stream,
|
||||||
GCredentials *credentials);
|
GCredentials *credentials);
|
||||||
|
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
@ -93,11 +93,11 @@ struct _GDBusAuthObserver
|
|||||||
GDBusAuthObserverPrivate *priv;
|
GDBusAuthObserverPrivate *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
GType g_dbus_auth_observer_get_type (void) G_GNUC_CONST;
|
GType g_dbus_auth_observer_get_type (void) G_GNUC_CONST;
|
||||||
GDBusAuthObserver *g_dbus_auth_observer_new (void);
|
GDBusAuthObserver *g_dbus_auth_observer_new (void);
|
||||||
gboolean g_dbus_auth_observer_deny_authenticated_peer (GDBusAuthObserver *observer,
|
gboolean g_dbus_auth_observer_authorize_authenticated_peer (GDBusAuthObserver *observer,
|
||||||
GIOStream *stream,
|
GIOStream *stream,
|
||||||
GCredentials *credentials);
|
GCredentials *credentials);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -100,8 +100,6 @@
|
|||||||
* when the returned GVariant is floating.
|
* when the returned GVariant is floating.
|
||||||
*
|
*
|
||||||
* - Consistent timeout handling (25s vs 30s?)
|
* - Consistent timeout handling (25s vs 30s?)
|
||||||
*
|
|
||||||
* - Update GDBusAuthObserver (s/deny/authorize/)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -1475,7 +1475,7 @@ g_dbus_address_get_stream_sync
|
|||||||
#if IN_FILE(__G_DBUS_AUTH_OBSERVER_C__)
|
#if IN_FILE(__G_DBUS_AUTH_OBSERVER_C__)
|
||||||
g_dbus_auth_observer_get_type G_GNUC_CONST
|
g_dbus_auth_observer_get_type G_GNUC_CONST
|
||||||
g_dbus_auth_observer_new
|
g_dbus_auth_observer_new
|
||||||
g_dbus_auth_observer_deny_authenticated_peer
|
g_dbus_auth_observer_authorize_authenticated_peer
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -203,24 +203,24 @@ on_proxy_signal_received (GDBusProxy *proxy,
|
|||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
on_deny_authenticated_peer (GDBusAuthObserver *observer,
|
on_authorize_authenticated_peer (GDBusAuthObserver *observer,
|
||||||
GIOStream *stream,
|
GIOStream *stream,
|
||||||
GCredentials *credentials,
|
GCredentials *credentials,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
PeerData *data = user_data;
|
PeerData *data = user_data;
|
||||||
gboolean deny_peer;
|
gboolean authorized;
|
||||||
|
|
||||||
data->num_connection_attempts++;
|
data->num_connection_attempts++;
|
||||||
|
|
||||||
deny_peer = FALSE;
|
authorized = TRUE;
|
||||||
if (!data->accept_connection)
|
if (!data->accept_connection)
|
||||||
{
|
{
|
||||||
deny_peer = TRUE;
|
authorized = FALSE;
|
||||||
g_main_loop_quit (loop);
|
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) */
|
/* 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),
|
G_CALLBACK (on_new_connection),
|
||||||
data);
|
data);
|
||||||
g_signal_connect (observer,
|
g_signal_connect (observer,
|
||||||
"deny-authenticated-peer",
|
"authorize-authenticated-peer",
|
||||||
G_CALLBACK (on_deny_authenticated_peer),
|
G_CALLBACK (on_authorize_authenticated_peer),
|
||||||
data);
|
data);
|
||||||
g_object_unref (observer);
|
g_object_unref (observer);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user