7684972a | /* 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. */ |
01c00cfe | #ifndef _PAM_H #define _PAM_H #include <memory> |
2fade7af | #include <vector> |
01c00cfe | #include <security/pam_modules.h> |
f46fb7b6 | class pam_ifc |
cdf7fd74 | { public: |
4d825470 | virtual ~pam_ifc() {} |
af675d2b | virtual int get_user (pam_handle *handle, const char **out) const { |
a3ac9ba7 | return PAM_SERVICE_ERR; } |
bb80149c | virtual int get_conv (pam_handle *handle, const pam_conv **out) const |
2fade7af | { return PAM_SERVICE_ERR; } |
01c00cfe | }; |
3ae0e083 | class pam |
cdf7fd74 | { |
f46fb7b6 | typedef std::shared_ptr<pam_ifc> delegate; private: delegate delegate_; |
cdf7fd74 | public: |
f46fb7b6 | pam (const delegate &delegate) : delegate_ (delegate) {} pam() : pam (delegate (new pam_ifc)) {} |
af675d2b | int get_user (pam_handle *handle, const char **out) const { return delegate_->get_user (handle, out); |
a3ac9ba7 | } |
bb80149c | int get_conv (pam_handle *handle, const pam_conv **out) const |
f46fb7b6 | { |
2fade7af | return delegate_->get_conv (handle, out); |
f46fb7b6 | } |
da1b9b25 | static pam create(); |
01c00cfe | }; #endif |
92957308 |