#ifndef PAMWRAPPER_H #define PAMWRAPPER_H #include #include #include /* virtual class - cannot be instantiated * you have to create a derived class and implement/override the 4 * virtual memberfunctions of this class */ class PamWrapper { private: pam_handle_t *m_pamh; bool m_isStarted; std::string m_service; pam_conv m_conv; public: PamWrapper(std::string service); virtual ~PamWrapper(); // standard PAM functions int start(std::string username = ""); int authenticate(int flags = 0); int account(int flags = 0); int end(int status = 0); int setCred(int flags = 0); int openSession(int flags = 0); int closeSession(int flags = 0); int changeAuthToken(int flags = 0); // PAM utility functions std::string strError(int err); int putEnv(std::string nameValue); std::string getEnv(std::string name); //std::vector getEnvList(); int setItem(int item_type, const void *item); int getItem(int item_type, const void **item); int failDelay(unsigned int usec); //override these functions, in your derived class virtual std::string promptEchoOff(std::string prompt) = 0; virtual std::string promptEchoOn(std::string prompt) = 0; virtual void errorMsg(std::string msg) = 0; virtual void textInfo(std::string msg) = 0; //all-in-one function //calls start(), authenticate(), account() and end() //returns true if auth and account where OK bool checkUser(std::string username = "", bool checkAccount = true); }; #endif //PAMWRAPPER_H