1
/* Copyright © 2005-2007 Roger Leigh <rleigh@debian.org>
3
* sbuild is free software: you can redistribute it and/or modify it
4
* under the terms of the GNU General Public License as published by
5
* the Free Software Foundation, either version 2 of the License, or
6
* (at your option) any later version.
8
* sbuild is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see
15
* <http://www.gnu.org/licenses/>.
17
*********************************************************************/
29
using namespace sbuild;
31
sbuild::passwd::passwd ():
39
sbuild::passwd::passwd (uid_t uid):
49
sbuild::passwd::passwd (const char *name):
59
sbuild::passwd::passwd (std::string const& name):
70
sbuild::passwd::clear ()
76
::passwd::pw_name = 0;
77
::passwd::pw_passwd = 0;
80
::passwd::pw_gecos = 0;
82
::passwd::pw_shell = 0;
86
sbuild::passwd::query_uid (uid_t uid)
88
buffer_type::size_type size = 1 << 7;
94
while ((error = getpwuid_r(uid, this,
95
&buffer[0], buffer.capacity(),
109
sbuild::passwd::query_name (const char *name)
111
buffer_type::size_type size = 1 << 8;
112
buffer.reserve(size);
115
::passwd *pwd_result;
117
while ((error = getpwnam_r(name, this,
118
&buffer[0], buffer.capacity(),
122
buffer.reserve(size);
132
sbuild::passwd::query_name (std::string const& name)
134
query_name(name.c_str());
138
sbuild::passwd::operator ! () const
143
sbuild::group::group ():
151
sbuild::group::group (gid_t gid):
161
sbuild::group::group (const char *name):
171
sbuild::group::group (std::string const& name):
182
sbuild::group::clear ()
188
::group::gr_name = 0;
189
::group::gr_passwd = 0;
195
sbuild::group::query_gid (gid_t gid)
197
buffer_type::size_type size = 1 << 7;
198
buffer.reserve(size);
203
while ((error = getgrgid_r(gid, this,
204
&buffer[0], buffer.capacity(),
208
buffer.reserve(size);
218
sbuild::group::query_name (const char *name)
220
buffer_type::size_type size = 1 << 8;
221
buffer.reserve(size);
226
while ((error = getgrnam_r(name, this,
227
&buffer[0], buffer.capacity(),
231
buffer.reserve(size);
241
sbuild::group::query_name (std::string const& name)
243
query_name(name.c_str());
247
sbuild::group::operator ! () const