~ubuntu-branches/ubuntu/trusty/schroot/trusty

« back to all changes in this revision

Viewing changes to sbuild/sbuild-auth.cc

  • Committer: Bazaar Package Importer
  • Author(s): Roger Leigh
  • Date: 2010-07-06 23:34:30 UTC
  • mfrom: (1.1.24 upstream) (2.2.9 sid)
  • Revision ID: james.westby@ubuntu.com-20100706233430-0xhzqj6105yuyvb1
* New upstream stable release.
* Use standards version 3.9.0.
* Correctly distribute profile conffiles (Closes: #588247).  Thanks
  to Mario Holbe.
* Update it and zh_CN translations.  Thanks to Vincenzo Campanella
  and Ji ZhengYu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include <sstream>
30
30
 
31
31
#include <syslog.h>
 
32
#include <unistd.h>
32
33
 
33
34
#include <boost/format.hpp>
34
35
 
77
78
  home(),
78
79
  wd(),
79
80
  shell(),
80
 
  user_environment(),
 
81
  user_environment(environ),
81
82
  ruid(),
82
83
  rgid(),
83
84
  ruser(),
84
 
  rgroup(),
85
 
  message_verbosity(VERBOSITY_NORMAL)
 
85
  rgroup()
86
86
{
87
87
  this->ruid = getuid();
88
88
  this->rgid = getgid();
211
211
}
212
212
 
213
213
environment const&
214
 
auth::get_environment () const
 
214
auth::get_user_environment () const
215
215
{
216
216
  return this->user_environment;
217
217
}
218
218
 
219
219
void
220
 
auth::set_environment (char **environment)
 
220
auth::set_user_environment (char **environment)
221
221
{
222
 
  set_environment(sbuild::environment(environment));
 
222
  set_user_environment(sbuild::environment(environment));
223
223
}
224
224
 
225
225
void
226
 
auth::set_environment (environment const& environment)
 
226
auth::set_user_environment (environment const& environment)
227
227
{
228
228
  this->user_environment = environment;
229
229
}
232
232
auth::get_minimal_environment () const
233
233
{
234
234
  environment minimal;
235
 
  if (!this->user_environment.empty())
236
 
    minimal = this->user_environment;
237
235
 
238
236
  // For security, PATH is always set to a sane state for root, but
239
237
  // only set in other cases if not preserving the environment.
240
238
  if (this->uid == 0)
241
239
    minimal.add(std::make_pair("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11"));
242
 
  else if (this->user_environment.empty())
 
240
  else
243
241
    minimal.add(std::make_pair("PATH", "/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games"));
244
242
 
245
243
  if (this->user_environment.empty())
265
263
  return minimal;
266
264
}
267
265
 
 
266
environment
 
267
auth::get_complete_environment () const
 
268
{
 
269
  environment complete;
 
270
 
 
271
  complete += get_minimal_environment();
 
272
  complete += get_auth_environment();
 
273
 
 
274
  environment user = get_user_environment();
 
275
 
 
276
  // For security, we don't preserve the user's PATH when switching to
 
277
  // root.
 
278
  if (this->uid == 0)
 
279
    user.remove("PATH");
 
280
 
 
281
  complete += user;
 
282
 
 
283
  return complete;
 
284
}
 
285
 
268
286
uid_t
269
287
auth::get_ruid () const
270
288
{
289
307
  return this->rgroup;
290
308
}
291
309
 
292
 
auth::verbosity
293
 
auth::get_verbosity () const
294
 
{
295
 
  return this->message_verbosity;
296
 
}
297
 
 
298
 
void
299
 
auth::set_verbosity (auth::verbosity verbosity)
300
 
{
301
 
  this->message_verbosity = verbosity;
302
 
}
303
 
 
304
310
void
305
311
auth::start ()
306
312
{