| Current File : //usr/share/doc/dbus/api/dbus-auth_8c_source.html |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>D-Bus: dbus-auth.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">D-Bus
 <span id="projectnumber">1.8.20</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.7.6.1 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File List</span></a></li>
</ul>
</div>
</div>
<div class="header">
<div class="headertitle">
<div class="title">dbus-auth.c</div> </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */</span>
<a name="l00002"></a>00002 <span class="comment">/* dbus-auth.c Authentication</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * Copyright (C) 2002, 2003, 2004 Red Hat Inc.</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * Licensed under the Academic Free License version 2.1</span>
<a name="l00007"></a>00007 <span class="comment"> * </span>
<a name="l00008"></a>00008 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00009"></a>00009 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00010"></a>00010 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00011"></a>00011 <span class="comment"> * (at your option) any later version.</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00014"></a>00014 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00015"></a>00015 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00016"></a>00016 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00017"></a>00017 <span class="comment"> * </span>
<a name="l00018"></a>00018 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00019"></a>00019 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00020"></a>00020 <span class="comment"> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA</span>
<a name="l00021"></a>00021 <span class="comment"> *</span>
<a name="l00022"></a>00022 <span class="comment"> */</span>
<a name="l00023"></a>00023
<a name="l00024"></a>00024 <span class="preprocessor">#include <config.h></span>
<a name="l00025"></a>00025 <span class="preprocessor">#include "dbus-auth.h"</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include "dbus-string.h"</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "dbus-list.h"</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include "dbus-internals.h"</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include "dbus-keyring.h"</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include "dbus-sha.h"</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include "dbus-protocol.h"</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include "dbus-credentials.h"</span>
<a name="l00033"></a>00033
<a name="l00070"></a><a class="code" href="group__DBusAuthInternals.html#ga08e4d15c4946cb0a89c4a472679103ec">00070</a> <span class="keyword">typedef</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> (* <a class="code" href="group__DBusAuthInternals.html#ga08e4d15c4946cb0a89c4a472679103ec" title="This function appends an initial client response to the given string.">DBusInitialResponseFunction</a>) (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00071"></a>00071 <a class="code" href="structDBusString.html">DBusString</a> *response);
<a name="l00072"></a>00072
<a name="l00077"></a><a class="code" href="group__DBusAuthInternals.html#gac1c31ba2ab9dc696b68b1c23bd0a6e6d">00077</a> <span class="keyword">typedef</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> (* <a class="code" href="group__DBusAuthInternals.html#gac1c31ba2ab9dc696b68b1c23bd0a6e6d" title="This function processes a block of data received from the peer.">DBusAuthDataFunction</a>) (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00078"></a>00078 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *data);
<a name="l00079"></a>00079
<a name="l00083"></a><a class="code" href="group__DBusAuthInternals.html#gad45cc5010eaba8388010b29e9fc1351d">00083</a> <span class="keyword">typedef</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> (* <a class="code" href="group__DBusAuthInternals.html#gad45cc5010eaba8388010b29e9fc1351d" title="This function encodes a block of data from the peer.">DBusAuthEncodeFunction</a>) (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00084"></a>00084 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *data,
<a name="l00085"></a>00085 <a class="code" href="structDBusString.html">DBusString</a> *encoded);
<a name="l00086"></a>00086
<a name="l00090"></a><a class="code" href="group__DBusAuthInternals.html#ga2aff28af19854c387ea8800f4b78a51a">00090</a> <span class="keyword">typedef</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> (* <a class="code" href="group__DBusAuthInternals.html#ga2aff28af19854c387ea8800f4b78a51a" title="This function decodes a block of data from the peer.">DBusAuthDecodeFunction</a>) (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00091"></a>00091 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *data,
<a name="l00092"></a>00092 <a class="code" href="structDBusString.html">DBusString</a> *decoded);
<a name="l00093"></a>00093
<a name="l00097"></a><a class="code" href="group__DBusAuthInternals.html#ga025a64340f118c0bd291228c98baf0ed">00097</a> <span class="keyword">typedef</span> void (* <a class="code" href="group__DBusAuthInternals.html#ga025a64340f118c0bd291228c98baf0ed" title="This function is called when the mechanism is abandoned.">DBusAuthShutdownFunction</a>) (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth);
<a name="l00098"></a>00098
<a name="l00102"></a><a class="code" href="structDBusAuthMechanismHandler.html">00102</a> <span class="keyword">typedef</span> <span class="keyword">struct</span>
<a name="l00103"></a>00103 {
<a name="l00104"></a><a class="code" href="structDBusAuthMechanismHandler.html#a353c8effcb16bdc37c2f225b8dad9415">00104</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="structDBusAuthMechanismHandler.html#a353c8effcb16bdc37c2f225b8dad9415" title="Name of the mechanism.">mechanism</a>;
<a name="l00105"></a><a class="code" href="structDBusAuthMechanismHandler.html#a6fb1fd485bf4f99f4d269cebe4625a8a">00105</a> <a class="code" href="group__DBusAuthInternals.html#gac1c31ba2ab9dc696b68b1c23bd0a6e6d" title="This function processes a block of data received from the peer.">DBusAuthDataFunction</a> <a class="code" href="structDBusAuthMechanismHandler.html#a6fb1fd485bf4f99f4d269cebe4625a8a" title="Function on server side for DATA.">server_data_func</a>;
<a name="l00106"></a><a class="code" href="structDBusAuthMechanismHandler.html#a7aedf6828bf1f232edb2532616b9a1da">00106</a> <a class="code" href="group__DBusAuthInternals.html#gad45cc5010eaba8388010b29e9fc1351d" title="This function encodes a block of data from the peer.">DBusAuthEncodeFunction</a> <a class="code" href="structDBusAuthMechanismHandler.html#a7aedf6828bf1f232edb2532616b9a1da" title="Function on server side to encode.">server_encode_func</a>;
<a name="l00107"></a><a class="code" href="structDBusAuthMechanismHandler.html#ac6785768ff465be230d2f127d8099953">00107</a> <a class="code" href="group__DBusAuthInternals.html#ga2aff28af19854c387ea8800f4b78a51a" title="This function decodes a block of data from the peer.">DBusAuthDecodeFunction</a> <a class="code" href="structDBusAuthMechanismHandler.html#ac6785768ff465be230d2f127d8099953" title="Function on server side to decode.">server_decode_func</a>;
<a name="l00108"></a><a class="code" href="structDBusAuthMechanismHandler.html#aa6e551c05863b85ee8c138a976497e8e">00108</a> <a class="code" href="group__DBusAuthInternals.html#ga025a64340f118c0bd291228c98baf0ed" title="This function is called when the mechanism is abandoned.">DBusAuthShutdownFunction</a> <a class="code" href="structDBusAuthMechanismHandler.html#aa6e551c05863b85ee8c138a976497e8e" title="Function on server side to shut down.">server_shutdown_func</a>;
<a name="l00109"></a><a class="code" href="structDBusAuthMechanismHandler.html#a7702073e4e001efcd921b413519646a1">00109</a> <a class="code" href="group__DBusAuthInternals.html#ga08e4d15c4946cb0a89c4a472679103ec" title="This function appends an initial client response to the given string.">DBusInitialResponseFunction</a> <a class="code" href="structDBusAuthMechanismHandler.html#a7702073e4e001efcd921b413519646a1" title="Function on client side to handle initial response.">client_initial_response_func</a>;
<a name="l00110"></a><a class="code" href="structDBusAuthMechanismHandler.html#a765bf360f3af4a7d418dd4f029cc4c26">00110</a> <a class="code" href="group__DBusAuthInternals.html#gac1c31ba2ab9dc696b68b1c23bd0a6e6d" title="This function processes a block of data received from the peer.">DBusAuthDataFunction</a> <a class="code" href="structDBusAuthMechanismHandler.html#a765bf360f3af4a7d418dd4f029cc4c26" title="Function on client side for DATA.">client_data_func</a>;
<a name="l00111"></a><a class="code" href="structDBusAuthMechanismHandler.html#ae72e69ef3b4513cbc5bdecae43dd380d">00111</a> <a class="code" href="group__DBusAuthInternals.html#gad45cc5010eaba8388010b29e9fc1351d" title="This function encodes a block of data from the peer.">DBusAuthEncodeFunction</a> <a class="code" href="structDBusAuthMechanismHandler.html#ae72e69ef3b4513cbc5bdecae43dd380d" title="Function on client side for encode.">client_encode_func</a>;
<a name="l00112"></a><a class="code" href="structDBusAuthMechanismHandler.html#ab1d5c9a8cd146bb9f71f4237be1ca415">00112</a> <a class="code" href="group__DBusAuthInternals.html#ga2aff28af19854c387ea8800f4b78a51a" title="This function decodes a block of data from the peer.">DBusAuthDecodeFunction</a> <a class="code" href="structDBusAuthMechanismHandler.html#ab1d5c9a8cd146bb9f71f4237be1ca415" title="Function on client side for decode.">client_decode_func</a>;
<a name="l00113"></a><a class="code" href="structDBusAuthMechanismHandler.html#aca0a9e37793ca20ed175b3c008c3494f">00113</a> <a class="code" href="group__DBusAuthInternals.html#ga025a64340f118c0bd291228c98baf0ed" title="This function is called when the mechanism is abandoned.">DBusAuthShutdownFunction</a> <a class="code" href="structDBusAuthMechanismHandler.html#aca0a9e37793ca20ed175b3c008c3494f" title="Function on client side for shutdown.">client_shutdown_func</a>;
<a name="l00114"></a>00114 } <a class="code" href="structDBusAuthMechanismHandler.html" title="Virtual table representing a particular auth mechanism.">DBusAuthMechanismHandler</a>;
<a name="l00115"></a>00115
<a name="l00119"></a><a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b">00119</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> {
<a name="l00120"></a>00120 DBUS_AUTH_COMMAND_AUTH,
<a name="l00121"></a>00121 DBUS_AUTH_COMMAND_CANCEL,
<a name="l00122"></a>00122 DBUS_AUTH_COMMAND_DATA,
<a name="l00123"></a>00123 DBUS_AUTH_COMMAND_BEGIN,
<a name="l00124"></a>00124 DBUS_AUTH_COMMAND_REJECTED,
<a name="l00125"></a>00125 DBUS_AUTH_COMMAND_OK,
<a name="l00126"></a>00126 DBUS_AUTH_COMMAND_ERROR,
<a name="l00127"></a>00127 DBUS_AUTH_COMMAND_UNKNOWN,
<a name="l00128"></a>00128 DBUS_AUTH_COMMAND_NEGOTIATE_UNIX_FD,
<a name="l00129"></a>00129 DBUS_AUTH_COMMAND_AGREE_UNIX_FD
<a name="l00130"></a>00130 } <a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b" title="Enumeration for the known authentication commands.">DBusAuthCommand</a>;
<a name="l00131"></a>00131
<a name="l00137"></a><a class="code" href="group__DBusAuthInternals.html#ga6dfbfa4f85db0ba63dbce208b27489ad">00137</a> <span class="keyword">typedef</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> (* <a class="code" href="group__DBusAuthInternals.html#ga6dfbfa4f85db0ba63dbce208b27489ad" title="Auth state function, determines the reaction to incoming events for a particular state.">DBusAuthStateFunction</a>) (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00138"></a>00138 <a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b" title="Enumeration for the known authentication commands.">DBusAuthCommand</a> command,
<a name="l00139"></a>00139 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args);
<a name="l00140"></a>00140
<a name="l00144"></a><a class="code" href="structDBusAuthStateData.html">00144</a> <span class="keyword">typedef</span> <span class="keyword">struct</span>
<a name="l00145"></a>00145 {
<a name="l00146"></a><a class="code" href="structDBusAuthStateData.html#ad5e3d100798e1f200c8b7b2277af46af">00146</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="structDBusAuthStateData.html#ad5e3d100798e1f200c8b7b2277af46af" title="Name of the state.">name</a>;
<a name="l00147"></a><a class="code" href="structDBusAuthStateData.html#a5b22dcc2e9ccfae518d95c14893fa495">00147</a> <a class="code" href="group__DBusAuthInternals.html#ga6dfbfa4f85db0ba63dbce208b27489ad" title="Auth state function, determines the reaction to incoming events for a particular state.">DBusAuthStateFunction</a> <a class="code" href="structDBusAuthStateData.html#a5b22dcc2e9ccfae518d95c14893fa495" title="State function for this state.">handler</a>;
<a name="l00148"></a>00148 } <a class="code" href="structDBusAuthStateData.html" title="Information about a auth state.">DBusAuthStateData</a>;
<a name="l00149"></a>00149
<a name="l00153"></a><a class="code" href="structDBusAuth.html">00153</a> <span class="keyword">struct </span><a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a>
<a name="l00154"></a>00154 {
<a name="l00155"></a><a class="code" href="structDBusAuth.html#ab91763afd6a9d19f821dffd5930e69a6">00155</a> <span class="keywordtype">int</span> <a class="code" href="structDBusAuth.html#ab91763afd6a9d19f821dffd5930e69a6" title="reference count">refcount</a>;
<a name="l00156"></a><a class="code" href="structDBusAuth.html#a8b930cb0d8a76c198914cf4a98192477">00156</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="structDBusAuth.html#a8b930cb0d8a76c198914cf4a98192477" title="Client or server.">side</a>;
<a name="l00158"></a><a class="code" href="structDBusAuth.html#a986a475be9c96ecb9dd9ca5f86f60f10">00158</a> <a class="code" href="structDBusString.html">DBusString</a> <a class="code" href="structDBusAuth.html#a986a475be9c96ecb9dd9ca5f86f60f10" title="Incoming data buffer.">incoming</a>;
<a name="l00159"></a><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085">00159</a> <a class="code" href="structDBusString.html">DBusString</a> <a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>;
<a name="l00161"></a><a class="code" href="structDBusAuth.html#a44bd9f6e01ee93e58aae551bb1a9fb0f">00161</a> <span class="keyword">const</span> <a class="code" href="structDBusAuthStateData.html" title="Information about a auth state.">DBusAuthStateData</a> *<a class="code" href="structDBusAuth.html#a44bd9f6e01ee93e58aae551bb1a9fb0f" title="Current protocol state.">state</a>;
<a name="l00163"></a><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848">00163</a> <span class="keyword">const</span> <a class="code" href="structDBusAuthMechanismHandler.html" title="Virtual table representing a particular auth mechanism.">DBusAuthMechanismHandler</a> *<a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a>;
<a name="l00165"></a><a class="code" href="structDBusAuth.html#a8e70b9e2cc090fe006e1214983d79eed">00165</a> <a class="code" href="structDBusString.html">DBusString</a> <a class="code" href="structDBusAuth.html#a8e70b9e2cc090fe006e1214983d79eed" title="Current identity we're authorizing as.">identity</a>;
<a name="l00169"></a><a class="code" href="structDBusAuth.html#aed82f21abc1ad5aa8c0db8a43f93bc22">00169</a> <a class="code" href="structDBusCredentials.html">DBusCredentials</a> *<a class="code" href="structDBusAuth.html#aed82f21abc1ad5aa8c0db8a43f93bc22" title="Credentials read from socket.">credentials</a>;
<a name="l00172"></a><a class="code" href="structDBusAuth.html#afb4928fcc0f7af56d87fd6a512ad5a0a">00172</a> <a class="code" href="structDBusCredentials.html">DBusCredentials</a> *<a class="code" href="structDBusAuth.html#afb4928fcc0f7af56d87fd6a512ad5a0a" title="Credentials that are authorized.">authorized_identity</a>;
<a name="l00174"></a><a class="code" href="structDBusAuth.html#a6cfcba06657099d879b1e08aa886420f">00174</a> <a class="code" href="structDBusCredentials.html">DBusCredentials</a> *<a class="code" href="structDBusAuth.html#a6cfcba06657099d879b1e08aa886420f" title="Identity client has requested.">desired_identity</a>;
<a name="l00176"></a><a class="code" href="structDBusAuth.html#aedf6904d461a6f6eba2ee21f12f89611">00176</a> <a class="code" href="structDBusString.html">DBusString</a> <a class="code" href="structDBusAuth.html#aedf6904d461a6f6eba2ee21f12f89611" title="Cookie scope.">context</a>;
<a name="l00177"></a><a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9">00177</a> <a class="code" href="structDBusKeyring.html" title="Internals of DBusKeyring.">DBusKeyring</a> *<a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9" title="Keyring for cookie mechanism.">keyring</a>;
<a name="l00178"></a><a class="code" href="structDBusAuth.html#a43851f8413177b398c63e2045605ae4b">00178</a> <span class="keywordtype">int</span> <a class="code" href="structDBusAuth.html#a43851f8413177b398c63e2045605ae4b" title="ID of cookie to use.">cookie_id</a>;
<a name="l00179"></a><a class="code" href="structDBusAuth.html#a4f2f7bfce0a53b41fb165a8854804443">00179</a> <a class="code" href="structDBusString.html">DBusString</a> <a class="code" href="structDBusAuth.html#a4f2f7bfce0a53b41fb165a8854804443" title="Challenge sent to client.">challenge</a>;
<a name="l00181"></a><a class="code" href="structDBusAuth.html#a234096e729cabc43efcc85ce5094a305">00181</a> <span class="keywordtype">char</span> **<a class="code" href="structDBusAuth.html#a234096e729cabc43efcc85ce5094a305" title="Mechanisms we're allowed to use, or NULL if we can use any.">allowed_mechs</a>;
<a name="l00185"></a><a class="code" href="structDBusAuth.html#a246a00c89875045268403243c76b5166">00185</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structDBusAuth.html#a246a00c89875045268403243c76b5166" title="We needed memory to continue since last successful getting something done.">needed_memory</a> : 1;
<a name="l00188"></a><a class="code" href="structDBusAuth.html#a027172d9bc452832d4a61df9aec4f04a">00188</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structDBusAuth.html#a027172d9bc452832d4a61df9aec4f04a" title="Client already got mech list.">already_got_mechanisms</a> : 1;
<a name="l00189"></a><a class="code" href="structDBusAuth.html#ac216729b05c963c58935727594971739">00189</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structDBusAuth.html#ac216729b05c963c58935727594971739" title="Already sent a blank challenge to get an initial response.">already_asked_for_initial_response</a> : 1;
<a name="l00190"></a><a class="code" href="structDBusAuth.html#af9809523776f243d5e8f5f631d24562b">00190</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structDBusAuth.html#af9809523776f243d5e8f5f631d24562b" title="Buffer is "checked out" for reading data into.">buffer_outstanding</a> : 1;
<a name="l00192"></a><a class="code" href="structDBusAuth.html#a7e5d15e7861774d7b49339c452e2829a">00192</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structDBusAuth.html#a7e5d15e7861774d7b49339c452e2829a" title="This side could do unix fd passing.">unix_fd_possible</a> : 1;
<a name="l00193"></a><a class="code" href="structDBusAuth.html#af363f74ce5f14b2a63ea0ef71b3d3bd3">00193</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structDBusAuth.html#af363f74ce5f14b2a63ea0ef71b3d3bd3" title="Unix fd was successfully negotiated.">unix_fd_negotiated</a> : 1;
<a name="l00194"></a>00194 };
<a name="l00195"></a>00195
<a name="l00199"></a><a class="code" href="structDBusAuthClient.html">00199</a> <span class="keyword">typedef</span> <span class="keyword">struct</span>
<a name="l00200"></a>00200 {
<a name="l00201"></a><a class="code" href="structDBusAuthClient.html#a7aaf0c9832007ece465ac5289e5d7a8b">00201</a> <a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> <a class="code" href="structDBusAuthClient.html#a7aaf0c9832007ece465ac5289e5d7a8b" title="Parent class.">base</a>;
<a name="l00203"></a><a class="code" href="structDBusAuthClient.html#a646ae1e39e617ec3e3dd097fc18372eb">00203</a> <a class="code" href="structDBusList.html" title="A node in a linked list.">DBusList</a> *<a class="code" href="structDBusAuthClient.html#a646ae1e39e617ec3e3dd097fc18372eb" title="Mechanisms we got from the server that we're going to try using.">mechs_to_try</a>;
<a name="l00205"></a><a class="code" href="structDBusAuthClient.html#a91607b9958e0eaf7da388d9b9a347f08">00205</a> <a class="code" href="structDBusString.html">DBusString</a> <a class="code" href="structDBusAuthClient.html#a91607b9958e0eaf7da388d9b9a347f08" title="GUID received from server.">guid_from_server</a>;
<a name="l00207"></a>00207 } <a class="code" href="structDBusAuthClient.html" title=""Subclass" of DBusAuth for client side">DBusAuthClient</a>;
<a name="l00208"></a>00208
<a name="l00212"></a><a class="code" href="structDBusAuthServer.html">00212</a> <span class="keyword">typedef</span> <span class="keyword">struct</span>
<a name="l00213"></a>00213 {
<a name="l00214"></a><a class="code" href="structDBusAuthServer.html#ab43e81116262d4dde5e6b923120ac3a0">00214</a> <a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> <a class="code" href="structDBusAuthServer.html#ab43e81116262d4dde5e6b923120ac3a0" title="Parent class.">base</a>;
<a name="l00216"></a><a class="code" href="structDBusAuthServer.html#ac73a6f0760eca6e1b7204b3c8e9c6127">00216</a> <span class="keywordtype">int</span> <a class="code" href="structDBusAuthServer.html#ac73a6f0760eca6e1b7204b3c8e9c6127" title="Number of times client has been rejected.">failures</a>;
<a name="l00217"></a><a class="code" href="structDBusAuthServer.html#a0527732b2f979011cfeb501c8347fda0">00217</a> <span class="keywordtype">int</span> <a class="code" href="structDBusAuthServer.html#a0527732b2f979011cfeb501c8347fda0" title="Number of times we reject before disconnect.">max_failures</a>;
<a name="l00219"></a><a class="code" href="structDBusAuthServer.html#a4e5f1bdf9bf827a0d6d370bbad73af1c">00219</a> <a class="code" href="structDBusString.html">DBusString</a> <a class="code" href="structDBusAuthServer.html#a4e5f1bdf9bf827a0d6d370bbad73af1c" title="Our globally unique ID in hex encoding.">guid</a>;
<a name="l00221"></a>00221 } <a class="code" href="structDBusAuthServer.html" title=""Subclass" of DBusAuth for server side.">DBusAuthServer</a>;
<a name="l00222"></a>00222
<a name="l00223"></a>00223 <span class="keyword">static</span> <span class="keywordtype">void</span> goto_state (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00224"></a>00224 <span class="keyword">const</span> <a class="code" href="structDBusAuthStateData.html" title="Information about a auth state.">DBusAuthStateData</a> *new_state);
<a name="l00225"></a>00225 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> send_auth (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00226"></a>00226 <span class="keyword">const</span> <a class="code" href="structDBusAuthMechanismHandler.html" title="Virtual table representing a particular auth mechanism.">DBusAuthMechanismHandler</a> *mech);
<a name="l00227"></a>00227 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> send_data (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00228"></a>00228 <a class="code" href="structDBusString.html">DBusString</a> *data);
<a name="l00229"></a>00229 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> send_rejected (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth);
<a name="l00230"></a>00230 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> send_error (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00231"></a>00231 <span class="keyword">const</span> <span class="keywordtype">char</span> *message);
<a name="l00232"></a>00232 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> send_ok (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth);
<a name="l00233"></a>00233 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> send_begin (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth);
<a name="l00234"></a>00234 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> send_cancel (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth);
<a name="l00235"></a>00235 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> send_negotiate_unix_fd (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth);
<a name="l00236"></a>00236 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> send_agree_unix_fd (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth);
<a name="l00237"></a>00237
<a name="l00242"></a>00242 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> handle_server_state_waiting_for_auth (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00243"></a>00243 <a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b" title="Enumeration for the known authentication commands.">DBusAuthCommand</a> command,
<a name="l00244"></a>00244 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args);
<a name="l00245"></a>00245 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> handle_server_state_waiting_for_data (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00246"></a>00246 <a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b" title="Enumeration for the known authentication commands.">DBusAuthCommand</a> command,
<a name="l00247"></a>00247 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args);
<a name="l00248"></a>00248 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> handle_server_state_waiting_for_begin (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00249"></a>00249 <a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b" title="Enumeration for the known authentication commands.">DBusAuthCommand</a> command,
<a name="l00250"></a>00250 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args);
<a name="l00251"></a>00251
<a name="l00252"></a>00252 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="structDBusAuthStateData.html" title="Information about a auth state.">DBusAuthStateData</a> server_state_waiting_for_auth = {
<a name="l00253"></a>00253 <span class="stringliteral">"WaitingForAuth"</span>, handle_server_state_waiting_for_auth
<a name="l00254"></a>00254 };
<a name="l00255"></a>00255 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="structDBusAuthStateData.html" title="Information about a auth state.">DBusAuthStateData</a> server_state_waiting_for_data = {
<a name="l00256"></a>00256 <span class="stringliteral">"WaitingForData"</span>, handle_server_state_waiting_for_data
<a name="l00257"></a>00257 };
<a name="l00258"></a>00258 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="structDBusAuthStateData.html" title="Information about a auth state.">DBusAuthStateData</a> server_state_waiting_for_begin = {
<a name="l00259"></a>00259 <span class="stringliteral">"WaitingForBegin"</span>, handle_server_state_waiting_for_begin
<a name="l00260"></a>00260 };
<a name="l00261"></a>00261
<a name="l00266"></a>00266 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> handle_client_state_waiting_for_data (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00267"></a>00267 <a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b" title="Enumeration for the known authentication commands.">DBusAuthCommand</a> command,
<a name="l00268"></a>00268 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args);
<a name="l00269"></a>00269 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> handle_client_state_waiting_for_ok (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00270"></a>00270 <a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b" title="Enumeration for the known authentication commands.">DBusAuthCommand</a> command,
<a name="l00271"></a>00271 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args);
<a name="l00272"></a>00272 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> handle_client_state_waiting_for_reject (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00273"></a>00273 <a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b" title="Enumeration for the known authentication commands.">DBusAuthCommand</a> command,
<a name="l00274"></a>00274 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args);
<a name="l00275"></a>00275 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> handle_client_state_waiting_for_agree_unix_fd (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00276"></a>00276 <a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b" title="Enumeration for the known authentication commands.">DBusAuthCommand</a> command,
<a name="l00277"></a>00277 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args);
<a name="l00278"></a>00278
<a name="l00279"></a>00279 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="structDBusAuthStateData.html" title="Information about a auth state.">DBusAuthStateData</a> client_state_need_send_auth = {
<a name="l00280"></a>00280 <span class="stringliteral">"NeedSendAuth"</span>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>
<a name="l00281"></a>00281 };
<a name="l00282"></a>00282 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="structDBusAuthStateData.html" title="Information about a auth state.">DBusAuthStateData</a> client_state_waiting_for_data = {
<a name="l00283"></a>00283 <span class="stringliteral">"WaitingForData"</span>, handle_client_state_waiting_for_data
<a name="l00284"></a>00284 };
<a name="l00285"></a>00285 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="structDBusAuthStateData.html" title="Information about a auth state.">DBusAuthStateData</a> client_state_waiting_for_ok = {
<a name="l00286"></a>00286 <span class="stringliteral">"WaitingForOK"</span>, handle_client_state_waiting_for_ok
<a name="l00287"></a>00287 };
<a name="l00288"></a>00288 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="structDBusAuthStateData.html" title="Information about a auth state.">DBusAuthStateData</a> client_state_waiting_for_reject = {
<a name="l00289"></a>00289 <span class="stringliteral">"WaitingForReject"</span>, handle_client_state_waiting_for_reject
<a name="l00290"></a>00290 };
<a name="l00291"></a>00291 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="structDBusAuthStateData.html" title="Information about a auth state.">DBusAuthStateData</a> client_state_waiting_for_agree_unix_fd = {
<a name="l00292"></a>00292 <span class="stringliteral">"WaitingForAgreeUnixFD"</span>, handle_client_state_waiting_for_agree_unix_fd
<a name="l00293"></a>00293 };
<a name="l00294"></a>00294
<a name="l00299"></a>00299 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="structDBusAuthStateData.html" title="Information about a auth state.">DBusAuthStateData</a> common_state_authenticated = {
<a name="l00300"></a>00300 <span class="stringliteral">"Authenticated"</span>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>
<a name="l00301"></a>00301 };
<a name="l00302"></a>00302
<a name="l00303"></a>00303 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="structDBusAuthStateData.html" title="Information about a auth state.">DBusAuthStateData</a> common_state_need_disconnect = {
<a name="l00304"></a>00304 <span class="stringliteral">"NeedDisconnect"</span>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>
<a name="l00305"></a>00305 };
<a name="l00306"></a>00306
<a name="l00307"></a>00307 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> auth_side_client[] = <span class="stringliteral">"client"</span>;
<a name="l00308"></a>00308 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> auth_side_server[] = <span class="stringliteral">"server"</span>;
<a name="l00313"></a><a class="code" href="group__DBusAuthInternals.html#ga4211a12320d0b32bb2fbf0b56d6752a1">00313</a> <span class="preprocessor">#define DBUS_AUTH_IS_SERVER(auth) ((auth)->side == auth_side_server)</span>
<a name="l00314"></a>00314 <span class="preprocessor"></span>
<a name="l00318"></a><a class="code" href="group__DBusAuthInternals.html#ga74120265335a7f6a84041541c19074c9">00318</a> <span class="preprocessor">#define DBUS_AUTH_IS_CLIENT(auth) ((auth)->side == auth_side_client)</span>
<a name="l00319"></a>00319 <span class="preprocessor"></span>
<a name="l00323"></a><a class="code" href="group__DBusAuthInternals.html#ga6c2966c96fefbc8b40106d6b5235c854">00323</a> <span class="preprocessor">#define DBUS_AUTH_CLIENT(auth) ((DBusAuthClient*)(auth))</span>
<a name="l00324"></a>00324 <span class="preprocessor"></span>
<a name="l00328"></a><a class="code" href="group__DBusAuthInternals.html#ga3d476942b91b7b5825a914c2ae743717">00328</a> <span class="preprocessor">#define DBUS_AUTH_SERVER(auth) ((DBusAuthServer*)(auth))</span>
<a name="l00329"></a>00329 <span class="preprocessor"></span>
<a name="l00335"></a><a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8">00335</a> <span class="preprocessor">#define DBUS_AUTH_NAME(auth) ((auth)->side)</span>
<a name="l00336"></a>00336 <span class="preprocessor"></span>
<a name="l00337"></a>00337 <span class="keyword">static</span> <a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a>*
<a name="l00338"></a>00338 _dbus_auth_new (<span class="keywordtype">int</span> size)
<a name="l00339"></a>00339 {
<a name="l00340"></a>00340 <a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth;
<a name="l00341"></a>00341
<a name="l00342"></a>00342 auth = <a class="code" href="group__DBusMemory.html#gaa02722b030a091f6c14c4cb11a593623" title="Allocates the given number of bytes, as with standard malloc(), but all bytes are initialized to zero...">dbus_malloc0</a> (size);
<a name="l00343"></a>00343 <span class="keywordflow">if</span> (auth == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00344"></a>00344 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00345"></a>00345
<a name="l00346"></a>00346 auth-><a class="code" href="structDBusAuth.html#ab91763afd6a9d19f821dffd5930e69a6" title="reference count">refcount</a> = 1;
<a name="l00347"></a>00347
<a name="l00348"></a>00348 auth-><a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9" title="Keyring for cookie mechanism.">keyring</a> = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00349"></a>00349 auth-><a class="code" href="structDBusAuth.html#a43851f8413177b398c63e2045605ae4b" title="ID of cookie to use.">cookie_id</a> = -1;
<a name="l00350"></a>00350
<a name="l00351"></a>00351 <span class="comment">/* note that we don't use the max string length feature,</span>
<a name="l00352"></a>00352 <span class="comment"> * because you can't use that feature if you're going to</span>
<a name="l00353"></a>00353 <span class="comment"> * try to recover from out-of-memory (it creates</span>
<a name="l00354"></a>00354 <span class="comment"> * what looks like unrecoverable inability to alloc</span>
<a name="l00355"></a>00355 <span class="comment"> * more space in the string). But we do handle</span>
<a name="l00356"></a>00356 <span class="comment"> * overlong buffers in _dbus_auth_do_work().</span>
<a name="l00357"></a>00357 <span class="comment"> */</span>
<a name="l00358"></a>00358
<a name="l00359"></a>00359 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&auth-><a class="code" href="structDBusAuth.html#a986a475be9c96ecb9dd9ca5f86f60f10" title="Incoming data buffer.">incoming</a>))
<a name="l00360"></a>00360 <span class="keywordflow">goto</span> enomem_0;
<a name="l00361"></a>00361
<a name="l00362"></a>00362 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>))
<a name="l00363"></a>00363 <span class="keywordflow">goto</span> enomem_1;
<a name="l00364"></a>00364
<a name="l00365"></a>00365 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&auth-><a class="code" href="structDBusAuth.html#a8e70b9e2cc090fe006e1214983d79eed" title="Current identity we're authorizing as.">identity</a>))
<a name="l00366"></a>00366 <span class="keywordflow">goto</span> enomem_2;
<a name="l00367"></a>00367
<a name="l00368"></a>00368 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&auth-><a class="code" href="structDBusAuth.html#aedf6904d461a6f6eba2ee21f12f89611" title="Cookie scope.">context</a>))
<a name="l00369"></a>00369 <span class="keywordflow">goto</span> enomem_3;
<a name="l00370"></a>00370
<a name="l00371"></a>00371 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&auth-><a class="code" href="structDBusAuth.html#a4f2f7bfce0a53b41fb165a8854804443" title="Challenge sent to client.">challenge</a>))
<a name="l00372"></a>00372 <span class="keywordflow">goto</span> enomem_4;
<a name="l00373"></a>00373
<a name="l00374"></a>00374 <span class="comment">/* default context if none is specified */</span>
<a name="l00375"></a>00375 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&auth-><a class="code" href="structDBusAuth.html#aedf6904d461a6f6eba2ee21f12f89611" title="Cookie scope.">context</a>, <span class="stringliteral">"org_freedesktop_general"</span>))
<a name="l00376"></a>00376 <span class="keywordflow">goto</span> enomem_5;
<a name="l00377"></a>00377
<a name="l00378"></a>00378 auth-><a class="code" href="structDBusAuth.html#aed82f21abc1ad5aa8c0db8a43f93bc22" title="Credentials read from socket.">credentials</a> = <a class="code" href="group__DBusCredentials.html#ga749dd398d725f37a7943d60074785844" title="Creates a new credentials object.">_dbus_credentials_new</a> ();
<a name="l00379"></a>00379 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#aed82f21abc1ad5aa8c0db8a43f93bc22" title="Credentials read from socket.">credentials</a> == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00380"></a>00380 <span class="keywordflow">goto</span> enomem_6;
<a name="l00381"></a>00381
<a name="l00382"></a>00382 auth-><a class="code" href="structDBusAuth.html#afb4928fcc0f7af56d87fd6a512ad5a0a" title="Credentials that are authorized.">authorized_identity</a> = <a class="code" href="group__DBusCredentials.html#ga749dd398d725f37a7943d60074785844" title="Creates a new credentials object.">_dbus_credentials_new</a> ();
<a name="l00383"></a>00383 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#afb4928fcc0f7af56d87fd6a512ad5a0a" title="Credentials that are authorized.">authorized_identity</a> == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00384"></a>00384 <span class="keywordflow">goto</span> enomem_7;
<a name="l00385"></a>00385
<a name="l00386"></a>00386 auth-><a class="code" href="structDBusAuth.html#a6cfcba06657099d879b1e08aa886420f" title="Identity client has requested.">desired_identity</a> = <a class="code" href="group__DBusCredentials.html#ga749dd398d725f37a7943d60074785844" title="Creates a new credentials object.">_dbus_credentials_new</a> ();
<a name="l00387"></a>00387 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#a6cfcba06657099d879b1e08aa886420f" title="Identity client has requested.">desired_identity</a> == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00388"></a>00388 <span class="keywordflow">goto</span> enomem_8;
<a name="l00389"></a>00389
<a name="l00390"></a>00390 <span class="keywordflow">return</span> auth;
<a name="l00391"></a>00391
<a name="l00392"></a>00392 <span class="preprocessor">#if 0</span>
<a name="l00393"></a>00393 <span class="preprocessor"></span> enomem_9:
<a name="l00394"></a>00394 <a class="code" href="group__DBusCredentials.html#ga89913c830c3627cd006a50ca693af580" title="Decrement refcount on credentials.">_dbus_credentials_unref</a> (auth-><a class="code" href="structDBusAuth.html#a6cfcba06657099d879b1e08aa886420f" title="Identity client has requested.">desired_identity</a>);
<a name="l00395"></a>00395 <span class="preprocessor">#endif</span>
<a name="l00396"></a>00396 <span class="preprocessor"></span> enomem_8:
<a name="l00397"></a>00397 <a class="code" href="group__DBusCredentials.html#ga89913c830c3627cd006a50ca693af580" title="Decrement refcount on credentials.">_dbus_credentials_unref</a> (auth-><a class="code" href="structDBusAuth.html#afb4928fcc0f7af56d87fd6a512ad5a0a" title="Credentials that are authorized.">authorized_identity</a>);
<a name="l00398"></a>00398 enomem_7:
<a name="l00399"></a>00399 <a class="code" href="group__DBusCredentials.html#ga89913c830c3627cd006a50ca693af580" title="Decrement refcount on credentials.">_dbus_credentials_unref</a> (auth-><a class="code" href="structDBusAuth.html#aed82f21abc1ad5aa8c0db8a43f93bc22" title="Credentials read from socket.">credentials</a>);
<a name="l00400"></a>00400 enomem_6:
<a name="l00401"></a>00401 <span class="comment">/* last alloc was an append to context, which is freed already below */</span> ;
<a name="l00402"></a>00402 enomem_5:
<a name="l00403"></a>00403 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&auth-><a class="code" href="structDBusAuth.html#a4f2f7bfce0a53b41fb165a8854804443" title="Challenge sent to client.">challenge</a>);
<a name="l00404"></a>00404 enomem_4:
<a name="l00405"></a>00405 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&auth-><a class="code" href="structDBusAuth.html#aedf6904d461a6f6eba2ee21f12f89611" title="Cookie scope.">context</a>);
<a name="l00406"></a>00406 enomem_3:
<a name="l00407"></a>00407 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&auth-><a class="code" href="structDBusAuth.html#a8e70b9e2cc090fe006e1214983d79eed" title="Current identity we're authorizing as.">identity</a>);
<a name="l00408"></a>00408 enomem_2:
<a name="l00409"></a>00409 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>);
<a name="l00410"></a>00410 enomem_1:
<a name="l00411"></a>00411 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&auth-><a class="code" href="structDBusAuth.html#a986a475be9c96ecb9dd9ca5f86f60f10" title="Incoming data buffer.">incoming</a>);
<a name="l00412"></a>00412 enomem_0:
<a name="l00413"></a>00413 <a class="code" href="group__DBusMemory.html#ga34e666b19b015035a9a31e53da84b39a" title="Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().">dbus_free</a> (auth);
<a name="l00414"></a>00414 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00415"></a>00415 }
<a name="l00416"></a>00416
<a name="l00417"></a>00417 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00418"></a>00418 shutdown_mech (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l00419"></a>00419 {
<a name="l00420"></a>00420 <span class="comment">/* Cancel any auth */</span>
<a name="l00421"></a>00421 auth-><a class="code" href="structDBusAuth.html#ac216729b05c963c58935727594971739" title="Already sent a blank challenge to get an initial response.">already_asked_for_initial_response</a> = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00422"></a>00422 <a class="code" href="group__DBusString.html#ga08c423b93c28dd746dcb93e0461ab95c" title="Sets the length of a string.">_dbus_string_set_length</a> (&auth-><a class="code" href="structDBusAuth.html#a8e70b9e2cc090fe006e1214983d79eed" title="Current identity we're authorizing as.">identity</a>, 0);
<a name="l00423"></a>00423
<a name="l00424"></a>00424 <a class="code" href="group__DBusCredentials.html#ga40a5c7e37b10419e233a473dc7173f3c" title="Clear all credentials in the object.">_dbus_credentials_clear</a> (auth-><a class="code" href="structDBusAuth.html#afb4928fcc0f7af56d87fd6a512ad5a0a" title="Credentials that are authorized.">authorized_identity</a>);
<a name="l00425"></a>00425 <a class="code" href="group__DBusCredentials.html#ga40a5c7e37b10419e233a473dc7173f3c" title="Clear all credentials in the object.">_dbus_credentials_clear</a> (auth-><a class="code" href="structDBusAuth.html#a6cfcba06657099d879b1e08aa886420f" title="Identity client has requested.">desired_identity</a>);
<a name="l00426"></a>00426
<a name="l00427"></a>00427 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00428"></a>00428 {
<a name="l00429"></a>00429 _dbus_verbose (<span class="stringliteral">"%s: Shutting down mechanism %s\n"</span>,
<a name="l00430"></a>00430 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth), auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a>-><a class="code" href="structDBusAuthMechanismHandler.html#a353c8effcb16bdc37c2f225b8dad9415" title="Name of the mechanism.">mechanism</a>);
<a name="l00431"></a>00431
<a name="l00432"></a>00432 <span class="keywordflow">if</span> (<a class="code" href="group__DBusAuthInternals.html#ga74120265335a7f6a84041541c19074c9">DBUS_AUTH_IS_CLIENT</a> (auth))
<a name="l00433"></a>00433 (* auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a>-><a class="code" href="structDBusAuthMechanismHandler.html#aca0a9e37793ca20ed175b3c008c3494f" title="Function on client side for shutdown.">client_shutdown_func</a>) (auth);
<a name="l00434"></a>00434 <span class="keywordflow">else</span>
<a name="l00435"></a>00435 (* auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a>-><a class="code" href="structDBusAuthMechanismHandler.html#aa6e551c05863b85ee8c138a976497e8e" title="Function on server side to shut down.">server_shutdown_func</a>) (auth);
<a name="l00436"></a>00436
<a name="l00437"></a>00437 auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a> = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00438"></a>00438 }
<a name="l00439"></a>00439 }
<a name="l00440"></a>00440
<a name="l00441"></a>00441 <span class="comment">/*</span>
<a name="l00442"></a>00442 <span class="comment"> * DBUS_COOKIE_SHA1 mechanism</span>
<a name="l00443"></a>00443 <span class="comment"> */</span>
<a name="l00444"></a>00444
<a name="l00445"></a>00445 <span class="comment">/* Returns TRUE but with an empty string hash if the</span>
<a name="l00446"></a>00446 <span class="comment"> * cookie_id isn't known. As with all this code</span>
<a name="l00447"></a>00447 <span class="comment"> * TRUE just means we had enough memory.</span>
<a name="l00448"></a>00448 <span class="comment"> */</span>
<a name="l00449"></a>00449 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00450"></a>00450 sha1_compute_hash (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00451"></a>00451 <span class="keywordtype">int</span> cookie_id,
<a name="l00452"></a>00452 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *server_challenge,
<a name="l00453"></a>00453 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *client_challenge,
<a name="l00454"></a>00454 <a class="code" href="structDBusString.html">DBusString</a> *hash)
<a name="l00455"></a>00455 {
<a name="l00456"></a>00456 <a class="code" href="structDBusString.html">DBusString</a> cookie;
<a name="l00457"></a>00457 <a class="code" href="structDBusString.html">DBusString</a> to_hash;
<a name="l00458"></a>00458 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> retval;
<a name="l00459"></a>00459
<a name="l00460"></a>00460 _dbus_assert (auth-><a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9" title="Keyring for cookie mechanism.">keyring</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00461"></a>00461
<a name="l00462"></a>00462 retval = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00463"></a>00463
<a name="l00464"></a>00464 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&cookie))
<a name="l00465"></a>00465 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00466"></a>00466
<a name="l00467"></a>00467 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusKeyring.html#ga6adfb998247ab4d0c1d5652f59c354e4" title="Gets the hex-encoded secret key for the given ID.">_dbus_keyring_get_hex_key</a> (auth-><a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9" title="Keyring for cookie mechanism.">keyring</a>, cookie_id,
<a name="l00468"></a>00468 &cookie))
<a name="l00469"></a>00469 <span class="keywordflow">goto</span> out_0;
<a name="l00470"></a>00470
<a name="l00471"></a>00471 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&cookie) == 0)
<a name="l00472"></a>00472 {
<a name="l00473"></a>00473 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00474"></a>00474 <span class="keywordflow">goto</span> out_0;
<a name="l00475"></a>00475 }
<a name="l00476"></a>00476
<a name="l00477"></a>00477 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&to_hash))
<a name="l00478"></a>00478 <span class="keywordflow">goto</span> out_0;
<a name="l00479"></a>00479
<a name="l00480"></a>00480 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga3c10f0d1bcaa3b450025b9c6a8b901d7" title="Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...">_dbus_string_copy</a> (server_challenge, 0,
<a name="l00481"></a>00481 &to_hash, <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&to_hash)))
<a name="l00482"></a>00482 <span class="keywordflow">goto</span> out_1;
<a name="l00483"></a>00483
<a name="l00484"></a>00484 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&to_hash, <span class="stringliteral">":"</span>))
<a name="l00485"></a>00485 <span class="keywordflow">goto</span> out_1;
<a name="l00486"></a>00486
<a name="l00487"></a>00487 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga3c10f0d1bcaa3b450025b9c6a8b901d7" title="Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...">_dbus_string_copy</a> (client_challenge, 0,
<a name="l00488"></a>00488 &to_hash, <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&to_hash)))
<a name="l00489"></a>00489 <span class="keywordflow">goto</span> out_1;
<a name="l00490"></a>00490
<a name="l00491"></a>00491 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&to_hash, <span class="stringliteral">":"</span>))
<a name="l00492"></a>00492 <span class="keywordflow">goto</span> out_1;
<a name="l00493"></a>00493
<a name="l00494"></a>00494 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga3c10f0d1bcaa3b450025b9c6a8b901d7" title="Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...">_dbus_string_copy</a> (&cookie, 0,
<a name="l00495"></a>00495 &to_hash, <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&to_hash)))
<a name="l00496"></a>00496 <span class="keywordflow">goto</span> out_1;
<a name="l00497"></a>00497
<a name="l00498"></a>00498 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusSHA.html#ga4278fb9df967943834c4ad6332f2c28b" title="Computes the ASCII hex-encoded shasum of the given data and appends it to the output string...">_dbus_sha_compute</a> (&to_hash, hash))
<a name="l00499"></a>00499 <span class="keywordflow">goto</span> out_1;
<a name="l00500"></a>00500
<a name="l00501"></a>00501 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00502"></a>00502
<a name="l00503"></a>00503 out_1:
<a name="l00504"></a>00504 <a class="code" href="group__DBusString.html#ga9385fd0de31b3f5f4f8baa96bad3fac6" title="Clears all allocated bytes in the string to zero.">_dbus_string_zero</a> (&to_hash);
<a name="l00505"></a>00505 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&to_hash);
<a name="l00506"></a>00506 out_0:
<a name="l00507"></a>00507 <a class="code" href="group__DBusString.html#ga9385fd0de31b3f5f4f8baa96bad3fac6" title="Clears all allocated bytes in the string to zero.">_dbus_string_zero</a> (&cookie);
<a name="l00508"></a>00508 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&cookie);
<a name="l00509"></a>00509 <span class="keywordflow">return</span> retval;
<a name="l00510"></a>00510 }
<a name="l00511"></a>00511
<a name="l00516"></a><a class="code" href="group__DBusAuthInternals.html#gae379752f3a8ebb11e727e75d87a35554">00516</a> <span class="preprocessor">#define N_CHALLENGE_BYTES (128/8)</span>
<a name="l00517"></a>00517 <span class="preprocessor"></span>
<a name="l00518"></a>00518 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00519"></a>00519 sha1_handle_first_client_response (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00520"></a>00520 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *data)
<a name="l00521"></a>00521 {
<a name="l00522"></a>00522 <span class="comment">/* We haven't sent a challenge yet, we're expecting a desired</span>
<a name="l00523"></a>00523 <span class="comment"> * username from the client.</span>
<a name="l00524"></a>00524 <span class="comment"> */</span>
<a name="l00525"></a>00525 <a class="code" href="structDBusString.html">DBusString</a> tmp;
<a name="l00526"></a>00526 <a class="code" href="structDBusString.html">DBusString</a> tmp2;
<a name="l00527"></a>00527 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> retval;
<a name="l00528"></a>00528 <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a> error;
<a name="l00529"></a>00529
<a name="l00530"></a>00530 retval = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00531"></a>00531
<a name="l00532"></a>00532 <a class="code" href="group__DBusString.html#ga08c423b93c28dd746dcb93e0461ab95c" title="Sets the length of a string.">_dbus_string_set_length</a> (&auth-><a class="code" href="structDBusAuth.html#a4f2f7bfce0a53b41fb165a8854804443" title="Challenge sent to client.">challenge</a>, 0);
<a name="l00533"></a>00533
<a name="l00534"></a>00534 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (data) > 0)
<a name="l00535"></a>00535 {
<a name="l00536"></a>00536 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&auth-><a class="code" href="structDBusAuth.html#a8e70b9e2cc090fe006e1214983d79eed" title="Current identity we're authorizing as.">identity</a>) > 0)
<a name="l00537"></a>00537 {
<a name="l00538"></a>00538 <span class="comment">/* Tried to send two auth identities, wtf */</span>
<a name="l00539"></a>00539 _dbus_verbose (<span class="stringliteral">"%s: client tried to send auth identity, but we already have one\n"</span>,
<a name="l00540"></a>00540 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth));
<a name="l00541"></a>00541 <span class="keywordflow">return</span> send_rejected (auth);
<a name="l00542"></a>00542 }
<a name="l00543"></a>00543 <span class="keywordflow">else</span>
<a name="l00544"></a>00544 {
<a name="l00545"></a>00545 <span class="comment">/* this is our auth identity */</span>
<a name="l00546"></a>00546 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga3c10f0d1bcaa3b450025b9c6a8b901d7" title="Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...">_dbus_string_copy</a> (data, 0, &auth-><a class="code" href="structDBusAuth.html#a8e70b9e2cc090fe006e1214983d79eed" title="Current identity we're authorizing as.">identity</a>, 0))
<a name="l00547"></a>00547 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00548"></a>00548 }
<a name="l00549"></a>00549 }
<a name="l00550"></a>00550
<a name="l00551"></a>00551 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusSysdeps.html#gacecdbb00a3c8b63e821edae537ae3c7b" title="Adds the credentials corresponding to the given username.">_dbus_credentials_add_from_user</a> (auth-><a class="code" href="structDBusAuth.html#a6cfcba06657099d879b1e08aa886420f" title="Identity client has requested.">desired_identity</a>, data))
<a name="l00552"></a>00552 {
<a name="l00553"></a>00553 _dbus_verbose (<span class="stringliteral">"%s: Did not get a valid username from client\n"</span>,
<a name="l00554"></a>00554 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth));
<a name="l00555"></a>00555 <span class="keywordflow">return</span> send_rejected (auth);
<a name="l00556"></a>00556 }
<a name="l00557"></a>00557
<a name="l00558"></a>00558 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&tmp))
<a name="l00559"></a>00559 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00560"></a>00560
<a name="l00561"></a>00561 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&tmp2))
<a name="l00562"></a>00562 {
<a name="l00563"></a>00563 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&tmp);
<a name="l00564"></a>00564 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00565"></a>00565 }
<a name="l00566"></a>00566
<a name="l00567"></a>00567 <span class="comment">/* we cache the keyring for speed, so here we drop it if it's the</span>
<a name="l00568"></a>00568 <span class="comment"> * wrong one. FIXME caching the keyring here is useless since we use</span>
<a name="l00569"></a>00569 <span class="comment"> * a different DBusAuth for every connection.</span>
<a name="l00570"></a>00570 <span class="comment"> */</span>
<a name="l00571"></a>00571 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9" title="Keyring for cookie mechanism.">keyring</a> &&
<a name="l00572"></a>00572 !<a class="code" href="group__DBusKeyring.html#ga5ef8c7224182f27ff56b3105c6963cfd" title="Checks whether the keyring is for the same user as the given credentials.">_dbus_keyring_is_for_credentials</a> (auth-><a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9" title="Keyring for cookie mechanism.">keyring</a>,
<a name="l00573"></a>00573 auth-><a class="code" href="structDBusAuth.html#a6cfcba06657099d879b1e08aa886420f" title="Identity client has requested.">desired_identity</a>))
<a name="l00574"></a>00574 {
<a name="l00575"></a>00575 <a class="code" href="group__DBusKeyring.html#gadd42b029d08dc477b6847e91bdcb23ca" title="Decrements refcount and finalizes if it reaches zero.">_dbus_keyring_unref</a> (auth-><a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9" title="Keyring for cookie mechanism.">keyring</a>);
<a name="l00576"></a>00576 auth-><a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9" title="Keyring for cookie mechanism.">keyring</a> = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00577"></a>00577 }
<a name="l00578"></a>00578
<a name="l00579"></a>00579 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9" title="Keyring for cookie mechanism.">keyring</a> == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00580"></a>00580 {
<a name="l00581"></a>00581 <a class="code" href="group__DBusErrors.html#ga8937f0b7cdf8554fa6305158ce453fbe" title="Initializes a DBusError structure.">dbus_error_init</a> (&error);
<a name="l00582"></a>00582 auth-><a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9" title="Keyring for cookie mechanism.">keyring</a> = <a class="code" href="group__DBusKeyring.html#ga6dad1720cf97ca6017c39330bec8d09f" title="Creates a new keyring that lives in the ~/.dbus-keyrings directory of the user represented by credent...">_dbus_keyring_new_for_credentials</a> (auth-><a class="code" href="structDBusAuth.html#a6cfcba06657099d879b1e08aa886420f" title="Identity client has requested.">desired_identity</a>,
<a name="l00583"></a>00583 &auth-><a class="code" href="structDBusAuth.html#aedf6904d461a6f6eba2ee21f12f89611" title="Cookie scope.">context</a>,
<a name="l00584"></a>00584 &error);
<a name="l00585"></a>00585
<a name="l00586"></a>00586 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9" title="Keyring for cookie mechanism.">keyring</a> == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00587"></a>00587 {
<a name="l00588"></a>00588 <span class="keywordflow">if</span> (<a class="code" href="group__DBusErrors.html#ga48515c580199514026542fe053ef1887" title="Checks whether the error is set and has the given name.">dbus_error_has_name</a> (&error,
<a name="l00589"></a>00589 <a class="code" href="group__DBusProtocol.html#gac32eaf0b92f798307853cd4fe0cf11c2" title="There was not enough memory to complete an operation.">DBUS_ERROR_NO_MEMORY</a>))
<a name="l00590"></a>00590 {
<a name="l00591"></a>00591 <a class="code" href="group__DBusErrors.html#gaac6c14ead14829ee4e090f39de6a7568" title="Frees an error that's been set (or just initialized), then reinitializes the error as in dbus_error_i...">dbus_error_free</a> (&error);
<a name="l00592"></a>00592 <span class="keywordflow">goto</span> out;
<a name="l00593"></a>00593 }
<a name="l00594"></a>00594 <span class="keywordflow">else</span>
<a name="l00595"></a>00595 {
<a name="l00596"></a>00596 _DBUS_ASSERT_ERROR_IS_SET (&error);
<a name="l00597"></a>00597 _dbus_verbose (<span class="stringliteral">"%s: Error loading keyring: %s\n"</span>,
<a name="l00598"></a>00598 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth), error.<a class="code" href="structDBusError.html#afb559175326de5b6b340e26204e92d72" title="public error message field">message</a>);
<a name="l00599"></a>00599 <span class="keywordflow">if</span> (send_rejected (auth))
<a name="l00600"></a>00600 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>; <span class="comment">/* retval is only about mem */</span>
<a name="l00601"></a>00601 <a class="code" href="group__DBusErrors.html#gaac6c14ead14829ee4e090f39de6a7568" title="Frees an error that's been set (or just initialized), then reinitializes the error as in dbus_error_i...">dbus_error_free</a> (&error);
<a name="l00602"></a>00602 <span class="keywordflow">goto</span> out;
<a name="l00603"></a>00603 }
<a name="l00604"></a>00604 }
<a name="l00605"></a>00605 <span class="keywordflow">else</span>
<a name="l00606"></a>00606 {
<a name="l00607"></a>00607 _dbus_assert (!<a class="code" href="group__DBusErrors.html#gab0ed62e9fc2685897eb2d41467c89405" title="Checks whether an error occurred (the error is set).">dbus_error_is_set</a> (&error));
<a name="l00608"></a>00608 }
<a name="l00609"></a>00609 }
<a name="l00610"></a>00610
<a name="l00611"></a>00611 _dbus_assert (auth-><a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9" title="Keyring for cookie mechanism.">keyring</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00612"></a>00612
<a name="l00613"></a>00613 <a class="code" href="group__DBusErrors.html#ga8937f0b7cdf8554fa6305158ce453fbe" title="Initializes a DBusError structure.">dbus_error_init</a> (&error);
<a name="l00614"></a>00614 auth-><a class="code" href="structDBusAuth.html#a43851f8413177b398c63e2045605ae4b" title="ID of cookie to use.">cookie_id</a> = <a class="code" href="group__DBusKeyring.html#ga0daf16cfb75ab28d67d5dfa881f457a6" title="Gets a recent key to use for authentication.">_dbus_keyring_get_best_key</a> (auth-><a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9" title="Keyring for cookie mechanism.">keyring</a>, &error);
<a name="l00615"></a>00615 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#a43851f8413177b398c63e2045605ae4b" title="ID of cookie to use.">cookie_id</a> < 0)
<a name="l00616"></a>00616 {
<a name="l00617"></a>00617 _DBUS_ASSERT_ERROR_IS_SET (&error);
<a name="l00618"></a>00618 _dbus_verbose (<span class="stringliteral">"%s: Could not get a cookie ID to send to client: %s\n"</span>,
<a name="l00619"></a>00619 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth), error.<a class="code" href="structDBusError.html#afb559175326de5b6b340e26204e92d72" title="public error message field">message</a>);
<a name="l00620"></a>00620 <span class="keywordflow">if</span> (send_rejected (auth))
<a name="l00621"></a>00621 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00622"></a>00622 <a class="code" href="group__DBusErrors.html#gaac6c14ead14829ee4e090f39de6a7568" title="Frees an error that's been set (or just initialized), then reinitializes the error as in dbus_error_i...">dbus_error_free</a> (&error);
<a name="l00623"></a>00623 <span class="keywordflow">goto</span> out;
<a name="l00624"></a>00624 }
<a name="l00625"></a>00625 <span class="keywordflow">else</span>
<a name="l00626"></a>00626 {
<a name="l00627"></a>00627 _dbus_assert (!<a class="code" href="group__DBusErrors.html#gab0ed62e9fc2685897eb2d41467c89405" title="Checks whether an error occurred (the error is set).">dbus_error_is_set</a> (&error));
<a name="l00628"></a>00628 }
<a name="l00629"></a>00629
<a name="l00630"></a>00630 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga3c10f0d1bcaa3b450025b9c6a8b901d7" title="Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...">_dbus_string_copy</a> (&auth-><a class="code" href="structDBusAuth.html#aedf6904d461a6f6eba2ee21f12f89611" title="Cookie scope.">context</a>, 0,
<a name="l00631"></a>00631 &tmp2, <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&tmp2)))
<a name="l00632"></a>00632 <span class="keywordflow">goto</span> out;
<a name="l00633"></a>00633
<a name="l00634"></a>00634 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&tmp2, <span class="stringliteral">" "</span>))
<a name="l00635"></a>00635 <span class="keywordflow">goto</span> out;
<a name="l00636"></a>00636
<a name="l00637"></a>00637 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga41141ca36c361f92b6029530ff83fa66" title="Appends an integer to a DBusString.">_dbus_string_append_int</a> (&tmp2, auth-><a class="code" href="structDBusAuth.html#a43851f8413177b398c63e2045605ae4b" title="ID of cookie to use.">cookie_id</a>))
<a name="l00638"></a>00638 <span class="keywordflow">goto</span> out;
<a name="l00639"></a>00639
<a name="l00640"></a>00640 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&tmp2, <span class="stringliteral">" "</span>))
<a name="l00641"></a>00641 <span class="keywordflow">goto</span> out;
<a name="l00642"></a>00642
<a name="l00643"></a>00643 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusSysdeps.html#gac9fd08af5e54c0e9b3db108b48a65778" title="Generates the given number of random bytes, using the best mechanism we can come up with...">_dbus_generate_random_bytes</a> (&tmp, <a class="code" href="group__DBusAuthInternals.html#gae379752f3a8ebb11e727e75d87a35554" title="http://www.ietf.org/rfc/rfc2831.txt suggests at least 64 bits of entropy, we use 128.">N_CHALLENGE_BYTES</a>))
<a name="l00644"></a>00644 <span class="keywordflow">goto</span> out;
<a name="l00645"></a>00645
<a name="l00646"></a>00646 <a class="code" href="group__DBusString.html#ga08c423b93c28dd746dcb93e0461ab95c" title="Sets the length of a string.">_dbus_string_set_length</a> (&auth-><a class="code" href="structDBusAuth.html#a4f2f7bfce0a53b41fb165a8854804443" title="Challenge sent to client.">challenge</a>, 0);
<a name="l00647"></a>00647 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#gaabb4873f436e015944a33cd1e3815cc9" title="Encodes a string in hex, the way MD5 and SHA-1 are usually encoded.">_dbus_string_hex_encode</a> (&tmp, 0, &auth-><a class="code" href="structDBusAuth.html#a4f2f7bfce0a53b41fb165a8854804443" title="Challenge sent to client.">challenge</a>, 0))
<a name="l00648"></a>00648 <span class="keywordflow">goto</span> out;
<a name="l00649"></a>00649
<a name="l00650"></a>00650 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#gaabb4873f436e015944a33cd1e3815cc9" title="Encodes a string in hex, the way MD5 and SHA-1 are usually encoded.">_dbus_string_hex_encode</a> (&tmp, 0, &tmp2,
<a name="l00651"></a>00651 <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&tmp2)))
<a name="l00652"></a>00652 <span class="keywordflow">goto</span> out;
<a name="l00653"></a>00653
<a name="l00654"></a>00654 <span class="keywordflow">if</span> (!send_data (auth, &tmp2))
<a name="l00655"></a>00655 <span class="keywordflow">goto</span> out;
<a name="l00656"></a>00656
<a name="l00657"></a>00657 goto_state (auth, &server_state_waiting_for_data);
<a name="l00658"></a>00658 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00659"></a>00659
<a name="l00660"></a>00660 out:
<a name="l00661"></a>00661 <a class="code" href="group__DBusString.html#ga9385fd0de31b3f5f4f8baa96bad3fac6" title="Clears all allocated bytes in the string to zero.">_dbus_string_zero</a> (&tmp);
<a name="l00662"></a>00662 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&tmp);
<a name="l00663"></a>00663 <a class="code" href="group__DBusString.html#ga9385fd0de31b3f5f4f8baa96bad3fac6" title="Clears all allocated bytes in the string to zero.">_dbus_string_zero</a> (&tmp2);
<a name="l00664"></a>00664 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&tmp2);
<a name="l00665"></a>00665
<a name="l00666"></a>00666 <span class="keywordflow">return</span> retval;
<a name="l00667"></a>00667 }
<a name="l00668"></a>00668
<a name="l00669"></a>00669 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00670"></a>00670 sha1_handle_second_client_response (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00671"></a>00671 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *data)
<a name="l00672"></a>00672 {
<a name="l00673"></a>00673 <span class="comment">/* We are expecting a response which is the hex-encoded client</span>
<a name="l00674"></a>00674 <span class="comment"> * challenge, space, then SHA-1 hash of the concatenation of our</span>
<a name="l00675"></a>00675 <span class="comment"> * challenge, ":", client challenge, ":", secret key, all</span>
<a name="l00676"></a>00676 <span class="comment"> * hex-encoded.</span>
<a name="l00677"></a>00677 <span class="comment"> */</span>
<a name="l00678"></a>00678 <span class="keywordtype">int</span> i;
<a name="l00679"></a>00679 <a class="code" href="structDBusString.html">DBusString</a> client_challenge;
<a name="l00680"></a>00680 <a class="code" href="structDBusString.html">DBusString</a> client_hash;
<a name="l00681"></a>00681 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> retval;
<a name="l00682"></a>00682 <a class="code" href="structDBusString.html">DBusString</a> correct_hash;
<a name="l00683"></a>00683
<a name="l00684"></a>00684 retval = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00685"></a>00685
<a name="l00686"></a>00686 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga677ddb4246c7e7f67ed3145dc3c1c96b" title="Finds a blank (space or tab) in the string.">_dbus_string_find_blank</a> (data, 0, &i))
<a name="l00687"></a>00687 {
<a name="l00688"></a>00688 _dbus_verbose (<span class="stringliteral">"%s: no space separator in client response\n"</span>,
<a name="l00689"></a>00689 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth));
<a name="l00690"></a>00690 <span class="keywordflow">return</span> send_rejected (auth);
<a name="l00691"></a>00691 }
<a name="l00692"></a>00692
<a name="l00693"></a>00693 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&client_challenge))
<a name="l00694"></a>00694 <span class="keywordflow">goto</span> out_0;
<a name="l00695"></a>00695
<a name="l00696"></a>00696 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&client_hash))
<a name="l00697"></a>00697 <span class="keywordflow">goto</span> out_1;
<a name="l00698"></a>00698
<a name="l00699"></a>00699 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#gaf5f13bc7ac7a623516930d26ae2589bf" title="Like _dbus_string_copy(), but can copy a segment from the middle of the source string.">_dbus_string_copy_len</a> (data, 0, i, &client_challenge,
<a name="l00700"></a>00700 0))
<a name="l00701"></a>00701 <span class="keywordflow">goto</span> out_2;
<a name="l00702"></a>00702
<a name="l00703"></a>00703 <a class="code" href="group__DBusString.html#ga5698b163289be0066cf10c0f1caf877a" title="Skips blanks from start, storing the first non-blank in *end (blank is space or tab).">_dbus_string_skip_blank</a> (data, i, &i);
<a name="l00704"></a>00704
<a name="l00705"></a>00705 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#gaf5f13bc7ac7a623516930d26ae2589bf" title="Like _dbus_string_copy(), but can copy a segment from the middle of the source string.">_dbus_string_copy_len</a> (data, i,
<a name="l00706"></a>00706 <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (data) - i,
<a name="l00707"></a>00707 &client_hash,
<a name="l00708"></a>00708 0))
<a name="l00709"></a>00709 <span class="keywordflow">goto</span> out_2;
<a name="l00710"></a>00710
<a name="l00711"></a>00711 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&client_challenge) == 0 ||
<a name="l00712"></a>00712 <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&client_hash) == 0)
<a name="l00713"></a>00713 {
<a name="l00714"></a>00714 _dbus_verbose (<span class="stringliteral">"%s: zero-length client challenge or hash\n"</span>,
<a name="l00715"></a>00715 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth));
<a name="l00716"></a>00716 <span class="keywordflow">if</span> (send_rejected (auth))
<a name="l00717"></a>00717 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00718"></a>00718 <span class="keywordflow">goto</span> out_2;
<a name="l00719"></a>00719 }
<a name="l00720"></a>00720
<a name="l00721"></a>00721 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&correct_hash))
<a name="l00722"></a>00722 <span class="keywordflow">goto</span> out_2;
<a name="l00723"></a>00723
<a name="l00724"></a>00724 <span class="keywordflow">if</span> (!sha1_compute_hash (auth, auth-><a class="code" href="structDBusAuth.html#a43851f8413177b398c63e2045605ae4b" title="ID of cookie to use.">cookie_id</a>,
<a name="l00725"></a>00725 &auth-><a class="code" href="structDBusAuth.html#a4f2f7bfce0a53b41fb165a8854804443" title="Challenge sent to client.">challenge</a>,
<a name="l00726"></a>00726 &client_challenge,
<a name="l00727"></a>00727 &correct_hash))
<a name="l00728"></a>00728 <span class="keywordflow">goto</span> out_3;
<a name="l00729"></a>00729
<a name="l00730"></a>00730 <span class="comment">/* if cookie_id was invalid, then we get an empty hash */</span>
<a name="l00731"></a>00731 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&correct_hash) == 0)
<a name="l00732"></a>00732 {
<a name="l00733"></a>00733 <span class="keywordflow">if</span> (send_rejected (auth))
<a name="l00734"></a>00734 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00735"></a>00735 <span class="keywordflow">goto</span> out_3;
<a name="l00736"></a>00736 }
<a name="l00737"></a>00737
<a name="l00738"></a>00738 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#gad79c34af55b58f0e8b81ecf11b8694bb" title="Tests two DBusString for equality.">_dbus_string_equal</a> (&client_hash, &correct_hash))
<a name="l00739"></a>00739 {
<a name="l00740"></a>00740 <span class="keywordflow">if</span> (send_rejected (auth))
<a name="l00741"></a>00741 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00742"></a>00742 <span class="keywordflow">goto</span> out_3;
<a name="l00743"></a>00743 }
<a name="l00744"></a>00744
<a name="l00745"></a>00745 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusCredentials.html#ga6b6cab83ecaa05e765967c188f62dd05" title="Merge all credentials found in the second object into the first object, overwriting the first object ...">_dbus_credentials_add_credentials</a> (auth-><a class="code" href="structDBusAuth.html#afb4928fcc0f7af56d87fd6a512ad5a0a" title="Credentials that are authorized.">authorized_identity</a>,
<a name="l00746"></a>00746 auth-><a class="code" href="structDBusAuth.html#a6cfcba06657099d879b1e08aa886420f" title="Identity client has requested.">desired_identity</a>))
<a name="l00747"></a>00747 <span class="keywordflow">goto</span> out_3;
<a name="l00748"></a>00748
<a name="l00749"></a>00749 <span class="comment">/* Copy process ID from the socket credentials if it's there</span>
<a name="l00750"></a>00750 <span class="comment"> */</span>
<a name="l00751"></a>00751 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusCredentials.html#gabd5a6d038f1d35fd23af8b2e73bb7ef8" title="Merge the given credential found in the second object into the first object, overwriting the first ob...">_dbus_credentials_add_credential</a> (auth-><a class="code" href="structDBusAuth.html#afb4928fcc0f7af56d87fd6a512ad5a0a" title="Credentials that are authorized.">authorized_identity</a>,
<a name="l00752"></a>00752 DBUS_CREDENTIAL_UNIX_PROCESS_ID,
<a name="l00753"></a>00753 auth-><a class="code" href="structDBusAuth.html#aed82f21abc1ad5aa8c0db8a43f93bc22" title="Credentials read from socket.">credentials</a>))
<a name="l00754"></a>00754 <span class="keywordflow">goto</span> out_3;
<a name="l00755"></a>00755
<a name="l00756"></a>00756 <span class="keywordflow">if</span> (!send_ok (auth))
<a name="l00757"></a>00757 <span class="keywordflow">goto</span> out_3;
<a name="l00758"></a>00758
<a name="l00759"></a>00759 _dbus_verbose (<span class="stringliteral">"%s: authenticated client using DBUS_COOKIE_SHA1\n"</span>,
<a name="l00760"></a>00760 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth));
<a name="l00761"></a>00761
<a name="l00762"></a>00762 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00763"></a>00763
<a name="l00764"></a>00764 out_3:
<a name="l00765"></a>00765 <a class="code" href="group__DBusString.html#ga9385fd0de31b3f5f4f8baa96bad3fac6" title="Clears all allocated bytes in the string to zero.">_dbus_string_zero</a> (&correct_hash);
<a name="l00766"></a>00766 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&correct_hash);
<a name="l00767"></a>00767 out_2:
<a name="l00768"></a>00768 <a class="code" href="group__DBusString.html#ga9385fd0de31b3f5f4f8baa96bad3fac6" title="Clears all allocated bytes in the string to zero.">_dbus_string_zero</a> (&client_hash);
<a name="l00769"></a>00769 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&client_hash);
<a name="l00770"></a>00770 out_1:
<a name="l00771"></a>00771 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&client_challenge);
<a name="l00772"></a>00772 out_0:
<a name="l00773"></a>00773 <span class="keywordflow">return</span> retval;
<a name="l00774"></a>00774 }
<a name="l00775"></a>00775
<a name="l00776"></a>00776 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00777"></a>00777 handle_server_data_cookie_sha1_mech (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00778"></a>00778 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *data)
<a name="l00779"></a>00779 {
<a name="l00780"></a>00780 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#a43851f8413177b398c63e2045605ae4b" title="ID of cookie to use.">cookie_id</a> < 0)
<a name="l00781"></a>00781 <span class="keywordflow">return</span> sha1_handle_first_client_response (auth, data);
<a name="l00782"></a>00782 <span class="keywordflow">else</span>
<a name="l00783"></a>00783 <span class="keywordflow">return</span> sha1_handle_second_client_response (auth, data);
<a name="l00784"></a>00784 }
<a name="l00785"></a>00785
<a name="l00786"></a>00786 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00787"></a>00787 handle_server_shutdown_cookie_sha1_mech (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l00788"></a>00788 {
<a name="l00789"></a>00789 auth-><a class="code" href="structDBusAuth.html#a43851f8413177b398c63e2045605ae4b" title="ID of cookie to use.">cookie_id</a> = -1;
<a name="l00790"></a>00790 <a class="code" href="group__DBusString.html#ga08c423b93c28dd746dcb93e0461ab95c" title="Sets the length of a string.">_dbus_string_set_length</a> (&auth-><a class="code" href="structDBusAuth.html#a4f2f7bfce0a53b41fb165a8854804443" title="Challenge sent to client.">challenge</a>, 0);
<a name="l00791"></a>00791 }
<a name="l00792"></a>00792
<a name="l00793"></a>00793 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00794"></a>00794 handle_client_initial_response_cookie_sha1_mech (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00795"></a>00795 <a class="code" href="structDBusString.html">DBusString</a> *response)
<a name="l00796"></a>00796 {
<a name="l00797"></a>00797 <a class="code" href="structDBusString.html">DBusString</a> username;
<a name="l00798"></a>00798 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> retval;
<a name="l00799"></a>00799
<a name="l00800"></a>00800 retval = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00801"></a>00801
<a name="l00802"></a>00802 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&username))
<a name="l00803"></a>00803 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00804"></a>00804
<a name="l00805"></a>00805 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusSysdeps.html#ga095c54de3974c6d04c29ef86c6e06e35" title="Append to the string the identity we would like to have when we authenticate, on UNIX this is the cur...">_dbus_append_user_from_current_process</a> (&username))
<a name="l00806"></a>00806 <span class="keywordflow">goto</span> out_0;
<a name="l00807"></a>00807
<a name="l00808"></a>00808 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#gaabb4873f436e015944a33cd1e3815cc9" title="Encodes a string in hex, the way MD5 and SHA-1 are usually encoded.">_dbus_string_hex_encode</a> (&username, 0,
<a name="l00809"></a>00809 response,
<a name="l00810"></a>00810 <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (response)))
<a name="l00811"></a>00811 <span class="keywordflow">goto</span> out_0;
<a name="l00812"></a>00812
<a name="l00813"></a>00813 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00814"></a>00814
<a name="l00815"></a>00815 out_0:
<a name="l00816"></a>00816 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&username);
<a name="l00817"></a>00817
<a name="l00818"></a>00818 <span class="keywordflow">return</span> retval;
<a name="l00819"></a>00819 }
<a name="l00820"></a>00820
<a name="l00821"></a>00821 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00822"></a>00822 handle_client_data_cookie_sha1_mech (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l00823"></a>00823 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *data)
<a name="l00824"></a>00824 {
<a name="l00825"></a>00825 <span class="comment">/* The data we get from the server should be the cookie context</span>
<a name="l00826"></a>00826 <span class="comment"> * name, the cookie ID, and the server challenge, separated by</span>
<a name="l00827"></a>00827 <span class="comment"> * spaces. We send back our challenge string and the correct hash.</span>
<a name="l00828"></a>00828 <span class="comment"> */</span>
<a name="l00829"></a>00829 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> retval;
<a name="l00830"></a>00830 <a class="code" href="structDBusString.html">DBusString</a> context;
<a name="l00831"></a>00831 <a class="code" href="structDBusString.html">DBusString</a> cookie_id_str;
<a name="l00832"></a>00832 <a class="code" href="structDBusString.html">DBusString</a> server_challenge;
<a name="l00833"></a>00833 <a class="code" href="structDBusString.html">DBusString</a> client_challenge;
<a name="l00834"></a>00834 <a class="code" href="structDBusString.html">DBusString</a> correct_hash;
<a name="l00835"></a>00835 <a class="code" href="structDBusString.html">DBusString</a> tmp;
<a name="l00836"></a>00836 <span class="keywordtype">int</span> i, j;
<a name="l00837"></a>00837 <span class="keywordtype">long</span> val;
<a name="l00838"></a>00838
<a name="l00839"></a>00839 retval = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00840"></a>00840
<a name="l00841"></a>00841 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga677ddb4246c7e7f67ed3145dc3c1c96b" title="Finds a blank (space or tab) in the string.">_dbus_string_find_blank</a> (data, 0, &i))
<a name="l00842"></a>00842 {
<a name="l00843"></a>00843 <span class="keywordflow">if</span> (send_error (auth,
<a name="l00844"></a>00844 <span class="stringliteral">"Server did not send context/ID/challenge properly"</span>))
<a name="l00845"></a>00845 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00846"></a>00846 <span class="keywordflow">goto</span> out_0;
<a name="l00847"></a>00847 }
<a name="l00848"></a>00848
<a name="l00849"></a>00849 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&context))
<a name="l00850"></a>00850 <span class="keywordflow">goto</span> out_0;
<a name="l00851"></a>00851
<a name="l00852"></a>00852 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#gaf5f13bc7ac7a623516930d26ae2589bf" title="Like _dbus_string_copy(), but can copy a segment from the middle of the source string.">_dbus_string_copy_len</a> (data, 0, i,
<a name="l00853"></a>00853 &context, 0))
<a name="l00854"></a>00854 <span class="keywordflow">goto</span> out_1;
<a name="l00855"></a>00855
<a name="l00856"></a>00856 <a class="code" href="group__DBusString.html#ga5698b163289be0066cf10c0f1caf877a" title="Skips blanks from start, storing the first non-blank in *end (blank is space or tab).">_dbus_string_skip_blank</a> (data, i, &i);
<a name="l00857"></a>00857 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga677ddb4246c7e7f67ed3145dc3c1c96b" title="Finds a blank (space or tab) in the string.">_dbus_string_find_blank</a> (data, i, &j))
<a name="l00858"></a>00858 {
<a name="l00859"></a>00859 <span class="keywordflow">if</span> (send_error (auth,
<a name="l00860"></a>00860 <span class="stringliteral">"Server did not send context/ID/challenge properly"</span>))
<a name="l00861"></a>00861 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00862"></a>00862 <span class="keywordflow">goto</span> out_1;
<a name="l00863"></a>00863 }
<a name="l00864"></a>00864
<a name="l00865"></a>00865 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&cookie_id_str))
<a name="l00866"></a>00866 <span class="keywordflow">goto</span> out_1;
<a name="l00867"></a>00867
<a name="l00868"></a>00868 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#gaf5f13bc7ac7a623516930d26ae2589bf" title="Like _dbus_string_copy(), but can copy a segment from the middle of the source string.">_dbus_string_copy_len</a> (data, i, j - i,
<a name="l00869"></a>00869 &cookie_id_str, 0))
<a name="l00870"></a>00870 <span class="keywordflow">goto</span> out_2;
<a name="l00871"></a>00871
<a name="l00872"></a>00872 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&server_challenge))
<a name="l00873"></a>00873 <span class="keywordflow">goto</span> out_2;
<a name="l00874"></a>00874
<a name="l00875"></a>00875 i = j;
<a name="l00876"></a>00876 <a class="code" href="group__DBusString.html#ga5698b163289be0066cf10c0f1caf877a" title="Skips blanks from start, storing the first non-blank in *end (blank is space or tab).">_dbus_string_skip_blank</a> (data, i, &i);
<a name="l00877"></a>00877 j = <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (data);
<a name="l00878"></a>00878
<a name="l00879"></a>00879 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#gaf5f13bc7ac7a623516930d26ae2589bf" title="Like _dbus_string_copy(), but can copy a segment from the middle of the source string.">_dbus_string_copy_len</a> (data, i, j - i,
<a name="l00880"></a>00880 &server_challenge, 0))
<a name="l00881"></a>00881 <span class="keywordflow">goto</span> out_3;
<a name="l00882"></a>00882
<a name="l00883"></a>00883 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusKeyring.html#ga5bbeeef1ba831a89d7f0f211e886e7c2" title="Checks whether the context is a valid context.">_dbus_keyring_validate_context</a> (&context))
<a name="l00884"></a>00884 {
<a name="l00885"></a>00885 <span class="keywordflow">if</span> (send_error (auth, <span class="stringliteral">"Server sent invalid cookie context"</span>))
<a name="l00886"></a>00886 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00887"></a>00887 <span class="keywordflow">goto</span> out_3;
<a name="l00888"></a>00888 }
<a name="l00889"></a>00889
<a name="l00890"></a>00890 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga93e22894a5e2e0d65c179c7d36a8b1c8" title="Parses an integer contained in a DBusString.">_dbus_string_parse_int</a> (&cookie_id_str, 0, &val, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>))
<a name="l00891"></a>00891 {
<a name="l00892"></a>00892 <span class="keywordflow">if</span> (send_error (auth, <span class="stringliteral">"Could not parse cookie ID as an integer"</span>))
<a name="l00893"></a>00893 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00894"></a>00894 <span class="keywordflow">goto</span> out_3;
<a name="l00895"></a>00895 }
<a name="l00896"></a>00896
<a name="l00897"></a>00897 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&server_challenge) == 0)
<a name="l00898"></a>00898 {
<a name="l00899"></a>00899 <span class="keywordflow">if</span> (send_error (auth, <span class="stringliteral">"Empty server challenge string"</span>))
<a name="l00900"></a>00900 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00901"></a>00901 <span class="keywordflow">goto</span> out_3;
<a name="l00902"></a>00902 }
<a name="l00903"></a>00903
<a name="l00904"></a>00904 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9" title="Keyring for cookie mechanism.">keyring</a> == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00905"></a>00905 {
<a name="l00906"></a>00906 <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a> error;
<a name="l00907"></a>00907
<a name="l00908"></a>00908 <a class="code" href="group__DBusErrors.html#ga8937f0b7cdf8554fa6305158ce453fbe" title="Initializes a DBusError structure.">dbus_error_init</a> (&error);
<a name="l00909"></a>00909 auth-><a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9" title="Keyring for cookie mechanism.">keyring</a> = <a class="code" href="group__DBusKeyring.html#ga6dad1720cf97ca6017c39330bec8d09f" title="Creates a new keyring that lives in the ~/.dbus-keyrings directory of the user represented by credent...">_dbus_keyring_new_for_credentials</a> (<a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>,
<a name="l00910"></a>00910 &context,
<a name="l00911"></a>00911 &error);
<a name="l00912"></a>00912
<a name="l00913"></a>00913 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9" title="Keyring for cookie mechanism.">keyring</a> == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00914"></a>00914 {
<a name="l00915"></a>00915 <span class="keywordflow">if</span> (<a class="code" href="group__DBusErrors.html#ga48515c580199514026542fe053ef1887" title="Checks whether the error is set and has the given name.">dbus_error_has_name</a> (&error,
<a name="l00916"></a>00916 <a class="code" href="group__DBusProtocol.html#gac32eaf0b92f798307853cd4fe0cf11c2" title="There was not enough memory to complete an operation.">DBUS_ERROR_NO_MEMORY</a>))
<a name="l00917"></a>00917 {
<a name="l00918"></a>00918 <a class="code" href="group__DBusErrors.html#gaac6c14ead14829ee4e090f39de6a7568" title="Frees an error that's been set (or just initialized), then reinitializes the error as in dbus_error_i...">dbus_error_free</a> (&error);
<a name="l00919"></a>00919 <span class="keywordflow">goto</span> out_3;
<a name="l00920"></a>00920 }
<a name="l00921"></a>00921 <span class="keywordflow">else</span>
<a name="l00922"></a>00922 {
<a name="l00923"></a>00923 _DBUS_ASSERT_ERROR_IS_SET (&error);
<a name="l00924"></a>00924
<a name="l00925"></a>00925 _dbus_verbose (<span class="stringliteral">"%s: Error loading keyring: %s\n"</span>,
<a name="l00926"></a>00926 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth), error.<a class="code" href="structDBusError.html#afb559175326de5b6b340e26204e92d72" title="public error message field">message</a>);
<a name="l00927"></a>00927
<a name="l00928"></a>00928 <span class="keywordflow">if</span> (send_error (auth, <span class="stringliteral">"Could not load cookie file"</span>))
<a name="l00929"></a>00929 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>; <span class="comment">/* retval is only about mem */</span>
<a name="l00930"></a>00930
<a name="l00931"></a>00931 <a class="code" href="group__DBusErrors.html#gaac6c14ead14829ee4e090f39de6a7568" title="Frees an error that's been set (or just initialized), then reinitializes the error as in dbus_error_i...">dbus_error_free</a> (&error);
<a name="l00932"></a>00932 <span class="keywordflow">goto</span> out_3;
<a name="l00933"></a>00933 }
<a name="l00934"></a>00934 }
<a name="l00935"></a>00935 <span class="keywordflow">else</span>
<a name="l00936"></a>00936 {
<a name="l00937"></a>00937 _dbus_assert (!<a class="code" href="group__DBusErrors.html#gab0ed62e9fc2685897eb2d41467c89405" title="Checks whether an error occurred (the error is set).">dbus_error_is_set</a> (&error));
<a name="l00938"></a>00938 }
<a name="l00939"></a>00939 }
<a name="l00940"></a>00940
<a name="l00941"></a>00941 _dbus_assert (auth-><a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9" title="Keyring for cookie mechanism.">keyring</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00942"></a>00942
<a name="l00943"></a>00943 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&tmp))
<a name="l00944"></a>00944 <span class="keywordflow">goto</span> out_3;
<a name="l00945"></a>00945
<a name="l00946"></a>00946 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusSysdeps.html#gac9fd08af5e54c0e9b3db108b48a65778" title="Generates the given number of random bytes, using the best mechanism we can come up with...">_dbus_generate_random_bytes</a> (&tmp, <a class="code" href="group__DBusAuthInternals.html#gae379752f3a8ebb11e727e75d87a35554" title="http://www.ietf.org/rfc/rfc2831.txt suggests at least 64 bits of entropy, we use 128.">N_CHALLENGE_BYTES</a>))
<a name="l00947"></a>00947 <span class="keywordflow">goto</span> out_4;
<a name="l00948"></a>00948
<a name="l00949"></a>00949 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&client_challenge))
<a name="l00950"></a>00950 <span class="keywordflow">goto</span> out_4;
<a name="l00951"></a>00951
<a name="l00952"></a>00952 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#gaabb4873f436e015944a33cd1e3815cc9" title="Encodes a string in hex, the way MD5 and SHA-1 are usually encoded.">_dbus_string_hex_encode</a> (&tmp, 0, &client_challenge, 0))
<a name="l00953"></a>00953 <span class="keywordflow">goto</span> out_5;
<a name="l00954"></a>00954
<a name="l00955"></a>00955 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&correct_hash))
<a name="l00956"></a>00956 <span class="keywordflow">goto</span> out_5;
<a name="l00957"></a>00957
<a name="l00958"></a>00958 <span class="keywordflow">if</span> (!sha1_compute_hash (auth, val,
<a name="l00959"></a>00959 &server_challenge,
<a name="l00960"></a>00960 &client_challenge,
<a name="l00961"></a>00961 &correct_hash))
<a name="l00962"></a>00962 <span class="keywordflow">goto</span> out_6;
<a name="l00963"></a>00963
<a name="l00964"></a>00964 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&correct_hash) == 0)
<a name="l00965"></a>00965 {
<a name="l00966"></a>00966 <span class="comment">/* couldn't find the cookie ID or something */</span>
<a name="l00967"></a>00967 <span class="keywordflow">if</span> (send_error (auth, <span class="stringliteral">"Don't have the requested cookie ID"</span>))
<a name="l00968"></a>00968 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00969"></a>00969 <span class="keywordflow">goto</span> out_6;
<a name="l00970"></a>00970 }
<a name="l00971"></a>00971
<a name="l00972"></a>00972 <a class="code" href="group__DBusString.html#ga08c423b93c28dd746dcb93e0461ab95c" title="Sets the length of a string.">_dbus_string_set_length</a> (&tmp, 0);
<a name="l00973"></a>00973
<a name="l00974"></a>00974 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga3c10f0d1bcaa3b450025b9c6a8b901d7" title="Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...">_dbus_string_copy</a> (&client_challenge, 0, &tmp,
<a name="l00975"></a>00975 <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&tmp)))
<a name="l00976"></a>00976 <span class="keywordflow">goto</span> out_6;
<a name="l00977"></a>00977
<a name="l00978"></a>00978 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&tmp, <span class="stringliteral">" "</span>))
<a name="l00979"></a>00979 <span class="keywordflow">goto</span> out_6;
<a name="l00980"></a>00980
<a name="l00981"></a>00981 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga3c10f0d1bcaa3b450025b9c6a8b901d7" title="Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...">_dbus_string_copy</a> (&correct_hash, 0, &tmp,
<a name="l00982"></a>00982 <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&tmp)))
<a name="l00983"></a>00983 <span class="keywordflow">goto</span> out_6;
<a name="l00984"></a>00984
<a name="l00985"></a>00985 <span class="keywordflow">if</span> (!send_data (auth, &tmp))
<a name="l00986"></a>00986 <span class="keywordflow">goto</span> out_6;
<a name="l00987"></a>00987
<a name="l00988"></a>00988 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00989"></a>00989
<a name="l00990"></a>00990 out_6:
<a name="l00991"></a>00991 <a class="code" href="group__DBusString.html#ga9385fd0de31b3f5f4f8baa96bad3fac6" title="Clears all allocated bytes in the string to zero.">_dbus_string_zero</a> (&correct_hash);
<a name="l00992"></a>00992 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&correct_hash);
<a name="l00993"></a>00993 out_5:
<a name="l00994"></a>00994 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&client_challenge);
<a name="l00995"></a>00995 out_4:
<a name="l00996"></a>00996 <a class="code" href="group__DBusString.html#ga9385fd0de31b3f5f4f8baa96bad3fac6" title="Clears all allocated bytes in the string to zero.">_dbus_string_zero</a> (&tmp);
<a name="l00997"></a>00997 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&tmp);
<a name="l00998"></a>00998 out_3:
<a name="l00999"></a>00999 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&server_challenge);
<a name="l01000"></a>01000 out_2:
<a name="l01001"></a>01001 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&cookie_id_str);
<a name="l01002"></a>01002 out_1:
<a name="l01003"></a>01003 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&context);
<a name="l01004"></a>01004 out_0:
<a name="l01005"></a>01005 <span class="keywordflow">return</span> retval;
<a name="l01006"></a>01006 }
<a name="l01007"></a>01007
<a name="l01008"></a>01008 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l01009"></a>01009 handle_client_shutdown_cookie_sha1_mech (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l01010"></a>01010 {
<a name="l01011"></a>01011 auth-><a class="code" href="structDBusAuth.html#a43851f8413177b398c63e2045605ae4b" title="ID of cookie to use.">cookie_id</a> = -1;
<a name="l01012"></a>01012 <a class="code" href="group__DBusString.html#ga08c423b93c28dd746dcb93e0461ab95c" title="Sets the length of a string.">_dbus_string_set_length</a> (&auth-><a class="code" href="structDBusAuth.html#a4f2f7bfce0a53b41fb165a8854804443" title="Challenge sent to client.">challenge</a>, 0);
<a name="l01013"></a>01013 }
<a name="l01014"></a>01014
<a name="l01015"></a>01015 <span class="comment">/*</span>
<a name="l01016"></a>01016 <span class="comment"> * EXTERNAL mechanism</span>
<a name="l01017"></a>01017 <span class="comment"> */</span>
<a name="l01018"></a>01018
<a name="l01019"></a>01019 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01020"></a>01020 handle_server_data_external_mech (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l01021"></a>01021 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *data)
<a name="l01022"></a>01022 {
<a name="l01023"></a>01023 <span class="keywordflow">if</span> (<a class="code" href="group__DBusCredentials.html#gabfd7a1f681a91b45ba2f4e7461131827" title="Checks whether a credentials object contains a user identity.">_dbus_credentials_are_anonymous</a> (auth-><a class="code" href="structDBusAuth.html#aed82f21abc1ad5aa8c0db8a43f93bc22" title="Credentials read from socket.">credentials</a>))
<a name="l01024"></a>01024 {
<a name="l01025"></a>01025 _dbus_verbose (<span class="stringliteral">"%s: no credentials, mechanism EXTERNAL can't authenticate\n"</span>,
<a name="l01026"></a>01026 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth));
<a name="l01027"></a>01027 <span class="keywordflow">return</span> send_rejected (auth);
<a name="l01028"></a>01028 }
<a name="l01029"></a>01029
<a name="l01030"></a>01030 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (data) > 0)
<a name="l01031"></a>01031 {
<a name="l01032"></a>01032 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&auth-><a class="code" href="structDBusAuth.html#a8e70b9e2cc090fe006e1214983d79eed" title="Current identity we're authorizing as.">identity</a>) > 0)
<a name="l01033"></a>01033 {
<a name="l01034"></a>01034 <span class="comment">/* Tried to send two auth identities, wtf */</span>
<a name="l01035"></a>01035 _dbus_verbose (<span class="stringliteral">"%s: client tried to send auth identity, but we already have one\n"</span>,
<a name="l01036"></a>01036 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth));
<a name="l01037"></a>01037 <span class="keywordflow">return</span> send_rejected (auth);
<a name="l01038"></a>01038 }
<a name="l01039"></a>01039 <span class="keywordflow">else</span>
<a name="l01040"></a>01040 {
<a name="l01041"></a>01041 <span class="comment">/* this is our auth identity */</span>
<a name="l01042"></a>01042 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga3c10f0d1bcaa3b450025b9c6a8b901d7" title="Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...">_dbus_string_copy</a> (data, 0, &auth-><a class="code" href="structDBusAuth.html#a8e70b9e2cc090fe006e1214983d79eed" title="Current identity we're authorizing as.">identity</a>, 0))
<a name="l01043"></a>01043 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01044"></a>01044 }
<a name="l01045"></a>01045 }
<a name="l01046"></a>01046
<a name="l01047"></a>01047 <span class="comment">/* Poke client for an auth identity, if none given */</span>
<a name="l01048"></a>01048 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&auth-><a class="code" href="structDBusAuth.html#a8e70b9e2cc090fe006e1214983d79eed" title="Current identity we're authorizing as.">identity</a>) == 0 &&
<a name="l01049"></a>01049 !auth-><a class="code" href="structDBusAuth.html#ac216729b05c963c58935727594971739" title="Already sent a blank challenge to get an initial response.">already_asked_for_initial_response</a>)
<a name="l01050"></a>01050 {
<a name="l01051"></a>01051 <span class="keywordflow">if</span> (send_data (auth, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>))
<a name="l01052"></a>01052 {
<a name="l01053"></a>01053 _dbus_verbose (<span class="stringliteral">"%s: sending empty challenge asking client for auth identity\n"</span>,
<a name="l01054"></a>01054 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth));
<a name="l01055"></a>01055 auth-><a class="code" href="structDBusAuth.html#ac216729b05c963c58935727594971739" title="Already sent a blank challenge to get an initial response.">already_asked_for_initial_response</a> = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01056"></a>01056 goto_state (auth, &server_state_waiting_for_data);
<a name="l01057"></a>01057 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01058"></a>01058 }
<a name="l01059"></a>01059 <span class="keywordflow">else</span>
<a name="l01060"></a>01060 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01061"></a>01061 }
<a name="l01062"></a>01062
<a name="l01063"></a>01063 <a class="code" href="group__DBusCredentials.html#ga40a5c7e37b10419e233a473dc7173f3c" title="Clear all credentials in the object.">_dbus_credentials_clear</a> (auth-><a class="code" href="structDBusAuth.html#a6cfcba06657099d879b1e08aa886420f" title="Identity client has requested.">desired_identity</a>);
<a name="l01064"></a>01064
<a name="l01065"></a>01065 <span class="comment">/* If auth->identity is still empty here, then client</span>
<a name="l01066"></a>01066 <span class="comment"> * responded with an empty string after we poked it for</span>
<a name="l01067"></a>01067 <span class="comment"> * an initial response. This means to try to auth the</span>
<a name="l01068"></a>01068 <span class="comment"> * identity provided in the credentials.</span>
<a name="l01069"></a>01069 <span class="comment"> */</span>
<a name="l01070"></a>01070 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&auth-><a class="code" href="structDBusAuth.html#a8e70b9e2cc090fe006e1214983d79eed" title="Current identity we're authorizing as.">identity</a>) == 0)
<a name="l01071"></a>01071 {
<a name="l01072"></a>01072 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusCredentials.html#ga6b6cab83ecaa05e765967c188f62dd05" title="Merge all credentials found in the second object into the first object, overwriting the first object ...">_dbus_credentials_add_credentials</a> (auth-><a class="code" href="structDBusAuth.html#a6cfcba06657099d879b1e08aa886420f" title="Identity client has requested.">desired_identity</a>,
<a name="l01073"></a>01073 auth-><a class="code" href="structDBusAuth.html#aed82f21abc1ad5aa8c0db8a43f93bc22" title="Credentials read from socket.">credentials</a>))
<a name="l01074"></a>01074 {
<a name="l01075"></a>01075 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>; <span class="comment">/* OOM */</span>
<a name="l01076"></a>01076 }
<a name="l01077"></a>01077 }
<a name="l01078"></a>01078 <span class="keywordflow">else</span>
<a name="l01079"></a>01079 {
<a name="l01080"></a>01080 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusSysdeps.html#gacecdbb00a3c8b63e821edae537ae3c7b" title="Adds the credentials corresponding to the given username.">_dbus_credentials_add_from_user</a> (auth-><a class="code" href="structDBusAuth.html#a6cfcba06657099d879b1e08aa886420f" title="Identity client has requested.">desired_identity</a>,
<a name="l01081"></a>01081 &auth-><a class="code" href="structDBusAuth.html#a8e70b9e2cc090fe006e1214983d79eed" title="Current identity we're authorizing as.">identity</a>))
<a name="l01082"></a>01082 {
<a name="l01083"></a>01083 _dbus_verbose (<span class="stringliteral">"%s: could not get credentials from uid string\n"</span>,
<a name="l01084"></a>01084 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth));
<a name="l01085"></a>01085 <span class="keywordflow">return</span> send_rejected (auth);
<a name="l01086"></a>01086 }
<a name="l01087"></a>01087 }
<a name="l01088"></a>01088
<a name="l01089"></a>01089 <span class="keywordflow">if</span> (<a class="code" href="group__DBusCredentials.html#gabfd7a1f681a91b45ba2f4e7461131827" title="Checks whether a credentials object contains a user identity.">_dbus_credentials_are_anonymous</a> (auth-><a class="code" href="structDBusAuth.html#a6cfcba06657099d879b1e08aa886420f" title="Identity client has requested.">desired_identity</a>))
<a name="l01090"></a>01090 {
<a name="l01091"></a>01091 _dbus_verbose (<span class="stringliteral">"%s: desired user %s is no good\n"</span>,
<a name="l01092"></a>01092 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth),
<a name="l01093"></a>01093 <a class="code" href="group__DBusString.html#ga33e20241ae7d784624f97d89b1a0539e" title="Gets the raw character buffer from a const string.">_dbus_string_get_const_data</a> (&auth-><a class="code" href="structDBusAuth.html#a8e70b9e2cc090fe006e1214983d79eed" title="Current identity we're authorizing as.">identity</a>));
<a name="l01094"></a>01094 <span class="keywordflow">return</span> send_rejected (auth);
<a name="l01095"></a>01095 }
<a name="l01096"></a>01096
<a name="l01097"></a>01097 <span class="keywordflow">if</span> (<a class="code" href="group__DBusCredentials.html#ga1c6090c76e5151ae8a1efe9e84382934" title="Checks whether the first credentials object contains all the credentials found in the second credenti...">_dbus_credentials_are_superset</a> (auth-><a class="code" href="structDBusAuth.html#aed82f21abc1ad5aa8c0db8a43f93bc22" title="Credentials read from socket.">credentials</a>,
<a name="l01098"></a>01098 auth-><a class="code" href="structDBusAuth.html#a6cfcba06657099d879b1e08aa886420f" title="Identity client has requested.">desired_identity</a>))
<a name="l01099"></a>01099 {
<a name="l01100"></a>01100 <span class="comment">/* client has authenticated */</span>
<a name="l01101"></a>01101 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusCredentials.html#ga6b6cab83ecaa05e765967c188f62dd05" title="Merge all credentials found in the second object into the first object, overwriting the first object ...">_dbus_credentials_add_credentials</a> (auth-><a class="code" href="structDBusAuth.html#afb4928fcc0f7af56d87fd6a512ad5a0a" title="Credentials that are authorized.">authorized_identity</a>,
<a name="l01102"></a>01102 auth-><a class="code" href="structDBusAuth.html#a6cfcba06657099d879b1e08aa886420f" title="Identity client has requested.">desired_identity</a>))
<a name="l01103"></a>01103 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01104"></a>01104
<a name="l01105"></a>01105 <span class="comment">/* also copy process ID from the socket credentials</span>
<a name="l01106"></a>01106 <span class="comment"> */</span>
<a name="l01107"></a>01107 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusCredentials.html#gabd5a6d038f1d35fd23af8b2e73bb7ef8" title="Merge the given credential found in the second object into the first object, overwriting the first ob...">_dbus_credentials_add_credential</a> (auth-><a class="code" href="structDBusAuth.html#afb4928fcc0f7af56d87fd6a512ad5a0a" title="Credentials that are authorized.">authorized_identity</a>,
<a name="l01108"></a>01108 DBUS_CREDENTIAL_UNIX_PROCESS_ID,
<a name="l01109"></a>01109 auth-><a class="code" href="structDBusAuth.html#aed82f21abc1ad5aa8c0db8a43f93bc22" title="Credentials read from socket.">credentials</a>))
<a name="l01110"></a>01110 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01111"></a>01111
<a name="l01112"></a>01112 <span class="comment">/* also copy audit data from the socket credentials</span>
<a name="l01113"></a>01113 <span class="comment"> */</span>
<a name="l01114"></a>01114 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusCredentials.html#gabd5a6d038f1d35fd23af8b2e73bb7ef8" title="Merge the given credential found in the second object into the first object, overwriting the first ob...">_dbus_credentials_add_credential</a> (auth-><a class="code" href="structDBusAuth.html#afb4928fcc0f7af56d87fd6a512ad5a0a" title="Credentials that are authorized.">authorized_identity</a>,
<a name="l01115"></a>01115 DBUS_CREDENTIAL_ADT_AUDIT_DATA_ID,
<a name="l01116"></a>01116 auth-><a class="code" href="structDBusAuth.html#aed82f21abc1ad5aa8c0db8a43f93bc22" title="Credentials read from socket.">credentials</a>))
<a name="l01117"></a>01117 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01118"></a>01118
<a name="l01119"></a>01119 <span class="keywordflow">if</span> (!send_ok (auth))
<a name="l01120"></a>01120 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01121"></a>01121
<a name="l01122"></a>01122 _dbus_verbose (<span class="stringliteral">"%s: authenticated client based on socket credentials\n"</span>,
<a name="l01123"></a>01123 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth));
<a name="l01124"></a>01124
<a name="l01125"></a>01125 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01126"></a>01126 }
<a name="l01127"></a>01127 <span class="keywordflow">else</span>
<a name="l01128"></a>01128 {
<a name="l01129"></a>01129 _dbus_verbose (<span class="stringliteral">"%s: desired identity not found in socket credentials\n"</span>,
<a name="l01130"></a>01130 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth));
<a name="l01131"></a>01131 <span class="keywordflow">return</span> send_rejected (auth);
<a name="l01132"></a>01132 }
<a name="l01133"></a>01133 }
<a name="l01134"></a>01134
<a name="l01135"></a>01135 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l01136"></a>01136 handle_server_shutdown_external_mech (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l01137"></a>01137 {
<a name="l01138"></a>01138
<a name="l01139"></a>01139 }
<a name="l01140"></a>01140
<a name="l01141"></a>01141 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01142"></a>01142 handle_client_initial_response_external_mech (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l01143"></a>01143 <a class="code" href="structDBusString.html">DBusString</a> *response)
<a name="l01144"></a>01144 {
<a name="l01145"></a>01145 <span class="comment">/* We always append our UID as an initial response, so the server</span>
<a name="l01146"></a>01146 <span class="comment"> * doesn't have to send back an empty challenge to check whether we</span>
<a name="l01147"></a>01147 <span class="comment"> * want to specify an identity. i.e. this avoids a round trip that</span>
<a name="l01148"></a>01148 <span class="comment"> * the spec for the EXTERNAL mechanism otherwise requires.</span>
<a name="l01149"></a>01149 <span class="comment"> */</span>
<a name="l01150"></a>01150 <a class="code" href="structDBusString.html">DBusString</a> plaintext;
<a name="l01151"></a>01151
<a name="l01152"></a>01152 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&plaintext))
<a name="l01153"></a>01153 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01154"></a>01154
<a name="l01155"></a>01155 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusSysdeps.html#ga095c54de3974c6d04c29ef86c6e06e35" title="Append to the string the identity we would like to have when we authenticate, on UNIX this is the cur...">_dbus_append_user_from_current_process</a> (&plaintext))
<a name="l01156"></a>01156 <span class="keywordflow">goto</span> failed;
<a name="l01157"></a>01157
<a name="l01158"></a>01158 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#gaabb4873f436e015944a33cd1e3815cc9" title="Encodes a string in hex, the way MD5 and SHA-1 are usually encoded.">_dbus_string_hex_encode</a> (&plaintext, 0,
<a name="l01159"></a>01159 response,
<a name="l01160"></a>01160 <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (response)))
<a name="l01161"></a>01161 <span class="keywordflow">goto</span> failed;
<a name="l01162"></a>01162
<a name="l01163"></a>01163 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&plaintext);
<a name="l01164"></a>01164
<a name="l01165"></a>01165 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01166"></a>01166
<a name="l01167"></a>01167 failed:
<a name="l01168"></a>01168 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&plaintext);
<a name="l01169"></a>01169 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01170"></a>01170 }
<a name="l01171"></a>01171
<a name="l01172"></a>01172 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01173"></a>01173 handle_client_data_external_mech (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l01174"></a>01174 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *data)
<a name="l01175"></a>01175 {
<a name="l01176"></a>01176
<a name="l01177"></a>01177 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01178"></a>01178 }
<a name="l01179"></a>01179
<a name="l01180"></a>01180 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l01181"></a>01181 handle_client_shutdown_external_mech (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l01182"></a>01182 {
<a name="l01183"></a>01183
<a name="l01184"></a>01184 }
<a name="l01185"></a>01185
<a name="l01186"></a>01186 <span class="comment">/*</span>
<a name="l01187"></a>01187 <span class="comment"> * ANONYMOUS mechanism</span>
<a name="l01188"></a>01188 <span class="comment"> */</span>
<a name="l01189"></a>01189
<a name="l01190"></a>01190 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01191"></a>01191 handle_server_data_anonymous_mech (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l01192"></a>01192 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *data)
<a name="l01193"></a>01193 {
<a name="l01194"></a>01194 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (data) > 0)
<a name="l01195"></a>01195 {
<a name="l01196"></a>01196 <span class="comment">/* Client is allowed to send "trace" data, the only defined</span>
<a name="l01197"></a>01197 <span class="comment"> * meaning is that if it contains '@' it is an email address,</span>
<a name="l01198"></a>01198 <span class="comment"> * and otherwise it is anything else, and it's supposed to be</span>
<a name="l01199"></a>01199 <span class="comment"> * UTF-8</span>
<a name="l01200"></a>01200 <span class="comment"> */</span>
<a name="l01201"></a>01201 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga65f0f04b7c9371406fc87343f691e8da" title="Checks that the given range of the string is valid UTF-8.">_dbus_string_validate_utf8</a> (data, 0, <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (data)))
<a name="l01202"></a>01202 {
<a name="l01203"></a>01203 _dbus_verbose (<span class="stringliteral">"%s: Received invalid UTF-8 trace data from ANONYMOUS client\n"</span>,
<a name="l01204"></a>01204 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth));
<a name="l01205"></a>01205 <span class="keywordflow">return</span> send_rejected (auth);
<a name="l01206"></a>01206 }
<a name="l01207"></a>01207
<a name="l01208"></a>01208 _dbus_verbose (<span class="stringliteral">"%s: ANONYMOUS client sent trace string: '%s'\n"</span>,
<a name="l01209"></a>01209 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth),
<a name="l01210"></a>01210 <a class="code" href="group__DBusString.html#ga33e20241ae7d784624f97d89b1a0539e" title="Gets the raw character buffer from a const string.">_dbus_string_get_const_data</a> (data));
<a name="l01211"></a>01211 }
<a name="l01212"></a>01212
<a name="l01213"></a>01213 <span class="comment">/* We want to be anonymous (clear in case some other protocol got midway through I guess) */</span>
<a name="l01214"></a>01214 <a class="code" href="group__DBusCredentials.html#ga40a5c7e37b10419e233a473dc7173f3c" title="Clear all credentials in the object.">_dbus_credentials_clear</a> (auth-><a class="code" href="structDBusAuth.html#a6cfcba06657099d879b1e08aa886420f" title="Identity client has requested.">desired_identity</a>);
<a name="l01215"></a>01215
<a name="l01216"></a>01216 <span class="comment">/* Copy process ID from the socket credentials</span>
<a name="l01217"></a>01217 <span class="comment"> */</span>
<a name="l01218"></a>01218 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusCredentials.html#gabd5a6d038f1d35fd23af8b2e73bb7ef8" title="Merge the given credential found in the second object into the first object, overwriting the first ob...">_dbus_credentials_add_credential</a> (auth-><a class="code" href="structDBusAuth.html#afb4928fcc0f7af56d87fd6a512ad5a0a" title="Credentials that are authorized.">authorized_identity</a>,
<a name="l01219"></a>01219 DBUS_CREDENTIAL_UNIX_PROCESS_ID,
<a name="l01220"></a>01220 auth-><a class="code" href="structDBusAuth.html#aed82f21abc1ad5aa8c0db8a43f93bc22" title="Credentials read from socket.">credentials</a>))
<a name="l01221"></a>01221 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01222"></a>01222
<a name="l01223"></a>01223 <span class="comment">/* Anonymous is always allowed */</span>
<a name="l01224"></a>01224 <span class="keywordflow">if</span> (!send_ok (auth))
<a name="l01225"></a>01225 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01226"></a>01226
<a name="l01227"></a>01227 _dbus_verbose (<span class="stringliteral">"%s: authenticated client as anonymous\n"</span>,
<a name="l01228"></a>01228 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth));
<a name="l01229"></a>01229
<a name="l01230"></a>01230 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01231"></a>01231 }
<a name="l01232"></a>01232
<a name="l01233"></a>01233 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l01234"></a>01234 handle_server_shutdown_anonymous_mech (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l01235"></a>01235 {
<a name="l01236"></a>01236
<a name="l01237"></a>01237 }
<a name="l01238"></a>01238
<a name="l01239"></a>01239 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01240"></a>01240 handle_client_initial_response_anonymous_mech (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l01241"></a>01241 <a class="code" href="structDBusString.html">DBusString</a> *response)
<a name="l01242"></a>01242 {
<a name="l01243"></a>01243 <span class="comment">/* Our initial response is a "trace" string which must be valid UTF-8</span>
<a name="l01244"></a>01244 <span class="comment"> * and must be an email address if it contains '@'.</span>
<a name="l01245"></a>01245 <span class="comment"> * We just send the dbus implementation info, like a user-agent or</span>
<a name="l01246"></a>01246 <span class="comment"> * something, because... why not. There's nothing guaranteed here</span>
<a name="l01247"></a>01247 <span class="comment"> * though, we could change it later.</span>
<a name="l01248"></a>01248 <span class="comment"> */</span>
<a name="l01249"></a>01249 <a class="code" href="structDBusString.html">DBusString</a> plaintext;
<a name="l01250"></a>01250
<a name="l01251"></a>01251 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&plaintext))
<a name="l01252"></a>01252 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01253"></a>01253
<a name="l01254"></a>01254 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&plaintext,
<a name="l01255"></a>01255 <span class="stringliteral">"libdbus "</span> <a class="code" href="group__DBusMisc.html#ga538fff8f5929a940d195f3d74c49b27f" title="The COMPILE TIME version of libdbus, as a string "X.Y.Z".">DBUS_VERSION_STRING</a>))
<a name="l01256"></a>01256 <span class="keywordflow">goto</span> failed;
<a name="l01257"></a>01257
<a name="l01258"></a>01258 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#gaabb4873f436e015944a33cd1e3815cc9" title="Encodes a string in hex, the way MD5 and SHA-1 are usually encoded.">_dbus_string_hex_encode</a> (&plaintext, 0,
<a name="l01259"></a>01259 response,
<a name="l01260"></a>01260 <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (response)))
<a name="l01261"></a>01261 <span class="keywordflow">goto</span> failed;
<a name="l01262"></a>01262
<a name="l01263"></a>01263 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&plaintext);
<a name="l01264"></a>01264
<a name="l01265"></a>01265 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01266"></a>01266
<a name="l01267"></a>01267 failed:
<a name="l01268"></a>01268 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&plaintext);
<a name="l01269"></a>01269 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01270"></a>01270 }
<a name="l01271"></a>01271
<a name="l01272"></a>01272 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01273"></a>01273 handle_client_data_anonymous_mech (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l01274"></a>01274 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *data)
<a name="l01275"></a>01275 {
<a name="l01276"></a>01276
<a name="l01277"></a>01277 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01278"></a>01278 }
<a name="l01279"></a>01279
<a name="l01280"></a>01280 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l01281"></a>01281 handle_client_shutdown_anonymous_mech (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l01282"></a>01282 {
<a name="l01283"></a>01283
<a name="l01284"></a>01284 }
<a name="l01285"></a>01285
<a name="l01286"></a>01286 <span class="comment">/* Put mechanisms here in order of preference.</span>
<a name="l01287"></a>01287 <span class="comment"> * Right now we have:</span>
<a name="l01288"></a>01288 <span class="comment"> *</span>
<a name="l01289"></a>01289 <span class="comment"> * - EXTERNAL checks socket credentials (or in the future, other info from the OS)</span>
<a name="l01290"></a>01290 <span class="comment"> * - DBUS_COOKIE_SHA1 uses a cookie in the home directory, like xauth or ICE</span>
<a name="l01291"></a>01291 <span class="comment"> * - ANONYMOUS checks nothing but doesn't auth the person as a user</span>
<a name="l01292"></a>01292 <span class="comment"> *</span>
<a name="l01293"></a>01293 <span class="comment"> * We might ideally add a mechanism to chain to Cyrus SASL so we can</span>
<a name="l01294"></a>01294 <span class="comment"> * use its mechanisms as well.</span>
<a name="l01295"></a>01295 <span class="comment"> * </span>
<a name="l01296"></a>01296 <span class="comment"> */</span>
<a name="l01297"></a>01297 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="structDBusAuthMechanismHandler.html" title="Virtual table representing a particular auth mechanism.">DBusAuthMechanismHandler</a>
<a name="l01298"></a>01298 all_mechanisms[] = {
<a name="l01299"></a>01299 { <span class="stringliteral">"EXTERNAL"</span>,
<a name="l01300"></a>01300 handle_server_data_external_mech,
<a name="l01301"></a>01301 <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>,
<a name="l01302"></a>01302 handle_server_shutdown_external_mech,
<a name="l01303"></a>01303 handle_client_initial_response_external_mech,
<a name="l01304"></a>01304 handle_client_data_external_mech,
<a name="l01305"></a>01305 <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>,
<a name="l01306"></a>01306 handle_client_shutdown_external_mech },
<a name="l01307"></a>01307 { <span class="stringliteral">"DBUS_COOKIE_SHA1"</span>,
<a name="l01308"></a>01308 handle_server_data_cookie_sha1_mech,
<a name="l01309"></a>01309 <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>,
<a name="l01310"></a>01310 handle_server_shutdown_cookie_sha1_mech,
<a name="l01311"></a>01311 handle_client_initial_response_cookie_sha1_mech,
<a name="l01312"></a>01312 handle_client_data_cookie_sha1_mech,
<a name="l01313"></a>01313 <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>,
<a name="l01314"></a>01314 handle_client_shutdown_cookie_sha1_mech },
<a name="l01315"></a>01315 { <span class="stringliteral">"ANONYMOUS"</span>,
<a name="l01316"></a>01316 handle_server_data_anonymous_mech,
<a name="l01317"></a>01317 <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>,
<a name="l01318"></a>01318 handle_server_shutdown_anonymous_mech,
<a name="l01319"></a>01319 handle_client_initial_response_anonymous_mech,
<a name="l01320"></a>01320 handle_client_data_anonymous_mech,
<a name="l01321"></a>01321 <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>,
<a name="l01322"></a>01322 handle_client_shutdown_anonymous_mech },
<a name="l01323"></a>01323 { <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a> }
<a name="l01324"></a>01324 };
<a name="l01325"></a>01325
<a name="l01326"></a>01326 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="structDBusAuthMechanismHandler.html" title="Virtual table representing a particular auth mechanism.">DBusAuthMechanismHandler</a>*
<a name="l01327"></a>01327 find_mech (<span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *name,
<a name="l01328"></a>01328 <span class="keywordtype">char</span> **allowed_mechs)
<a name="l01329"></a>01329 {
<a name="l01330"></a>01330 <span class="keywordtype">int</span> i;
<a name="l01331"></a>01331
<a name="l01332"></a>01332 <span class="keywordflow">if</span> (allowed_mechs != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a> &&
<a name="l01333"></a>01333 !<a class="code" href="group__DBusInternalsUtils.html#ga751119e7273225a7e59787445b71fcd6" title="Checks whether a string array contains the given string.">_dbus_string_array_contains</a> ((<span class="keyword">const</span> <span class="keywordtype">char</span>**) allowed_mechs,
<a name="l01334"></a>01334 <a class="code" href="group__DBusString.html#ga33e20241ae7d784624f97d89b1a0539e" title="Gets the raw character buffer from a const string.">_dbus_string_get_const_data</a> (name)))
<a name="l01335"></a>01335 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l01336"></a>01336
<a name="l01337"></a>01337 i = 0;
<a name="l01338"></a>01338 <span class="keywordflow">while</span> (all_mechanisms[i].mechanism != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l01339"></a>01339 {
<a name="l01340"></a>01340 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#ga84f39f1bf398697920637d2982248c72" title="Checks whether a string is equal to a C string.">_dbus_string_equal_c_str</a> (name,
<a name="l01341"></a>01341 all_mechanisms[i].mechanism))
<a name="l01342"></a>01342
<a name="l01343"></a>01343 <span class="keywordflow">return</span> &all_mechanisms[i];
<a name="l01344"></a>01344
<a name="l01345"></a>01345 ++i;
<a name="l01346"></a>01346 }
<a name="l01347"></a>01347
<a name="l01348"></a>01348 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l01349"></a>01349 }
<a name="l01350"></a>01350
<a name="l01351"></a>01351 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01352"></a>01352 send_auth (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth, <span class="keyword">const</span> <a class="code" href="structDBusAuthMechanismHandler.html" title="Virtual table representing a particular auth mechanism.">DBusAuthMechanismHandler</a> *mech)
<a name="l01353"></a>01353 {
<a name="l01354"></a>01354 <a class="code" href="structDBusString.html">DBusString</a> auth_command;
<a name="l01355"></a>01355
<a name="l01356"></a>01356 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&auth_command))
<a name="l01357"></a>01357 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01358"></a>01358
<a name="l01359"></a>01359 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&auth_command,
<a name="l01360"></a>01360 <span class="stringliteral">"AUTH "</span>))
<a name="l01361"></a>01361 {
<a name="l01362"></a>01362 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&auth_command);
<a name="l01363"></a>01363 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01364"></a>01364 }
<a name="l01365"></a>01365
<a name="l01366"></a>01366 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&auth_command,
<a name="l01367"></a>01367 mech-><a class="code" href="structDBusAuthMechanismHandler.html#a353c8effcb16bdc37c2f225b8dad9415" title="Name of the mechanism.">mechanism</a>))
<a name="l01368"></a>01368 {
<a name="l01369"></a>01369 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&auth_command);
<a name="l01370"></a>01370 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01371"></a>01371 }
<a name="l01372"></a>01372
<a name="l01373"></a>01373 <span class="keywordflow">if</span> (mech-><a class="code" href="structDBusAuthMechanismHandler.html#a7702073e4e001efcd921b413519646a1" title="Function on client side to handle initial response.">client_initial_response_func</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l01374"></a>01374 {
<a name="l01375"></a>01375 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&auth_command, <span class="stringliteral">" "</span>))
<a name="l01376"></a>01376 {
<a name="l01377"></a>01377 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&auth_command);
<a name="l01378"></a>01378 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01379"></a>01379 }
<a name="l01380"></a>01380
<a name="l01381"></a>01381 <span class="keywordflow">if</span> (!(* mech-><a class="code" href="structDBusAuthMechanismHandler.html#a7702073e4e001efcd921b413519646a1" title="Function on client side to handle initial response.">client_initial_response_func</a>) (auth, &auth_command))
<a name="l01382"></a>01382 {
<a name="l01383"></a>01383 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&auth_command);
<a name="l01384"></a>01384 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01385"></a>01385 }
<a name="l01386"></a>01386 }
<a name="l01387"></a>01387
<a name="l01388"></a>01388 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&auth_command,
<a name="l01389"></a>01389 <span class="stringliteral">"\r\n"</span>))
<a name="l01390"></a>01390 {
<a name="l01391"></a>01391 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&auth_command);
<a name="l01392"></a>01392 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01393"></a>01393 }
<a name="l01394"></a>01394
<a name="l01395"></a>01395 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga3c10f0d1bcaa3b450025b9c6a8b901d7" title="Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...">_dbus_string_copy</a> (&auth_command, 0,
<a name="l01396"></a>01396 &auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>,
<a name="l01397"></a>01397 <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>)))
<a name="l01398"></a>01398 {
<a name="l01399"></a>01399 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&auth_command);
<a name="l01400"></a>01400 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01401"></a>01401 }
<a name="l01402"></a>01402
<a name="l01403"></a>01403 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&auth_command);
<a name="l01404"></a>01404 shutdown_mech (auth);
<a name="l01405"></a>01405 auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a> = mech;
<a name="l01406"></a>01406 goto_state (auth, &client_state_waiting_for_data);
<a name="l01407"></a>01407
<a name="l01408"></a>01408 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01409"></a>01409 }
<a name="l01410"></a>01410
<a name="l01411"></a>01411 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01412"></a>01412 send_data (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth, <a class="code" href="structDBusString.html">DBusString</a> *data)
<a name="l01413"></a>01413 {
<a name="l01414"></a>01414 <span class="keywordtype">int</span> old_len;
<a name="l01415"></a>01415
<a name="l01416"></a>01416 <span class="keywordflow">if</span> (data == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a> || <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (data) == 0)
<a name="l01417"></a>01417 <span class="keywordflow">return</span> <a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>, <span class="stringliteral">"DATA\r\n"</span>);
<a name="l01418"></a>01418 <span class="keywordflow">else</span>
<a name="l01419"></a>01419 {
<a name="l01420"></a>01420 old_len = <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>);
<a name="l01421"></a>01421 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>, <span class="stringliteral">"DATA "</span>))
<a name="l01422"></a>01422 <span class="keywordflow">goto</span> out;
<a name="l01423"></a>01423
<a name="l01424"></a>01424 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#gaabb4873f436e015944a33cd1e3815cc9" title="Encodes a string in hex, the way MD5 and SHA-1 are usually encoded.">_dbus_string_hex_encode</a> (data, 0, &auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>,
<a name="l01425"></a>01425 <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>)))
<a name="l01426"></a>01426 <span class="keywordflow">goto</span> out;
<a name="l01427"></a>01427
<a name="l01428"></a>01428 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>, <span class="stringliteral">"\r\n"</span>))
<a name="l01429"></a>01429 <span class="keywordflow">goto</span> out;
<a name="l01430"></a>01430
<a name="l01431"></a>01431 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01432"></a>01432
<a name="l01433"></a>01433 out:
<a name="l01434"></a>01434 <a class="code" href="group__DBusString.html#ga08c423b93c28dd746dcb93e0461ab95c" title="Sets the length of a string.">_dbus_string_set_length</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>, old_len);
<a name="l01435"></a>01435
<a name="l01436"></a>01436 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01437"></a>01437 }
<a name="l01438"></a>01438 }
<a name="l01439"></a>01439
<a name="l01440"></a>01440 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01441"></a>01441 send_rejected (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l01442"></a>01442 {
<a name="l01443"></a>01443 <a class="code" href="structDBusString.html">DBusString</a> command;
<a name="l01444"></a>01444 <a class="code" href="structDBusAuthServer.html" title=""Subclass" of DBusAuth for server side.">DBusAuthServer</a> *server_auth;
<a name="l01445"></a>01445 <span class="keywordtype">int</span> i;
<a name="l01446"></a>01446
<a name="l01447"></a>01447 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&command))
<a name="l01448"></a>01448 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01449"></a>01449
<a name="l01450"></a>01450 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&command,
<a name="l01451"></a>01451 <span class="stringliteral">"REJECTED"</span>))
<a name="l01452"></a>01452 <span class="keywordflow">goto</span> nomem;
<a name="l01453"></a>01453
<a name="l01454"></a>01454 i = 0;
<a name="l01455"></a>01455 <span class="keywordflow">while</span> (all_mechanisms[i].mechanism != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l01456"></a>01456 {
<a name="l01457"></a>01457 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&command,
<a name="l01458"></a>01458 <span class="stringliteral">" "</span>))
<a name="l01459"></a>01459 <span class="keywordflow">goto</span> nomem;
<a name="l01460"></a>01460
<a name="l01461"></a>01461 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&command,
<a name="l01462"></a>01462 all_mechanisms[i].mechanism))
<a name="l01463"></a>01463 <span class="keywordflow">goto</span> nomem;
<a name="l01464"></a>01464
<a name="l01465"></a>01465 ++i;
<a name="l01466"></a>01466 }
<a name="l01467"></a>01467
<a name="l01468"></a>01468 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&command, <span class="stringliteral">"\r\n"</span>))
<a name="l01469"></a>01469 <span class="keywordflow">goto</span> nomem;
<a name="l01470"></a>01470
<a name="l01471"></a>01471 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga3c10f0d1bcaa3b450025b9c6a8b901d7" title="Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...">_dbus_string_copy</a> (&command, 0, &auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>,
<a name="l01472"></a>01472 <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>)))
<a name="l01473"></a>01473 <span class="keywordflow">goto</span> nomem;
<a name="l01474"></a>01474
<a name="l01475"></a>01475 shutdown_mech (auth);
<a name="l01476"></a>01476
<a name="l01477"></a>01477 _dbus_assert (<a class="code" href="group__DBusAuthInternals.html#ga4211a12320d0b32bb2fbf0b56d6752a1">DBUS_AUTH_IS_SERVER</a> (auth));
<a name="l01478"></a>01478 server_auth = <a class="code" href="group__DBusAuthInternals.html#ga3d476942b91b7b5825a914c2ae743717">DBUS_AUTH_SERVER</a> (auth);
<a name="l01479"></a>01479 server_auth-><a class="code" href="structDBusAuthServer.html#ac73a6f0760eca6e1b7204b3c8e9c6127" title="Number of times client has been rejected.">failures</a> += 1;
<a name="l01480"></a>01480
<a name="l01481"></a>01481 <span class="keywordflow">if</span> (server_auth-><a class="code" href="structDBusAuthServer.html#ac73a6f0760eca6e1b7204b3c8e9c6127" title="Number of times client has been rejected.">failures</a> >= server_auth-><a class="code" href="structDBusAuthServer.html#a0527732b2f979011cfeb501c8347fda0" title="Number of times we reject before disconnect.">max_failures</a>)
<a name="l01482"></a>01482 goto_state (auth, &common_state_need_disconnect);
<a name="l01483"></a>01483 <span class="keywordflow">else</span>
<a name="l01484"></a>01484 goto_state (auth, &server_state_waiting_for_auth);
<a name="l01485"></a>01485
<a name="l01486"></a>01486 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&command);
<a name="l01487"></a>01487
<a name="l01488"></a>01488 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01489"></a>01489
<a name="l01490"></a>01490 nomem:
<a name="l01491"></a>01491 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&command);
<a name="l01492"></a>01492 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01493"></a>01493 }
<a name="l01494"></a>01494
<a name="l01495"></a>01495 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01496"></a>01496 send_error (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth, <span class="keyword">const</span> <span class="keywordtype">char</span> *message)
<a name="l01497"></a>01497 {
<a name="l01498"></a>01498 <span class="keywordflow">return</span> <a class="code" href="group__DBusString.html#gab0078cf7e0e5bd784ec6d6e0cc3923a2" title="Appends a printf-style formatted string to the DBusString.">_dbus_string_append_printf</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>,
<a name="l01499"></a>01499 <span class="stringliteral">"ERROR \"%s\"\r\n"</span>, message);
<a name="l01500"></a>01500 }
<a name="l01501"></a>01501
<a name="l01502"></a>01502 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01503"></a>01503 send_ok (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l01504"></a>01504 {
<a name="l01505"></a>01505 <span class="keywordtype">int</span> orig_len;
<a name="l01506"></a>01506
<a name="l01507"></a>01507 orig_len = <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>);
<a name="l01508"></a>01508
<a name="l01509"></a>01509 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>, <span class="stringliteral">"OK "</span>) &&
<a name="l01510"></a>01510 <a class="code" href="group__DBusString.html#ga3c10f0d1bcaa3b450025b9c6a8b901d7" title="Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...">_dbus_string_copy</a> (& <a class="code" href="group__DBusAuthInternals.html#ga3d476942b91b7b5825a914c2ae743717">DBUS_AUTH_SERVER</a> (auth)->guid,
<a name="l01511"></a>01511 0,
<a name="l01512"></a>01512 &auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>,
<a name="l01513"></a>01513 <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>)) &&
<a name="l01514"></a>01514 <a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>, <span class="stringliteral">"\r\n"</span>))
<a name="l01515"></a>01515 {
<a name="l01516"></a>01516 goto_state (auth, &server_state_waiting_for_begin);
<a name="l01517"></a>01517 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01518"></a>01518 }
<a name="l01519"></a>01519 <span class="keywordflow">else</span>
<a name="l01520"></a>01520 {
<a name="l01521"></a>01521 <a class="code" href="group__DBusString.html#ga08c423b93c28dd746dcb93e0461ab95c" title="Sets the length of a string.">_dbus_string_set_length</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>, orig_len);
<a name="l01522"></a>01522 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01523"></a>01523 }
<a name="l01524"></a>01524 }
<a name="l01525"></a>01525
<a name="l01526"></a>01526 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01527"></a>01527 send_begin (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l01528"></a>01528 {
<a name="l01529"></a>01529
<a name="l01530"></a>01530 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>,
<a name="l01531"></a>01531 <span class="stringliteral">"BEGIN\r\n"</span>))
<a name="l01532"></a>01532 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01533"></a>01533
<a name="l01534"></a>01534 goto_state (auth, &common_state_authenticated);
<a name="l01535"></a>01535 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01536"></a>01536 }
<a name="l01537"></a>01537
<a name="l01538"></a>01538 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01539"></a>01539 process_ok(<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l01540"></a>01540 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args_from_ok) {
<a name="l01541"></a>01541
<a name="l01542"></a>01542 <span class="keywordtype">int</span> end_of_hex;
<a name="l01543"></a>01543
<a name="l01544"></a>01544 <span class="comment">/* "args_from_ok" should be the GUID, whitespace already pulled off the front */</span>
<a name="l01545"></a>01545 _dbus_assert (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (& <a class="code" href="group__DBusAuthInternals.html#ga6c2966c96fefbc8b40106d6b5235c854">DBUS_AUTH_CLIENT</a> (auth)->guid_from_server) == 0);
<a name="l01546"></a>01546
<a name="l01547"></a>01547 <span class="comment">/* We decode the hex string to binary, using guid_from_server as scratch... */</span>
<a name="l01548"></a>01548
<a name="l01549"></a>01549 end_of_hex = 0;
<a name="l01550"></a>01550 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga0a8c20d855f9ddc05718b9e2ac0e33d8" title="Decodes a string from hex encoding.">_dbus_string_hex_decode</a> (args_from_ok, 0, &end_of_hex,
<a name="l01551"></a>01551 & <a class="code" href="group__DBusAuthInternals.html#ga6c2966c96fefbc8b40106d6b5235c854">DBUS_AUTH_CLIENT</a> (auth)->guid_from_server, 0))
<a name="l01552"></a>01552 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01553"></a>01553
<a name="l01554"></a>01554 <span class="comment">/* now clear out the scratch */</span>
<a name="l01555"></a>01555 <a class="code" href="group__DBusString.html#ga08c423b93c28dd746dcb93e0461ab95c" title="Sets the length of a string.">_dbus_string_set_length</a> (& <a class="code" href="group__DBusAuthInternals.html#ga6c2966c96fefbc8b40106d6b5235c854">DBUS_AUTH_CLIENT</a> (auth)->guid_from_server, 0);
<a name="l01556"></a>01556
<a name="l01557"></a>01557 <span class="keywordflow">if</span> (end_of_hex != <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (args_from_ok) ||
<a name="l01558"></a>01558 end_of_hex == 0)
<a name="l01559"></a>01559 {
<a name="l01560"></a>01560 _dbus_verbose (<span class="stringliteral">"Bad GUID from server, parsed %d bytes and had %d bytes from server\n"</span>,
<a name="l01561"></a>01561 end_of_hex, <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (args_from_ok));
<a name="l01562"></a>01562 goto_state (auth, &common_state_need_disconnect);
<a name="l01563"></a>01563 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01564"></a>01564 }
<a name="l01565"></a>01565
<a name="l01566"></a>01566 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga3c10f0d1bcaa3b450025b9c6a8b901d7" title="Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...">_dbus_string_copy</a> (args_from_ok, 0, &<a class="code" href="group__DBusAuthInternals.html#ga6c2966c96fefbc8b40106d6b5235c854">DBUS_AUTH_CLIENT</a> (auth)->guid_from_server, 0)) {
<a name="l01567"></a>01567 <a class="code" href="group__DBusString.html#ga08c423b93c28dd746dcb93e0461ab95c" title="Sets the length of a string.">_dbus_string_set_length</a> (& <a class="code" href="group__DBusAuthInternals.html#ga6c2966c96fefbc8b40106d6b5235c854">DBUS_AUTH_CLIENT</a> (auth)->guid_from_server, 0);
<a name="l01568"></a>01568 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01569"></a>01569 }
<a name="l01570"></a>01570
<a name="l01571"></a>01571 _dbus_verbose (<span class="stringliteral">"Got GUID '%s' from the server\n"</span>,
<a name="l01572"></a>01572 <a class="code" href="group__DBusString.html#ga33e20241ae7d784624f97d89b1a0539e" title="Gets the raw character buffer from a const string.">_dbus_string_get_const_data</a> (& <a class="code" href="group__DBusAuthInternals.html#ga6c2966c96fefbc8b40106d6b5235c854">DBUS_AUTH_CLIENT</a> (auth)->guid_from_server));
<a name="l01573"></a>01573
<a name="l01574"></a>01574 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#a7e5d15e7861774d7b49339c452e2829a" title="This side could do unix fd passing.">unix_fd_possible</a>)
<a name="l01575"></a>01575 <span class="keywordflow">return</span> send_negotiate_unix_fd(auth);
<a name="l01576"></a>01576
<a name="l01577"></a>01577 _dbus_verbose(<span class="stringliteral">"Not negotiating unix fd passing, since not possible\n"</span>);
<a name="l01578"></a>01578 <span class="keywordflow">return</span> send_begin (auth);
<a name="l01579"></a>01579 }
<a name="l01580"></a>01580
<a name="l01581"></a>01581 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01582"></a>01582 send_cancel (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l01583"></a>01583 {
<a name="l01584"></a>01584 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>, <span class="stringliteral">"CANCEL\r\n"</span>))
<a name="l01585"></a>01585 {
<a name="l01586"></a>01586 goto_state (auth, &client_state_waiting_for_reject);
<a name="l01587"></a>01587 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01588"></a>01588 }
<a name="l01589"></a>01589 <span class="keywordflow">else</span>
<a name="l01590"></a>01590 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01591"></a>01591 }
<a name="l01592"></a>01592
<a name="l01593"></a>01593 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01594"></a>01594 process_data (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l01595"></a>01595 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args,
<a name="l01596"></a>01596 <a class="code" href="group__DBusAuthInternals.html#gac1c31ba2ab9dc696b68b1c23bd0a6e6d" title="This function processes a block of data received from the peer.">DBusAuthDataFunction</a> data_func)
<a name="l01597"></a>01597 {
<a name="l01598"></a>01598 <span class="keywordtype">int</span> end;
<a name="l01599"></a>01599 <a class="code" href="structDBusString.html">DBusString</a> decoded;
<a name="l01600"></a>01600
<a name="l01601"></a>01601 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&decoded))
<a name="l01602"></a>01602 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01603"></a>01603
<a name="l01604"></a>01604 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga0a8c20d855f9ddc05718b9e2ac0e33d8" title="Decodes a string from hex encoding.">_dbus_string_hex_decode</a> (args, 0, &end, &decoded, 0))
<a name="l01605"></a>01605 {
<a name="l01606"></a>01606 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&decoded);
<a name="l01607"></a>01607 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01608"></a>01608 }
<a name="l01609"></a>01609
<a name="l01610"></a>01610 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (args) != end)
<a name="l01611"></a>01611 {
<a name="l01612"></a>01612 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&decoded);
<a name="l01613"></a>01613 <span class="keywordflow">if</span> (!send_error (auth, <span class="stringliteral">"Invalid hex encoding"</span>))
<a name="l01614"></a>01614 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01615"></a>01615
<a name="l01616"></a>01616 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01617"></a>01617 }
<a name="l01618"></a>01618
<a name="l01619"></a>01619 <span class="preprocessor">#ifdef DBUS_ENABLE_VERBOSE_MODE</span>
<a name="l01620"></a>01620 <span class="preprocessor"></span> <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa4324cd667e21beb31a5481cb0c12b6d" title="Checks that the given range of the string is valid ASCII with no nul bytes.">_dbus_string_validate_ascii</a> (&decoded, 0,
<a name="l01621"></a>01621 <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&decoded)))
<a name="l01622"></a>01622 _dbus_verbose (<span class="stringliteral">"%s: data: '%s'\n"</span>,
<a name="l01623"></a>01623 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth),
<a name="l01624"></a>01624 <a class="code" href="group__DBusString.html#ga33e20241ae7d784624f97d89b1a0539e" title="Gets the raw character buffer from a const string.">_dbus_string_get_const_data</a> (&decoded));
<a name="l01625"></a>01625 <span class="preprocessor">#endif</span>
<a name="l01626"></a>01626 <span class="preprocessor"></span>
<a name="l01627"></a>01627 <span class="keywordflow">if</span> (!(* data_func) (auth, &decoded))
<a name="l01628"></a>01628 {
<a name="l01629"></a>01629 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&decoded);
<a name="l01630"></a>01630 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01631"></a>01631 }
<a name="l01632"></a>01632
<a name="l01633"></a>01633 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&decoded);
<a name="l01634"></a>01634 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01635"></a>01635 }
<a name="l01636"></a>01636
<a name="l01637"></a>01637 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01638"></a>01638 send_negotiate_unix_fd (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l01639"></a>01639 {
<a name="l01640"></a>01640 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>,
<a name="l01641"></a>01641 <span class="stringliteral">"NEGOTIATE_UNIX_FD\r\n"</span>))
<a name="l01642"></a>01642 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01643"></a>01643
<a name="l01644"></a>01644 goto_state (auth, &client_state_waiting_for_agree_unix_fd);
<a name="l01645"></a>01645 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01646"></a>01646 }
<a name="l01647"></a>01647
<a name="l01648"></a>01648 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01649"></a>01649 send_agree_unix_fd (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l01650"></a>01650 {
<a name="l01651"></a>01651 _dbus_assert(auth-><a class="code" href="structDBusAuth.html#a7e5d15e7861774d7b49339c452e2829a" title="This side could do unix fd passing.">unix_fd_possible</a>);
<a name="l01652"></a>01652
<a name="l01653"></a>01653 auth-><a class="code" href="structDBusAuth.html#af363f74ce5f14b2a63ea0ef71b3d3bd3" title="Unix fd was successfully negotiated.">unix_fd_negotiated</a> = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01654"></a>01654 _dbus_verbose(<span class="stringliteral">"Agreed to UNIX FD passing\n"</span>);
<a name="l01655"></a>01655
<a name="l01656"></a>01656 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>,
<a name="l01657"></a>01657 <span class="stringliteral">"AGREE_UNIX_FD\r\n"</span>))
<a name="l01658"></a>01658 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01659"></a>01659
<a name="l01660"></a>01660 goto_state (auth, &server_state_waiting_for_begin);
<a name="l01661"></a>01661 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01662"></a>01662 }
<a name="l01663"></a>01663
<a name="l01664"></a>01664 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01665"></a>01665 handle_auth (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth, <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args)
<a name="l01666"></a>01666 {
<a name="l01667"></a>01667 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (args) == 0)
<a name="l01668"></a>01668 {
<a name="l01669"></a>01669 <span class="comment">/* No args to the auth, send mechanisms */</span>
<a name="l01670"></a>01670 <span class="keywordflow">if</span> (!send_rejected (auth))
<a name="l01671"></a>01671 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01672"></a>01672
<a name="l01673"></a>01673 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01674"></a>01674 }
<a name="l01675"></a>01675 <span class="keywordflow">else</span>
<a name="l01676"></a>01676 {
<a name="l01677"></a>01677 <span class="keywordtype">int</span> i;
<a name="l01678"></a>01678 <a class="code" href="structDBusString.html">DBusString</a> mech;
<a name="l01679"></a>01679 <a class="code" href="structDBusString.html">DBusString</a> hex_response;
<a name="l01680"></a>01680
<a name="l01681"></a>01681 <a class="code" href="group__DBusString.html#ga677ddb4246c7e7f67ed3145dc3c1c96b" title="Finds a blank (space or tab) in the string.">_dbus_string_find_blank</a> (args, 0, &i);
<a name="l01682"></a>01682
<a name="l01683"></a>01683 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&mech))
<a name="l01684"></a>01684 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01685"></a>01685
<a name="l01686"></a>01686 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&hex_response))
<a name="l01687"></a>01687 {
<a name="l01688"></a>01688 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&mech);
<a name="l01689"></a>01689 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01690"></a>01690 }
<a name="l01691"></a>01691
<a name="l01692"></a>01692 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#gaf5f13bc7ac7a623516930d26ae2589bf" title="Like _dbus_string_copy(), but can copy a segment from the middle of the source string.">_dbus_string_copy_len</a> (args, 0, i, &mech, 0))
<a name="l01693"></a>01693 <span class="keywordflow">goto</span> failed;
<a name="l01694"></a>01694
<a name="l01695"></a>01695 <a class="code" href="group__DBusString.html#ga5698b163289be0066cf10c0f1caf877a" title="Skips blanks from start, storing the first non-blank in *end (blank is space or tab).">_dbus_string_skip_blank</a> (args, i, &i);
<a name="l01696"></a>01696 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga3c10f0d1bcaa3b450025b9c6a8b901d7" title="Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...">_dbus_string_copy</a> (args, i, &hex_response, 0))
<a name="l01697"></a>01697 <span class="keywordflow">goto</span> failed;
<a name="l01698"></a>01698
<a name="l01699"></a>01699 auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a> = find_mech (&mech, auth-><a class="code" href="structDBusAuth.html#a234096e729cabc43efcc85ce5094a305" title="Mechanisms we're allowed to use, or NULL if we can use any.">allowed_mechs</a>);
<a name="l01700"></a>01700 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l01701"></a>01701 {
<a name="l01702"></a>01702 _dbus_verbose (<span class="stringliteral">"%s: Trying mechanism %s\n"</span>,
<a name="l01703"></a>01703 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth),
<a name="l01704"></a>01704 auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a>-><a class="code" href="structDBusAuthMechanismHandler.html#a353c8effcb16bdc37c2f225b8dad9415" title="Name of the mechanism.">mechanism</a>);
<a name="l01705"></a>01705
<a name="l01706"></a>01706 <span class="keywordflow">if</span> (!process_data (auth, &hex_response,
<a name="l01707"></a>01707 auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a>-><a class="code" href="structDBusAuthMechanismHandler.html#a6fb1fd485bf4f99f4d269cebe4625a8a" title="Function on server side for DATA.">server_data_func</a>))
<a name="l01708"></a>01708 <span class="keywordflow">goto</span> failed;
<a name="l01709"></a>01709 }
<a name="l01710"></a>01710 <span class="keywordflow">else</span>
<a name="l01711"></a>01711 {
<a name="l01712"></a>01712 <span class="comment">/* Unsupported mechanism */</span>
<a name="l01713"></a>01713 _dbus_verbose (<span class="stringliteral">"%s: Unsupported mechanism %s\n"</span>,
<a name="l01714"></a>01714 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth),
<a name="l01715"></a>01715 <a class="code" href="group__DBusString.html#ga33e20241ae7d784624f97d89b1a0539e" title="Gets the raw character buffer from a const string.">_dbus_string_get_const_data</a> (&mech));
<a name="l01716"></a>01716
<a name="l01717"></a>01717 <span class="keywordflow">if</span> (!send_rejected (auth))
<a name="l01718"></a>01718 <span class="keywordflow">goto</span> failed;
<a name="l01719"></a>01719 }
<a name="l01720"></a>01720
<a name="l01721"></a>01721 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&mech);
<a name="l01722"></a>01722 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&hex_response);
<a name="l01723"></a>01723
<a name="l01724"></a>01724 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01725"></a>01725
<a name="l01726"></a>01726 failed:
<a name="l01727"></a>01727 auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a> = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l01728"></a>01728 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&mech);
<a name="l01729"></a>01729 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&hex_response);
<a name="l01730"></a>01730 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01731"></a>01731 }
<a name="l01732"></a>01732 }
<a name="l01733"></a>01733
<a name="l01734"></a>01734 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01735"></a>01735 handle_server_state_waiting_for_auth (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l01736"></a>01736 <a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b" title="Enumeration for the known authentication commands.">DBusAuthCommand</a> command,
<a name="l01737"></a>01737 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args)
<a name="l01738"></a>01738 {
<a name="l01739"></a>01739 <span class="keywordflow">switch</span> (command)
<a name="l01740"></a>01740 {
<a name="l01741"></a>01741 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_AUTH:
<a name="l01742"></a>01742 <span class="keywordflow">return</span> handle_auth (auth, args);
<a name="l01743"></a>01743
<a name="l01744"></a>01744 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_CANCEL:
<a name="l01745"></a>01745 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_DATA:
<a name="l01746"></a>01746 <span class="keywordflow">return</span> send_error (auth, <span class="stringliteral">"Not currently in an auth conversation"</span>);
<a name="l01747"></a>01747
<a name="l01748"></a>01748 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_BEGIN:
<a name="l01749"></a>01749 goto_state (auth, &common_state_need_disconnect);
<a name="l01750"></a>01750 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01751"></a>01751
<a name="l01752"></a>01752 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_ERROR:
<a name="l01753"></a>01753 <span class="keywordflow">return</span> send_rejected (auth);
<a name="l01754"></a>01754
<a name="l01755"></a>01755 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_NEGOTIATE_UNIX_FD:
<a name="l01756"></a>01756 <span class="keywordflow">return</span> send_error (auth, <span class="stringliteral">"Need to authenticate first"</span>);
<a name="l01757"></a>01757
<a name="l01758"></a>01758 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_REJECTED:
<a name="l01759"></a>01759 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_OK:
<a name="l01760"></a>01760 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_UNKNOWN:
<a name="l01761"></a>01761 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_AGREE_UNIX_FD:
<a name="l01762"></a>01762 <span class="keywordflow">default</span>:
<a name="l01763"></a>01763 <span class="keywordflow">return</span> send_error (auth, <span class="stringliteral">"Unknown command"</span>);
<a name="l01764"></a>01764 }
<a name="l01765"></a>01765 }
<a name="l01766"></a>01766
<a name="l01767"></a>01767 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01768"></a>01768 handle_server_state_waiting_for_data (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l01769"></a>01769 <a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b" title="Enumeration for the known authentication commands.">DBusAuthCommand</a> command,
<a name="l01770"></a>01770 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args)
<a name="l01771"></a>01771 {
<a name="l01772"></a>01772 <span class="keywordflow">switch</span> (command)
<a name="l01773"></a>01773 {
<a name="l01774"></a>01774 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_AUTH:
<a name="l01775"></a>01775 <span class="keywordflow">return</span> send_error (auth, <span class="stringliteral">"Sent AUTH while another AUTH in progress"</span>);
<a name="l01776"></a>01776
<a name="l01777"></a>01777 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_CANCEL:
<a name="l01778"></a>01778 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_ERROR:
<a name="l01779"></a>01779 <span class="keywordflow">return</span> send_rejected (auth);
<a name="l01780"></a>01780
<a name="l01781"></a>01781 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_DATA:
<a name="l01782"></a>01782 <span class="keywordflow">return</span> process_data (auth, args, auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a>-><a class="code" href="structDBusAuthMechanismHandler.html#a6fb1fd485bf4f99f4d269cebe4625a8a" title="Function on server side for DATA.">server_data_func</a>);
<a name="l01783"></a>01783
<a name="l01784"></a>01784 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_BEGIN:
<a name="l01785"></a>01785 goto_state (auth, &common_state_need_disconnect);
<a name="l01786"></a>01786 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01787"></a>01787
<a name="l01788"></a>01788 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_NEGOTIATE_UNIX_FD:
<a name="l01789"></a>01789 <span class="keywordflow">return</span> send_error (auth, <span class="stringliteral">"Need to authenticate first"</span>);
<a name="l01790"></a>01790
<a name="l01791"></a>01791 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_REJECTED:
<a name="l01792"></a>01792 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_OK:
<a name="l01793"></a>01793 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_UNKNOWN:
<a name="l01794"></a>01794 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_AGREE_UNIX_FD:
<a name="l01795"></a>01795 <span class="keywordflow">default</span>:
<a name="l01796"></a>01796 <span class="keywordflow">return</span> send_error (auth, <span class="stringliteral">"Unknown command"</span>);
<a name="l01797"></a>01797 }
<a name="l01798"></a>01798 }
<a name="l01799"></a>01799
<a name="l01800"></a>01800 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01801"></a>01801 handle_server_state_waiting_for_begin (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l01802"></a>01802 <a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b" title="Enumeration for the known authentication commands.">DBusAuthCommand</a> command,
<a name="l01803"></a>01803 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args)
<a name="l01804"></a>01804 {
<a name="l01805"></a>01805 <span class="keywordflow">switch</span> (command)
<a name="l01806"></a>01806 {
<a name="l01807"></a>01807 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_AUTH:
<a name="l01808"></a>01808 <span class="keywordflow">return</span> send_error (auth, <span class="stringliteral">"Sent AUTH while expecting BEGIN"</span>);
<a name="l01809"></a>01809
<a name="l01810"></a>01810 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_DATA:
<a name="l01811"></a>01811 <span class="keywordflow">return</span> send_error (auth, <span class="stringliteral">"Sent DATA while expecting BEGIN"</span>);
<a name="l01812"></a>01812
<a name="l01813"></a>01813 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_BEGIN:
<a name="l01814"></a>01814 goto_state (auth, &common_state_authenticated);
<a name="l01815"></a>01815 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01816"></a>01816
<a name="l01817"></a>01817 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_NEGOTIATE_UNIX_FD:
<a name="l01818"></a>01818 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#a7e5d15e7861774d7b49339c452e2829a" title="This side could do unix fd passing.">unix_fd_possible</a>)
<a name="l01819"></a>01819 <span class="keywordflow">return</span> send_agree_unix_fd(auth);
<a name="l01820"></a>01820 <span class="keywordflow">else</span>
<a name="l01821"></a>01821 <span class="keywordflow">return</span> send_error(auth, <span class="stringliteral">"Unix FD passing not supported, not authenticated or otherwise not possible"</span>);
<a name="l01822"></a>01822
<a name="l01823"></a>01823 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_REJECTED:
<a name="l01824"></a>01824 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_OK:
<a name="l01825"></a>01825 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_UNKNOWN:
<a name="l01826"></a>01826 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_AGREE_UNIX_FD:
<a name="l01827"></a>01827 <span class="keywordflow">default</span>:
<a name="l01828"></a>01828 <span class="keywordflow">return</span> send_error (auth, <span class="stringliteral">"Unknown command"</span>);
<a name="l01829"></a>01829
<a name="l01830"></a>01830 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_CANCEL:
<a name="l01831"></a>01831 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_ERROR:
<a name="l01832"></a>01832 <span class="keywordflow">return</span> send_rejected (auth);
<a name="l01833"></a>01833 }
<a name="l01834"></a>01834 }
<a name="l01835"></a>01835
<a name="l01836"></a>01836 <span class="comment">/* return FALSE if no memory, TRUE if all OK */</span>
<a name="l01837"></a>01837 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01838"></a>01838 get_word (<span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *str,
<a name="l01839"></a>01839 <span class="keywordtype">int</span> *start,
<a name="l01840"></a>01840 <a class="code" href="structDBusString.html">DBusString</a> *word)
<a name="l01841"></a>01841 {
<a name="l01842"></a>01842 <span class="keywordtype">int</span> i;
<a name="l01843"></a>01843
<a name="l01844"></a>01844 <a class="code" href="group__DBusString.html#ga5698b163289be0066cf10c0f1caf877a" title="Skips blanks from start, storing the first non-blank in *end (blank is space or tab).">_dbus_string_skip_blank</a> (str, *start, start);
<a name="l01845"></a>01845 <a class="code" href="group__DBusString.html#ga677ddb4246c7e7f67ed3145dc3c1c96b" title="Finds a blank (space or tab) in the string.">_dbus_string_find_blank</a> (str, *start, &i);
<a name="l01846"></a>01846
<a name="l01847"></a>01847 <span class="keywordflow">if</span> (i > *start)
<a name="l01848"></a>01848 {
<a name="l01849"></a>01849 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#gaf5f13bc7ac7a623516930d26ae2589bf" title="Like _dbus_string_copy(), but can copy a segment from the middle of the source string.">_dbus_string_copy_len</a> (str, *start, i - *start, word, 0))
<a name="l01850"></a>01850 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01851"></a>01851
<a name="l01852"></a>01852 *start = i;
<a name="l01853"></a>01853 }
<a name="l01854"></a>01854
<a name="l01855"></a>01855 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01856"></a>01856 }
<a name="l01857"></a>01857
<a name="l01858"></a>01858 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01859"></a>01859 record_mechanisms (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l01860"></a>01860 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args)
<a name="l01861"></a>01861 {
<a name="l01862"></a>01862 <span class="keywordtype">int</span> next;
<a name="l01863"></a>01863 <span class="keywordtype">int</span> len;
<a name="l01864"></a>01864
<a name="l01865"></a>01865 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#a027172d9bc452832d4a61df9aec4f04a" title="Client already got mech list.">already_got_mechanisms</a>)
<a name="l01866"></a>01866 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01867"></a>01867
<a name="l01868"></a>01868 len = <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (args);
<a name="l01869"></a>01869
<a name="l01870"></a>01870 next = 0;
<a name="l01871"></a>01871 <span class="keywordflow">while</span> (next < len)
<a name="l01872"></a>01872 {
<a name="l01873"></a>01873 <a class="code" href="structDBusString.html">DBusString</a> m;
<a name="l01874"></a>01874 <span class="keyword">const</span> <a class="code" href="structDBusAuthMechanismHandler.html" title="Virtual table representing a particular auth mechanism.">DBusAuthMechanismHandler</a> *mech;
<a name="l01875"></a>01875
<a name="l01876"></a>01876 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&m))
<a name="l01877"></a>01877 <span class="keywordflow">goto</span> nomem;
<a name="l01878"></a>01878
<a name="l01879"></a>01879 <span class="keywordflow">if</span> (!get_word (args, &next, &m))
<a name="l01880"></a>01880 {
<a name="l01881"></a>01881 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&m);
<a name="l01882"></a>01882 <span class="keywordflow">goto</span> nomem;
<a name="l01883"></a>01883 }
<a name="l01884"></a>01884
<a name="l01885"></a>01885 mech = find_mech (&m, auth-><a class="code" href="structDBusAuth.html#a234096e729cabc43efcc85ce5094a305" title="Mechanisms we're allowed to use, or NULL if we can use any.">allowed_mechs</a>);
<a name="l01886"></a>01886
<a name="l01887"></a>01887 <span class="keywordflow">if</span> (mech != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l01888"></a>01888 {
<a name="l01889"></a>01889 <span class="comment">/* FIXME right now we try mechanisms in the order</span>
<a name="l01890"></a>01890 <span class="comment"> * the server lists them; should we do them in</span>
<a name="l01891"></a>01891 <span class="comment"> * some more deterministic order?</span>
<a name="l01892"></a>01892 <span class="comment"> *</span>
<a name="l01893"></a>01893 <span class="comment"> * Probably in all_mechanisms order, our order of</span>
<a name="l01894"></a>01894 <span class="comment"> * preference. Of course when the server is us,</span>
<a name="l01895"></a>01895 <span class="comment"> * it lists things in that order anyhow.</span>
<a name="l01896"></a>01896 <span class="comment"> */</span>
<a name="l01897"></a>01897
<a name="l01898"></a>01898 <span class="keywordflow">if</span> (mech != &all_mechanisms[0])
<a name="l01899"></a>01899 {
<a name="l01900"></a>01900 _dbus_verbose (<span class="stringliteral">"%s: Adding mechanism %s to list we will try\n"</span>,
<a name="l01901"></a>01901 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth), mech-><a class="code" href="structDBusAuthMechanismHandler.html#a353c8effcb16bdc37c2f225b8dad9415" title="Name of the mechanism.">mechanism</a>);
<a name="l01902"></a>01902
<a name="l01903"></a>01903 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusList.html#gad99045e79db46159babe69718f343053" title="Appends a value to the list.">_dbus_list_append</a> (& <a class="code" href="group__DBusAuthInternals.html#ga6c2966c96fefbc8b40106d6b5235c854">DBUS_AUTH_CLIENT</a> (auth)->mechs_to_try,
<a name="l01904"></a>01904 (<span class="keywordtype">void</span>*) mech))
<a name="l01905"></a>01905 {
<a name="l01906"></a>01906 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&m);
<a name="l01907"></a>01907 <span class="keywordflow">goto</span> nomem;
<a name="l01908"></a>01908 }
<a name="l01909"></a>01909 }
<a name="l01910"></a>01910 <span class="keywordflow">else</span>
<a name="l01911"></a>01911 {
<a name="l01912"></a>01912 _dbus_verbose (<span class="stringliteral">"%s: Already tried mechanism %s; not adding to list we will try\n"</span>,
<a name="l01913"></a>01913 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth), mech-><a class="code" href="structDBusAuthMechanismHandler.html#a353c8effcb16bdc37c2f225b8dad9415" title="Name of the mechanism.">mechanism</a>);
<a name="l01914"></a>01914 }
<a name="l01915"></a>01915 }
<a name="l01916"></a>01916 <span class="keywordflow">else</span>
<a name="l01917"></a>01917 {
<a name="l01918"></a>01918 _dbus_verbose (<span class="stringliteral">"%s: Server offered mechanism \"%s\" that we don't know how to use\n"</span>,
<a name="l01919"></a>01919 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth),
<a name="l01920"></a>01920 <a class="code" href="group__DBusString.html#ga33e20241ae7d784624f97d89b1a0539e" title="Gets the raw character buffer from a const string.">_dbus_string_get_const_data</a> (&m));
<a name="l01921"></a>01921 }
<a name="l01922"></a>01922
<a name="l01923"></a>01923 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&m);
<a name="l01924"></a>01924 }
<a name="l01925"></a>01925
<a name="l01926"></a>01926 auth-><a class="code" href="structDBusAuth.html#a027172d9bc452832d4a61df9aec4f04a" title="Client already got mech list.">already_got_mechanisms</a> = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01927"></a>01927
<a name="l01928"></a>01928 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01929"></a>01929
<a name="l01930"></a>01930 nomem:
<a name="l01931"></a>01931 <a class="code" href="group__DBusList.html#gaa36d13444a050a923941c53650b72f9d" title="Frees all links in the list and sets the list head to NULL.">_dbus_list_clear</a> (& <a class="code" href="group__DBusAuthInternals.html#ga6c2966c96fefbc8b40106d6b5235c854">DBUS_AUTH_CLIENT</a> (auth)->mechs_to_try);
<a name="l01932"></a>01932
<a name="l01933"></a>01933 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01934"></a>01934 }
<a name="l01935"></a>01935
<a name="l01936"></a>01936 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01937"></a>01937 process_rejected (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth, <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args)
<a name="l01938"></a>01938 {
<a name="l01939"></a>01939 <span class="keyword">const</span> <a class="code" href="structDBusAuthMechanismHandler.html" title="Virtual table representing a particular auth mechanism.">DBusAuthMechanismHandler</a> *mech;
<a name="l01940"></a>01940 <a class="code" href="structDBusAuthClient.html" title=""Subclass" of DBusAuth for client side">DBusAuthClient</a> *client;
<a name="l01941"></a>01941
<a name="l01942"></a>01942 client = <a class="code" href="group__DBusAuthInternals.html#ga6c2966c96fefbc8b40106d6b5235c854">DBUS_AUTH_CLIENT</a> (auth);
<a name="l01943"></a>01943
<a name="l01944"></a>01944 <span class="keywordflow">if</span> (!auth-><a class="code" href="structDBusAuth.html#a027172d9bc452832d4a61df9aec4f04a" title="Client already got mech list.">already_got_mechanisms</a>)
<a name="l01945"></a>01945 {
<a name="l01946"></a>01946 <span class="keywordflow">if</span> (!record_mechanisms (auth, args))
<a name="l01947"></a>01947 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01948"></a>01948 }
<a name="l01949"></a>01949
<a name="l01950"></a>01950 <span class="keywordflow">if</span> (<a class="code" href="group__DBusAuthInternals.html#ga6c2966c96fefbc8b40106d6b5235c854">DBUS_AUTH_CLIENT</a> (auth)->mechs_to_try != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l01951"></a>01951 {
<a name="l01952"></a>01952 mech = client-><a class="code" href="structDBusAuthClient.html#a646ae1e39e617ec3e3dd097fc18372eb" title="Mechanisms we got from the server that we're going to try using.">mechs_to_try</a>-><a class="code" href="structDBusList.html#a29ab457bcf9092252bb0c4282c727055" title="Data stored at this element.">data</a>;
<a name="l01953"></a>01953
<a name="l01954"></a>01954 <span class="keywordflow">if</span> (!send_auth (auth, mech))
<a name="l01955"></a>01955 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01956"></a>01956
<a name="l01957"></a>01957 <a class="code" href="group__DBusList.html#gacb96c9d3e9a869e63b8db4f8913a5a60" title="Removes the first value in the list and returns it.">_dbus_list_pop_first</a> (&client-><a class="code" href="structDBusAuthClient.html#a646ae1e39e617ec3e3dd097fc18372eb" title="Mechanisms we got from the server that we're going to try using.">mechs_to_try</a>);
<a name="l01958"></a>01958
<a name="l01959"></a>01959 _dbus_verbose (<span class="stringliteral">"%s: Trying mechanism %s\n"</span>,
<a name="l01960"></a>01960 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth),
<a name="l01961"></a>01961 mech-><a class="code" href="structDBusAuthMechanismHandler.html#a353c8effcb16bdc37c2f225b8dad9415" title="Name of the mechanism.">mechanism</a>);
<a name="l01962"></a>01962 }
<a name="l01963"></a>01963 <span class="keywordflow">else</span>
<a name="l01964"></a>01964 {
<a name="l01965"></a>01965 <span class="comment">/* Give up */</span>
<a name="l01966"></a>01966 _dbus_verbose (<span class="stringliteral">"%s: Disconnecting because we are out of mechanisms to try using\n"</span>,
<a name="l01967"></a>01967 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth));
<a name="l01968"></a>01968 goto_state (auth, &common_state_need_disconnect);
<a name="l01969"></a>01969 }
<a name="l01970"></a>01970
<a name="l01971"></a>01971 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01972"></a>01972 }
<a name="l01973"></a>01973
<a name="l01974"></a>01974
<a name="l01975"></a>01975 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01976"></a>01976 handle_client_state_waiting_for_data (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l01977"></a>01977 <a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b" title="Enumeration for the known authentication commands.">DBusAuthCommand</a> command,
<a name="l01978"></a>01978 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args)
<a name="l01979"></a>01979 {
<a name="l01980"></a>01980 _dbus_assert (auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l01981"></a>01981
<a name="l01982"></a>01982 <span class="keywordflow">switch</span> (command)
<a name="l01983"></a>01983 {
<a name="l01984"></a>01984 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_DATA:
<a name="l01985"></a>01985 <span class="keywordflow">return</span> process_data (auth, args, auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a>-><a class="code" href="structDBusAuthMechanismHandler.html#a765bf360f3af4a7d418dd4f029cc4c26" title="Function on client side for DATA.">client_data_func</a>);
<a name="l01986"></a>01986
<a name="l01987"></a>01987 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_REJECTED:
<a name="l01988"></a>01988 <span class="keywordflow">return</span> process_rejected (auth, args);
<a name="l01989"></a>01989
<a name="l01990"></a>01990 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_OK:
<a name="l01991"></a>01991 <span class="keywordflow">return</span> process_ok(auth, args);
<a name="l01992"></a>01992
<a name="l01993"></a>01993 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_ERROR:
<a name="l01994"></a>01994 <span class="keywordflow">return</span> send_cancel (auth);
<a name="l01995"></a>01995
<a name="l01996"></a>01996 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_AUTH:
<a name="l01997"></a>01997 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_CANCEL:
<a name="l01998"></a>01998 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_BEGIN:
<a name="l01999"></a>01999 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_UNKNOWN:
<a name="l02000"></a>02000 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_NEGOTIATE_UNIX_FD:
<a name="l02001"></a>02001 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_AGREE_UNIX_FD:
<a name="l02002"></a>02002 <span class="keywordflow">default</span>:
<a name="l02003"></a>02003 <span class="keywordflow">return</span> send_error (auth, <span class="stringliteral">"Unknown command"</span>);
<a name="l02004"></a>02004 }
<a name="l02005"></a>02005 }
<a name="l02006"></a>02006
<a name="l02007"></a>02007 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l02008"></a>02008 handle_client_state_waiting_for_ok (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l02009"></a>02009 <a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b" title="Enumeration for the known authentication commands.">DBusAuthCommand</a> command,
<a name="l02010"></a>02010 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args)
<a name="l02011"></a>02011 {
<a name="l02012"></a>02012 <span class="keywordflow">switch</span> (command)
<a name="l02013"></a>02013 {
<a name="l02014"></a>02014 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_REJECTED:
<a name="l02015"></a>02015 <span class="keywordflow">return</span> process_rejected (auth, args);
<a name="l02016"></a>02016
<a name="l02017"></a>02017 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_OK:
<a name="l02018"></a>02018 <span class="keywordflow">return</span> process_ok(auth, args);
<a name="l02019"></a>02019
<a name="l02020"></a>02020 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_DATA:
<a name="l02021"></a>02021 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_ERROR:
<a name="l02022"></a>02022 <span class="keywordflow">return</span> send_cancel (auth);
<a name="l02023"></a>02023
<a name="l02024"></a>02024 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_AUTH:
<a name="l02025"></a>02025 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_CANCEL:
<a name="l02026"></a>02026 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_BEGIN:
<a name="l02027"></a>02027 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_UNKNOWN:
<a name="l02028"></a>02028 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_NEGOTIATE_UNIX_FD:
<a name="l02029"></a>02029 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_AGREE_UNIX_FD:
<a name="l02030"></a>02030 <span class="keywordflow">default</span>:
<a name="l02031"></a>02031 <span class="keywordflow">return</span> send_error (auth, <span class="stringliteral">"Unknown command"</span>);
<a name="l02032"></a>02032 }
<a name="l02033"></a>02033 }
<a name="l02034"></a>02034
<a name="l02035"></a>02035 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l02036"></a>02036 handle_client_state_waiting_for_reject (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l02037"></a>02037 <a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b" title="Enumeration for the known authentication commands.">DBusAuthCommand</a> command,
<a name="l02038"></a>02038 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args)
<a name="l02039"></a>02039 {
<a name="l02040"></a>02040 <span class="keywordflow">switch</span> (command)
<a name="l02041"></a>02041 {
<a name="l02042"></a>02042 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_REJECTED:
<a name="l02043"></a>02043 <span class="keywordflow">return</span> process_rejected (auth, args);
<a name="l02044"></a>02044
<a name="l02045"></a>02045 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_AUTH:
<a name="l02046"></a>02046 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_CANCEL:
<a name="l02047"></a>02047 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_DATA:
<a name="l02048"></a>02048 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_BEGIN:
<a name="l02049"></a>02049 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_OK:
<a name="l02050"></a>02050 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_ERROR:
<a name="l02051"></a>02051 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_UNKNOWN:
<a name="l02052"></a>02052 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_NEGOTIATE_UNIX_FD:
<a name="l02053"></a>02053 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_AGREE_UNIX_FD:
<a name="l02054"></a>02054 <span class="keywordflow">default</span>:
<a name="l02055"></a>02055 goto_state (auth, &common_state_need_disconnect);
<a name="l02056"></a>02056 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l02057"></a>02057 }
<a name="l02058"></a>02058 }
<a name="l02059"></a>02059
<a name="l02060"></a>02060 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l02061"></a>02061 handle_client_state_waiting_for_agree_unix_fd(<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l02062"></a>02062 <a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b" title="Enumeration for the known authentication commands.">DBusAuthCommand</a> command,
<a name="l02063"></a>02063 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *args)
<a name="l02064"></a>02064 {
<a name="l02065"></a>02065 <span class="keywordflow">switch</span> (command)
<a name="l02066"></a>02066 {
<a name="l02067"></a>02067 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_AGREE_UNIX_FD:
<a name="l02068"></a>02068 _dbus_assert(auth-><a class="code" href="structDBusAuth.html#a7e5d15e7861774d7b49339c452e2829a" title="This side could do unix fd passing.">unix_fd_possible</a>);
<a name="l02069"></a>02069 auth-><a class="code" href="structDBusAuth.html#af363f74ce5f14b2a63ea0ef71b3d3bd3" title="Unix fd was successfully negotiated.">unix_fd_negotiated</a> = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l02070"></a>02070 _dbus_verbose(<span class="stringliteral">"Successfully negotiated UNIX FD passing\n"</span>);
<a name="l02071"></a>02071 <span class="keywordflow">return</span> send_begin (auth);
<a name="l02072"></a>02072
<a name="l02073"></a>02073 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_ERROR:
<a name="l02074"></a>02074 _dbus_assert(auth-><a class="code" href="structDBusAuth.html#a7e5d15e7861774d7b49339c452e2829a" title="This side could do unix fd passing.">unix_fd_possible</a>);
<a name="l02075"></a>02075 auth-><a class="code" href="structDBusAuth.html#af363f74ce5f14b2a63ea0ef71b3d3bd3" title="Unix fd was successfully negotiated.">unix_fd_negotiated</a> = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l02076"></a>02076 _dbus_verbose(<span class="stringliteral">"Failed to negotiate UNIX FD passing\n"</span>);
<a name="l02077"></a>02077 <span class="keywordflow">return</span> send_begin (auth);
<a name="l02078"></a>02078
<a name="l02079"></a>02079 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_OK:
<a name="l02080"></a>02080 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_DATA:
<a name="l02081"></a>02081 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_REJECTED:
<a name="l02082"></a>02082 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_AUTH:
<a name="l02083"></a>02083 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_CANCEL:
<a name="l02084"></a>02084 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_BEGIN:
<a name="l02085"></a>02085 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_UNKNOWN:
<a name="l02086"></a>02086 <span class="keywordflow">case</span> DBUS_AUTH_COMMAND_NEGOTIATE_UNIX_FD:
<a name="l02087"></a>02087 <span class="keywordflow">default</span>:
<a name="l02088"></a>02088 <span class="keywordflow">return</span> send_error (auth, <span class="stringliteral">"Unknown command"</span>);
<a name="l02089"></a>02089 }
<a name="l02090"></a>02090 }
<a name="l02091"></a>02091
<a name="l02095"></a><a class="code" href="structDBusAuthCommandName.html">02095</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
<a name="l02096"></a><a class="code" href="structDBusAuthCommandName.html#a2add11cf5b74a9352c0283b89da4e740">02096</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="structDBusAuthCommandName.html#a2add11cf5b74a9352c0283b89da4e740" title="Name of the command.">name</a>;
<a name="l02097"></a><a class="code" href="structDBusAuthCommandName.html#a094aa3c70fec28e6be184e2c71e036da">02097</a> <a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b" title="Enumeration for the known authentication commands.">DBusAuthCommand</a> <a class="code" href="structDBusAuthCommandName.html#a094aa3c70fec28e6be184e2c71e036da" title="Corresponding enum.">command</a>;
<a name="l02098"></a>02098 } <a class="code" href="structDBusAuthCommandName.html" title="Mapping from command name to enum.">DBusAuthCommandName</a>;
<a name="l02099"></a>02099
<a name="l02100"></a>02100 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="structDBusAuthCommandName.html" title="Mapping from command name to enum.">DBusAuthCommandName</a> auth_command_names[] = {
<a name="l02101"></a>02101 { <span class="stringliteral">"AUTH"</span>, DBUS_AUTH_COMMAND_AUTH },
<a name="l02102"></a>02102 { <span class="stringliteral">"CANCEL"</span>, DBUS_AUTH_COMMAND_CANCEL },
<a name="l02103"></a>02103 { <span class="stringliteral">"DATA"</span>, DBUS_AUTH_COMMAND_DATA },
<a name="l02104"></a>02104 { <span class="stringliteral">"BEGIN"</span>, DBUS_AUTH_COMMAND_BEGIN },
<a name="l02105"></a>02105 { <span class="stringliteral">"REJECTED"</span>, DBUS_AUTH_COMMAND_REJECTED },
<a name="l02106"></a>02106 { <span class="stringliteral">"OK"</span>, DBUS_AUTH_COMMAND_OK },
<a name="l02107"></a>02107 { <span class="stringliteral">"ERROR"</span>, DBUS_AUTH_COMMAND_ERROR },
<a name="l02108"></a>02108 { <span class="stringliteral">"NEGOTIATE_UNIX_FD"</span>, DBUS_AUTH_COMMAND_NEGOTIATE_UNIX_FD },
<a name="l02109"></a>02109 { <span class="stringliteral">"AGREE_UNIX_FD"</span>, DBUS_AUTH_COMMAND_AGREE_UNIX_FD }
<a name="l02110"></a>02110 };
<a name="l02111"></a>02111
<a name="l02112"></a>02112 <span class="keyword">static</span> <a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b" title="Enumeration for the known authentication commands.">DBusAuthCommand</a>
<a name="l02113"></a>02113 lookup_command_from_name (<a class="code" href="structDBusString.html">DBusString</a> *command)
<a name="l02114"></a>02114 {
<a name="l02115"></a>02115 <span class="keywordtype">int</span> i;
<a name="l02116"></a>02116
<a name="l02117"></a>02117 <span class="keywordflow">for</span> (i = 0; i < _DBUS_N_ELEMENTS (auth_command_names); i++)
<a name="l02118"></a>02118 {
<a name="l02119"></a>02119 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#ga84f39f1bf398697920637d2982248c72" title="Checks whether a string is equal to a C string.">_dbus_string_equal_c_str</a> (command,
<a name="l02120"></a>02120 auth_command_names[i].name))
<a name="l02121"></a>02121 <span class="keywordflow">return</span> auth_command_names[i].command;
<a name="l02122"></a>02122 }
<a name="l02123"></a>02123
<a name="l02124"></a>02124 <span class="keywordflow">return</span> DBUS_AUTH_COMMAND_UNKNOWN;
<a name="l02125"></a>02125 }
<a name="l02126"></a>02126
<a name="l02127"></a>02127 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l02128"></a>02128 goto_state (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l02129"></a>02129 <span class="keyword">const</span> <a class="code" href="structDBusAuthStateData.html" title="Information about a auth state.">DBusAuthStateData</a> *state)
<a name="l02130"></a>02130 {
<a name="l02131"></a>02131 _dbus_verbose (<span class="stringliteral">"%s: going from state %s to state %s\n"</span>,
<a name="l02132"></a>02132 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth),
<a name="l02133"></a>02133 auth-><a class="code" href="structDBusAuth.html#a44bd9f6e01ee93e58aae551bb1a9fb0f" title="Current protocol state.">state</a>-><a class="code" href="structDBusAuthStateData.html#ad5e3d100798e1f200c8b7b2277af46af" title="Name of the state.">name</a>,
<a name="l02134"></a>02134 state-><a class="code" href="structDBusAuthStateData.html#ad5e3d100798e1f200c8b7b2277af46af" title="Name of the state.">name</a>);
<a name="l02135"></a>02135
<a name="l02136"></a>02136 auth-><a class="code" href="structDBusAuth.html#a44bd9f6e01ee93e58aae551bb1a9fb0f" title="Current protocol state.">state</a> = state;
<a name="l02137"></a>02137 }
<a name="l02138"></a>02138
<a name="l02139"></a>02139 <span class="comment">/* returns whether to call it again right away */</span>
<a name="l02140"></a>02140 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l02141"></a>02141 process_command (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l02142"></a>02142 {
<a name="l02143"></a>02143 <a class="code" href="group__DBusAuthInternals.html#gabb6518f15bcdde0584166353ba8dca3b" title="Enumeration for the known authentication commands.">DBusAuthCommand</a> command;
<a name="l02144"></a>02144 <a class="code" href="structDBusString.html">DBusString</a> line;
<a name="l02145"></a>02145 <a class="code" href="structDBusString.html">DBusString</a> args;
<a name="l02146"></a>02146 <span class="keywordtype">int</span> eol;
<a name="l02147"></a>02147 <span class="keywordtype">int</span> i, j;
<a name="l02148"></a>02148 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> retval;
<a name="l02149"></a>02149
<a name="l02150"></a>02150 <span class="comment">/* _dbus_verbose ("%s: trying process_command()\n"); */</span>
<a name="l02151"></a>02151
<a name="l02152"></a>02152 retval = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l02153"></a>02153
<a name="l02154"></a>02154 eol = 0;
<a name="l02155"></a>02155 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga5fe47873b2838339107c3e1f03d1a703" title="Finds the given substring in the string, returning TRUE and filling in the byte index where the subst...">_dbus_string_find</a> (&auth-><a class="code" href="structDBusAuth.html#a986a475be9c96ecb9dd9ca5f86f60f10" title="Incoming data buffer.">incoming</a>, 0, <span class="stringliteral">"\r\n"</span>, &eol))
<a name="l02156"></a>02156 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l02157"></a>02157
<a name="l02158"></a>02158 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&line))
<a name="l02159"></a>02159 {
<a name="l02160"></a>02160 auth-><a class="code" href="structDBusAuth.html#a246a00c89875045268403243c76b5166" title="We needed memory to continue since last successful getting something done.">needed_memory</a> = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l02161"></a>02161 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l02162"></a>02162 }
<a name="l02163"></a>02163
<a name="l02164"></a>02164 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&args))
<a name="l02165"></a>02165 {
<a name="l02166"></a>02166 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&line);
<a name="l02167"></a>02167 auth-><a class="code" href="structDBusAuth.html#a246a00c89875045268403243c76b5166" title="We needed memory to continue since last successful getting something done.">needed_memory</a> = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l02168"></a>02168 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l02169"></a>02169 }
<a name="l02170"></a>02170
<a name="l02171"></a>02171 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#gaf5f13bc7ac7a623516930d26ae2589bf" title="Like _dbus_string_copy(), but can copy a segment from the middle of the source string.">_dbus_string_copy_len</a> (&auth-><a class="code" href="structDBusAuth.html#a986a475be9c96ecb9dd9ca5f86f60f10" title="Incoming data buffer.">incoming</a>, 0, eol, &line, 0))
<a name="l02172"></a>02172 <span class="keywordflow">goto</span> out;
<a name="l02173"></a>02173
<a name="l02174"></a>02174 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#gaa4324cd667e21beb31a5481cb0c12b6d" title="Checks that the given range of the string is valid ASCII with no nul bytes.">_dbus_string_validate_ascii</a> (&line, 0,
<a name="l02175"></a>02175 <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&line)))
<a name="l02176"></a>02176 {
<a name="l02177"></a>02177 _dbus_verbose (<span class="stringliteral">"%s: Command contained non-ASCII chars or embedded nul\n"</span>,
<a name="l02178"></a>02178 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth));
<a name="l02179"></a>02179 <span class="keywordflow">if</span> (!send_error (auth, <span class="stringliteral">"Command contained non-ASCII"</span>))
<a name="l02180"></a>02180 <span class="keywordflow">goto</span> out;
<a name="l02181"></a>02181 <span class="keywordflow">else</span>
<a name="l02182"></a>02182 <span class="keywordflow">goto</span> next_command;
<a name="l02183"></a>02183 }
<a name="l02184"></a>02184
<a name="l02185"></a>02185 _dbus_verbose (<span class="stringliteral">"%s: got command \"%s\"\n"</span>,
<a name="l02186"></a>02186 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth),
<a name="l02187"></a>02187 <a class="code" href="group__DBusString.html#ga33e20241ae7d784624f97d89b1a0539e" title="Gets the raw character buffer from a const string.">_dbus_string_get_const_data</a> (&line));
<a name="l02188"></a>02188
<a name="l02189"></a>02189 <a class="code" href="group__DBusString.html#ga677ddb4246c7e7f67ed3145dc3c1c96b" title="Finds a blank (space or tab) in the string.">_dbus_string_find_blank</a> (&line, 0, &i);
<a name="l02190"></a>02190 <a class="code" href="group__DBusString.html#ga5698b163289be0066cf10c0f1caf877a" title="Skips blanks from start, storing the first non-blank in *end (blank is space or tab).">_dbus_string_skip_blank</a> (&line, i, &j);
<a name="l02191"></a>02191
<a name="l02192"></a>02192 <span class="keywordflow">if</span> (j > i)
<a name="l02193"></a>02193 <a class="code" href="group__DBusString.html#ga7e0e164ad5bb094e5ccad9edc7ae4235" title="Deletes a segment of a DBusString with length len starting at start.">_dbus_string_delete</a> (&line, i, j - i);
<a name="l02194"></a>02194
<a name="l02195"></a>02195 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#gad379fce8d4ef4f7e28f81f50b46ee4c9" title="Moves the end of one string into another string.">_dbus_string_move</a> (&line, i, &args, 0))
<a name="l02196"></a>02196 <span class="keywordflow">goto</span> out;
<a name="l02197"></a>02197
<a name="l02198"></a>02198 <span class="comment">/* FIXME 1.0 we should probably validate that only the allowed</span>
<a name="l02199"></a>02199 <span class="comment"> * chars are in the command name</span>
<a name="l02200"></a>02200 <span class="comment"> */</span>
<a name="l02201"></a>02201
<a name="l02202"></a>02202 command = lookup_command_from_name (&line);
<a name="l02203"></a>02203 <span class="keywordflow">if</span> (!(* auth-><a class="code" href="structDBusAuth.html#a44bd9f6e01ee93e58aae551bb1a9fb0f" title="Current protocol state.">state</a>-><a class="code" href="structDBusAuthStateData.html#a5b22dcc2e9ccfae518d95c14893fa495" title="State function for this state.">handler</a>) (auth, command, &args))
<a name="l02204"></a>02204 <span class="keywordflow">goto</span> out;
<a name="l02205"></a>02205
<a name="l02206"></a>02206 next_command:
<a name="l02207"></a>02207
<a name="l02208"></a>02208 <span class="comment">/* We've succeeded in processing the whole command so drop it out</span>
<a name="l02209"></a>02209 <span class="comment"> * of the incoming buffer and return TRUE to try another command.</span>
<a name="l02210"></a>02210 <span class="comment"> */</span>
<a name="l02211"></a>02211
<a name="l02212"></a>02212 <a class="code" href="group__DBusString.html#ga7e0e164ad5bb094e5ccad9edc7ae4235" title="Deletes a segment of a DBusString with length len starting at start.">_dbus_string_delete</a> (&auth-><a class="code" href="structDBusAuth.html#a986a475be9c96ecb9dd9ca5f86f60f10" title="Incoming data buffer.">incoming</a>, 0, eol);
<a name="l02213"></a>02213
<a name="l02214"></a>02214 <span class="comment">/* kill the \r\n */</span>
<a name="l02215"></a>02215 <a class="code" href="group__DBusString.html#ga7e0e164ad5bb094e5ccad9edc7ae4235" title="Deletes a segment of a DBusString with length len starting at start.">_dbus_string_delete</a> (&auth-><a class="code" href="structDBusAuth.html#a986a475be9c96ecb9dd9ca5f86f60f10" title="Incoming data buffer.">incoming</a>, 0, 2);
<a name="l02216"></a>02216
<a name="l02217"></a>02217 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l02218"></a>02218
<a name="l02219"></a>02219 out:
<a name="l02220"></a>02220 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&args);
<a name="l02221"></a>02221 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&line);
<a name="l02222"></a>02222
<a name="l02223"></a>02223 <span class="keywordflow">if</span> (!retval)
<a name="l02224"></a>02224 auth-><a class="code" href="structDBusAuth.html#a246a00c89875045268403243c76b5166" title="We needed memory to continue since last successful getting something done.">needed_memory</a> = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l02225"></a>02225 <span class="keywordflow">else</span>
<a name="l02226"></a>02226 auth-><a class="code" href="structDBusAuth.html#a246a00c89875045268403243c76b5166" title="We needed memory to continue since last successful getting something done.">needed_memory</a> = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l02227"></a>02227
<a name="l02228"></a>02228 <span class="keywordflow">return</span> retval;
<a name="l02229"></a>02229 }
<a name="l02230"></a>02230
<a name="l02231"></a>02231
<a name="l02246"></a>02246 <a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a>*
<a name="l02247"></a><a class="code" href="group__DBusAuth.html#ga302e454600ae0e1aa27193d4b0a86385">02247</a> <a class="code" href="group__DBusAuth.html#ga302e454600ae0e1aa27193d4b0a86385" title="Creates a new auth conversation object for the server side.">_dbus_auth_server_new</a> (<span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *guid)
<a name="l02248"></a>02248 {
<a name="l02249"></a>02249 <a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth;
<a name="l02250"></a>02250 <a class="code" href="structDBusAuthServer.html" title=""Subclass" of DBusAuth for server side.">DBusAuthServer</a> *server_auth;
<a name="l02251"></a>02251 <a class="code" href="structDBusString.html">DBusString</a> guid_copy;
<a name="l02252"></a>02252
<a name="l02253"></a>02253 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&guid_copy))
<a name="l02254"></a>02254 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l02255"></a>02255
<a name="l02256"></a>02256 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga3c10f0d1bcaa3b450025b9c6a8b901d7" title="Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...">_dbus_string_copy</a> (guid, 0, &guid_copy, 0))
<a name="l02257"></a>02257 {
<a name="l02258"></a>02258 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&guid_copy);
<a name="l02259"></a>02259 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l02260"></a>02260 }
<a name="l02261"></a>02261
<a name="l02262"></a>02262 auth = _dbus_auth_new (<span class="keyword">sizeof</span> (<a class="code" href="structDBusAuthServer.html" title=""Subclass" of DBusAuth for server side.">DBusAuthServer</a>));
<a name="l02263"></a>02263 <span class="keywordflow">if</span> (auth == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l02264"></a>02264 {
<a name="l02265"></a>02265 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&guid_copy);
<a name="l02266"></a>02266 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l02267"></a>02267 }
<a name="l02268"></a>02268
<a name="l02269"></a>02269 auth-><a class="code" href="structDBusAuth.html#a8b930cb0d8a76c198914cf4a98192477" title="Client or server.">side</a> = auth_side_server;
<a name="l02270"></a>02270 auth-><a class="code" href="structDBusAuth.html#a44bd9f6e01ee93e58aae551bb1a9fb0f" title="Current protocol state.">state</a> = &server_state_waiting_for_auth;
<a name="l02271"></a>02271
<a name="l02272"></a>02272 server_auth = <a class="code" href="group__DBusAuthInternals.html#ga3d476942b91b7b5825a914c2ae743717">DBUS_AUTH_SERVER</a> (auth);
<a name="l02273"></a>02273
<a name="l02274"></a>02274 server_auth-><a class="code" href="structDBusAuthServer.html#a4e5f1bdf9bf827a0d6d370bbad73af1c" title="Our globally unique ID in hex encoding.">guid</a> = guid_copy;
<a name="l02275"></a>02275
<a name="l02276"></a>02276 <span class="comment">/* perhaps this should be per-mechanism with a lower</span>
<a name="l02277"></a>02277 <span class="comment"> * max</span>
<a name="l02278"></a>02278 <span class="comment"> */</span>
<a name="l02279"></a>02279 server_auth-><a class="code" href="structDBusAuthServer.html#ac73a6f0760eca6e1b7204b3c8e9c6127" title="Number of times client has been rejected.">failures</a> = 0;
<a name="l02280"></a>02280 server_auth-><a class="code" href="structDBusAuthServer.html#a0527732b2f979011cfeb501c8347fda0" title="Number of times we reject before disconnect.">max_failures</a> = 6;
<a name="l02281"></a>02281
<a name="l02282"></a>02282 <span class="keywordflow">return</span> auth;
<a name="l02283"></a>02283 }
<a name="l02284"></a>02284
<a name="l02292"></a>02292 <a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a>*
<a name="l02293"></a><a class="code" href="group__DBusAuth.html#gaee76dbcdada8bcafe131f5a2de151ac3">02293</a> <a class="code" href="group__DBusAuth.html#gaee76dbcdada8bcafe131f5a2de151ac3" title="Creates a new auth conversation object for the client side.">_dbus_auth_client_new</a> (<span class="keywordtype">void</span>)
<a name="l02294"></a>02294 {
<a name="l02295"></a>02295 <a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth;
<a name="l02296"></a>02296 <a class="code" href="structDBusString.html">DBusString</a> guid_str;
<a name="l02297"></a>02297
<a name="l02298"></a>02298 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&guid_str))
<a name="l02299"></a>02299 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l02300"></a>02300
<a name="l02301"></a>02301 auth = _dbus_auth_new (<span class="keyword">sizeof</span> (<a class="code" href="structDBusAuthClient.html" title=""Subclass" of DBusAuth for client side">DBusAuthClient</a>));
<a name="l02302"></a>02302 <span class="keywordflow">if</span> (auth == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l02303"></a>02303 {
<a name="l02304"></a>02304 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&guid_str);
<a name="l02305"></a>02305 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l02306"></a>02306 }
<a name="l02307"></a>02307
<a name="l02308"></a>02308 <a class="code" href="group__DBusAuthInternals.html#ga6c2966c96fefbc8b40106d6b5235c854">DBUS_AUTH_CLIENT</a> (auth)->guid_from_server = guid_str;
<a name="l02309"></a>02309
<a name="l02310"></a>02310 auth-><a class="code" href="structDBusAuth.html#a8b930cb0d8a76c198914cf4a98192477" title="Client or server.">side</a> = auth_side_client;
<a name="l02311"></a>02311 auth-><a class="code" href="structDBusAuth.html#a44bd9f6e01ee93e58aae551bb1a9fb0f" title="Current protocol state.">state</a> = &client_state_need_send_auth;
<a name="l02312"></a>02312
<a name="l02313"></a>02313 <span class="comment">/* Start the auth conversation by sending AUTH for our default</span>
<a name="l02314"></a>02314 <span class="comment"> * mechanism */</span>
<a name="l02315"></a>02315 <span class="keywordflow">if</span> (!send_auth (auth, &all_mechanisms[0]))
<a name="l02316"></a>02316 {
<a name="l02317"></a>02317 <a class="code" href="group__DBusAuth.html#ga7fb648be9d6d451917195a0e43eeece0" title="Decrements the refcount of an auth object.">_dbus_auth_unref</a> (auth);
<a name="l02318"></a>02318 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l02319"></a>02319 }
<a name="l02320"></a>02320
<a name="l02321"></a>02321 <span class="keywordflow">return</span> auth;
<a name="l02322"></a>02322 }
<a name="l02323"></a>02323
<a name="l02330"></a>02330 <a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *
<a name="l02331"></a><a class="code" href="group__DBusAuth.html#gaebe46c0887021bb3f6de3d283e0c66db">02331</a> <a class="code" href="group__DBusAuth.html#gaebe46c0887021bb3f6de3d283e0c66db" title="Increments the refcount of an auth object.">_dbus_auth_ref</a> (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l02332"></a>02332 {
<a name="l02333"></a>02333 _dbus_assert (auth != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l02334"></a>02334
<a name="l02335"></a>02335 auth-><a class="code" href="structDBusAuth.html#ab91763afd6a9d19f821dffd5930e69a6" title="reference count">refcount</a> += 1;
<a name="l02336"></a>02336
<a name="l02337"></a>02337 <span class="keywordflow">return</span> auth;
<a name="l02338"></a>02338 }
<a name="l02339"></a>02339
<a name="l02345"></a>02345 <span class="keywordtype">void</span>
<a name="l02346"></a><a class="code" href="group__DBusAuth.html#ga7fb648be9d6d451917195a0e43eeece0">02346</a> <a class="code" href="group__DBusAuth.html#ga7fb648be9d6d451917195a0e43eeece0" title="Decrements the refcount of an auth object.">_dbus_auth_unref</a> (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l02347"></a>02347 {
<a name="l02348"></a>02348 _dbus_assert (auth != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l02349"></a>02349 _dbus_assert (auth-><a class="code" href="structDBusAuth.html#ab91763afd6a9d19f821dffd5930e69a6" title="reference count">refcount</a> > 0);
<a name="l02350"></a>02350
<a name="l02351"></a>02351 auth-><a class="code" href="structDBusAuth.html#ab91763afd6a9d19f821dffd5930e69a6" title="reference count">refcount</a> -= 1;
<a name="l02352"></a>02352 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#ab91763afd6a9d19f821dffd5930e69a6" title="reference count">refcount</a> == 0)
<a name="l02353"></a>02353 {
<a name="l02354"></a>02354 shutdown_mech (auth);
<a name="l02355"></a>02355
<a name="l02356"></a>02356 <span class="keywordflow">if</span> (<a class="code" href="group__DBusAuthInternals.html#ga74120265335a7f6a84041541c19074c9">DBUS_AUTH_IS_CLIENT</a> (auth))
<a name="l02357"></a>02357 {
<a name="l02358"></a>02358 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (& <a class="code" href="group__DBusAuthInternals.html#ga6c2966c96fefbc8b40106d6b5235c854">DBUS_AUTH_CLIENT</a> (auth)->guid_from_server);
<a name="l02359"></a>02359 <a class="code" href="group__DBusList.html#gaa36d13444a050a923941c53650b72f9d" title="Frees all links in the list and sets the list head to NULL.">_dbus_list_clear</a> (& <a class="code" href="group__DBusAuthInternals.html#ga6c2966c96fefbc8b40106d6b5235c854">DBUS_AUTH_CLIENT</a> (auth)->mechs_to_try);
<a name="l02360"></a>02360 }
<a name="l02361"></a>02361 <span class="keywordflow">else</span>
<a name="l02362"></a>02362 {
<a name="l02363"></a>02363 _dbus_assert (<a class="code" href="group__DBusAuthInternals.html#ga4211a12320d0b32bb2fbf0b56d6752a1">DBUS_AUTH_IS_SERVER</a> (auth));
<a name="l02364"></a>02364
<a name="l02365"></a>02365 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (& <a class="code" href="group__DBusAuthInternals.html#ga3d476942b91b7b5825a914c2ae743717">DBUS_AUTH_SERVER</a> (auth)->guid);
<a name="l02366"></a>02366 }
<a name="l02367"></a>02367
<a name="l02368"></a>02368 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9" title="Keyring for cookie mechanism.">keyring</a>)
<a name="l02369"></a>02369 <a class="code" href="group__DBusKeyring.html#gadd42b029d08dc477b6847e91bdcb23ca" title="Decrements refcount and finalizes if it reaches zero.">_dbus_keyring_unref</a> (auth-><a class="code" href="structDBusAuth.html#ae1048ad3a586619ce6f3730e99ae2db9" title="Keyring for cookie mechanism.">keyring</a>);
<a name="l02370"></a>02370
<a name="l02371"></a>02371 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&auth-><a class="code" href="structDBusAuth.html#aedf6904d461a6f6eba2ee21f12f89611" title="Cookie scope.">context</a>);
<a name="l02372"></a>02372 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&auth-><a class="code" href="structDBusAuth.html#a4f2f7bfce0a53b41fb165a8854804443" title="Challenge sent to client.">challenge</a>);
<a name="l02373"></a>02373 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&auth-><a class="code" href="structDBusAuth.html#a8e70b9e2cc090fe006e1214983d79eed" title="Current identity we're authorizing as.">identity</a>);
<a name="l02374"></a>02374 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&auth-><a class="code" href="structDBusAuth.html#a986a475be9c96ecb9dd9ca5f86f60f10" title="Incoming data buffer.">incoming</a>);
<a name="l02375"></a>02375 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>);
<a name="l02376"></a>02376
<a name="l02377"></a>02377 <a class="code" href="group__DBusMemory.html#gac200b2dbc8b3f6ecac4d42426fb97b40" title="Frees a NULL-terminated array of strings.">dbus_free_string_array</a> (auth-><a class="code" href="structDBusAuth.html#a234096e729cabc43efcc85ce5094a305" title="Mechanisms we're allowed to use, or NULL if we can use any.">allowed_mechs</a>);
<a name="l02378"></a>02378
<a name="l02379"></a>02379 <a class="code" href="group__DBusCredentials.html#ga89913c830c3627cd006a50ca693af580" title="Decrement refcount on credentials.">_dbus_credentials_unref</a> (auth-><a class="code" href="structDBusAuth.html#aed82f21abc1ad5aa8c0db8a43f93bc22" title="Credentials read from socket.">credentials</a>);
<a name="l02380"></a>02380 <a class="code" href="group__DBusCredentials.html#ga89913c830c3627cd006a50ca693af580" title="Decrement refcount on credentials.">_dbus_credentials_unref</a> (auth-><a class="code" href="structDBusAuth.html#afb4928fcc0f7af56d87fd6a512ad5a0a" title="Credentials that are authorized.">authorized_identity</a>);
<a name="l02381"></a>02381 <a class="code" href="group__DBusCredentials.html#ga89913c830c3627cd006a50ca693af580" title="Decrement refcount on credentials.">_dbus_credentials_unref</a> (auth-><a class="code" href="structDBusAuth.html#a6cfcba06657099d879b1e08aa886420f" title="Identity client has requested.">desired_identity</a>);
<a name="l02382"></a>02382
<a name="l02383"></a>02383 <a class="code" href="group__DBusMemory.html#ga34e666b19b015035a9a31e53da84b39a" title="Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().">dbus_free</a> (auth);
<a name="l02384"></a>02384 }
<a name="l02385"></a>02385 }
<a name="l02386"></a>02386
<a name="l02395"></a>02395 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l02396"></a><a class="code" href="group__DBusAuth.html#ga9454e2c512b4e2ea54d47cff6acaa4db">02396</a> <a class="code" href="group__DBusAuth.html#ga9454e2c512b4e2ea54d47cff6acaa4db" title="Sets an array of authentication mechanism names that we are willing to use.">_dbus_auth_set_mechanisms</a> (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l02397"></a>02397 <span class="keyword">const</span> <span class="keywordtype">char</span> **mechanisms)
<a name="l02398"></a>02398 {
<a name="l02399"></a>02399 <span class="keywordtype">char</span> **copy;
<a name="l02400"></a>02400
<a name="l02401"></a>02401 <span class="keywordflow">if</span> (mechanisms != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l02402"></a>02402 {
<a name="l02403"></a>02403 copy = <a class="code" href="group__DBusInternalsUtils.html#ga53bbcbbd0b564c14c599813dde535443" title="Duplicates a string array.">_dbus_dup_string_array</a> (mechanisms);
<a name="l02404"></a>02404 <span class="keywordflow">if</span> (copy == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l02405"></a>02405 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l02406"></a>02406 }
<a name="l02407"></a>02407 <span class="keywordflow">else</span>
<a name="l02408"></a>02408 copy = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l02409"></a>02409
<a name="l02410"></a>02410 <a class="code" href="group__DBusMemory.html#gac200b2dbc8b3f6ecac4d42426fb97b40" title="Frees a NULL-terminated array of strings.">dbus_free_string_array</a> (auth-><a class="code" href="structDBusAuth.html#a234096e729cabc43efcc85ce5094a305" title="Mechanisms we're allowed to use, or NULL if we can use any.">allowed_mechs</a>);
<a name="l02411"></a>02411
<a name="l02412"></a>02412 auth-><a class="code" href="structDBusAuth.html#a234096e729cabc43efcc85ce5094a305" title="Mechanisms we're allowed to use, or NULL if we can use any.">allowed_mechs</a> = copy;
<a name="l02413"></a>02413
<a name="l02414"></a>02414 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l02415"></a>02415 }
<a name="l02416"></a>02416
<a name="l02421"></a><a class="code" href="group__DBusAuth.html#gaef3b2bcbcd611b935955eaf82ce238e2">02421</a> <span class="preprocessor">#define DBUS_AUTH_IN_END_STATE(auth) ((auth)->state->handler == NULL)</span>
<a name="l02422"></a>02422 <span class="preprocessor"></span>
<a name="l02430"></a>02430 DBusAuthState
<a name="l02431"></a><a class="code" href="group__DBusAuth.html#ga097c71f7f20b749275c6b31cd98623f5">02431</a> <a class="code" href="group__DBusAuth.html#ga097c71f7f20b749275c6b31cd98623f5" title="Analyzes buffered input and moves the auth conversation forward, returning the new state of the auth ...">_dbus_auth_do_work</a> (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l02432"></a>02432 {
<a name="l02433"></a>02433 auth-><a class="code" href="structDBusAuth.html#a246a00c89875045268403243c76b5166" title="We needed memory to continue since last successful getting something done.">needed_memory</a> = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l02434"></a>02434
<a name="l02435"></a>02435 <span class="comment">/* Max amount we'll buffer up before deciding someone's on crack */</span>
<a name="l02436"></a>02436 <span class="preprocessor">#define MAX_BUFFER (16 * _DBUS_ONE_KILOBYTE)</span>
<a name="l02437"></a>02437 <span class="preprocessor"></span>
<a name="l02438"></a>02438 <span class="keywordflow">do</span>
<a name="l02439"></a>02439 {
<a name="l02440"></a>02440 <span class="keywordflow">if</span> (<a class="code" href="group__DBusAuth.html#gaef3b2bcbcd611b935955eaf82ce238e2">DBUS_AUTH_IN_END_STATE</a> (auth))
<a name="l02441"></a>02441 <span class="keywordflow">break</span>;
<a name="l02442"></a>02442
<a name="l02443"></a>02443 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&auth-><a class="code" href="structDBusAuth.html#a986a475be9c96ecb9dd9ca5f86f60f10" title="Incoming data buffer.">incoming</a>) > MAX_BUFFER ||
<a name="l02444"></a>02444 <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>) > MAX_BUFFER)
<a name="l02445"></a>02445 {
<a name="l02446"></a>02446 goto_state (auth, &common_state_need_disconnect);
<a name="l02447"></a>02447 _dbus_verbose (<span class="stringliteral">"%s: Disconnecting due to excessive data buffered in auth phase\n"</span>,
<a name="l02448"></a>02448 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth));
<a name="l02449"></a>02449 <span class="keywordflow">break</span>;
<a name="l02450"></a>02450 }
<a name="l02451"></a>02451 }
<a name="l02452"></a>02452 <span class="keywordflow">while</span> (process_command (auth));
<a name="l02453"></a>02453
<a name="l02454"></a>02454 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#a246a00c89875045268403243c76b5166" title="We needed memory to continue since last successful getting something done.">needed_memory</a>)
<a name="l02455"></a>02455 <span class="keywordflow">return</span> DBUS_AUTH_STATE_WAITING_FOR_MEMORY;
<a name="l02456"></a>02456 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>) > 0)
<a name="l02457"></a>02457 <span class="keywordflow">return</span> DBUS_AUTH_STATE_HAVE_BYTES_TO_SEND;
<a name="l02458"></a>02458 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#a44bd9f6e01ee93e58aae551bb1a9fb0f" title="Current protocol state.">state</a> == &common_state_need_disconnect)
<a name="l02459"></a>02459 <span class="keywordflow">return</span> DBUS_AUTH_STATE_NEED_DISCONNECT;
<a name="l02460"></a>02460 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#a44bd9f6e01ee93e58aae551bb1a9fb0f" title="Current protocol state.">state</a> == &common_state_authenticated)
<a name="l02461"></a>02461 <span class="keywordflow">return</span> DBUS_AUTH_STATE_AUTHENTICATED;
<a name="l02462"></a>02462 <span class="keywordflow">else</span> <span class="keywordflow">return</span> DBUS_AUTH_STATE_WAITING_FOR_INPUT;
<a name="l02463"></a>02463 }
<a name="l02464"></a>02464
<a name="l02474"></a>02474 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l02475"></a><a class="code" href="group__DBusAuth.html#ga7befc68c815fe31d7fa556b699ef67de">02475</a> <a class="code" href="group__DBusAuth.html#ga7befc68c815fe31d7fa556b699ef67de" title="Gets bytes that need to be sent to the peer we're conversing with.">_dbus_auth_get_bytes_to_send</a> (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l02476"></a>02476 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> **str)
<a name="l02477"></a>02477 {
<a name="l02478"></a>02478 _dbus_assert (auth != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l02479"></a>02479 _dbus_assert (str != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l02480"></a>02480
<a name="l02481"></a>02481 *str = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l02482"></a>02482
<a name="l02483"></a>02483 <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>) == 0)
<a name="l02484"></a>02484 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l02485"></a>02485
<a name="l02486"></a>02486 *str = &auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>;
<a name="l02487"></a>02487
<a name="l02488"></a>02488 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l02489"></a>02489 }
<a name="l02490"></a>02490
<a name="l02499"></a>02499 <span class="keywordtype">void</span>
<a name="l02500"></a><a class="code" href="group__DBusAuth.html#gaed9f7f1d3289a0ae2fea2204729ac01f">02500</a> <a class="code" href="group__DBusAuth.html#gaed9f7f1d3289a0ae2fea2204729ac01f" title="Notifies the auth conversation object that the given number of bytes of the outgoing buffer have been...">_dbus_auth_bytes_sent</a> (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l02501"></a>02501 <span class="keywordtype">int</span> bytes_sent)
<a name="l02502"></a>02502 {
<a name="l02503"></a>02503 _dbus_verbose (<span class="stringliteral">"%s: Sent %d bytes of: %s\n"</span>,
<a name="l02504"></a>02504 <a class="code" href="group__DBusAuthInternals.html#ga533f0d915e592df54a97401b597441b8" title="The name of the auth ("client" or "server")">DBUS_AUTH_NAME</a> (auth),
<a name="l02505"></a>02505 bytes_sent,
<a name="l02506"></a>02506 <a class="code" href="group__DBusString.html#ga33e20241ae7d784624f97d89b1a0539e" title="Gets the raw character buffer from a const string.">_dbus_string_get_const_data</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>));
<a name="l02507"></a>02507
<a name="l02508"></a>02508 <a class="code" href="group__DBusString.html#ga7e0e164ad5bb094e5ccad9edc7ae4235" title="Deletes a segment of a DBusString with length len starting at start.">_dbus_string_delete</a> (&auth-><a class="code" href="structDBusAuth.html#ae57f6861636a989dc3bd7a24d6731085" title="Outgoing data buffer.">outgoing</a>,
<a name="l02509"></a>02509 0, bytes_sent);
<a name="l02510"></a>02510 }
<a name="l02511"></a>02511
<a name="l02519"></a>02519 <span class="keywordtype">void</span>
<a name="l02520"></a><a class="code" href="group__DBusAuth.html#gac0fc38d8d0d139e4d52787881a324c05">02520</a> <a class="code" href="group__DBusAuth.html#gac0fc38d8d0d139e4d52787881a324c05" title="Get a buffer to be used for reading bytes from the peer we're conversing with.">_dbus_auth_get_buffer</a> (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l02521"></a>02521 <a class="code" href="structDBusString.html">DBusString</a> **buffer)
<a name="l02522"></a>02522 {
<a name="l02523"></a>02523 _dbus_assert (auth != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l02524"></a>02524 _dbus_assert (!auth-><a class="code" href="structDBusAuth.html#af9809523776f243d5e8f5f631d24562b" title="Buffer is "checked out" for reading data into.">buffer_outstanding</a>);
<a name="l02525"></a>02525
<a name="l02526"></a>02526 *buffer = &auth-><a class="code" href="structDBusAuth.html#a986a475be9c96ecb9dd9ca5f86f60f10" title="Incoming data buffer.">incoming</a>;
<a name="l02527"></a>02527
<a name="l02528"></a>02528 auth-><a class="code" href="structDBusAuth.html#af9809523776f243d5e8f5f631d24562b" title="Buffer is "checked out" for reading data into.">buffer_outstanding</a> = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l02529"></a>02529 }
<a name="l02530"></a>02530
<a name="l02537"></a>02537 <span class="keywordtype">void</span>
<a name="l02538"></a><a class="code" href="group__DBusAuth.html#ga842c246877d16cb9a75cc9828a5433c2">02538</a> <a class="code" href="group__DBusAuth.html#ga842c246877d16cb9a75cc9828a5433c2" title="Returns a buffer with new data read into it.">_dbus_auth_return_buffer</a> (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l02539"></a>02539 <a class="code" href="structDBusString.html">DBusString</a> *buffer)
<a name="l02540"></a>02540 {
<a name="l02541"></a>02541 _dbus_assert (buffer == &auth-><a class="code" href="structDBusAuth.html#a986a475be9c96ecb9dd9ca5f86f60f10" title="Incoming data buffer.">incoming</a>);
<a name="l02542"></a>02542 _dbus_assert (auth-><a class="code" href="structDBusAuth.html#af9809523776f243d5e8f5f631d24562b" title="Buffer is "checked out" for reading data into.">buffer_outstanding</a>);
<a name="l02543"></a>02543
<a name="l02544"></a>02544 auth-><a class="code" href="structDBusAuth.html#af9809523776f243d5e8f5f631d24562b" title="Buffer is "checked out" for reading data into.">buffer_outstanding</a> = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l02545"></a>02545 }
<a name="l02546"></a>02546
<a name="l02556"></a>02556 <span class="keywordtype">void</span>
<a name="l02557"></a><a class="code" href="group__DBusAuth.html#gaf9e2ab67f2ddd26eeb7deeb8b0af7817">02557</a> <a class="code" href="group__DBusAuth.html#gaf9e2ab67f2ddd26eeb7deeb8b0af7817" title="Returns leftover bytes that were not used as part of the auth conversation.">_dbus_auth_get_unused_bytes</a> (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l02558"></a>02558 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> **str)
<a name="l02559"></a>02559 {
<a name="l02560"></a>02560 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusAuth.html#gaef3b2bcbcd611b935955eaf82ce238e2">DBUS_AUTH_IN_END_STATE</a> (auth))
<a name="l02561"></a>02561 <span class="keywordflow">return</span>;
<a name="l02562"></a>02562
<a name="l02563"></a>02563 *str = &auth-><a class="code" href="structDBusAuth.html#a986a475be9c96ecb9dd9ca5f86f60f10" title="Incoming data buffer.">incoming</a>;
<a name="l02564"></a>02564 }
<a name="l02565"></a>02565
<a name="l02566"></a>02566
<a name="l02573"></a>02573 <span class="keywordtype">void</span>
<a name="l02574"></a><a class="code" href="group__DBusAuth.html#gabbe8cf9e5958357c49a190ca259aa9b3">02574</a> <a class="code" href="group__DBusAuth.html#gabbe8cf9e5958357c49a190ca259aa9b3" title="Gets rid of unused bytes returned by _dbus_auth_get_unused_bytes() after we've gotten them and succes...">_dbus_auth_delete_unused_bytes</a> (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l02575"></a>02575 {
<a name="l02576"></a>02576 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusAuth.html#gaef3b2bcbcd611b935955eaf82ce238e2">DBUS_AUTH_IN_END_STATE</a> (auth))
<a name="l02577"></a>02577 <span class="keywordflow">return</span>;
<a name="l02578"></a>02578
<a name="l02579"></a>02579 <a class="code" href="group__DBusString.html#ga08c423b93c28dd746dcb93e0461ab95c" title="Sets the length of a string.">_dbus_string_set_length</a> (&auth-><a class="code" href="structDBusAuth.html#a986a475be9c96ecb9dd9ca5f86f60f10" title="Incoming data buffer.">incoming</a>, 0);
<a name="l02580"></a>02580 }
<a name="l02581"></a>02581
<a name="l02590"></a>02590 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l02591"></a><a class="code" href="group__DBusAuth.html#ga22ddfb5e12cba3d047dc1d1302c23490">02591</a> <a class="code" href="group__DBusAuth.html#ga22ddfb5e12cba3d047dc1d1302c23490" title="Called post-authentication, indicates whether we need to encode the message stream with _dbus_auth_en...">_dbus_auth_needs_encoding</a> (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l02592"></a>02592 {
<a name="l02593"></a>02593 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#a44bd9f6e01ee93e58aae551bb1a9fb0f" title="Current protocol state.">state</a> != &common_state_authenticated)
<a name="l02594"></a>02594 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l02595"></a>02595
<a name="l02596"></a>02596 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l02597"></a>02597 {
<a name="l02598"></a>02598 <span class="keywordflow">if</span> (<a class="code" href="group__DBusAuthInternals.html#ga74120265335a7f6a84041541c19074c9">DBUS_AUTH_IS_CLIENT</a> (auth))
<a name="l02599"></a>02599 <span class="keywordflow">return</span> auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a>-><a class="code" href="structDBusAuthMechanismHandler.html#ae72e69ef3b4513cbc5bdecae43dd380d" title="Function on client side for encode.">client_encode_func</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l02600"></a>02600 <span class="keywordflow">else</span>
<a name="l02601"></a>02601 <span class="keywordflow">return</span> auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a>-><a class="code" href="structDBusAuthMechanismHandler.html#a7aedf6828bf1f232edb2532616b9a1da" title="Function on server side to encode.">server_encode_func</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l02602"></a>02602 }
<a name="l02603"></a>02603 <span class="keywordflow">else</span>
<a name="l02604"></a>02604 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l02605"></a>02605 }
<a name="l02606"></a>02606
<a name="l02617"></a>02617 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l02618"></a><a class="code" href="group__DBusAuth.html#ga0d59bcf62c098cdfb95f610cdfd12690">02618</a> <a class="code" href="group__DBusAuth.html#ga0d59bcf62c098cdfb95f610cdfd12690" title="Called post-authentication, encodes a block of bytes for sending to the peer.">_dbus_auth_encode_data</a> (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l02619"></a>02619 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *plaintext,
<a name="l02620"></a>02620 <a class="code" href="structDBusString.html">DBusString</a> *encoded)
<a name="l02621"></a>02621 {
<a name="l02622"></a>02622 _dbus_assert (plaintext != encoded);
<a name="l02623"></a>02623
<a name="l02624"></a>02624 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#a44bd9f6e01ee93e58aae551bb1a9fb0f" title="Current protocol state.">state</a> != &common_state_authenticated)
<a name="l02625"></a>02625 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l02626"></a>02626
<a name="l02627"></a>02627 <span class="keywordflow">if</span> (<a class="code" href="group__DBusAuth.html#ga22ddfb5e12cba3d047dc1d1302c23490" title="Called post-authentication, indicates whether we need to encode the message stream with _dbus_auth_en...">_dbus_auth_needs_encoding</a> (auth))
<a name="l02628"></a>02628 {
<a name="l02629"></a>02629 <span class="keywordflow">if</span> (<a class="code" href="group__DBusAuthInternals.html#ga74120265335a7f6a84041541c19074c9">DBUS_AUTH_IS_CLIENT</a> (auth))
<a name="l02630"></a>02630 <span class="keywordflow">return</span> (* auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a>-><a class="code" href="structDBusAuthMechanismHandler.html#ae72e69ef3b4513cbc5bdecae43dd380d" title="Function on client side for encode.">client_encode_func</a>) (auth, plaintext, encoded);
<a name="l02631"></a>02631 <span class="keywordflow">else</span>
<a name="l02632"></a>02632 <span class="keywordflow">return</span> (* auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a>-><a class="code" href="structDBusAuthMechanismHandler.html#a7aedf6828bf1f232edb2532616b9a1da" title="Function on server side to encode.">server_encode_func</a>) (auth, plaintext, encoded);
<a name="l02633"></a>02633 }
<a name="l02634"></a>02634 <span class="keywordflow">else</span>
<a name="l02635"></a>02635 {
<a name="l02636"></a>02636 <span class="keywordflow">return</span> <a class="code" href="group__DBusString.html#ga3c10f0d1bcaa3b450025b9c6a8b901d7" title="Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...">_dbus_string_copy</a> (plaintext, 0, encoded,
<a name="l02637"></a>02637 <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (encoded));
<a name="l02638"></a>02638 }
<a name="l02639"></a>02639 }
<a name="l02640"></a>02640
<a name="l02649"></a>02649 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l02650"></a><a class="code" href="group__DBusAuth.html#gac6e9dc07335a6291842374d834e95ad2">02650</a> <a class="code" href="group__DBusAuth.html#gac6e9dc07335a6291842374d834e95ad2" title="Called post-authentication, indicates whether we need to decode the message stream with _dbus_auth_de...">_dbus_auth_needs_decoding</a> (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l02651"></a>02651 {
<a name="l02652"></a>02652 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#a44bd9f6e01ee93e58aae551bb1a9fb0f" title="Current protocol state.">state</a> != &common_state_authenticated)
<a name="l02653"></a>02653 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l02654"></a>02654
<a name="l02655"></a>02655 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l02656"></a>02656 {
<a name="l02657"></a>02657 <span class="keywordflow">if</span> (<a class="code" href="group__DBusAuthInternals.html#ga74120265335a7f6a84041541c19074c9">DBUS_AUTH_IS_CLIENT</a> (auth))
<a name="l02658"></a>02658 <span class="keywordflow">return</span> auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a>-><a class="code" href="structDBusAuthMechanismHandler.html#ab1d5c9a8cd146bb9f71f4237be1ca415" title="Function on client side for decode.">client_decode_func</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l02659"></a>02659 <span class="keywordflow">else</span>
<a name="l02660"></a>02660 <span class="keywordflow">return</span> auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a>-><a class="code" href="structDBusAuthMechanismHandler.html#ac6785768ff465be230d2f127d8099953" title="Function on server side to decode.">server_decode_func</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l02661"></a>02661 }
<a name="l02662"></a>02662 <span class="keywordflow">else</span>
<a name="l02663"></a>02663 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l02664"></a>02664 }
<a name="l02665"></a>02665
<a name="l02666"></a>02666
<a name="l02680"></a>02680 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l02681"></a><a class="code" href="group__DBusAuth.html#ga7eb40f71c0ede79f954bcb2c001c8502">02681</a> <a class="code" href="group__DBusAuth.html#ga7eb40f71c0ede79f954bcb2c001c8502" title="Called post-authentication, decodes a block of bytes received from the peer.">_dbus_auth_decode_data</a> (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l02682"></a>02682 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *encoded,
<a name="l02683"></a>02683 <a class="code" href="structDBusString.html">DBusString</a> *plaintext)
<a name="l02684"></a>02684 {
<a name="l02685"></a>02685 _dbus_assert (plaintext != encoded);
<a name="l02686"></a>02686
<a name="l02687"></a>02687 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#a44bd9f6e01ee93e58aae551bb1a9fb0f" title="Current protocol state.">state</a> != &common_state_authenticated)
<a name="l02688"></a>02688 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l02689"></a>02689
<a name="l02690"></a>02690 <span class="keywordflow">if</span> (<a class="code" href="group__DBusAuth.html#gac6e9dc07335a6291842374d834e95ad2" title="Called post-authentication, indicates whether we need to decode the message stream with _dbus_auth_de...">_dbus_auth_needs_decoding</a> (auth))
<a name="l02691"></a>02691 {
<a name="l02692"></a>02692 <span class="keywordflow">if</span> (<a class="code" href="group__DBusAuthInternals.html#ga74120265335a7f6a84041541c19074c9">DBUS_AUTH_IS_CLIENT</a> (auth))
<a name="l02693"></a>02693 <span class="keywordflow">return</span> (* auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a>-><a class="code" href="structDBusAuthMechanismHandler.html#ab1d5c9a8cd146bb9f71f4237be1ca415" title="Function on client side for decode.">client_decode_func</a>) (auth, encoded, plaintext);
<a name="l02694"></a>02694 <span class="keywordflow">else</span>
<a name="l02695"></a>02695 <span class="keywordflow">return</span> (* auth-><a class="code" href="structDBusAuth.html#a1c284d7d38784b7ad81507199f33f848" title="Current auth mechanism.">mech</a>-><a class="code" href="structDBusAuthMechanismHandler.html#ac6785768ff465be230d2f127d8099953" title="Function on server side to decode.">server_decode_func</a>) (auth, encoded, plaintext);
<a name="l02696"></a>02696 }
<a name="l02697"></a>02697 <span class="keywordflow">else</span>
<a name="l02698"></a>02698 {
<a name="l02699"></a>02699 <span class="keywordflow">return</span> <a class="code" href="group__DBusString.html#ga3c10f0d1bcaa3b450025b9c6a8b901d7" title="Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...">_dbus_string_copy</a> (encoded, 0, plaintext,
<a name="l02700"></a>02700 <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (plaintext));
<a name="l02701"></a>02701 }
<a name="l02702"></a>02702 }
<a name="l02703"></a>02703
<a name="l02712"></a>02712 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l02713"></a><a class="code" href="group__DBusAuth.html#ga2bb917d44b44b1a2813f60dec03731cd">02713</a> <a class="code" href="group__DBusAuth.html#ga2bb917d44b44b1a2813f60dec03731cd" title="Sets credentials received via reliable means from the operating system.">_dbus_auth_set_credentials</a> (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l02714"></a>02714 <a class="code" href="structDBusCredentials.html">DBusCredentials</a> *credentials)
<a name="l02715"></a>02715 {
<a name="l02716"></a>02716 <a class="code" href="group__DBusCredentials.html#ga40a5c7e37b10419e233a473dc7173f3c" title="Clear all credentials in the object.">_dbus_credentials_clear</a> (auth-><a class="code" href="structDBusAuth.html#aed82f21abc1ad5aa8c0db8a43f93bc22" title="Credentials read from socket.">credentials</a>);
<a name="l02717"></a>02717 <span class="keywordflow">return</span> <a class="code" href="group__DBusCredentials.html#ga6b6cab83ecaa05e765967c188f62dd05" title="Merge all credentials found in the second object into the first object, overwriting the first object ...">_dbus_credentials_add_credentials</a> (auth-><a class="code" href="structDBusAuth.html#aed82f21abc1ad5aa8c0db8a43f93bc22" title="Credentials read from socket.">credentials</a>,
<a name="l02718"></a>02718 credentials);
<a name="l02719"></a>02719 }
<a name="l02720"></a>02720
<a name="l02730"></a>02730 <a class="code" href="structDBusCredentials.html">DBusCredentials</a>*
<a name="l02731"></a><a class="code" href="group__DBusAuth.html#gabfa5450530b999bcb0fabf37c414a80e">02731</a> <a class="code" href="group__DBusAuth.html#gabfa5450530b999bcb0fabf37c414a80e" title="Gets the identity we authorized the client as.">_dbus_auth_get_identity</a> (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l02732"></a>02732 {
<a name="l02733"></a>02733 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#a44bd9f6e01ee93e58aae551bb1a9fb0f" title="Current protocol state.">state</a> == &common_state_authenticated)
<a name="l02734"></a>02734 {
<a name="l02735"></a>02735 <span class="keywordflow">return</span> auth-><a class="code" href="structDBusAuth.html#afb4928fcc0f7af56d87fd6a512ad5a0a" title="Credentials that are authorized.">authorized_identity</a>;
<a name="l02736"></a>02736 }
<a name="l02737"></a>02737 <span class="keywordflow">else</span>
<a name="l02738"></a>02738 {
<a name="l02739"></a>02739 <span class="comment">/* FIXME instead of this, keep an empty credential around that</span>
<a name="l02740"></a>02740 <span class="comment"> * doesn't require allocation or something</span>
<a name="l02741"></a>02741 <span class="comment"> */</span>
<a name="l02742"></a>02742 <span class="comment">/* return empty credentials */</span>
<a name="l02743"></a>02743 _dbus_assert (<a class="code" href="group__DBusCredentials.html#ga9aea1a288097b0820d1cd05c2448501d" title="Checks whether a credentials object contains anything.">_dbus_credentials_are_empty</a> (auth-><a class="code" href="structDBusAuth.html#afb4928fcc0f7af56d87fd6a512ad5a0a" title="Credentials that are authorized.">authorized_identity</a>));
<a name="l02744"></a>02744 <span class="keywordflow">return</span> auth-><a class="code" href="structDBusAuth.html#afb4928fcc0f7af56d87fd6a512ad5a0a" title="Credentials that are authorized.">authorized_identity</a>;
<a name="l02745"></a>02745 }
<a name="l02746"></a>02746 }
<a name="l02747"></a>02747
<a name="l02754"></a>02754 <span class="keyword">const</span> <span class="keywordtype">char</span>*
<a name="l02755"></a><a class="code" href="group__DBusAuth.html#gad0bf394093dd9ac43ebf71a5f35a4f3f">02755</a> <a class="code" href="group__DBusAuth.html#gad0bf394093dd9ac43ebf71a5f35a4f3f" title="Gets the GUID from the server if we've authenticated; gets NULL otherwise.">_dbus_auth_get_guid_from_server</a> (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l02756"></a>02756 {
<a name="l02757"></a>02757 _dbus_assert (<a class="code" href="group__DBusAuthInternals.html#ga74120265335a7f6a84041541c19074c9">DBUS_AUTH_IS_CLIENT</a> (auth));
<a name="l02758"></a>02758
<a name="l02759"></a>02759 <span class="keywordflow">if</span> (auth-><a class="code" href="structDBusAuth.html#a44bd9f6e01ee93e58aae551bb1a9fb0f" title="Current protocol state.">state</a> == &common_state_authenticated)
<a name="l02760"></a>02760 <span class="keywordflow">return</span> <a class="code" href="group__DBusString.html#ga33e20241ae7d784624f97d89b1a0539e" title="Gets the raw character buffer from a const string.">_dbus_string_get_const_data</a> (& <a class="code" href="group__DBusAuthInternals.html#ga6c2966c96fefbc8b40106d6b5235c854">DBUS_AUTH_CLIENT</a> (auth)->guid_from_server);
<a name="l02761"></a>02761 <span class="keywordflow">else</span>
<a name="l02762"></a>02762 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l02763"></a>02763 }
<a name="l02764"></a>02764
<a name="l02773"></a>02773 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l02774"></a><a class="code" href="group__DBusAuth.html#gad6d64040b2cf1c91f808a1f31f7ff2f0">02774</a> <a class="code" href="group__DBusAuth.html#gad6d64040b2cf1c91f808a1f31f7ff2f0" title="Sets the "authentication context" which scopes cookies with the DBUS_COOKIE_SHA1 auth mechanism for e...">_dbus_auth_set_context</a> (<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth,
<a name="l02775"></a>02775 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *context)
<a name="l02776"></a>02776 {
<a name="l02777"></a>02777 <span class="keywordflow">return</span> <a class="code" href="group__DBusString.html#gafe7921a92467cdefaa0a7829d6cf260b" title="Replaces a segment of dest string with a segment of source string.">_dbus_string_replace_len</a> (context, 0, <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (context),
<a name="l02778"></a>02778 &auth-><a class="code" href="structDBusAuth.html#aedf6904d461a6f6eba2ee21f12f89611" title="Cookie scope.">context</a>, 0, <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (context));
<a name="l02779"></a>02779 }
<a name="l02780"></a>02780
<a name="l02788"></a>02788 <span class="keywordtype">void</span>
<a name="l02789"></a><a class="code" href="group__DBusAuth.html#ga831cbd78b6c7f382840e4094f02efdb5">02789</a> <a class="code" href="group__DBusAuth.html#ga831cbd78b6c7f382840e4094f02efdb5" title="Sets whether unix fd passing is potentially on the transport and hence shall be negotiated.">_dbus_auth_set_unix_fd_possible</a>(<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth, <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> b)
<a name="l02790"></a>02790 {
<a name="l02791"></a>02791 auth-><a class="code" href="structDBusAuth.html#a7e5d15e7861774d7b49339c452e2829a" title="This side could do unix fd passing.">unix_fd_possible</a> = b;
<a name="l02792"></a>02792 }
<a name="l02793"></a>02793
<a name="l02800"></a>02800 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l02801"></a><a class="code" href="group__DBusAuth.html#ga2d9119a45123f6b513a60391fb617d5c">02801</a> <a class="code" href="group__DBusAuth.html#ga2d9119a45123f6b513a60391fb617d5c" title="Queries whether unix fd passing was successfully negotiated.">_dbus_auth_get_unix_fd_negotiated</a>(<a class="code" href="structDBusAuth.html" title="Internal members of DBusAuth.">DBusAuth</a> *auth)
<a name="l02802"></a>02802 {
<a name="l02803"></a>02803 <span class="keywordflow">return</span> auth-><a class="code" href="structDBusAuth.html#af363f74ce5f14b2a63ea0ef71b3d3bd3" title="Unix fd was successfully negotiated.">unix_fd_negotiated</a>;
<a name="l02804"></a>02804 }
<a name="l02805"></a>02805
<a name="l02808"></a>02808 <span class="comment">/* tests in dbus-auth-util.c */</span>
</pre></div></div><!-- contents -->
<hr class="footer"/><address class="footer"><small>
Generated on Thu Mar 3 2016 17:50:29 for D-Bus by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>
</body>
</html>