a9690b1d | /* 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. */ #include <syslog.h> |
9526a1d3 | #include <security/pam_modules.h> |
a9690b1d | #include "sys_syslog.h" #include "logger.h" |
bc6c3d35 | namespace { class impl : public logger_ifc { private: sys_syslog syslog_; public: impl (const sys_syslog &sys_syslog) : syslog_ (sys_syslog) {} void log (int result, const std::string &user_name, const std::string &token) { std::string message; int facility; int priority; switch (result) { case PAM_SUCCESS: facility = LOG_AUTHPRIV; priority = LOG_NOTICE; message = user_name + " " + token + " " + "success"; break; case PAM_AUTH_ERR: facility = LOG_AUTHPRIV; priority = LOG_NOTICE; message = user_name + " " + token + " " + "fail"; break; default: facility = LOG_AUTH; priority = LOG_ERR; message = user_name + " pam returned error"; break; } syslog_.openlog ("dual-control", 0, facility); syslog_.syslog (priority, message.c_str()); syslog_.closelog(); } }; |
a9690b1d | } |
bc6c3d35 | logger logger::create (const sys_syslog &sys_syslog) { return logger (delegate (new impl (sys_syslog))); |
a9690b1d | } |
bc6c3d35 |