/* 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. */ #ifndef _PAM_H #define _PAM_H #include #include #include class pam_ifc { public: virtual ~pam_ifc() {} virtual int get_user (pam_handle *handle, const char **out) const { return PAM_SERVICE_ERR; } virtual int get_conv (pam_handle *handle, const pam_conv **out) const { return PAM_SERVICE_ERR; } }; class pam { typedef std::shared_ptr delegate; private: delegate delegate_; public: pam (const delegate &delegate) : delegate_ (delegate) {} pam() : pam (delegate (new pam_ifc)) {} int get_user (pam_handle *handle, const char **out) const { return delegate_->get_user (handle, out); } int get_conv (pam_handle *handle, const pam_conv **out) const { return delegate_->get_conv (handle, out); } static pam create(); }; #endif