<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>GDBusAuthObserver</title> <meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> <link rel="home" href="index.html" title="GIO Reference Manual"> <link rel="up" href="gdbus-lowlevel.html" title="Lowlevel D-Bus Support"> <link rel="prev" href="GDBusServer.html" title="GDBusServer"> <link rel="next" href="gdbus-convenience.html" title="Highlevel D-Bus Support"> <meta name="generator" content="GTK-Doc V1.17 (XML mode)"> <link rel="stylesheet" href="style.css" type="text/css"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"> <tr valign="middle"> <td><a accesskey="p" href="GDBusServer.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td> <td><a accesskey="u" href="gdbus-lowlevel.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td> <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td> <th width="100%" align="center">GIO Reference Manual</th> <td><a accesskey="n" href="gdbus-convenience.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td> </tr> <tr><td colspan="5" class="shortcuts"> <a href="#GDBusAuthObserver.synopsis" class="shortcut">Top</a> | <a href="#GDBusAuthObserver.description" class="shortcut">Description</a> | <a href="#GDBusAuthObserver.object-hierarchy" class="shortcut">Object Hierarchy</a> | <a href="#GDBusAuthObserver.signals" class="shortcut">Signals</a> </td></tr> </table> <div class="refentry"> <a name="GDBusAuthObserver"></a><div class="titlepage"></div> <div class="refnamediv"><table width="100%"><tr> <td valign="top"> <h2><span class="refentrytitle"><a name="GDBusAuthObserver.top_of_page"></a>GDBusAuthObserver</span></h2> <p>GDBusAuthObserver — Object used for authenticating connections</p> </td> <td valign="top" align="right"></td> </tr></table></div> <div class="refsynopsisdiv"> <a name="GDBusAuthObserver.synopsis"></a><h2>Synopsis</h2> <pre class="synopsis"> #include <gio/gio.h> <a class="link" href="GDBusAuthObserver.html#GDBusAuthObserver-struct" title="GDBusAuthObserver">GDBusAuthObserver</a>; <a class="link" href="GDBusAuthObserver.html" title="GDBusAuthObserver"><span class="returnvalue">GDBusAuthObserver</span></a> * <a class="link" href="GDBusAuthObserver.html#g-dbus-auth-observer-new" title="g_dbus_auth_observer_new ()">g_dbus_auth_observer_new</a> (<em class="parameter"><code><span class="type">void</span></code></em>); <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="GDBusAuthObserver.html#g-dbus-auth-observer-authorize-authenticated-peer" title="g_dbus_auth_observer_authorize_authenticated_peer ()">g_dbus_auth_observer_authorize_authenticated_peer</a> (<em class="parameter"><code><a class="link" href="GDBusAuthObserver.html" title="GDBusAuthObserver"><span class="type">GDBusAuthObserver</span></a> *observer</code></em>, <em class="parameter"><code><a class="link" href="GIOStream.html" title="GIOStream"><span class="type">GIOStream</span></a> *stream</code></em>, <em class="parameter"><code><a class="link" href="GCredentials.html" title="GCredentials"><span class="type">GCredentials</span></a> *credentials</code></em>); </pre> </div> <div class="refsect1"> <a name="GDBusAuthObserver.object-hierarchy"></a><h2>Object Hierarchy</h2> <pre class="synopsis"> <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject">GObject</a> +----GDBusAuthObserver </pre> </div> <div class="refsect1"> <a name="GDBusAuthObserver.signals"></a><h2>Signals</h2> <pre class="synopsis"> "<a class="link" href="GDBusAuthObserver.html#GDBusAuthObserver-authorize-authenticated-peer" title='The "authorize-authenticated-peer" signal'>authorize-authenticated-peer</a>" : <a href="/usr/share/gtk-doc/html/gobject/gobject-Signals.html#G-SIGNAL-RUN-LAST:CAPS"><code class="literal">Run Last</code></a> </pre> </div> <div class="refsect1"> <a name="GDBusAuthObserver.description"></a><h2>Description</h2> <p> The <a class="link" href="GDBusAuthObserver.html" title="GDBusAuthObserver"><span class="type">GDBusAuthObserver</span></a> type provides a mechanism for participating in how a <a class="link" href="GDBusServer.html" title="GDBusServer"><span class="type">GDBusServer</span></a> (or a <a class="link" href="GDBusConnection.html" title="GDBusConnection"><span class="type">GDBusConnection</span></a>) authenticates remote peers. Simply instantiate a <a class="link" href="GDBusAuthObserver.html" title="GDBusAuthObserver"><span class="type">GDBusAuthObserver</span></a> and connect to the signals you are interested in. Note that new signals may be added in the future </p> <p> For example, if you only want to allow D-Bus connections from processes owned by the same uid as the server, you would use a signal handler like the following: </p> <div class="example"> <a name="auth-observer"></a><p class="title"><b>Example 7. Controlling Authentication</b></p> <div class="example-contents"> <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="listing_lines" align="right"><pre>1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20</pre></td> <td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a></span> <span class="function">on_authorize_authenticated_peer</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">GDBusAuthObserver</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">observer</span><span class="symbol">,</span> <span class="normal"> </span><span class="usertype">GIOStream</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">stream</span><span class="symbol">,</span> <span class="normal"> </span><span class="usertype">GCredentials</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">credentials</span><span class="symbol">,</span> <span class="normal"> </span><span class="usertype">gpointer</span><span class="normal"> user_data</span><span class="symbol">)</span> <span class="cbracket">{</span> <span class="normal"> </span><span class="usertype">gboolean</span><span class="normal"> authorized</span><span class="symbol">;</span> <span class="normal"> authorized </span><span class="symbol">=</span><span class="normal"> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS">FALSE</a></span><span class="symbol">;</span> <span class="normal"> </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">credentials </span><span class="symbol">!=</span><span class="normal"> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">)</span> <span class="normal"> </span><span class="cbracket">{</span> <span class="normal"> </span><span class="usertype">GCredentials</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">own_credentials</span><span class="symbol">;</span> <span class="normal"> own_credentials </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="GCredentials.html#g-credentials-new">g_credentials_new</a></span><span class="normal"> </span><span class="symbol">();</span> <span class="normal"> </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="function"><a href="GCredentials.html#g-credentials-is-same-user">g_credentials_is_same_user</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">credentials</span><span class="symbol">,</span><span class="normal"> own_credentials</span><span class="symbol">,</span><span class="normal"> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">))</span> <span class="normal"> authorized </span><span class="symbol">=</span><span class="normal"> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS">TRUE</a></span><span class="symbol">;</span> <span class="normal"> </span><span class="function"><a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#g-object-unref">g_object_unref</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">own_credentials</span><span class="symbol">);</span> <span class="normal"> </span><span class="cbracket">}</span> <span class="normal"> </span><span class="keyword">return</span><span class="normal"> authorized</span><span class="symbol">;</span> <span class="cbracket">}</span></pre></td> </tr> </tbody> </table> </div> </div> <p><br class="example-break"> </p> </div> <div class="refsect1"> <a name="GDBusAuthObserver.details"></a><h2>Details</h2> <div class="refsect2"> <a name="GDBusAuthObserver-struct"></a><h3>GDBusAuthObserver</h3> <pre class="programlisting">typedef struct _GDBusAuthObserver GDBusAuthObserver;</pre> <p> The <a class="link" href="GDBusAuthObserver.html" title="GDBusAuthObserver"><span class="type">GDBusAuthObserver</span></a> structure contains only private data and should only be accessed using the provided API. </p> <p class="since">Since 2.26</p> </div> <hr> <div class="refsect2"> <a name="g-dbus-auth-observer-new"></a><h3>g_dbus_auth_observer_new ()</h3> <pre class="programlisting"><a class="link" href="GDBusAuthObserver.html" title="GDBusAuthObserver"><span class="returnvalue">GDBusAuthObserver</span></a> * g_dbus_auth_observer_new (<em class="parameter"><code><span class="type">void</span></code></em>);</pre> <p> Creates a new <a class="link" href="GDBusAuthObserver.html" title="GDBusAuthObserver"><span class="type">GDBusAuthObserver</span></a> object. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody><tr> <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> <td>A <a class="link" href="GDBusAuthObserver.html" title="GDBusAuthObserver"><span class="type">GDBusAuthObserver</span></a>. Free with <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a>.</td> </tr></tbody> </table></div> <p class="since">Since 2.26</p> </div> <hr> <div class="refsect2"> <a name="g-dbus-auth-observer-authorize-authenticated-peer"></a><h3>g_dbus_auth_observer_authorize_authenticated_peer ()</h3> <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_dbus_auth_observer_authorize_authenticated_peer (<em class="parameter"><code><a class="link" href="GDBusAuthObserver.html" title="GDBusAuthObserver"><span class="type">GDBusAuthObserver</span></a> *observer</code></em>, <em class="parameter"><code><a class="link" href="GIOStream.html" title="GIOStream"><span class="type">GIOStream</span></a> *stream</code></em>, <em class="parameter"><code><a class="link" href="GCredentials.html" title="GCredentials"><span class="type">GCredentials</span></a> *credentials</code></em>);</pre> <p> Emits the <a class="link" href="GDBusAuthObserver.html#GDBusAuthObserver-authorize-authenticated-peer" title='The "authorize-authenticated-peer" signal'><span class="type">"authorize-authenticated-peer"</span></a> signal on <em class="parameter"><code>observer</code></em>. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><p><span class="term"><em class="parameter"><code>observer</code></em> :</span></p></td> <td>A <a class="link" href="GDBusAuthObserver.html" title="GDBusAuthObserver"><span class="type">GDBusAuthObserver</span></a>.</td> </tr> <tr> <td><p><span class="term"><em class="parameter"><code>stream</code></em> :</span></p></td> <td>A <a class="link" href="GIOStream.html" title="GIOStream"><span class="type">GIOStream</span></a> for the <a class="link" href="GDBusConnection.html" title="GDBusConnection"><span class="type">GDBusConnection</span></a>.</td> </tr> <tr> <td><p><span class="term"><em class="parameter"><code>credentials</code></em> :</span></p></td> <td>Credentials received from the peer or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.</td> </tr> <tr> <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> <td> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the peer is authorized, <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> if not.</td> </tr> </tbody> </table></div> <p class="since">Since 2.26</p> </div> </div> <div class="refsect1"> <a name="GDBusAuthObserver.signal-details"></a><h2>Signal Details</h2> <div class="refsect2"> <a name="GDBusAuthObserver-authorize-authenticated-peer"></a><h3>The <code class="literal">"authorize-authenticated-peer"</code> signal</h3> <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> user_function (<a class="link" href="GDBusAuthObserver.html" title="GDBusAuthObserver"><span class="type">GDBusAuthObserver</span></a> *observer, <a class="link" href="GIOStream.html" title="GIOStream"><span class="type">GIOStream</span></a> *stream, <a class="link" href="GCredentials.html" title="GCredentials"><span class="type">GCredentials</span></a> *credentials, <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> user_data) : <a href="/usr/share/gtk-doc/html/gobject/gobject-Signals.html#G-SIGNAL-RUN-LAST:CAPS"><code class="literal">Run Last</code></a></pre> <p> Emitted to check if a peer that is successfully authenticated is authorized. </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><p><span class="term"><em class="parameter"><code>observer</code></em> :</span></p></td> <td>The <a class="link" href="GDBusAuthObserver.html" title="GDBusAuthObserver"><span class="type">GDBusAuthObserver</span></a> emitting the signal.</td> </tr> <tr> <td><p><span class="term"><em class="parameter"><code>stream</code></em> :</span></p></td> <td>A <a class="link" href="GIOStream.html" title="GIOStream"><span class="type">GIOStream</span></a> for the <a class="link" href="GDBusConnection.html" title="GDBusConnection"><span class="type">GDBusConnection</span></a>.</td> </tr> <tr> <td><p><span class="term"><em class="parameter"><code>credentials</code></em> :</span></p></td> <td>Credentials received from the peer or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.</td> </tr> <tr> <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td> <td>user data set when the signal handler was connected.</td> </tr> <tr> <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> <td> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the peer is authorized, <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> if not.</td> </tr> </tbody> </table></div> <p class="since">Since 2.26</p> </div> </div> </div> <div class="footer"> <hr> Generated by GTK-Doc V1.17</div> </body> </html>