git.fiddlerwoaroof.com
session.cc
af675d2b
 /* Copyright (C) CJ Affiliate
  *
  * You may use, distribute and modify this code under  the
  * terms of the  GNU General Public License  version 2  or
  * later.
  *
  * You should have received a copy of the license with this
  * file. If not, you will find a copy in the "LICENSE" file
  * at https://github.com/cjdev/dual-control.
  */
 
bb80149c
 #include <memory>
 #include <string>
 
 #include "session.h"
 #include "sys_pam.h"
 #include "request.h"
 
 namespace
 {
af675d2b
 class impl : public sessions_ifc
 {
 private:
     pam pam_;
 public:
     impl (const pam &pam) : pam_ (pam) {}
     std::string user_name (const pam_request &request)  const
     {
bb80149c
         const char *user_name;
af675d2b
         pam_.get_user (request.handle(), &user_name);
bb80149c
         return user_name;
     }
 };
 
 }
 
af675d2b
 sessions sessions::create (const pam &pam)
 {
     return sessions (std::make_shared<impl> (pam));
bb80149c
 }
af675d2b