|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /usr/share/devhelp/books/dbus/api/ |
Upload File : |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>D-Bus: dbus-userdb-util.c Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.7 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</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 id="current"><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
</ul></div>
<h1>dbus-userdb-util.c</h1><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-userdb-util.c Would be in dbus-userdb.c, but not used in libdbus</span>
<a name="l00003"></a>00003 <span class="comment"> * </span>
<a name="l00004"></a>00004 <span class="comment"> * Copyright (C) 2003, 2004, 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 <span class="preprocessor">#define DBUS_USERDB_INCLUDES_PRIVATE 1</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#include "dbus-userdb.h"</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include "dbus-test.h"</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include "dbus-internals.h"</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "dbus-protocol.h"</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include <string.h></span>
<a name="l00029"></a>00029
<a name="l00042"></a>00042 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l00043"></a><a class="code" href="group__DBusInternalsUtils.html#ga504db352a939909051a494d06c5b607">00043</a> <a class="code" href="group__DBusInternalsUtils.html#ga504db352a939909051a494d06c5b607">_dbus_is_console_user</a> (<a class="code" href="group__DBusSysdeps.html#g186e987b700f9ddc6cea8aa0db82b151">dbus_uid_t</a> uid,
<a name="l00044"></a>00044 <a class="code" href="structDBusError.html">DBusError</a> *error)
<a name="l00045"></a>00045 {
<a name="l00046"></a>00046
<a name="l00047"></a>00047 DBusUserDatabase *db;
<a name="l00048"></a>00048 <span class="keyword">const</span> <a class="code" href="structDBusUserInfo.html">DBusUserInfo</a> *info;
<a name="l00049"></a>00049 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> result = <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00050"></a>00050
<a name="l00051"></a>00051 <span class="preprocessor">#ifdef HAVE_CONSOLE_OWNER_FILE</span>
<a name="l00052"></a>00052 <span class="preprocessor"></span>
<a name="l00053"></a>00053 <a class="code" href="structDBusString.html">DBusString</a> f;
<a name="l00054"></a>00054 <a class="code" href="structDBusStat.html">DBusStat</a> st;
<a name="l00055"></a>00055
<a name="l00056"></a>00056 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#g348252317f7bb8ac43529972945830ae">_dbus_string_init</a> (&f))
<a name="l00057"></a>00057 {
<a name="l00058"></a>00058 _DBUS_SET_OOM (error);
<a name="l00059"></a>00059 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00060"></a>00060 }
<a name="l00061"></a>00061
<a name="l00062"></a>00062 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#g100c5ce0696822c5a4cfbdfaba674d96">_dbus_string_append</a>(&f, DBUS_CONSOLE_OWNER_FILE))
<a name="l00063"></a>00063 {
<a name="l00064"></a>00064 <a class="code" href="group__DBusString.html#g781ca91acda49a834dce7d0ed0eef212">_dbus_string_free</a>(&f);
<a name="l00065"></a>00065 _DBUS_SET_OOM (error);
<a name="l00066"></a>00066 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00067"></a>00067 }
<a name="l00068"></a>00068
<a name="l00069"></a>00069 <span class="keywordflow">if</span> (<a class="code" href="group__DBusInternalsUtils.html#g04e98ad0e3a181f0a5921a4cbc49cf08">_dbus_stat</a>(&f, &st, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) && (st.<a class="code" href="structDBusStat.html#300fac914534803bcfacdd87b15e1a8d">uid</a> == uid))
<a name="l00070"></a>00070 {
<a name="l00071"></a>00071 <a class="code" href="group__DBusString.html#g781ca91acda49a834dce7d0ed0eef212">_dbus_string_free</a>(&f);
<a name="l00072"></a>00072 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l00073"></a>00073 }
<a name="l00074"></a>00074
<a name="l00075"></a>00075 <a class="code" href="group__DBusString.html#g781ca91acda49a834dce7d0ed0eef212">_dbus_string_free</a>(&f);
<a name="l00076"></a>00076
<a name="l00077"></a>00077 <span class="preprocessor">#endif </span><span class="comment">/* HAVE_CONSOLE_OWNER_FILE */</span>
<a name="l00078"></a>00078
<a name="l00079"></a>00079 <a class="code" href="group__DBusInternalsUtils.html#gd670eb00ca49ee18fe1c526d440131b7">_dbus_user_database_lock_system</a> ();
<a name="l00080"></a>00080
<a name="l00081"></a>00081 db = <a class="code" href="group__DBusInternalsUtils.html#g79b6c3cf0d735622b6af2795840f9d21">_dbus_user_database_get_system</a> ();
<a name="l00082"></a>00082 <span class="keywordflow">if</span> (db == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00083"></a>00083 {
<a name="l00084"></a>00084 <a class="code" href="group__DBusErrors.html#g4e1b4b297468006781a957129ad9cf00">dbus_set_error</a> (error, <a class="code" href="group__DBusProtocol.html#gbb62fd6340d0787fbd56ff8dd2f326c7">DBUS_ERROR_FAILED</a>, <span class="stringliteral">"Could not get system database."</span>);
<a name="l00085"></a>00085 <a class="code" href="group__DBusInternalsUtils.html#g468e1d62e1df24bb699c4a37fdfa274c">_dbus_user_database_unlock_system</a> ();
<a name="l00086"></a>00086 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00087"></a>00087 }
<a name="l00088"></a>00088
<a name="l00089"></a>00089 <span class="comment">/* TPTD: this should be cache-safe, we've locked the DB and</span>
<a name="l00090"></a>00090 <span class="comment"> _dbus_user_at_console doesn't pass it on. */</span>
<a name="l00091"></a>00091 info = <a class="code" href="group__DBusInternalsUtils.html#g959372f7d7cdea35ffbac3b78e29a1b0">_dbus_user_database_lookup</a> (db, uid, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, error);
<a name="l00092"></a>00092
<a name="l00093"></a>00093 <span class="keywordflow">if</span> (info == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00094"></a>00094 {
<a name="l00095"></a>00095 <a class="code" href="group__DBusInternalsUtils.html#g468e1d62e1df24bb699c4a37fdfa274c">_dbus_user_database_unlock_system</a> ();
<a name="l00096"></a>00096 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00097"></a>00097 }
<a name="l00098"></a>00098
<a name="l00099"></a>00099 result = <a class="code" href="group__DBusInternalsUtils.html#g31ec42cef2d15ca358e737bb5f19c5cf">_dbus_user_at_console</a> (info-><a class="code" href="structDBusUserInfo.html#c6b57db1dc8315eee3f532f4e77912d1">username</a>, error);
<a name="l00100"></a>00100
<a name="l00101"></a>00101 <a class="code" href="group__DBusInternalsUtils.html#g468e1d62e1df24bb699c4a37fdfa274c">_dbus_user_database_unlock_system</a> ();
<a name="l00102"></a>00102
<a name="l00103"></a>00103 <span class="keywordflow">return</span> result;
<a name="l00104"></a>00104 }
<a name="l00105"></a>00105
<a name="l00113"></a>00113 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l00114"></a><a class="code" href="group__DBusInternalsUtils.html#gf07ee24eddcb3b0f85fa54196bc44fe1">00114</a> <a class="code" href="group__DBusInternalsUtils.html#gf07ee24eddcb3b0f85fa54196bc44fe1">_dbus_get_user_id</a> (<span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *username,
<a name="l00115"></a>00115 <a class="code" href="group__DBusSysdeps.html#g186e987b700f9ddc6cea8aa0db82b151">dbus_uid_t</a> *uid)
<a name="l00116"></a>00116 {
<a name="l00117"></a>00117 <span class="keywordflow">return</span> <a class="code" href="group__DBusInternalsUtils.html#gc82f42ff83fabbde717cc08569265e6e">_dbus_get_user_id_and_primary_group</a> (username, uid, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00118"></a>00118 }
<a name="l00119"></a>00119
<a name="l00127"></a>00127 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l00128"></a><a class="code" href="group__DBusInternalsUtils.html#g90657adefa9bbac9b35eee63dd46a854">00128</a> <a class="code" href="group__DBusInternalsUtils.html#g90657adefa9bbac9b35eee63dd46a854">_dbus_get_group_id</a> (<span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *groupname,
<a name="l00129"></a>00129 <a class="code" href="group__DBusSysdeps.html#g2f5c2e418b81ec2a86594f56ec6d7627">dbus_gid_t</a> *gid)
<a name="l00130"></a>00130 {
<a name="l00131"></a>00131 DBusUserDatabase *db;
<a name="l00132"></a>00132 <span class="keyword">const</span> <a class="code" href="structDBusGroupInfo.html">DBusGroupInfo</a> *info;
<a name="l00133"></a>00133 <a class="code" href="group__DBusInternalsUtils.html#gd670eb00ca49ee18fe1c526d440131b7">_dbus_user_database_lock_system</a> ();
<a name="l00134"></a>00134
<a name="l00135"></a>00135 db = <a class="code" href="group__DBusInternalsUtils.html#g79b6c3cf0d735622b6af2795840f9d21">_dbus_user_database_get_system</a> ();
<a name="l00136"></a>00136 <span class="keywordflow">if</span> (db == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00137"></a>00137 {
<a name="l00138"></a>00138 <a class="code" href="group__DBusInternalsUtils.html#g468e1d62e1df24bb699c4a37fdfa274c">_dbus_user_database_unlock_system</a> ();
<a name="l00139"></a>00139 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00140"></a>00140 }
<a name="l00141"></a>00141
<a name="l00142"></a>00142 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusInternalsUtils.html#gd370299b907799440331c47e8d2357e0">_dbus_user_database_get_groupname</a> (db, groupname,
<a name="l00143"></a>00143 &info, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>))
<a name="l00144"></a>00144 {
<a name="l00145"></a>00145 <a class="code" href="group__DBusInternalsUtils.html#g468e1d62e1df24bb699c4a37fdfa274c">_dbus_user_database_unlock_system</a> ();
<a name="l00146"></a>00146 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00147"></a>00147 }
<a name="l00148"></a>00148
<a name="l00149"></a>00149 *gid = info-><a class="code" href="structDBusGroupInfo.html#583e8d6d421fa85fb1d43789efae4b75">gid</a>;
<a name="l00150"></a>00150
<a name="l00151"></a>00151 <a class="code" href="group__DBusInternalsUtils.html#g468e1d62e1df24bb699c4a37fdfa274c">_dbus_user_database_unlock_system</a> ();
<a name="l00152"></a>00152 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l00153"></a>00153 }
<a name="l00154"></a>00154
<a name="l00163"></a>00163 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l00164"></a><a class="code" href="group__DBusInternalsUtils.html#gc82f42ff83fabbde717cc08569265e6e">00164</a> <a class="code" href="group__DBusInternalsUtils.html#gc82f42ff83fabbde717cc08569265e6e">_dbus_get_user_id_and_primary_group</a> (<span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *username,
<a name="l00165"></a>00165 <a class="code" href="group__DBusSysdeps.html#g186e987b700f9ddc6cea8aa0db82b151">dbus_uid_t</a> *uid_p,
<a name="l00166"></a>00166 <a class="code" href="group__DBusSysdeps.html#g2f5c2e418b81ec2a86594f56ec6d7627">dbus_gid_t</a> *gid_p)
<a name="l00167"></a>00167 {
<a name="l00168"></a>00168 DBusUserDatabase *db;
<a name="l00169"></a>00169 <span class="keyword">const</span> <a class="code" href="structDBusUserInfo.html">DBusUserInfo</a> *info;
<a name="l00170"></a>00170 <a class="code" href="group__DBusInternalsUtils.html#gd670eb00ca49ee18fe1c526d440131b7">_dbus_user_database_lock_system</a> ();
<a name="l00171"></a>00171
<a name="l00172"></a>00172 db = <a class="code" href="group__DBusInternalsUtils.html#g79b6c3cf0d735622b6af2795840f9d21">_dbus_user_database_get_system</a> ();
<a name="l00173"></a>00173 <span class="keywordflow">if</span> (db == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00174"></a>00174 {
<a name="l00175"></a>00175 <a class="code" href="group__DBusInternalsUtils.html#g468e1d62e1df24bb699c4a37fdfa274c">_dbus_user_database_unlock_system</a> ();
<a name="l00176"></a>00176 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00177"></a>00177 }
<a name="l00178"></a>00178
<a name="l00179"></a>00179 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusInternalsUtils.html#gccf1d5b330707a1835dcf4ce49a29c8c">_dbus_user_database_get_username</a> (db, username,
<a name="l00180"></a>00180 &info, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>))
<a name="l00181"></a>00181 {
<a name="l00182"></a>00182 <a class="code" href="group__DBusInternalsUtils.html#g468e1d62e1df24bb699c4a37fdfa274c">_dbus_user_database_unlock_system</a> ();
<a name="l00183"></a>00183 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00184"></a>00184 }
<a name="l00185"></a>00185
<a name="l00186"></a>00186 <span class="keywordflow">if</span> (uid_p)
<a name="l00187"></a>00187 *uid_p = info-><a class="code" href="structDBusUserInfo.html#2d9c74d29f371e391a79b81162050b2e">uid</a>;
<a name="l00188"></a>00188 <span class="keywordflow">if</span> (gid_p)
<a name="l00189"></a>00189 *gid_p = info-><a class="code" href="structDBusUserInfo.html#c970de2fac9ea4ba91485e6c37c3bf93">primary_gid</a>;
<a name="l00190"></a>00190
<a name="l00191"></a>00191 <a class="code" href="group__DBusInternalsUtils.html#g468e1d62e1df24bb699c4a37fdfa274c">_dbus_user_database_unlock_system</a> ();
<a name="l00192"></a>00192 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l00193"></a>00193 }
<a name="l00194"></a>00194
<a name="l00207"></a>00207 <a class="code" href="structDBusGroupInfo.html">DBusGroupInfo</a>*
<a name="l00208"></a><a class="code" href="group__DBusInternalsUtils.html#gf6b7452691c0c7d11fec4b9214137052">00208</a> <a class="code" href="group__DBusInternalsUtils.html#gf6b7452691c0c7d11fec4b9214137052">_dbus_user_database_lookup_group</a> (DBusUserDatabase *db,
<a name="l00209"></a>00209 <a class="code" href="group__DBusSysdeps.html#g2f5c2e418b81ec2a86594f56ec6d7627">dbus_gid_t</a> gid,
<a name="l00210"></a>00210 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *groupname,
<a name="l00211"></a>00211 <a class="code" href="structDBusError.html">DBusError</a> *error)
<a name="l00212"></a>00212 {
<a name="l00213"></a>00213 <a class="code" href="structDBusGroupInfo.html">DBusGroupInfo</a> *info;
<a name="l00214"></a>00214
<a name="l00215"></a>00215 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
<a name="l00216"></a>00216
<a name="l00217"></a>00217 <span class="comment">/* See if the group is really a number */</span>
<a name="l00218"></a>00218 <span class="keywordflow">if</span> (gid == <a class="code" href="group__DBusSysdeps.html#g3d2f3fb32bb759cabe362ca2de383f7d">DBUS_UID_UNSET</a>)
<a name="l00219"></a>00219 {
<a name="l00220"></a>00220 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> n;
<a name="l00221"></a>00221
<a name="l00222"></a>00222 <span class="keywordflow">if</span> (<a class="code" href="group__DBusInternalsUtils.html#gd1c3538c544df91f438a13c9fb4d3a1b">_dbus_is_a_number</a> (groupname, &n))
<a name="l00223"></a>00223 gid = n;
<a name="l00224"></a>00224 }
<a name="l00225"></a>00225
<a name="l00226"></a>00226 <span class="preprocessor">#ifdef DBUS_ENABLE_USER_CACHE</span>
<a name="l00227"></a>00227 <span class="preprocessor"></span> <span class="keywordflow">if</span> (gid != <a class="code" href="group__DBusSysdeps.html#g768a080926a119a6131083facc0bd42b">DBUS_GID_UNSET</a>)
<a name="l00228"></a>00228 info = <a class="code" href="group__DBusHashTable.html#g5d9caa38b663955ee0c4766f66e4e317">_dbus_hash_table_lookup_ulong</a> (db->groups, gid);
<a name="l00229"></a>00229 <span class="keywordflow">else</span>
<a name="l00230"></a>00230 info = <a class="code" href="group__DBusHashTable.html#gd51eb3fe682721dd4f6a920ca87cb730">_dbus_hash_table_lookup_string</a> (db->groups_by_name,
<a name="l00231"></a>00231 _dbus_string_get_const_data (groupname));
<a name="l00232"></a>00232 <span class="keywordflow">if</span> (info)
<a name="l00233"></a>00233 {
<a name="l00234"></a>00234 _dbus_verbose (<span class="stringliteral">"Using cache for GID "</span><a class="code" href="group__DBusSysdeps.html#gaab5918b2ae57886d9783df09bd61c7e">DBUS_GID_FORMAT</a><span class="stringliteral">" information\n"</span>,
<a name="l00235"></a>00235 info-><a class="code" href="structDBusGroupInfo.html#583e8d6d421fa85fb1d43789efae4b75">gid</a>);
<a name="l00236"></a>00236 <span class="keywordflow">return</span> info;
<a name="l00237"></a>00237 }
<a name="l00238"></a>00238 <span class="keywordflow">else</span>
<a name="l00239"></a>00239 <span class="preprocessor">#else</span>
<a name="l00240"></a>00240 <span class="preprocessor"></span> <span class="keywordflow">if</span> (1)
<a name="l00241"></a>00241 <span class="preprocessor">#endif</span>
<a name="l00242"></a>00242 <span class="preprocessor"></span> {
<a name="l00243"></a>00243 <span class="keywordflow">if</span> (gid != <a class="code" href="group__DBusSysdeps.html#g768a080926a119a6131083facc0bd42b">DBUS_GID_UNSET</a>)
<a name="l00244"></a>00244 _dbus_verbose (<span class="stringliteral">"No cache for GID "</span><a class="code" href="group__DBusSysdeps.html#gaab5918b2ae57886d9783df09bd61c7e">DBUS_GID_FORMAT</a><span class="stringliteral">"\n"</span>,
<a name="l00245"></a>00245 gid);
<a name="l00246"></a>00246 <span class="keywordflow">else</span>
<a name="l00247"></a>00247 _dbus_verbose (<span class="stringliteral">"No cache for groupname \"%s\"\n"</span>,
<a name="l00248"></a>00248 _dbus_string_get_const_data (groupname));
<a name="l00249"></a>00249
<a name="l00250"></a>00250 info = <a class="code" href="group__DBusMemory.html#gba9d823abda7f4cadbaf5177d3b8b793">dbus_new0</a> (<a class="code" href="structDBusGroupInfo.html">DBusGroupInfo</a>, 1);
<a name="l00251"></a>00251 <span class="keywordflow">if</span> (info == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00252"></a>00252 {
<a name="l00253"></a>00253 <a class="code" href="group__DBusErrors.html#g4e1b4b297468006781a957129ad9cf00">dbus_set_error</a> (error, <a class="code" href="group__DBusProtocol.html#gc32eaf0b92f798307853cd4fe0cf11c2">DBUS_ERROR_NO_MEMORY</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00254"></a>00254 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00255"></a>00255 }
<a name="l00256"></a>00256
<a name="l00257"></a>00257 <span class="keywordflow">if</span> (gid != <a class="code" href="group__DBusSysdeps.html#g768a080926a119a6131083facc0bd42b">DBUS_GID_UNSET</a>)
<a name="l00258"></a>00258 {
<a name="l00259"></a>00259 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusSysdepsUnix.html#gd235e373b223982b7d3aba8a2b602b58">_dbus_group_info_fill_gid</a> (info, gid, error))
<a name="l00260"></a>00260 {
<a name="l00261"></a>00261 _DBUS_ASSERT_ERROR_IS_SET (error);
<a name="l00262"></a>00262 <a class="code" href="group__DBusInternalsUtils.html#gb9420d7a4a31329a00fd5709f8cf08ba">_dbus_group_info_free_allocated</a> (info);
<a name="l00263"></a>00263 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00264"></a>00264 }
<a name="l00265"></a>00265 }
<a name="l00266"></a>00266 <span class="keywordflow">else</span>
<a name="l00267"></a>00267 {
<a name="l00268"></a>00268 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusSysdepsUnix.html#g23814bdf1859c6aa52da1feab8f1aed4">_dbus_group_info_fill</a> (info, groupname, error))
<a name="l00269"></a>00269 {
<a name="l00270"></a>00270 _DBUS_ASSERT_ERROR_IS_SET (error);
<a name="l00271"></a>00271 <a class="code" href="group__DBusInternalsUtils.html#gb9420d7a4a31329a00fd5709f8cf08ba">_dbus_group_info_free_allocated</a> (info);
<a name="l00272"></a>00272 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00273"></a>00273 }
<a name="l00274"></a>00274 }
<a name="l00275"></a>00275
<a name="l00276"></a>00276 <span class="comment">/* don't use these past here */</span>
<a name="l00277"></a>00277 gid = <a class="code" href="group__DBusSysdeps.html#g768a080926a119a6131083facc0bd42b">DBUS_GID_UNSET</a>;
<a name="l00278"></a>00278 groupname = <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00279"></a>00279
<a name="l00280"></a>00280 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusHashTable.html#gf40df7d2c9b05a67ac8c80d9ed88175c">_dbus_hash_table_insert_ulong</a> (db->groups, info-><a class="code" href="structDBusGroupInfo.html#583e8d6d421fa85fb1d43789efae4b75">gid</a>, info))
<a name="l00281"></a>00281 {
<a name="l00282"></a>00282 <a class="code" href="group__DBusErrors.html#g4e1b4b297468006781a957129ad9cf00">dbus_set_error</a> (error, <a class="code" href="group__DBusProtocol.html#gc32eaf0b92f798307853cd4fe0cf11c2">DBUS_ERROR_NO_MEMORY</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00283"></a>00283 <a class="code" href="group__DBusInternalsUtils.html#gb9420d7a4a31329a00fd5709f8cf08ba">_dbus_group_info_free_allocated</a> (info);
<a name="l00284"></a>00284 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00285"></a>00285 }
<a name="l00286"></a>00286
<a name="l00287"></a>00287
<a name="l00288"></a>00288 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusHashTable.html#g43e98a91a11952824c544330e19f6c22">_dbus_hash_table_insert_string</a> (db->groups_by_name,
<a name="l00289"></a>00289 info-><a class="code" href="structDBusGroupInfo.html#f1a4b925663336f64c62cfcab40571c6">groupname</a>,
<a name="l00290"></a>00290 info))
<a name="l00291"></a>00291 {
<a name="l00292"></a>00292 <a class="code" href="group__DBusHashTable.html#g2211f0b52ae08e195186b7d438913b11">_dbus_hash_table_remove_ulong</a> (db->groups, info-><a class="code" href="structDBusGroupInfo.html#583e8d6d421fa85fb1d43789efae4b75">gid</a>);
<a name="l00293"></a>00293 <a class="code" href="group__DBusErrors.html#g4e1b4b297468006781a957129ad9cf00">dbus_set_error</a> (error, <a class="code" href="group__DBusProtocol.html#gc32eaf0b92f798307853cd4fe0cf11c2">DBUS_ERROR_NO_MEMORY</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00294"></a>00294 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00295"></a>00295 }
<a name="l00296"></a>00296
<a name="l00297"></a>00297 <span class="keywordflow">return</span> info;
<a name="l00298"></a>00298 }
<a name="l00299"></a>00299 }
<a name="l00300"></a>00300
<a name="l00301"></a>00301
<a name="l00312"></a>00312 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l00313"></a><a class="code" href="group__DBusInternalsUtils.html#gd370299b907799440331c47e8d2357e0">00313</a> <a class="code" href="group__DBusInternalsUtils.html#gd370299b907799440331c47e8d2357e0">_dbus_user_database_get_groupname</a> (DBusUserDatabase *db,
<a name="l00314"></a>00314 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *groupname,
<a name="l00315"></a>00315 <span class="keyword">const</span> <a class="code" href="structDBusGroupInfo.html">DBusGroupInfo</a> **info,
<a name="l00316"></a>00316 <a class="code" href="structDBusError.html">DBusError</a> *error)
<a name="l00317"></a>00317 {
<a name="l00318"></a>00318 *info = <a class="code" href="group__DBusInternalsUtils.html#gf6b7452691c0c7d11fec4b9214137052">_dbus_user_database_lookup_group</a> (db, <a class="code" href="group__DBusSysdeps.html#g768a080926a119a6131083facc0bd42b">DBUS_GID_UNSET</a>, groupname, error);
<a name="l00319"></a>00319 <span class="keywordflow">return</span> *info != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00320"></a>00320 }
<a name="l00321"></a>00321
<a name="l00332"></a>00332 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l00333"></a><a class="code" href="group__DBusInternalsUtils.html#g70d3fd2edd61c69edc6f7fe1d5cfa6ea">00333</a> <a class="code" href="group__DBusInternalsUtils.html#g70d3fd2edd61c69edc6f7fe1d5cfa6ea">_dbus_user_database_get_gid</a> (DBusUserDatabase *db,
<a name="l00334"></a>00334 <a class="code" href="group__DBusSysdeps.html#g2f5c2e418b81ec2a86594f56ec6d7627">dbus_gid_t</a> gid,
<a name="l00335"></a>00335 <span class="keyword">const</span> <a class="code" href="structDBusGroupInfo.html">DBusGroupInfo</a> **info,
<a name="l00336"></a>00336 <a class="code" href="structDBusError.html">DBusError</a> *error)
<a name="l00337"></a>00337 {
<a name="l00338"></a>00338 *info = <a class="code" href="group__DBusInternalsUtils.html#gf6b7452691c0c7d11fec4b9214137052">_dbus_user_database_lookup_group</a> (db, gid, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, error);
<a name="l00339"></a>00339 <span class="keywordflow">return</span> *info != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00340"></a>00340 }
<a name="l00341"></a>00341
<a name="l00342"></a>00342
<a name="l00353"></a>00353 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l00354"></a><a class="code" href="group__DBusInternalsUtils.html#ge9408936869314101f8ea13dfa5ba968">00354</a> <a class="code" href="group__DBusInternalsUtils.html#ge9408936869314101f8ea13dfa5ba968">_dbus_groups_from_uid</a> (<a class="code" href="group__DBusSysdeps.html#g186e987b700f9ddc6cea8aa0db82b151">dbus_uid_t</a> uid,
<a name="l00355"></a>00355 <a class="code" href="group__DBusSysdeps.html#g2f5c2e418b81ec2a86594f56ec6d7627">dbus_gid_t</a> **group_ids,
<a name="l00356"></a>00356 <span class="keywordtype">int</span> *n_group_ids)
<a name="l00357"></a>00357 {
<a name="l00358"></a>00358 DBusUserDatabase *db;
<a name="l00359"></a>00359 <span class="keyword">const</span> <a class="code" href="structDBusUserInfo.html">DBusUserInfo</a> *info;
<a name="l00360"></a>00360 *group_ids = <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00361"></a>00361 *n_group_ids = 0;
<a name="l00362"></a>00362
<a name="l00363"></a>00363 <a class="code" href="group__DBusInternalsUtils.html#gd670eb00ca49ee18fe1c526d440131b7">_dbus_user_database_lock_system</a> ();
<a name="l00364"></a>00364
<a name="l00365"></a>00365 db = <a class="code" href="group__DBusInternalsUtils.html#g79b6c3cf0d735622b6af2795840f9d21">_dbus_user_database_get_system</a> ();
<a name="l00366"></a>00366 <span class="keywordflow">if</span> (db == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00367"></a>00367 {
<a name="l00368"></a>00368 <a class="code" href="group__DBusInternalsUtils.html#g468e1d62e1df24bb699c4a37fdfa274c">_dbus_user_database_unlock_system</a> ();
<a name="l00369"></a>00369 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00370"></a>00370 }
<a name="l00371"></a>00371
<a name="l00372"></a>00372 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusInternalsUtils.html#g6a7e8b8cf3a6968972e9a49726022638">_dbus_user_database_get_uid</a> (db, uid,
<a name="l00373"></a>00373 &info, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>))
<a name="l00374"></a>00374 {
<a name="l00375"></a>00375 <a class="code" href="group__DBusInternalsUtils.html#g468e1d62e1df24bb699c4a37fdfa274c">_dbus_user_database_unlock_system</a> ();
<a name="l00376"></a>00376 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00377"></a>00377 }
<a name="l00378"></a>00378
<a name="l00379"></a>00379 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (info-><a class="code" href="structDBusUserInfo.html#2d9c74d29f371e391a79b81162050b2e">uid</a> == uid);
<a name="l00380"></a>00380
<a name="l00381"></a>00381 <span class="keywordflow">if</span> (info-><a class="code" href="structDBusUserInfo.html#21c07867fbffb1854a97aed265d87c89">n_group_ids</a> > 0)
<a name="l00382"></a>00382 {
<a name="l00383"></a>00383 *group_ids = <a class="code" href="group__DBusMemory.html#g54ccb556e7964112a825a7f46c156ca0">dbus_new</a> (<a class="code" href="group__DBusSysdeps.html#g2f5c2e418b81ec2a86594f56ec6d7627">dbus_gid_t</a>, info-><a class="code" href="structDBusUserInfo.html#21c07867fbffb1854a97aed265d87c89">n_group_ids</a>);
<a name="l00384"></a>00384 <span class="keywordflow">if</span> (*group_ids == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00385"></a>00385 {
<a name="l00386"></a>00386 <a class="code" href="group__DBusInternalsUtils.html#g468e1d62e1df24bb699c4a37fdfa274c">_dbus_user_database_unlock_system</a> ();
<a name="l00387"></a>00387 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00388"></a>00388 }
<a name="l00389"></a>00389
<a name="l00390"></a>00390 *n_group_ids = info-><a class="code" href="structDBusUserInfo.html#21c07867fbffb1854a97aed265d87c89">n_group_ids</a>;
<a name="l00391"></a>00391
<a name="l00392"></a>00392 memcpy (*group_ids, info-><a class="code" href="structDBusUserInfo.html#902af9e0fb7d37c14eefb7d2b016ab11">group_ids</a>, info-><a class="code" href="structDBusUserInfo.html#21c07867fbffb1854a97aed265d87c89">n_group_ids</a> * sizeof (<a class="code" href="group__DBusSysdeps.html#g2f5c2e418b81ec2a86594f56ec6d7627">dbus_gid_t</a>));
<a name="l00393"></a>00393 }
<a name="l00394"></a>00394
<a name="l00395"></a>00395 <a class="code" href="group__DBusInternalsUtils.html#g468e1d62e1df24bb699c4a37fdfa274c">_dbus_user_database_unlock_system</a> ();
<a name="l00396"></a>00396 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l00397"></a>00397 }
<a name="l00400"></a>00400 <span class="preprocessor">#ifdef DBUS_BUILD_TESTS</span>
<a name="l00401"></a>00401 <span class="preprocessor"></span><span class="preprocessor">#include <stdio.h></span>
<a name="l00402"></a>00402
<a name="l00408"></a>00408 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l00409"></a>00409 _dbus_userdb_test (<span class="keyword">const</span> <span class="keywordtype">char</span> *test_data_dir)
<a name="l00410"></a>00410 {
<a name="l00411"></a>00411 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *username;
<a name="l00412"></a>00412 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *homedir;
<a name="l00413"></a>00413 <a class="code" href="group__DBusSysdeps.html#g186e987b700f9ddc6cea8aa0db82b151">dbus_uid_t</a> uid;
<a name="l00414"></a>00414 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *group_ids;
<a name="l00415"></a>00415 <span class="keywordtype">int</span> n_group_ids, i;
<a name="l00416"></a>00416
<a name="l00417"></a>00417 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusInternalsUtils.html#g9c4c1850787bfd457107b95fa1878869">_dbus_username_from_current_process</a> (&username))
<a name="l00418"></a>00418 <a class="code" href="group__DBusInternalsUtils.html#g0c4961ec784874f1b1f3aeccea8d3da1">_dbus_assert_not_reached</a> (<span class="stringliteral">"didn't get username"</span>);
<a name="l00419"></a>00419
<a name="l00420"></a>00420 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusInternalsUtils.html#g17ce3ab061a3ae2441cd33ece34f5e7a">_dbus_homedir_from_current_process</a> (&homedir))
<a name="l00421"></a>00421 <a class="code" href="group__DBusInternalsUtils.html#g0c4961ec784874f1b1f3aeccea8d3da1">_dbus_assert_not_reached</a> (<span class="stringliteral">"didn't get homedir"</span>);
<a name="l00422"></a>00422
<a name="l00423"></a>00423 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusInternalsUtils.html#gf07ee24eddcb3b0f85fa54196bc44fe1">_dbus_get_user_id</a> (username, &uid))
<a name="l00424"></a>00424 <a class="code" href="group__DBusInternalsUtils.html#g0c4961ec784874f1b1f3aeccea8d3da1">_dbus_assert_not_reached</a> (<span class="stringliteral">"didn't get uid"</span>);
<a name="l00425"></a>00425
<a name="l00426"></a>00426 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusInternalsUtils.html#ge9408936869314101f8ea13dfa5ba968">_dbus_groups_from_uid</a> (uid, &group_ids, &n_group_ids))
<a name="l00427"></a>00427 <a class="code" href="group__DBusInternalsUtils.html#g0c4961ec784874f1b1f3aeccea8d3da1">_dbus_assert_not_reached</a> (<span class="stringliteral">"didn't get groups"</span>);
<a name="l00428"></a>00428
<a name="l00429"></a>00429 printf (<span class="stringliteral">" Current user: %s homedir: %s gids:"</span>,
<a name="l00430"></a>00430 _dbus_string_get_const_data (username),
<a name="l00431"></a>00431 _dbus_string_get_const_data (homedir));
<a name="l00432"></a>00432
<a name="l00433"></a>00433 <span class="keywordflow">for</span> (i=0; i<n_group_ids; i++)
<a name="l00434"></a>00434 printf(<span class="stringliteral">" %ld"</span>, group_ids[i]);
<a name="l00435"></a>00435
<a name="l00436"></a>00436 printf (<span class="stringliteral">"\n"</span>);
<a name="l00437"></a>00437
<a name="l00438"></a>00438 <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a> (group_ids);
<a name="l00439"></a>00439
<a name="l00440"></a>00440 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l00441"></a>00441 }
<a name="l00442"></a>00442 <span class="preprocessor">#endif </span><span class="comment">/* DBUS_BUILD_TESTS */</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Dec 14 22:26:13 2009 for D-Bus by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address>
</body>
</html>