Logo Search packages:      
Sourcecode: schroot version File versions  Download package

void auth::set_user ( std::string const &  user  )  [inherited]

Set the name of the user. This is the user to run as in the session.

As a side effect, the uid, gid, home and shell member variables will also be set, so calling the corresponding get methods will now return meaningful values.

Parameters:
user the name to set.

Definition at line 162 of file sbuild-auth.cc.

References sbuild::auth::gid, sbuild::auth::home, sbuild::auth::shell, and sbuild::auth::uid.

Referenced by sbuild::auth::auth().

{
  this->uid = 0;
  this->gid = 0;
  this->home = "/";
  this->shell = "/bin/false";

  this->user = user;

  struct passwd *pwent = getpwnam(this->user.c_str());
  if (pwent == 0)
    {
      format fmt(_("%1%: user not found: %2%"));
      fmt % this->user.c_str() % strerror(errno);
      throw error(fmt);
    }
  this->uid = pwent->pw_uid;
  this->gid = pwent->pw_gid;
  this->home = pwent->pw_dir;
  this->shell = pwent->pw_shell;
  log_debug(DEBUG_INFO)
    << format("auth uid = %1%, gid = %2%") % this->uid % this->gid
    << endl;
}


Generated by  Doxygen 1.6.0   Back to index