mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-03 17:56:17 +01:00
GDBusAuthObserver: Fix docs
Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
parent
7eba41346e
commit
9b0a08449f
@ -42,7 +42,8 @@
|
|||||||
* in the future
|
* in the future
|
||||||
*
|
*
|
||||||
* For example, if you only want to allow D-Bus connections from
|
* For example, if you only want to allow D-Bus connections from
|
||||||
* processes owned by the same uid as the server, you would do this:
|
* processes owned by the same uid as the server, you would use a
|
||||||
|
* signal handler like the following:
|
||||||
* <example id="auth-observer"><title>Controlling Authentication</title><programlisting>
|
* <example id="auth-observer"><title>Controlling Authentication</title><programlisting>
|
||||||
* static gboolean
|
* static gboolean
|
||||||
* on_authorize_authenticated_peer (GDBusAuthObserver *observer,
|
* on_authorize_authenticated_peer (GDBusAuthObserver *observer,
|
||||||
@ -50,52 +51,20 @@
|
|||||||
* GCredentials *credentials,
|
* GCredentials *credentials,
|
||||||
* gpointer user_data)
|
* gpointer user_data)
|
||||||
* {
|
* {
|
||||||
* GCredentials *me;
|
|
||||||
* gboolean authorized;
|
* gboolean authorized;
|
||||||
*
|
*
|
||||||
* authorized = FALSE;
|
* authorized = FALSE;
|
||||||
* me = g_credentials_new ();
|
* if (credentials != NULL)
|
||||||
*
|
* {
|
||||||
* if (credentials != NULL &&
|
* GCredentials *own_credentials;
|
||||||
* !g_credentials_is_same_user (credentials, me))
|
* own_credentials = g_credentials_new ();
|
||||||
|
* if (g_credentials_is_same_user (credentials, own_credentials, NULL))
|
||||||
* authorized = TRUE;
|
* authorized = TRUE;
|
||||||
*
|
* g_object_unref (own_credentials);
|
||||||
* g_object_unref (me);
|
* }
|
||||||
*
|
*
|
||||||
* return authorized;
|
* return authorized;
|
||||||
* }
|
* }
|
||||||
*
|
|
||||||
* static gboolean
|
|
||||||
* on_new_connection (GDBusServer *server,
|
|
||||||
* GDBusConnection *connection,
|
|
||||||
* gpointer user_data)
|
|
||||||
* {
|
|
||||||
* /<!-- -->* Guaranteed here that @connection is from a process owned by the same user *<!-- -->/
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* [...]
|
|
||||||
*
|
|
||||||
* GDBusAuthObserver *observer;
|
|
||||||
* GDBusServer *server;
|
|
||||||
* GError *error;
|
|
||||||
*
|
|
||||||
* error = NULL;
|
|
||||||
* observer = g_dbus_auth_observer_new ();
|
|
||||||
* server = g_dbus_server_new_sync ("unix:tmpdir=/tmp/my-app-name",
|
|
||||||
* G_DBUS_SERVER_FLAGS_NONE,
|
|
||||||
* observer,
|
|
||||||
* NULL, /<!-- -->* GCancellable *<!-- -->/
|
|
||||||
* &error);
|
|
||||||
* g_signal_connect (observer,
|
|
||||||
* "authorize-authenticated-peer",
|
|
||||||
* G_CALLBACK (on_authorize_authenticated_peer),
|
|
||||||
* NULL);
|
|
||||||
* g_signal_connect (server,
|
|
||||||
* "new-connection",
|
|
||||||
* G_CALLBACK (on_new_connection),
|
|
||||||
* NULL);
|
|
||||||
* g_object_unref (observer);
|
|
||||||
* g_dbus_server_start (server);
|
|
||||||
* </programlisting></example>
|
* </programlisting></example>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -243,7 +212,7 @@ g_dbus_auth_observer_new (void)
|
|||||||
*
|
*
|
||||||
* Emits the #GDBusAuthObserver::authorize-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 is authorized, %FALSE if not.
|
||||||
*
|
*
|
||||||
* Since: 2.26
|
* Since: 2.26
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user